From caed3172d035df6f371cf16d40b0c705cc434f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Thu, 16 May 2024 16:57:55 +0200 Subject: [PATCH 01/62] Base KMP structure with no JS or iOS implementations. --- .gitignore | 1 + build-logic/gradle-plugins/build.gradle.kts | 12 + .../pubnub/gradle/PubNubJavaLibraryPlugin.kt | 21 + .../gradle/PubNubKotlinLibraryPlugin.kt | 58 + .../com/pubnub/gradle/PubNubSharedPlugin.kt | 72 - .../com/pubnub/gradle/PubNubTestPlugin.kt | 34 + gradle.properties | 4 +- gradle/libs.versions.toml | 4 +- kotlin-js-store/yarn.lock | 3042 +++++++++++++++++ pubnub-core/pubnub-core-api/build.gradle.kts | 54 +- .../kotlin/com/pubnub/api/JsonElement.kt | 6 + .../kotlin/com/pubnub/api/PubNubError.kt | 0 .../kotlin/com/pubnub/api/PubNubException.kt | 17 + .../kotlin/com/pubnub/api/UserId.kt | 0 .../com/pubnub/api/callbacks/Listener.kt | 0 .../endpoints/remoteaction/RemoteAction.kt | 2 +- .../enums/PNHeartbeatNotificationOptions.kt | 0 .../com/pubnub/api/enums/PNLogVerbosity.kt | 0 .../com/pubnub/api/enums/PNOperationType.kt | 121 + .../com/pubnub/api/enums/PNPushEnvironment.kt | 0 .../kotlin/com/pubnub/api/enums/PNPushType.kt | 4 +- .../pubnub/api/enums/PNReconnectionPolicy.kt | 0 .../com/pubnub/api/enums/PNStatusCategory.kt | 0 .../com/pubnub/api/models/TokenBitmask.kt | 0 .../api/models/consumer/PNBoundedPage.kt | 0 .../api/models/consumer/PNPublishResult.kt | 0 .../pubnub/api/models/consumer/PNStatus.kt | 1 + .../api/models/consumer/PNTimeResult.kt | 0 .../access_manager/v3/PNGrantTokenResult.kt | 0 .../consumer/access_manager/v3/PNToken.kt | 0 .../channel_group/PNChannelGroupsResults.kt | 0 .../consumer/files/PNDeleteFileResult.kt | 0 .../consumer/files/PNDownloadableFile.kt | 0 .../api/models/consumer/files/PNFile.kt | 0 .../consumer/files/PNFileUploadResult.kt | 0 .../models/consumer/files/PNFileUrlResult.kt | 0 .../consumer/files/PNListFilesResult.kt | 0 .../files/PNPublishFileMessageResult.kt | 0 .../consumer/history/HistoryMessageType.kt | 0 .../history/PNDeleteMessagesResult.kt | 0 .../models/consumer/history/PNFetchMessage.kt | 2 +- .../consumer/history/PNHistoryResult.kt | 8 +- .../consumer/history/PNMessageCountResult.kt | 0 .../PNAddMessageActionResult.kt | 0 .../PNGetMessageActionsResult.kt | 2 +- .../message_actions/PNMessageAction.kt | 2 + .../PNRemoveMessageActionResult.kt | 0 .../api/models/consumer/objects/PNPage.kt | 0 .../objects/channel/PNChannelMetadata.kt | 0 .../channel/PNChannelMetadataArrayResult.kt | 0 .../channel/PNChannelMetadataResult.kt | 0 .../consumer/objects/uuid/PNUUIDMetadata.kt | 2 +- .../consumer/presence/PNGetStateResult.kt | 2 +- .../api/models/consumer/presence/PNHereNow.kt | 2 +- .../consumer/presence/PNSetStateResult.kt | 2 +- .../consumer/pubsub/BasePubSubResult.kt | 2 +- .../models/consumer/pubsub/MessageResult.kt | 2 +- .../api/models/consumer/pubsub/PNEvent.kt | 0 .../models/consumer/pubsub/PNMessageResult.kt | 7 +- .../consumer/pubsub/PNPresenceEventResult.kt | 7 +- .../models/consumer/pubsub/PNSignalResult.kt | 2 +- .../pubsub/files/PNFileEventResult.kt | 7 +- .../message_actions/PNMessageActionResult.kt | 5 +- .../consumer/pubsub/objects/ObjectPayload.kt | 2 +- .../consumer/pubsub/objects/ObjectResult.kt | 0 .../consumer/push/PNPushAddChannelResult.kt | 0 .../push/PNPushListProvisionsResult.kt | 0 .../push/PNPushRemoveAllChannelsResult.kt | 0 .../push/PNPushRemoveChannelResult.kt | 0 .../push/payload/PushPayloadHelper.kt | 3 +- .../push/payload/PushPayloadSerializer.kt | 0 .../pubnub/api/retry/RetryConfiguration.kt | 19 +- .../api/retry/RetryableEndpointGroup.kt | 0 .../api/v2/callbacks/BaseEventEmitter.kt | 0 .../api/v2/callbacks/BaseEventListener.kt | 0 .../api/v2/callbacks/BaseStatusEmitter.kt | 0 .../api/v2/callbacks/BaseStatusListener.kt | 0 .../com/pubnub/api/v2/callbacks/Consumer.kt | 5 + .../com/pubnub/api/v2/callbacks/Result.kt | 233 ++ .../com/pubnub/api/v2/entities/BaseChannel.kt | 0 .../api/v2/entities/BaseChannelGroup.kt | 0 .../api/v2/entities/BaseChannelMetadata.kt | 0 .../api/v2/entities/BaseUserMetadata.kt | 0 .../pubnub/api/v2/entities/Subscribable.kt | 0 .../api/v2/subscriptions/BaseSubscription.kt | 1 + .../v2/subscriptions/BaseSubscriptionSet.kt | 1 + .../api/v2/subscriptions/SubscribeCapable.kt | 0 .../v2/subscriptions/SubscriptionCursor.kt | 0 .../v2/subscriptions/SubscriptionOptions.kt | 1 + .../kotlin/com/pubnub/api/JsonElement.ios.kt | 7 + .../com/pubnub/api/PubNubException.ios.kt | 27 + .../pubnub/api/v2/callbacks/Consumer.ios.kt | 5 + .../kotlin/com/pubnub/api/JsonElement.js.kt | 6 + .../com/pubnub/api/PubNubException.js.kt | 25 + .../pubnub/api/v2/callbacks/Consumer.js.kt | 5 + .../kotlin/com/pubnub/api/BasePubNub.kt | 0 .../kotlin/com/pubnub/api/JsonElement.jvm.kt | 8 + .../kotlin/com/pubnub/api/PubNubException.kt | 10 +- .../com/pubnub/api/crypto/CryptoModule.kt | 0 .../com/pubnub/api/crypto/cryptor/Cryptor.kt | 0 .../pubnub/api/crypto/data/EncryptedData.kt | 0 .../api/crypto/data/EncryptedStreamData.kt | 0 .../api/endpoints/HasOverridableConfig.kt | 0 .../remoteaction/ComposableRemoteAction.kt | 0 .../remoteaction/MappingRemoteAction.kt | 0 .../consumer/files/PNDownloadFileResult.kt | 2 +- .../com/pubnub/api/v2/BasePNConfiguration.kt | 0 .../api/v2/BasePNConfigurationOverride.kt | 0 .../pubnub/api/v2/callbacks/Consumer.jvm.kt | 5 + .../com/pubnub/api/enums/PNOperationType.kt | 362 -- .../com/pubnub/api/v2/callbacks/Result.kt | 184 - pubnub-core/pubnub-core-impl/build.gradle.kts | 4 +- .../kotlin/com/pubnub/internal/PubNubCore.kt | 3 +- .../internal/endpoints/HistoryEndpoint.kt | 8 +- .../endpoints/files/DeleteFileEndpoint.kt | 2 +- .../endpoints/files/DeleteFileInterface.kt | 2 +- .../eventEngine/step/EventEngineSteps.kt | 2 +- .../internal/retry/RetryableCallbackTest.kt | 8 +- .../internal/retry/RetryableRestCallerTest.kt | 8 +- pubnub-gson/build.gradle.kts | 2 +- pubnub-gson/pubnub-gson-api/build.gradle.kts | 3 +- pubnub-gson/pubnub-gson-impl/build.gradle.kts | 4 +- .../internal/endpoints/HistoryImpl.java | 2 +- pubnub-kotlin/build.gradle.kts | 2 +- .../pubnub-kotlin-api/PubNubKMP.podspec | 54 + .../pubnub-kotlin-api/build.gradle.kts | 105 +- .../kotlin/com/pubnub/api/Endpoint.kt | 8 + .../kotlin/com/pubnub/api/PubNub.kt | 447 +++ .../kotlin/com/pubnub/api/SpaceId.kt | 0 .../pubnub/api/endpoints/DeleteMessages.kt | 9 + .../com/pubnub/api/endpoints/FetchMessages.kt | 10 + .../com/pubnub/api/endpoints/MessageCounts.kt | 9 + .../kotlin/com/pubnub/api/endpoints/Time.kt | 2 +- .../pubnub/api/endpoints/access/GrantToken.kt | 7 + .../api/endpoints/access/RevokeToken.kt | 2 +- .../channel_groups/AddChannelChannelGroup.kt | 9 + .../channel_groups/AllChannelsChannelGroup.kt | 9 + .../channel_groups/DeleteChannelGroup.kt | 9 + .../channel_groups/ListAllChannelGroup.kt | 2 +- .../RemoveChannelChannelGroup.kt | 10 + .../pubnub/api/endpoints/files/DeleteFile.kt | 2 +- .../pubnub/api/endpoints/files/GetFileUrl.kt | 2 +- .../pubnub/api/endpoints/files/ListFiles.kt | 2 +- .../api/endpoints/files/PublishFileMessage.kt | 3 +- .../message_actions/AddMessageAction.kt | 10 + .../message_actions/GetMessageActions.kt | 10 + .../message_actions/RemoveMessageAction.kt | 10 + .../objects/channel/GetAllChannelMetadata.kt | 10 + .../objects/channel/GetChannelMetadata.kt | 3 +- .../objects/channel/RemoveChannelMetadata.kt | 3 +- .../objects/channel/SetChannelMetadata.kt | 3 +- .../objects/member/GetChannelMembers.kt | 3 +- .../objects/member/ManageChannelMembers.kt | 3 +- .../objects/membership/GetMemberships.kt | 3 +- .../objects/membership/ManageMemberships.kt | 3 +- .../objects/uuid/GetAllUUIDMetadata.kt | 3 +- .../endpoints/objects/uuid/GetUUIDMetadata.kt | 10 + .../objects/uuid/RemoveUUIDMetadata.kt | 7 + .../endpoints/objects/uuid/SetUUIDMetadata.kt | 3 +- .../pubnub/api/endpoints/presence/GetState.kt | 10 + .../pubnub/api/endpoints/presence/HereNow.kt | 10 + .../pubnub/api/endpoints/presence/SetState.kt | 10 + .../pubnub/api/endpoints/presence/WhereNow.kt | 10 + .../pubnub/api/endpoints/pubsub/Publish.kt | 9 + .../com/pubnub/api/endpoints/pubsub/Signal.kt | 9 + .../api/endpoints/push/AddChannelsToPush.kt | 2 +- .../api/endpoints/push/ListPushProvisions.kt | 2 +- .../push/RemoveAllPushChannelsForDevice.kt | 2 +- .../endpoints/push/RemoveChannelsFromPush.kt | 2 +- .../PNAccessManagerGrantResults.kt | 38 +- .../access_manager/sum/SpacePermissions.kt | 0 .../access_manager/sum/UserPermissions.kt | 0 .../access_manager/v3/ChannelGrant.kt | 0 .../access_manager/v3/ChannelGroupGrant.kt | 0 .../consumer/access_manager/v3/Grants.kt | 0 .../consumer/access_manager/v3/UUIDGrant.kt | 0 .../objects/PNRemoveMetadataResult.kt | 3 + .../api/models/consumer/objects/PNSortKey.kt | 0 .../consumer/objects/member/MemberInput.kt | 0 .../consumer/objects/member/PNMember.kt | 13 - .../objects/member/PNMemberArrayResult.kt | 11 + .../objects/member/PNUUIDDetailsLevel.kt | 0 .../membership/ChannelMembershipInput.kt | 0 .../membership/PNChannelDetailsLevel.kt | 0 .../objects/membership/PNChannelMembership.kt | 12 - .../PNChannelMembershipArrayResult.kt | 0 .../objects/uuid/PNUUIDMetadataArrayResult.kt | 11 + .../objects/uuid/PNUUIDMetadataResult.kt | 6 + .../consumer/presence/PNWhereNowResult.kt | 4 +- .../pubsub/objects/PNObjectEventResult.kt | 0 .../com/pubnub/api/v2/PNConfiguration.kt | 19 + .../pubnub/api/v2/callbacks/EventListener.kt | 7 + .../pubnub/api/v2/callbacks/StatusListener.kt | 10 + .../kotlin/com/pubnub/kmp/Optional.kt | 10 + .../kotlin/com/pubnub/api/Endpoint.ios.kt | 8 + .../kotlin/com/pubnub/api/PubNub.ios.kt | 444 +++ .../kotlin/com/pubnub/api/PubNubImpl.kt | 485 +++ .../api/endpoints/DeleteMessages.ios.kt | 9 + .../pubnub/api/endpoints/FetchMessages.ios.kt | 10 + .../pubnub/api/endpoints/MessageCounts.ios.kt | 9 + .../com/pubnub/api/endpoints/Time.ios.kt | 9 + .../api/endpoints/access/GrantToken.ios.kt | 7 + .../api/endpoints/access/RevokeToken.ios.kt | 5 + .../AddChannelChannelGroup.ios.kt | 10 + .../AllChannelsChannelGroup.ios.kt | 10 + .../channel_groups/DeleteChannelGroup.ios.kt | 9 + .../channel_groups/ListAllChannelGroup.ios.kt | 9 + .../RemoveChannelChannelGroup.ios.kt | 10 + .../api/endpoints/files/DeleteFile.ios.kt | 9 + .../api/endpoints/files/GetFileUrl.ios.kt | 9 + .../api/endpoints/files/ListFiles.ios.kt | 9 + .../endpoints/files/PublishFileMessage.ios.kt | 9 + .../message_actions/AddMessageAction.ios.kt | 10 + .../message_actions/GetMessageActions.ios.kt | 10 + .../RemoveMessageAction.ios.kt | 10 + .../channel/GetAllChannelMetadata.ios.kt | 10 + .../objects/channel/GetChannelMetadata.ios.kt | 9 + .../channel/RemoveChannelMetadata.ios.kt | 6 + .../objects/channel/SetChannelMetadata.ios.kt | 9 + .../objects/member/GetChannelMembers.ios.kt | 9 + .../member/ManageChannelMembers.ios.kt | 9 + .../objects/membership/GetMemberships.ios.kt | 9 + .../membership/ManageMemberships.ios.kt | 9 + .../objects/uuid/GetAllUUIDMetadata.ios.kt | 9 + .../objects/uuid/GetUUIDMetadata.ios.kt | 10 + .../objects/uuid/RemoveUUIDMetadata.ios.kt | 7 + .../objects/uuid/SetUUIDMetadata.ios.kt | 9 + .../api/endpoints/presence/GetState.ios.kt | 10 + .../api/endpoints/presence/HereNow.ios.kt | 10 + .../api/endpoints/presence/SetState.ios.kt | 10 + .../api/endpoints/presence/WhereNow.ios.kt | 10 + .../api/endpoints/pubsub/Publish.ios.kt | 9 + .../pubnub/api/endpoints/pubsub/Signal.ios.kt | 9 + .../endpoints/push/AddChannelsToPush.ios.kt | 9 + .../endpoints/push/ListPushProvisions.ios.kt | 9 + .../RemoveAllPushChannelsForDevice.ios.kt | 9 + .../push/RemoveChannelsFromPush.ios.kt | 9 + .../com/pubnub/api/v2/PNConfiguration.ios.kt | 33 + .../api/v2/callbacks/EventListener.ios.kt | 7 + .../api/v2/callbacks/StatusListener.ios.kt | 7 + .../src/jsMain/kotlin/Pubnub.d.kt | 1662 +++++++++ .../kotlin/com/pubnub/api/Endpoint.js.kt | 8 + .../kotlin/com/pubnub/api/EndpointImpl.kt | 20 + .../jsMain/kotlin/com/pubnub/api/PubNub.js.kt | 477 +++ .../kotlin/com/pubnub/api/PubNubImpl.kt | 564 +++ .../pubnub/api/endpoints/DeleteMessages.js.kt | 9 + .../pubnub/api/endpoints/FetchMessages.js.kt | 11 + .../pubnub/api/endpoints/MessageCounts.js.kt | 9 + .../com/pubnub/api/endpoints/Time.js.kt | 9 + .../api/endpoints/access/GrantToken.js.kt | 7 + .../api/endpoints/access/RevokeToken.js.kt | 5 + .../AddChannelChannelGroup.js.kt | 11 + .../AllChannelsChannelGroup.js.kt | 11 + .../channel_groups/DeleteChannelGroup.js.kt | 9 + .../channel_groups/ListAllChannelGroup.js.kt | 11 + .../RemoveChannelChannelGroup.js.kt | 10 + .../api/endpoints/files/DeleteFile.js.kt | 9 + .../api/endpoints/files/GetFileUrl.js.kt | 9 + .../api/endpoints/files/ListFiles.js.kt | 9 + .../endpoints/files/PublishFileMessage.js.kt | 9 + .../message_actions/AddMessageAction.js.kt | 11 + .../message_actions/GetMessageActions.js.kt | 10 + .../message_actions/RemoveMessageAction.js.kt | 11 + .../channel/GetAllChannelMetadata.js.kt | 10 + .../objects/channel/GetChannelMetadata.js.kt | 9 + .../channel/RemoveChannelMetadata.js.kt | 6 + .../objects/channel/SetChannelMetadata.js.kt | 9 + .../objects/member/GetChannelMembers.js.kt | 10 + .../objects/member/ManageChannelMembers.js.kt | 14 + .../objects/membership/GetMemberships.js.kt | 9 + .../membership/ManageMemberships.js.kt | 9 + .../objects/uuid/GetAllUUIDMetadata.js.kt | 9 + .../objects/uuid/GetUUIDMetadata.js.kt | 10 + .../objects/uuid/RemoveUUIDMetadata.js.kt | 18 + .../objects/uuid/SetUUIDMetadata.js.kt | 11 + .../api/endpoints/presence/GetState.js.kt | 10 + .../api/endpoints/presence/HereNow.js.kt | 11 + .../api/endpoints/presence/SetState.js.kt | 10 + .../api/endpoints/presence/WhereNow.js.kt | 11 + .../pubnub/api/endpoints/pubsub/Publish.js.kt | 10 + .../pubnub/api/endpoints/pubsub/Signal.js.kt | 11 + .../endpoints/push/AddChannelsToPush.js.kt | 9 + .../endpoints/push/ListPushProvisions.js.kt | 9 + .../push/RemoveAllPushChannelsForDevice.js.kt | 9 + .../push/RemoveChannelsFromPush.js.kt | 9 + .../com/pubnub/api/v2/PNConfiguration.js.kt | 37 + .../api/v2/callbacks/EventListener.js.kt | 8 + .../api/v2/callbacks/StatusListener.js.kt | 12 + .../kotlin/com/pubnub/api/Endpoint.kt | 3 +- .../kotlin/com/pubnub/api/PNConfiguration.kt | 4 +- .../kotlin/com/pubnub/api/PubNub.jvm.kt | 69 + .../kotlin/com/pubnub/api/PubNub.kt | 471 +-- .../pubnub/api/callbacks/SubscribeCallback.kt | 2 +- .../pubnub/api/endpoints/DeleteMessages.kt | 2 +- .../com/pubnub/api/endpoints/FetchMessages.kt | 2 +- .../com/pubnub/api/endpoints/History.kt | 0 .../com/pubnub/api/endpoints/MessageCounts.kt | 2 +- .../kotlin/com/pubnub/api/endpoints/Time.kt | 9 + .../com/pubnub/api/endpoints/access/Grant.kt | 0 .../pubnub/api/endpoints/access/GrantToken.kt | 2 +- .../api/endpoints/access/RevokeToken.kt | 5 + .../channel_groups/AddChannelChannelGroup.kt | 2 +- .../channel_groups/AllChannelsChannelGroup.kt | 2 +- .../channel_groups/DeleteChannelGroup.kt | 2 +- .../channel_groups/ListAllChannelGroup.kt | 9 + .../RemoveChannelChannelGroup.kt | 2 +- .../pubnub/api/endpoints/files/DeleteFile.kt | 9 + .../api/endpoints/files/DownloadFile.kt | 0 .../pubnub/api/endpoints/files/GetFileUrl.kt | 9 + .../pubnub/api/endpoints/files/ListFiles.kt | 9 + .../api/endpoints/files/PublishFileMessage.kt | 9 + .../pubnub/api/endpoints/files/SendFile.kt | 0 .../message_actions/AddMessageAction.kt | 3 +- .../message_actions/GetMessageActions.kt | 3 +- .../message_actions/RemoveMessageAction.kt | 2 +- .../objects/channel/GetAllChannelMetadata.kt | 2 +- .../objects/channel/GetChannelMetadata.kt | 9 + .../objects/channel/RemoveChannelMetadata.kt | 6 + .../objects/channel/SetChannelMetadata.kt | 9 + .../objects/member/GetChannelMembers.kt | 9 + .../objects/member/ManageChannelMembers.kt | 9 + .../objects/membership/GetMemberships.kt | 9 + .../objects/membership/ManageMemberships.kt | 9 + .../objects/uuid/GetAllUUIDMetadata.kt | 9 + .../endpoints/objects/uuid/GetUUIDMetadata.kt | 3 +- .../objects/uuid/RemoveUUIDMetadata.kt | 3 +- .../endpoints/objects/uuid/SetUUIDMetadata.kt | 9 + .../pubnub/api/endpoints/presence/GetState.kt | 2 +- .../pubnub/api/endpoints/presence/HereNow.kt | 2 +- .../pubnub/api/endpoints/presence/SetState.kt | 2 +- .../pubnub/api/endpoints/presence/WhereNow.kt | 2 +- .../pubnub/api/endpoints/pubsub/Publish.kt | 2 +- .../com/pubnub/api/endpoints/pubsub/Signal.kt | 2 +- .../api/endpoints/push/AddChannelsToPush.kt | 9 + .../api/endpoints/push/ListPushProvisions.kt | 9 + .../push/RemoveAllPushChannelsForDevice.kt | 9 + .../endpoints/push/RemoveChannelsFromPush.kt | 9 + .../com/pubnub/api/v2/PNConfiguration.jvm.kt | 13 + .../com/pubnub/api/v2/PNConfiguration.kt | 2 +- .../pubnub/api/v2/callbacks/EventEmitter.kt | 0 .../pubnub/api/v2/callbacks/EventListener.kt | 4 +- .../pubnub/api/v2/callbacks/StatusEmitter.kt | 0 .../pubnub/api/v2/callbacks/StatusListener.kt | 4 +- .../com/pubnub/api/v2/entities/Channel.kt | 0 .../pubnub/api/v2/entities/ChannelGroup.kt | 0 .../pubnub/api/v2/entities/ChannelMetadata.kt | 0 .../pubnub/api/v2/entities/UserMetadata.kt | 0 .../api/v2/subscriptions/Subscription.kt | 0 .../api/v2/subscriptions/SubscriptionSet.kt | 0 .../objects/PNRemoveMetadataResult.kt | 11 - .../objects/member/PNMemberArrayResult.kt | 24 - .../objects/uuid/PNUUIDMetadataArrayResult.kt | 23 - .../objects/uuid/PNUUIDMetadataResult.kt | 17 - .../pubnub-kotlin-impl/build.gradle.kts | 3 +- .../integration/HeartbeatIntegrationTest.kt | 3 +- .../kotlin/com/pubnub/internal/PubNubImpl.kt | 3 +- .../internal/endpoints/access/GrantImpl.kt | 33 +- .../endpoints/files/DeleteFileImpl.kt | 2 +- .../channel/RemoveChannelMetadataImpl.kt | 3 +- .../objects/member/GetChannelMembersImpl.kt | 3 +- .../member/ManageChannelMembersImpl.kt | 3 +- .../objects/uuid/GetAllUUIDMetadataImpl.kt | 3 +- .../objects/uuid/GetUUIDMetadataImpl.kt | 3 +- .../objects/uuid/RemoveUUIDMetadataImpl.kt | 3 +- .../objects/uuid/SetUUIDMetadataImpl.kt | 3 +- .../com/pubnub/internal/models/Converters.kt | 64 +- .../DelegatingSubscribeCallbackTest.kt | 5 +- .../pubnub-kotlin-test/build.gradle.kts | 41 + .../kotlin/com.pubnub.test/FakePubNub.kt | 1182 +++++++ .../kotlin/com.pubnub.test/createEndpoint.kt | 5 + .../kotlin/com.pubnub.test/FakePubNub.js.kt | 7 + .../kotlin/com.pubnub.test/FakePubNub.jvm.kt | 45 + settings.gradle.kts | 1 + 373 files changed, 11122 insertions(+), 1147 deletions(-) create mode 100644 build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt create mode 100644 build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt create mode 100644 build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubTestPlugin.kt create mode 100644 kotlin-js-store/yarn.lock create mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/PubNubError.kt (100%) create mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/UserId.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/callbacks/Listener.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt (97%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/enums/PNHeartbeatNotificationOptions.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/enums/PNLogVerbosity.kt (100%) create mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNOperationType.kt rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/enums/PNPushType.kt (81%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/enums/PNReconnectionPolicy.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/enums/PNStatusCategory.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/TokenBitmask.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/PNBoundedPage.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/PNPublishResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/PNStatus.kt (98%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/PNTimeResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNGrantTokenResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNToken.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/channel_group/PNChannelGroupsResults.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/files/PNDeleteFileResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/files/PNDownloadableFile.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/files/PNFile.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/files/PNFileUploadResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/files/PNFileUrlResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/files/PNListFilesResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/files/PNPublishFileMessageResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/history/PNDeleteMessagesResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt (98%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt (92%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/history/PNMessageCountResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/message_actions/PNAddMessageActionResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt (90%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt (98%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/message_actions/PNRemoveMessageActionResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/PNPage.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt (89%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt (87%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt (97%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt (86%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt (96%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt (83%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/pubsub/PNEvent.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt (87%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt (96%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt (88%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt (93%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt (93%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt (85%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/push/PNPushAddChannelResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/push/PNPushListProvisionsResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveAllChannelsResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveChannelResult.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt (98%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadSerializer.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/retry/RetryConfiguration.kt (88%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/retry/RetryableEndpointGroup.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/callbacks/BaseEventEmitter.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/callbacks/BaseEventListener.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/callbacks/BaseStatusEmitter.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/callbacks/BaseStatusListener.kt (100%) create mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt create mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/entities/BaseChannel.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/entities/BaseChannelGroup.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/entities/BaseChannelMetadata.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/entities/BaseUserMetadata.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/entities/Subscribable.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt (96%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscriptionSet.kt (97%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/subscriptions/SubscribeCapable.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => commonMain}/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt (98%) create mode 100644 pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt create mode 100644 pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt create mode 100644 pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt create mode 100644 pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt create mode 100644 pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt create mode 100644 pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/BasePubNub.kt (100%) create mode 100644 pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/PubNubException.kt (86%) rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/crypto/CryptoModule.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/crypto/cryptor/Cryptor.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/crypto/data/EncryptedData.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/crypto/data/EncryptedStreamData.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/HasOverridableConfig.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/remoteaction/ComposableRemoteAction.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/remoteaction/MappingRemoteAction.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt (98%) rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/BasePNConfiguration.kt (100%) rename pubnub-core/pubnub-core-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/BasePNConfigurationOverride.kt (100%) create mode 100644 pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt delete mode 100644 pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNOperationType.kt delete mode 100644 pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/Result.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/PubNubKMP.podspec create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/Endpoint.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/SpaceId.kt (100%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/Time.kt (76%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt (61%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt (72%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt (74%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt (75%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt (75%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt (71%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt (74%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt (67%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt (74%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt (74%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt (74%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt (74%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt (73%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt (73%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt (74%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt (73%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt (72%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt (71%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt (72%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResults.kt (50%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/access_manager/sum/SpacePermissions.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/access_manager/sum/UserPermissions.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/access_manager/v3/ChannelGrant.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/access_manager/v3/ChannelGroupGrant.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/access_manager/v3/Grants.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/access_manager/v3/UUIDGrant.kt (100%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/PNSortKey.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInput.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt (53%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMemberArrayResult.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/member/PNUUIDDetailsLevel.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/membership/ChannelMembershipInput.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelDetailsLevel.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt (59%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipArrayResult.kt (100%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/presence/PNWhereNowResult.kt (67%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => commonMain}/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt (100%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/Endpoint.kt (95%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/PNConfiguration.kt (99%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.jvm.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/PubNub.kt (87%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/callbacks/SubscribeCallback.kt (99%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt (79%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/FetchMessages.kt (86%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/History.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/MessageCounts.kt (78%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/Time.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/access/Grant.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt (73%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt (76%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt (73%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt (74%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt (75%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt (100%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/files/SendFile.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt (82%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt (80%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt (89%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt (86%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt (75%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt (70%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/presence/GetState.kt (82%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt (84%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/presence/SetState.kt (83%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt (77%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt (85%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt (79%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/PNConfiguration.kt (98%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt (98%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/callbacks/StatusEmitter.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt (94%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/entities/Channel.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{main => jvmMain}/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt (100%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/member/PNMemberArrayResult.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/createEndpoint.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt diff --git a/.gitignore b/.gitignore index 85e832866..0b71ca818 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.kotlin examples .gradle/ .idea/ diff --git a/build-logic/gradle-plugins/build.gradle.kts b/build-logic/gradle-plugins/build.gradle.kts index 1b7a24348..4c427abce 100644 --- a/build-logic/gradle-plugins/build.gradle.kts +++ b/build-logic/gradle-plugins/build.gradle.kts @@ -30,5 +30,17 @@ gradlePlugin { id = "pubnub.integration-test" implementationClass = "com.pubnub.gradle.PubNubIntegrationTestPlugin" } + register("pubnubTest") { + id = "pubnub.test" + implementationClass = "com.pubnub.gradle.PubNubTestPlugin" + } + register("pubnubJavaLibrary") { + id = "pubnub.java-library" + implementationClass = "com.pubnub.gradle.PubNubJavaLibraryPlugin" + } + register("pubnubKotlinLibrary") { + id = "pubnub.kotlin-library" + implementationClass = "com.pubnub.gradle.PubNubKotlinLibraryPlugin" + } } } \ No newline at end of file diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt new file mode 100644 index 000000000..9017fed50 --- /dev/null +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt @@ -0,0 +1,21 @@ +package com.pubnub.gradle + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.JavaLibraryPlugin +import org.gradle.api.tasks.compile.JavaCompile +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.withType + +class PubNubJavaLibraryPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + apply() + apply() + + tasks.withType().configureEach { + it.options.compilerArgs.add("-parameters") + } + } + } +} \ No newline at end of file diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt new file mode 100644 index 000000000..280d86506 --- /dev/null +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt @@ -0,0 +1,58 @@ +package com.pubnub.gradle + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.project +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension +import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper +import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile +import org.jlleitschuh.gradle.ktlint.KtlintExtension +import org.jlleitschuh.gradle.ktlint.KtlintPlugin + +class PubNubKotlinLibraryPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + apply() + apply() + apply() + + // Kotlin + extensions.configure { + jvmToolchain(8) + } + + tasks.named("compileKotlin", KotlinJvmCompile::class.java) { + it.compilerOptions { + javaParameters.set(true) + } + } + + // Ktlint + extensions.configure { + outputToConsole.set(true) + verbose.set(true) + additionalEditorconfig.set( + mapOf( + "ij_kotlin_imports_layout" to "*,java.**,javax.**,kotlin.**,^", + "indent_size" to "4", + "ktlint_standard_multiline-expression-wrapping" to "disabled", + "ktlint_standard_string-template-indent" to "disabled", + "ktlint_standard_max-line-length" to "disabled", + "ktlint_standard_if-else-wrapping" to "disabled", + "ktlint_standard_discouraged-comment-location" to "disabled", + "ktlint_standard_trailing-comma-on-declaration-site" to "disabled", + "ktlint_standard_trailing-comma-on-call-site" to "disabled", + "ktlint_standard_function-signature" to "disabled", + ) + ) + } + + dependencies { + "ktlintRuleset"(project(":build-logic:ktlint-custom-rules")) + } + } + } +} \ No newline at end of file diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt index b9dae867f..4f89ea109 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt @@ -3,87 +3,15 @@ package com.pubnub.gradle import com.vanniktech.maven.publish.MavenPublishPlugin import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.api.plugins.JavaLibraryPlugin -import org.gradle.api.tasks.compile.JavaCompile -import org.gradle.api.tasks.testing.Test import org.gradle.kotlin.dsl.apply -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.dependencies -import org.gradle.kotlin.dsl.named -import org.gradle.kotlin.dsl.project -import org.gradle.kotlin.dsl.withType -import org.gradle.testing.jacoco.plugins.JacocoPlugin -import org.gradle.testing.jacoco.tasks.JacocoReport -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension -import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper -import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile -import org.jlleitschuh.gradle.ktlint.KtlintExtension -import org.jlleitschuh.gradle.ktlint.KtlintPlugin class PubNubSharedPlugin : Plugin { override fun apply(target: Project) { with(target) { apply() - apply() - apply() - apply() - apply() group = providers.gradleProperty("GROUP").get() version = providers.gradleProperty("VERSION_NAME").get() - - // Kotlin - extensions.configure { - jvmToolchain(8) - } - - tasks.named("compileKotlin", KotlinJvmCompile::class.java) { - it.compilerOptions { - javaParameters.set(true) - } - } - tasks.withType().configureEach { - it.options.compilerArgs.add("-parameters") - } - - - // Ktlint - extensions.configure { - outputToConsole.set(true) - verbose.set(true) - additionalEditorconfig.set( - mapOf( - "ij_kotlin_imports_layout" to "*,java.**,javax.**,kotlin.**,^", - "indent_size" to "4", - "ktlint_standard_multiline-expression-wrapping" to "disabled", - "ktlint_standard_string-template-indent" to "disabled", - "ktlint_standard_max-line-length" to "disabled", - "ktlint_standard_if-else-wrapping" to "disabled", - "ktlint_standard_discouraged-comment-location" to "disabled", - "ktlint_standard_trailing-comma-on-declaration-site" to "disabled", - "ktlint_standard_trailing-comma-on-call-site" to "disabled", - "ktlint_standard_function-signature" to "disabled", - ) - ) - } - - dependencies { - "ktlintRuleset"(project(":build-logic:ktlint-custom-rules")) - } - - // Tests - tasks.named("test").configure { test -> - test.failFast = true - test.exclude("**/contract/*.class") - test.useJUnitPlatform() - } - - tasks.withType().configureEach { task -> - task.reports { - it.xml.required.set(true) - it.html.required.set(true) - } - } } } } \ No newline at end of file diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubTestPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubTestPlugin.kt new file mode 100644 index 000000000..73967ae79 --- /dev/null +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubTestPlugin.kt @@ -0,0 +1,34 @@ +package com.pubnub.gradle + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.JavaLibraryPlugin +import org.gradle.api.tasks.testing.Test +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.named +import org.gradle.kotlin.dsl.withType +import org.gradle.testing.jacoco.plugins.JacocoPlugin +import org.gradle.testing.jacoco.tasks.JacocoReport + +class PubNubTestPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + apply() + apply() + + // Tests + tasks.named("test").configure { test -> + test.failFast = true + test.exclude("**/contract/*.class") + test.useJUnitPlatform() + } + + tasks.withType().configureEach { task -> + task.reports { + it.xml.required.set(true) + it.html.required.set(true) + } + } + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index a9e45cb97..b5ae4e47f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,11 +15,11 @@ org.gradle.parallel=true kotlin.code.style=official org.gradle.unsafe.configuration-cache=false -RELEASE_SIGNING_ENABLED=true +RELEASE_SIGNING_ENABLED=false SONATYPE_HOST=DEFAULT SONATYPE_AUTOMATIC_RELEASE=false GROUP=com.pubnub -VERSION_NAME=9.1.1 +VERSION_NAME=9.2-DEV POM_PACKAGING=jar POM_NAME=PubNub SDK diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7744a2c40..b1b5fbff6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,10 +5,10 @@ logback = "1.2.11" okhttp = "4.12.0" retrofit2 = "2.9.0" nexus = "2.0.0-rc-2" -kotlin = "1.8.22" +kotlin = "2.0.0-RC3" vanniktech = "0.22.0" ktlint = "12.1.0" -dokka = "1.8.20" +dokka = "1.9.20" [libraries] retrofit2 = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit2" } diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock new file mode 100644 index 000000000..1a5ead1f0 --- /dev/null +++ b/kotlin-js-store/yarn.lock @@ -0,0 +1,3042 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@colors/colors@1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@colors/colors/-/colors-1.5.0.tgz#bb504579c1cae923e6576a4f5da43d25f97bdbd9" + integrity sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ== + +"@discoveryjs/json-ext@^0.5.0": + version "0.5.7" + resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" + integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== + +"@isaacs/cliui@^8.0.2": + version "8.0.2" + resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550" + integrity sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA== + dependencies: + string-width "^5.1.2" + string-width-cjs "npm:string-width@^4.2.0" + strip-ansi "^7.0.1" + strip-ansi-cjs "npm:strip-ansi@^6.0.1" + wrap-ansi "^8.1.0" + wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" + +"@jridgewell/gen-mapping@^0.3.5": + version "0.3.5" + resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz#dcce6aff74bdf6dad1a95802b69b04a2fcb1fb36" + integrity sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg== + dependencies: + "@jridgewell/set-array" "^1.2.1" + "@jridgewell/sourcemap-codec" "^1.4.10" + "@jridgewell/trace-mapping" "^0.3.24" + +"@jridgewell/resolve-uri@^3.1.0": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz#7a0ee601f60f99a20c7c7c5ff0c80388c1189bd6" + integrity sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw== + +"@jridgewell/set-array@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.2.1.tgz#558fb6472ed16a4c850b889530e6b36438c49280" + integrity sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A== + +"@jridgewell/source-map@^0.3.3": + version "0.3.6" + resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.6.tgz#9d71ca886e32502eb9362c9a74a46787c36df81a" + integrity sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ== + dependencies: + "@jridgewell/gen-mapping" "^0.3.5" + "@jridgewell/trace-mapping" "^0.3.25" + +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14": + version "1.4.15" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz#d7c6e6755c78567a951e04ab52ef0fd26de59f32" + integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== + +"@jridgewell/trace-mapping@^0.3.20", "@jridgewell/trace-mapping@^0.3.24", "@jridgewell/trace-mapping@^0.3.25": + version "0.3.25" + resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz#15f190e98895f3fc23276ee14bc76b675c2e50f0" + integrity sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ== + dependencies: + "@jridgewell/resolve-uri" "^3.1.0" + "@jridgewell/sourcemap-codec" "^1.4.14" + +"@js-joda/core@3.2.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@js-joda/core/-/core-3.2.0.tgz#3e61e21b7b2b8a6be746df1335cf91d70db2a273" + integrity sha512-PMqgJ0sw5B7FKb2d5bWYIoxjri+QlW/Pys7+Rw82jSH0QN3rB05jZ/VrrsUdh1w4+i2kw9JOejXGq/KhDOX7Kg== + +"@jsonjoy.com/base64@^1.1.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@jsonjoy.com/base64/-/base64-1.1.2.tgz#cf8ea9dcb849b81c95f14fc0aaa151c6b54d2578" + integrity sha512-q6XAnWQDIMA3+FTiOYajoYqySkO+JSat0ytXGSuRdq9uXE7o92gzuQwQM14xaCRlBLGq3v5miDGC4vkVTn54xA== + +"@jsonjoy.com/json-pack@^1.0.3": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@jsonjoy.com/json-pack/-/json-pack-1.0.4.tgz#ab59c642a2e5368e8bcfd815d817143d4f3035d0" + integrity sha512-aOcSN4MeAtFROysrbqG137b7gaDDSmVrl5mpo6sT/w+kcXpWnzhMjmY/Fh/sDx26NBxyIE7MB1seqLeCAzy9Sg== + dependencies: + "@jsonjoy.com/base64" "^1.1.1" + "@jsonjoy.com/util" "^1.1.2" + hyperdyperid "^1.2.0" + thingies "^1.20.0" + +"@jsonjoy.com/util@^1.1.2": + version "1.1.3" + resolved "https://registry.yarnpkg.com/@jsonjoy.com/util/-/util-1.1.3.tgz#75b1c3cf21b70e665789d1ad3eabeff8b7fd1429" + integrity sha512-g//kkF4kOwUjemValCtOc/xiYzmwMRmWq3Bn+YnzOzuZLHq2PpMOxxIayN3cKbo7Ko2Np65t6D9H81IvXbXhqg== + +"@leichtgewicht/ip-codec@^2.0.1": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz#4fc56c15c580b9adb7dc3c333a134e540b44bfb1" + integrity sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw== + +"@pkgjs/parseargs@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33" + integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg== + +"@socket.io/component-emitter@~3.1.0": + version "3.1.2" + resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz#821f8442f4175d8f0467b9daf26e3a18e2d02af2" + integrity sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA== + +"@types/body-parser@*": + version "1.19.5" + resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.5.tgz#04ce9a3b677dc8bd681a17da1ab9835dc9d3ede4" + integrity sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg== + dependencies: + "@types/connect" "*" + "@types/node" "*" + +"@types/bonjour@^3.5.13": + version "3.5.13" + resolved "https://registry.yarnpkg.com/@types/bonjour/-/bonjour-3.5.13.tgz#adf90ce1a105e81dd1f9c61fdc5afda1bfb92956" + integrity sha512-z9fJ5Im06zvUL548KvYNecEVlA7cVDkGUi6kZusb04mpyEFKCIZJvloCcmpmLaIahDpOQGHaHmG6imtPMmPXGQ== + dependencies: + "@types/node" "*" + +"@types/connect-history-api-fallback@^1.5.4": + version "1.5.4" + resolved "https://registry.yarnpkg.com/@types/connect-history-api-fallback/-/connect-history-api-fallback-1.5.4.tgz#7de71645a103056b48ac3ce07b3520b819c1d5b3" + integrity sha512-n6Cr2xS1h4uAulPRdlw6Jl6s1oG8KrVilPN2yUITEs+K48EzMJJ3W1xy8K5eWuFvjp3R74AOIGSmp2UfBJ8HFw== + dependencies: + "@types/express-serve-static-core" "*" + "@types/node" "*" + +"@types/connect@*": + version "3.4.38" + resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.38.tgz#5ba7f3bc4fbbdeaff8dded952e5ff2cc53f8d858" + integrity sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug== + dependencies: + "@types/node" "*" + +"@types/cookie@^0.4.1": + version "0.4.1" + resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.1.tgz#bfd02c1f2224567676c1545199f87c3a861d878d" + integrity sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q== + +"@types/cors@^2.8.12": + version "2.8.17" + resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.17.tgz#5d718a5e494a8166f569d986794e49c48b216b2b" + integrity sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA== + dependencies: + "@types/node" "*" + +"@types/eslint-scope@^3.7.3": + version "3.7.7" + resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.7.tgz#3108bd5f18b0cdb277c867b3dd449c9ed7079ac5" + integrity sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg== + dependencies: + "@types/eslint" "*" + "@types/estree" "*" + +"@types/eslint@*": + version "8.56.10" + resolved "https://registry.yarnpkg.com/@types/eslint/-/eslint-8.56.10.tgz#eb2370a73bf04a901eeba8f22595c7ee0f7eb58d" + integrity sha512-Shavhk87gCtY2fhXDctcfS3e6FdxWkCx1iUZ9eEUbh7rTqlZT0/IzOkCOVt0fCjcFuZ9FPYfuezTBImfHCDBGQ== + dependencies: + "@types/estree" "*" + "@types/json-schema" "*" + +"@types/estree@*", "@types/estree@^1.0.5": + version "1.0.5" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" + integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== + +"@types/express-serve-static-core@*", "@types/express-serve-static-core@^4.17.33": + version "4.19.0" + resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.19.0.tgz#3ae8ab3767d98d0b682cda063c3339e1e86ccfaa" + integrity sha512-bGyep3JqPCRry1wq+O5n7oiBgGWmeIJXPjXXCo8EK0u8duZGSYar7cGqd3ML2JUsLGeB7fmc06KYo9fLGWqPvQ== + dependencies: + "@types/node" "*" + "@types/qs" "*" + "@types/range-parser" "*" + "@types/send" "*" + +"@types/express@*", "@types/express@^4.17.21": + version "4.17.21" + resolved "https://registry.yarnpkg.com/@types/express/-/express-4.17.21.tgz#c26d4a151e60efe0084b23dc3369ebc631ed192d" + integrity sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ== + dependencies: + "@types/body-parser" "*" + "@types/express-serve-static-core" "^4.17.33" + "@types/qs" "*" + "@types/serve-static" "*" + +"@types/http-errors@*": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.4.tgz#7eb47726c391b7345a6ec35ad7f4de469cf5ba4f" + integrity sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA== + +"@types/http-proxy@^1.17.8": + version "1.17.14" + resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.14.tgz#57f8ccaa1c1c3780644f8a94f9c6b5000b5e2eec" + integrity sha512-SSrD0c1OQzlFX7pGu1eXxSEjemej64aaNPRhhVYUGqXh0BtldAAx37MG8btcumvpgKyZp1F5Gn3JkktdxiFv6w== + dependencies: + "@types/node" "*" + +"@types/json-schema@*", "@types/json-schema@^7.0.8", "@types/json-schema@^7.0.9": + version "7.0.15" + resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.15.tgz#596a1747233694d50f6ad8a7869fcb6f56cf5841" + integrity sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA== + +"@types/mime@^1": + version "1.3.5" + resolved "https://registry.yarnpkg.com/@types/mime/-/mime-1.3.5.tgz#1ef302e01cf7d2b5a0fa526790c9123bf1d06690" + integrity sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w== + +"@types/node-forge@^1.3.0": + version "1.3.11" + resolved "https://registry.yarnpkg.com/@types/node-forge/-/node-forge-1.3.11.tgz#0972ea538ddb0f4d9c2fa0ec5db5724773a604da" + integrity sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ== + dependencies: + "@types/node" "*" + +"@types/node@*", "@types/node@>=10.0.0": + version "20.12.10" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.12.10.tgz#8f0c3f12b0f075eee1fe20c1afb417e9765bef76" + integrity sha512-Eem5pH9pmWBHoGAT8Dr5fdc5rYA+4NAovdM4EktRPVAAiJhmWWfQrA0cFhAbOsQdSfIHjAud6YdkbL69+zSKjw== + dependencies: + undici-types "~5.26.4" + +"@types/qs@*": + version "6.9.15" + resolved "https://registry.yarnpkg.com/@types/qs/-/qs-6.9.15.tgz#adde8a060ec9c305a82de1babc1056e73bd64dce" + integrity sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg== + +"@types/range-parser@*": + version "1.2.7" + resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb" + integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ== + +"@types/retry@0.12.2": + version "0.12.2" + resolved "https://registry.yarnpkg.com/@types/retry/-/retry-0.12.2.tgz#ed279a64fa438bb69f2480eda44937912bb7480a" + integrity sha512-XISRgDJ2Tc5q4TRqvgJtzsRkFYNJzZrhTdtMoGVBttwzzQJkPnS3WWTFc7kuDRoPtPakl+T+OfdEUjYJj7Jbow== + +"@types/send@*": + version "0.17.4" + resolved "https://registry.yarnpkg.com/@types/send/-/send-0.17.4.tgz#6619cd24e7270793702e4e6a4b958a9010cfc57a" + integrity sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA== + dependencies: + "@types/mime" "^1" + "@types/node" "*" + +"@types/serve-index@^1.9.4": + version "1.9.4" + resolved "https://registry.yarnpkg.com/@types/serve-index/-/serve-index-1.9.4.tgz#e6ae13d5053cb06ed36392110b4f9a49ac4ec898" + integrity sha512-qLpGZ/c2fhSs5gnYsQxtDEq3Oy8SXPClIXkW5ghvAvsNuVSA8k+gCONcUCS/UjLEYvYps+e8uBtfgXgvhwfNug== + dependencies: + "@types/express" "*" + +"@types/serve-static@*", "@types/serve-static@^1.15.5": + version "1.15.7" + resolved "https://registry.yarnpkg.com/@types/serve-static/-/serve-static-1.15.7.tgz#22174bbd74fb97fe303109738e9b5c2f3064f714" + integrity sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw== + dependencies: + "@types/http-errors" "*" + "@types/node" "*" + "@types/send" "*" + +"@types/sockjs@^0.3.36": + version "0.3.36" + resolved "https://registry.yarnpkg.com/@types/sockjs/-/sockjs-0.3.36.tgz#ce322cf07bcc119d4cbf7f88954f3a3bd0f67535" + integrity sha512-MK9V6NzAS1+Ud7JV9lJLFqW85VbC9dq3LmwZCuBe4wBDgKC0Kj/jd8Xl+nSviU+Qc3+m7umHHyHg//2KSa0a0Q== + dependencies: + "@types/node" "*" + +"@types/ws@^8.5.10": + version "8.5.10" + resolved "https://registry.yarnpkg.com/@types/ws/-/ws-8.5.10.tgz#4acfb517970853fa6574a3a6886791d04a396787" + integrity sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A== + dependencies: + "@types/node" "*" + +"@webassemblyjs/ast@1.12.1", "@webassemblyjs/ast@^1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.12.1.tgz#bb16a0e8b1914f979f45864c23819cc3e3f0d4bb" + integrity sha512-EKfMUOPRRUTy5UII4qJDGPpqfwjOmZ5jeGFwid9mnoqIFK+e0vqoi1qH56JpmZSzEL53jKnNzScdmftJyG5xWg== + dependencies: + "@webassemblyjs/helper-numbers" "1.11.6" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + +"@webassemblyjs/floating-point-hex-parser@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.6.tgz#dacbcb95aff135c8260f77fa3b4c5fea600a6431" + integrity sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw== + +"@webassemblyjs/helper-api-error@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz#6132f68c4acd59dcd141c44b18cbebbd9f2fa768" + integrity sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q== + +"@webassemblyjs/helper-buffer@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.12.1.tgz#6df20d272ea5439bf20ab3492b7fb70e9bfcb3f6" + integrity sha512-nzJwQw99DNDKr9BVCOZcLuJJUlqkJh+kVzVl6Fmq/tI5ZtEyWT1KZMyOXltXLZJmDtvLCDgwsyrkohEtopTXCw== + +"@webassemblyjs/helper-numbers@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.6.tgz#cbce5e7e0c1bd32cf4905ae444ef64cea919f1b5" + integrity sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g== + dependencies: + "@webassemblyjs/floating-point-hex-parser" "1.11.6" + "@webassemblyjs/helper-api-error" "1.11.6" + "@xtuc/long" "4.2.2" + +"@webassemblyjs/helper-wasm-bytecode@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz#bb2ebdb3b83aa26d9baad4c46d4315283acd51e9" + integrity sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA== + +"@webassemblyjs/helper-wasm-section@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.12.1.tgz#3da623233ae1a60409b509a52ade9bc22a37f7bf" + integrity sha512-Jif4vfB6FJlUlSbgEMHUyk1j234GTNG9dBJ4XJdOySoj518Xj0oGsNi59cUQF4RRMS9ouBUxDDdyBVfPTypa5g== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/wasm-gen" "1.12.1" + +"@webassemblyjs/ieee754@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.11.6.tgz#bb665c91d0b14fffceb0e38298c329af043c6e3a" + integrity sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg== + dependencies: + "@xtuc/ieee754" "^1.2.0" + +"@webassemblyjs/leb128@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.11.6.tgz#70e60e5e82f9ac81118bc25381a0b283893240d7" + integrity sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ== + dependencies: + "@xtuc/long" "4.2.2" + +"@webassemblyjs/utf8@1.11.6": + version "1.11.6" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.11.6.tgz#90f8bc34c561595fe156603be7253cdbcd0fab5a" + integrity sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA== + +"@webassemblyjs/wasm-edit@^1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.12.1.tgz#9f9f3ff52a14c980939be0ef9d5df9ebc678ae3b" + integrity sha512-1DuwbVvADvS5mGnXbE+c9NfA8QRcZ6iKquqjjmR10k6o+zzsRVesil54DKexiowcFCPdr/Q0qaMgB01+SQ1u6g== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/helper-wasm-section" "1.12.1" + "@webassemblyjs/wasm-gen" "1.12.1" + "@webassemblyjs/wasm-opt" "1.12.1" + "@webassemblyjs/wasm-parser" "1.12.1" + "@webassemblyjs/wast-printer" "1.12.1" + +"@webassemblyjs/wasm-gen@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.12.1.tgz#a6520601da1b5700448273666a71ad0a45d78547" + integrity sha512-TDq4Ojh9fcohAw6OIMXqiIcTq5KUXTGRkVxbSo1hQnSy6lAM5GSdfwWeSxpAo0YzgsgF182E/U0mDNhuA0tW7w== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/ieee754" "1.11.6" + "@webassemblyjs/leb128" "1.11.6" + "@webassemblyjs/utf8" "1.11.6" + +"@webassemblyjs/wasm-opt@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.12.1.tgz#9e6e81475dfcfb62dab574ac2dda38226c232bc5" + integrity sha512-Jg99j/2gG2iaz3hijw857AVYekZe2SAskcqlWIZXjji5WStnOpVoat3gQfT/Q5tb2djnCjBtMocY/Su1GfxPBg== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-buffer" "1.12.1" + "@webassemblyjs/wasm-gen" "1.12.1" + "@webassemblyjs/wasm-parser" "1.12.1" + +"@webassemblyjs/wasm-parser@1.12.1", "@webassemblyjs/wasm-parser@^1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.12.1.tgz#c47acb90e6f083391e3fa61d113650eea1e95937" + integrity sha512-xikIi7c2FHXysxXe3COrVUPSheuBtpcfhbpFj4gmu7KRLYOzANztwUU0IbsqvMqzuNK2+glRGWCEqZo1WCLyAQ== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@webassemblyjs/helper-api-error" "1.11.6" + "@webassemblyjs/helper-wasm-bytecode" "1.11.6" + "@webassemblyjs/ieee754" "1.11.6" + "@webassemblyjs/leb128" "1.11.6" + "@webassemblyjs/utf8" "1.11.6" + +"@webassemblyjs/wast-printer@1.12.1": + version "1.12.1" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.12.1.tgz#bcecf661d7d1abdaf989d8341a4833e33e2b31ac" + integrity sha512-+X4WAlOisVWQMikjbcvY2e0rwPsKQ9F688lksZhBcPycBBuii3O7m8FACbDMWDojpAqvjIncrG8J0XHKyQfVeA== + dependencies: + "@webassemblyjs/ast" "1.12.1" + "@xtuc/long" "4.2.2" + +"@webpack-cli/configtest@^2.1.1": + version "2.1.1" + resolved "https://registry.yarnpkg.com/@webpack-cli/configtest/-/configtest-2.1.1.tgz#3b2f852e91dac6e3b85fb2a314fb8bef46d94646" + integrity sha512-wy0mglZpDSiSS0XHrVR+BAdId2+yxPSoJW8fsna3ZpYSlufjvxnP4YbKTCBZnNIcGN4r6ZPXV55X4mYExOfLmw== + +"@webpack-cli/info@^2.0.2": + version "2.0.2" + resolved "https://registry.yarnpkg.com/@webpack-cli/info/-/info-2.0.2.tgz#cc3fbf22efeb88ff62310cf885c5b09f44ae0fdd" + integrity sha512-zLHQdI/Qs1UyT5UBdWNqsARasIA+AaF8t+4u2aS2nEpBQh2mWIVb8qAklq0eUENnC5mOItrIB4LiS9xMtph18A== + +"@webpack-cli/serve@^2.0.5": + version "2.0.5" + resolved "https://registry.yarnpkg.com/@webpack-cli/serve/-/serve-2.0.5.tgz#325db42395cd49fe6c14057f9a900e427df8810e" + integrity sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ== + +"@xtuc/ieee754@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" + integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== + +"@xtuc/long@4.2.2": + version "4.2.2" + resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" + integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== + +accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.8: + version "1.3.8" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" + integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== + dependencies: + mime-types "~2.1.34" + negotiator "0.6.3" + +acorn-import-assertions@^1.9.0: + version "1.9.0" + resolved "https://registry.yarnpkg.com/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz#507276249d684797c84e0734ef84860334cfb1ac" + integrity sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA== + +acorn@^8.7.1, acorn@^8.8.2: + version "8.11.3" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" + integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== + +ajv-formats@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520" + integrity sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA== + dependencies: + ajv "^8.0.0" + +ajv-keywords@^3.5.2: + version "3.5.2" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d" + integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ== + +ajv-keywords@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-5.1.0.tgz#69d4d385a4733cdbeab44964a1170a88f87f0e16" + integrity sha512-YCS/JNFAUyr5vAuhk1DWm1CBxRHW9LbJ2ozWeemrIqpbsqKjHVxYPyi5GC0rjZIT5JxJ3virVTS8wk4i/Z+krw== + dependencies: + fast-deep-equal "^3.1.3" + +ajv@^6.12.5: + version "6.12.6" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4" + integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ajv@^8.0.0, ajv@^8.9.0: + version "8.13.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.13.0.tgz#a3939eaec9fb80d217ddf0c3376948c023f28c91" + integrity sha512-PRA911Blj99jR5RMeTunVbNXMF6Lp4vZXnk5GQjcnUWUTsrXtekg/pnmFFI2u/I36Y/2bITGS30GZCXei6uNkA== + dependencies: + fast-deep-equal "^3.1.3" + json-schema-traverse "^1.0.0" + require-from-string "^2.0.2" + uri-js "^4.4.1" + +ansi-colors@4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348" + integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA== + +ansi-html-community@^0.0.8: + version "0.0.8" + resolved "https://registry.yarnpkg.com/ansi-html-community/-/ansi-html-community-0.0.8.tgz#69fbc4d6ccbe383f9736934ae34c3f8290f1bf41" + integrity sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw== + +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + +ansi-regex@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== + +ansi-styles@^4.0.0, ansi-styles@^4.1.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937" + integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg== + dependencies: + color-convert "^2.0.1" + +ansi-styles@^6.1.0: + version "6.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5" + integrity sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug== + +anymatch@~3.1.2: + version "3.1.3" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" + integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + +argparse@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38" + integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q== + +array-flatten@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" + integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== + +balanced-match@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" + integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== + +base64id@2.0.0, base64id@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" + integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== + +batch@0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" + integrity sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw== + +binary-extensions@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.3.0.tgz#f6e14a97858d327252200242d4ccfe522c445522" + integrity sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw== + +body-parser@1.20.2, body-parser@^1.19.0: + version "1.20.2" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.2.tgz#6feb0e21c4724d06de7ff38da36dad4f57a747fd" + integrity sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA== + dependencies: + bytes "3.1.2" + content-type "~1.0.5" + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + http-errors "2.0.0" + iconv-lite "0.4.24" + on-finished "2.4.1" + qs "6.11.0" + raw-body "2.5.2" + type-is "~1.6.18" + unpipe "1.0.0" + +bonjour-service@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/bonjour-service/-/bonjour-service-1.2.1.tgz#eb41b3085183df3321da1264719fbada12478d02" + integrity sha512-oSzCS2zV14bh2kji6vNe7vrpJYCHGvcZnlffFQ1MEoX/WOeQ/teD8SYWKR942OI3INjq8OMNJlbPK5LLLUxFDw== + dependencies: + fast-deep-equal "^3.1.3" + multicast-dns "^7.2.5" + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + +braces@^3.0.2, braces@~3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" + integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== + dependencies: + fill-range "^7.0.1" + +browser-stdout@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" + integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw== + +browserslist@^4.21.10: + version "4.23.0" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.23.0.tgz#8f3acc2bbe73af7213399430890f86c63a5674ab" + integrity sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ== + dependencies: + caniuse-lite "^1.0.30001587" + electron-to-chromium "^1.4.668" + node-releases "^2.0.14" + update-browserslist-db "^1.0.13" + +buffer-from@^1.0.0: + version "1.1.2" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" + integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== + +bundle-name@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/bundle-name/-/bundle-name-4.1.0.tgz#f3b96b34160d6431a19d7688135af7cfb8797889" + integrity sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q== + dependencies: + run-applescript "^7.0.0" + +bytes@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048" + integrity sha512-pMhOfFDPiv9t5jjIXkHosWmkSyQbvsgEVNkz0ERHbuLh2T/7j4Mqqpz523Fe8MVY89KC6Sh/QfS2sM+SjgFDcw== + +bytes@3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" + integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== + +call-bind@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.7.tgz#06016599c40c56498c18769d2730be242b6fa3b9" + integrity sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + set-function-length "^1.2.1" + +camelcase@^6.0.0: + version "6.3.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" + integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== + +caniuse-lite@^1.0.30001587: + version "1.0.30001616" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001616.tgz#4342712750d35f71ebba9fcac65e2cf8870013c3" + integrity sha512-RHVYKov7IcdNjVHJFNY/78RdG4oGVjbayxv8u5IO74Wv7Hlq4PnJE6mo/OjFijjVFNy5ijnCt6H3IIo4t+wfEw== + +chalk@^4.1.0: + version "4.1.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles "^4.1.0" + supports-color "^7.1.0" + +chokidar@3.5.3: + version "3.5.3" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" + integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +chokidar@^3.5.1, chokidar@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b" + integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + +chrome-trace-event@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz#1015eced4741e15d06664a957dbbf50d041e26ac" + integrity sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg== + +cliui@^7.0.2: + version "7.0.4" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" + integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== + dependencies: + string-width "^4.2.0" + strip-ansi "^6.0.0" + wrap-ansi "^7.0.0" + +clone-deep@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/clone-deep/-/clone-deep-4.0.1.tgz#c19fd9bdbbf85942b4fd979c84dcf7d5f07c2387" + integrity sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ== + dependencies: + is-plain-object "^2.0.4" + kind-of "^6.0.2" + shallow-clone "^3.0.0" + +color-convert@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3" + integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ== + dependencies: + color-name "~1.1.4" + +color-name@~1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" + integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== + +colorette@^2.0.10, colorette@^2.0.14: + version "2.0.20" + resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" + integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== + +commander@^10.0.1: + version "10.0.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" + integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug== + +commander@^2.20.0: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + +compressible@~2.0.16: + version "2.0.18" + resolved "https://registry.yarnpkg.com/compressible/-/compressible-2.0.18.tgz#af53cca6b070d4c3c0750fbd77286a6d7cc46fba" + integrity sha512-AF3r7P5dWxL8MxyITRMlORQNaOA2IkAFaTr4k7BUumjPtRpGDTZpl0Pb1XCO6JeDCBdp126Cgs9sMxqSjgYyRg== + dependencies: + mime-db ">= 1.43.0 < 2" + +compression@^1.7.4: + version "1.7.4" + resolved "https://registry.yarnpkg.com/compression/-/compression-1.7.4.tgz#95523eff170ca57c29a0ca41e6fe131f41e5bb8f" + integrity sha512-jaSIDzP9pZVS4ZfQ+TzvtiWhdpFhE2RDHz8QJkpX9SIpLq88VueF5jJw6t+6CUQcAoA6t+x89MLrWAqpfDE8iQ== + dependencies: + accepts "~1.3.5" + bytes "3.0.0" + compressible "~2.0.16" + debug "2.6.9" + on-headers "~1.0.2" + safe-buffer "5.1.2" + vary "~1.1.2" + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== + +connect-history-api-fallback@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-2.0.0.tgz#647264845251a0daf25b97ce87834cace0f5f1c8" + integrity sha512-U73+6lQFmfiNPrYbXqr6kZ1i1wiRqXnp2nhMsINseWXO8lDau0LGEffJ8kQi4EjLZympVgRdvqjAgiZ1tgzDDA== + +connect@^3.7.0: + version "3.7.0" + resolved "https://registry.yarnpkg.com/connect/-/connect-3.7.0.tgz#5d49348910caa5e07a01800b030d0c35f20484f8" + integrity sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ== + dependencies: + debug "2.6.9" + finalhandler "1.1.2" + parseurl "~1.3.3" + utils-merge "1.0.1" + +content-disposition@0.5.4: + version "0.5.4" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe" + integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ== + dependencies: + safe-buffer "5.2.1" + +content-type@~1.0.4, content-type@~1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918" + integrity sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA== + +cookie-signature@1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" + integrity sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ== + +cookie@0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.6.0.tgz#2798b04b071b0ecbff0dbb62a505a8efa4e19051" + integrity sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw== + +cookie@~0.4.1: + version "0.4.2" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.2.tgz#0e41f24de5ecf317947c82fc789e06a884824432" + integrity sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA== + +core-util-is@~1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" + integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== + +cors@~2.8.5: + version "2.8.5" + resolved "https://registry.yarnpkg.com/cors/-/cors-2.8.5.tgz#eac11da51592dd86b9f06f6e7ac293b3df875d29" + integrity sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g== + dependencies: + object-assign "^4" + vary "^1" + +cross-spawn@^7.0.0, cross-spawn@^7.0.3: + version "7.0.3" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" + integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== + dependencies: + path-key "^3.1.0" + shebang-command "^2.0.0" + which "^2.0.1" + +custom-event@~1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" + integrity sha512-GAj5FOq0Hd+RsCGVJxZuKaIDXDf3h6GQoNEjFgbLLI/trgtavwUbSnZ5pVfg27DVCaWjIohryS0JFwIJyT2cMg== + +date-format@^4.0.14: + version "4.0.14" + resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.14.tgz#7a8e584434fb169a521c8b7aa481f355810d9400" + integrity sha512-39BOQLs9ZjKh0/patS9nrT8wc3ioX3/eA/zgbKNopnF2wCqJEoxywwwElATYvRsXdnOxA/OQeQoFZ3rFjVajhg== + +debug@2.6.9: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +debug@4.3.4, debug@^4.1.0, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2, debug@~4.3.4: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" + integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== + dependencies: + ms "2.1.2" + +decamelize@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837" + integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== + +default-browser-id@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/default-browser-id/-/default-browser-id-5.0.0.tgz#a1d98bf960c15082d8a3fa69e83150ccccc3af26" + integrity sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA== + +default-browser@^5.2.1: + version "5.2.1" + resolved "https://registry.yarnpkg.com/default-browser/-/default-browser-5.2.1.tgz#7b7ba61204ff3e425b556869ae6d3e9d9f1712cf" + integrity sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg== + dependencies: + bundle-name "^4.1.0" + default-browser-id "^5.0.0" + +default-gateway@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/default-gateway/-/default-gateway-6.0.3.tgz#819494c888053bdb743edbf343d6cdf7f2943a71" + integrity sha512-fwSOJsbbNzZ/CUFpqFBqYfYNLj1NbMPm8MMCIzHjC83iSJRBEGmDUxU+WP661BaBQImeC2yHwXtz+P/O9o+XEg== + dependencies: + execa "^5.0.0" + +define-data-property@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" + integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + gopd "^1.0.1" + +define-lazy-prop@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz#dbb19adfb746d7fc6d734a06b72f4a00d021255f" + integrity sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg== + +depd@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" + integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== + +depd@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" + integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ== + +destroy@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" + integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== + +detect-node@^2.0.4: + version "2.1.0" + resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1" + integrity sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g== + +di@^0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/di/-/di-0.0.1.tgz#806649326ceaa7caa3306d75d985ea2748ba913c" + integrity sha512-uJaamHkagcZtHPqCIHZxnFrXlunQXgBOsZSUOWwFw31QJCAbyTBoHMW75YOTur5ZNx8pIeAKgf6GWIgaqqiLhA== + +diff@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b" + integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w== + +dns-packet@^5.2.2: + version "5.6.1" + resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.6.1.tgz#ae888ad425a9d1478a0674256ab866de1012cf2f" + integrity sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw== + dependencies: + "@leichtgewicht/ip-codec" "^2.0.1" + +dom-serialize@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/dom-serialize/-/dom-serialize-2.2.1.tgz#562ae8999f44be5ea3076f5419dcd59eb43ac95b" + integrity sha512-Yra4DbvoW7/Z6LBN560ZwXMjoNOSAN2wRsKFGc4iBeso+mpIA6qj1vfdf9HpMaKAqG6wXTy+1SYEzmNpKXOSsQ== + dependencies: + custom-event "~1.0.0" + ent "~2.2.0" + extend "^3.0.0" + void-elements "^2.0.0" + +eastasianwidth@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/eastasianwidth/-/eastasianwidth-0.2.0.tgz#696ce2ec0aa0e6ea93a397ffcf24aa7840c827cb" + integrity sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA== + +ee-first@1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" + integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== + +electron-to-chromium@^1.4.668: + version "1.4.758" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.758.tgz#f39e530cae2ca4329a0f0e1840629d8d1da73156" + integrity sha512-/o9x6TCdrYZBMdGeTifAP3wlF/gVT+TtWJe3BSmtNh92Mw81U9hrYwW9OAGUh+sEOX/yz5e34sksqRruZbjYrw== + +emoji-regex@^8.0.0: + version "8.0.0" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" + integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== + +emoji-regex@^9.2.2: + version "9.2.2" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" + integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== + +encodeurl@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" + integrity sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w== + +engine.io-parser@~5.2.1: + version "5.2.2" + resolved "https://registry.yarnpkg.com/engine.io-parser/-/engine.io-parser-5.2.2.tgz#37b48e2d23116919a3453738c5720455e64e1c49" + integrity sha512-RcyUFKA93/CXH20l4SoVvzZfrSDMOTUS3bWVpTt2FuFP+XYrL8i8oonHP7WInRyVHXh0n/ORtoeiE1os+8qkSw== + +engine.io@~6.5.2: + version "6.5.4" + resolved "https://registry.yarnpkg.com/engine.io/-/engine.io-6.5.4.tgz#6822debf324e781add2254e912f8568508850cdc" + integrity sha512-KdVSDKhVKyOi+r5uEabrDLZw2qXStVvCsEB/LN3mw4WFi6Gx50jTyuxYVCwAAC0U46FdnzP/ScKRBTXb/NiEOg== + dependencies: + "@types/cookie" "^0.4.1" + "@types/cors" "^2.8.12" + "@types/node" ">=10.0.0" + accepts "~1.3.4" + base64id "2.0.0" + cookie "~0.4.1" + cors "~2.8.5" + debug "~4.3.1" + engine.io-parser "~5.2.1" + ws "~8.11.0" + +enhanced-resolve@^5.16.0: + version "5.16.1" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.16.1.tgz#e8bc63d51b826d6f1cbc0a150ecb5a8b0c62e567" + integrity sha512-4U5pNsuDl0EhuZpq46M5xPslstkviJuhrdobaRDBk2Jy2KO37FDAJl4lb2KlNabxT0m4MTK2UHNrsAcphE8nyw== + dependencies: + graceful-fs "^4.2.4" + tapable "^2.2.0" + +ent@~2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/ent/-/ent-2.2.0.tgz#e964219325a21d05f44466a2f686ed6ce5f5dd1d" + integrity sha512-GHrMyVZQWvTIdDtpiEXdHZnFQKzeO09apj8Cbl4pKWy4i0Oprcq17usfDt5aO63swf0JOeMWjWQE/LzgSRuWpA== + +envinfo@^7.7.3: + version "7.13.0" + resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.13.0.tgz#81fbb81e5da35d74e814941aeab7c325a606fb31" + integrity sha512-cvcaMr7KqXVh4nyzGTVqTum+gAiL265x5jUWQIDLq//zOGbW+gSW/C+OWLleY/rs9Qole6AZLMXPbtIFQbqu+Q== + +es-define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845" + integrity sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ== + dependencies: + get-intrinsic "^1.2.4" + +es-errors@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" + integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== + +es-module-lexer@^1.2.1: + version "1.5.2" + resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.5.2.tgz#00b423304f2500ac59359cc9b6844951f372d497" + integrity sha512-l60ETUTmLqbVbVHv1J4/qj+M8nq7AwMzEcg3kmJDt9dCNrTk+yHcYFf/Kw75pMDwd9mPcIGCG5LcS20SxYRzFA== + +escalade@^3.1.1, escalade@^3.1.2: + version "3.1.2" + resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27" + integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA== + +escape-html@~1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" + integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== + +escape-string-regexp@4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" + integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== + +eslint-scope@5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" + integrity sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw== + dependencies: + esrecurse "^4.3.0" + estraverse "^4.1.1" + +esrecurse@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" + integrity sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag== + dependencies: + estraverse "^5.2.0" + +estraverse@^4.1.1: + version "4.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" + integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== + +estraverse@^5.2.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" + integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== + +etag@~1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" + integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== + +eventemitter3@^4.0.0: + version "4.0.7" + resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + +events@^3.2.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.3.0.tgz#31a95ad0a924e2d2c419a813aeb2c4e878ea7400" + integrity sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q== + +execa@^5.0.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" + integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== + dependencies: + cross-spawn "^7.0.3" + get-stream "^6.0.0" + human-signals "^2.1.0" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.1" + onetime "^5.1.2" + signal-exit "^3.0.3" + strip-final-newline "^2.0.0" + +express@^4.17.3: + version "4.19.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.19.2.tgz#e25437827a3aa7f2a827bc8171bbbb664a356465" + integrity sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q== + dependencies: + accepts "~1.3.8" + array-flatten "1.1.1" + body-parser "1.20.2" + content-disposition "0.5.4" + content-type "~1.0.4" + cookie "0.6.0" + cookie-signature "1.0.6" + debug "2.6.9" + depd "2.0.0" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + finalhandler "1.2.0" + fresh "0.5.2" + http-errors "2.0.0" + merge-descriptors "1.0.1" + methods "~1.1.2" + on-finished "2.4.1" + parseurl "~1.3.3" + path-to-regexp "0.1.7" + proxy-addr "~2.0.7" + qs "6.11.0" + range-parser "~1.2.1" + safe-buffer "5.2.1" + send "0.18.0" + serve-static "1.15.0" + setprototypeof "1.2.0" + statuses "2.0.1" + type-is "~1.6.18" + utils-merge "1.0.1" + vary "~1.1.2" + +extend@^3.0.0: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" + integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== + +fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== + +fast-json-stable-stringify@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +fastest-levenshtein@^1.0.12: + version "1.0.16" + resolved "https://registry.yarnpkg.com/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz#210e61b6ff181de91ea9b3d1b84fdedd47e034e5" + integrity sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg== + +faye-websocket@^0.11.3: + version "0.11.4" + resolved "https://registry.yarnpkg.com/faye-websocket/-/faye-websocket-0.11.4.tgz#7f0d9275cfdd86a1c963dc8b65fcc451edcbb1da" + integrity sha512-CzbClwlXAuiRQAlUyfqPgvPoNKTckTPGfwZV4ZdAhVcP2lh9KUxJg2b5GkE7XbjKQ3YJnQ9z6D9ntLAlB+tP8g== + dependencies: + websocket-driver ">=0.5.1" + +fill-range@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" + integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== + dependencies: + to-regex-range "^5.0.1" + +finalhandler@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" + integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== + dependencies: + debug "2.6.9" + encodeurl "~1.0.2" + escape-html "~1.0.3" + on-finished "~2.3.0" + parseurl "~1.3.3" + statuses "~1.5.0" + unpipe "~1.0.0" + +finalhandler@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.2.0.tgz#7d23fe5731b207b4640e4fcd00aec1f9207a7b32" + integrity sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg== + dependencies: + debug "2.6.9" + encodeurl "~1.0.2" + escape-html "~1.0.3" + on-finished "2.4.1" + parseurl "~1.3.3" + statuses "2.0.1" + unpipe "~1.0.0" + +find-up@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc" + integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng== + dependencies: + locate-path "^6.0.0" + path-exists "^4.0.0" + +find-up@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19" + integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw== + dependencies: + locate-path "^5.0.0" + path-exists "^4.0.0" + +flat@^5.0.2: + version "5.0.2" + resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241" + integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== + +flatted@^3.2.7: + version "3.3.1" + resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.3.1.tgz#21db470729a6734d4997002f439cb308987f567a" + integrity sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw== + +follow-redirects@^1.0.0: + version "1.15.6" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.6.tgz#7f815c0cda4249c74ff09e95ef97c23b5fd0399b" + integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== + +foreground-child@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-3.1.1.tgz#1d173e776d75d2772fed08efe4a0de1ea1b12d0d" + integrity sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg== + dependencies: + cross-spawn "^7.0.0" + signal-exit "^4.0.1" + +format-util@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271" + integrity sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg== + +forwarded@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" + integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== + +fresh@0.5.2: + version "0.5.2" + resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" + integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== + +fs-extra@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" + integrity sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^4.0.0" + universalify "^0.1.0" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw== + +fsevents@~2.3.2: + version "2.3.3" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" + integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== + +function-bind@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.2.tgz#2c02d864d97f3ea6c8830c464cbd11ab6eab7a1c" + integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== + +get-caller-file@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-intrinsic@^1.1.3, get-intrinsic@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.4.tgz#e385f5a4b5227d449c3eabbad05494ef0abbeadd" + integrity sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ== + dependencies: + es-errors "^1.3.0" + function-bind "^1.1.2" + has-proto "^1.0.1" + has-symbols "^1.0.3" + hasown "^2.0.0" + +get-stream@^6.0.0: + version "6.0.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" + integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== + +glob-parent@~5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" + integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== + dependencies: + is-glob "^4.0.1" + +glob-to-regexp@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" + integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== + +glob@8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/glob/-/glob-8.1.0.tgz#d388f656593ef708ee3e34640fdfb99a9fd1c33e" + integrity sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^5.0.1" + once "^1.3.0" + +glob@^10.3.7: + version "10.3.12" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.3.12.tgz#3a65c363c2e9998d220338e88a5f6ac97302960b" + integrity sha512-TCNv8vJ+xz4QiqTpfOJA7HvYv+tNIRHKfUWw/q+v2jdgN4ebz+KY9tGx5J4rHP0o84mNP+ApH66HRX8us3Khqg== + dependencies: + foreground-child "^3.1.0" + jackspeak "^2.3.6" + minimatch "^9.0.1" + minipass "^7.0.4" + path-scurry "^1.10.2" + +glob@^7.1.3, glob@^7.1.7: + version "7.2.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.3.tgz#b8df0fb802bbfa8e89bd1d938b4e16578ed44f2b" + integrity sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.1.1" + once "^1.3.0" + path-is-absolute "^1.0.0" + +gopd@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/gopd/-/gopd-1.0.1.tgz#29ff76de69dac7489b7c0918a5788e56477c332c" + integrity sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA== + dependencies: + get-intrinsic "^1.1.3" + +graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.10, graceful-fs@^4.2.11, graceful-fs@^4.2.4, graceful-fs@^4.2.6: + version "4.2.11" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== + +handle-thing@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.1.tgz#857f79ce359580c340d43081cc648970d0bb234e" + integrity sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg== + +has-flag@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b" + integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ== + +has-property-descriptors@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" + integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== + dependencies: + es-define-property "^1.0.0" + +has-proto@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-proto/-/has-proto-1.0.3.tgz#b31ddfe9b0e6e9914536a6ab286426d0214f77fd" + integrity sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q== + +has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + +hasown@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" + integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== + dependencies: + function-bind "^1.1.2" + +he@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" + integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== + +hpack.js@^2.1.6: + version "2.1.6" + resolved "https://registry.yarnpkg.com/hpack.js/-/hpack.js-2.1.6.tgz#87774c0949e513f42e84575b3c45681fade2a0b2" + integrity sha512-zJxVehUdMGIKsRaNt7apO2Gqp0BdqW5yaiGHXXmbpvxgBYVZnAql+BJb4RO5ad2MgpbZKn5G6nMnegrH1FcNYQ== + dependencies: + inherits "^2.0.1" + obuf "^1.0.0" + readable-stream "^2.0.1" + wbuf "^1.1.0" + +html-entities@^2.4.0: + version "2.5.2" + resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.5.2.tgz#201a3cf95d3a15be7099521620d19dfb4f65359f" + integrity sha512-K//PSRMQk4FZ78Kyau+mZurHn3FH0Vwr+H36eE0rPbeYkRRi9YxceYPhuN60UwWorxyKHhqoAJl2OFKa4BVtaA== + +http-deceiver@^1.2.7: + version "1.2.7" + resolved "https://registry.yarnpkg.com/http-deceiver/-/http-deceiver-1.2.7.tgz#fa7168944ab9a519d337cb0bec7284dc3e723d87" + integrity sha512-LmpOGxTfbpgtGVxJrj5k7asXHCgNZp5nLfp+hWc8QQRqtb7fUy6kRY3BO1h9ddF6yIPYUARgxGOwB42DnxIaNw== + +http-errors@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" + integrity sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ== + dependencies: + depd "2.0.0" + inherits "2.0.4" + setprototypeof "1.2.0" + statuses "2.0.1" + toidentifier "1.0.1" + +http-errors@~1.6.2: + version "1.6.3" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" + integrity sha512-lks+lVC8dgGyh97jxvxeYTWQFvh4uw4yC12gVl63Cg30sjPX4wuGcdkICVXDAESr6OJGjqGA8Iz5mkeN6zlD7A== + dependencies: + depd "~1.1.2" + inherits "2.0.3" + setprototypeof "1.1.0" + statuses ">= 1.4.0 < 2" + +http-parser-js@>=0.5.1: + version "0.5.8" + resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.8.tgz#af23090d9ac4e24573de6f6aecc9d84a48bf20e3" + integrity sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q== + +http-proxy-middleware@^2.0.3: + version "2.0.6" + resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f" + integrity sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw== + dependencies: + "@types/http-proxy" "^1.17.8" + http-proxy "^1.18.1" + is-glob "^4.0.1" + is-plain-obj "^3.0.0" + micromatch "^4.0.2" + +http-proxy@^1.18.1: + version "1.18.1" + resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" + integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== + dependencies: + eventemitter3 "^4.0.0" + follow-redirects "^1.0.0" + requires-port "^1.0.0" + +human-signals@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" + integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== + +hyperdyperid@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/hyperdyperid/-/hyperdyperid-1.2.0.tgz#59668d323ada92228d2a869d3e474d5a33b69e6b" + integrity sha512-Y93lCzHYgGWdrJ66yIktxiaGULYc6oGiABxhcO5AufBeOyoIdZF7bIfLaOrbM0iGIOXQQgxxRrFEnb+Y6w1n4A== + +iconv-lite@0.4.24: + version "0.4.24" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b" + integrity sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA== + dependencies: + safer-buffer ">= 2.1.2 < 3" + +iconv-lite@^0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.6.3.tgz#a52f80bf38da1952eb5c681790719871a1a72501" + integrity sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw== + dependencies: + safer-buffer ">= 2.1.2 < 3.0.0" + +import-local@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" + integrity sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg== + dependencies: + pkg-dir "^4.2.0" + resolve-cwd "^3.0.0" + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA== + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@2.0.4, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw== + +interpret@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4" + integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ== + +ipaddr.js@1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" + integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== + +ipaddr.js@^2.1.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-2.2.0.tgz#d33fa7bac284f4de7af949638c9d68157c6b92e8" + integrity sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA== + +is-binary-path@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" + integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== + dependencies: + binary-extensions "^2.0.0" + +is-core-module@^2.13.0: + version "2.13.1" + resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.13.1.tgz#ad0d7532c6fea9da1ebdc82742d74525c6273384" + integrity sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw== + dependencies: + hasown "^2.0.0" + +is-docker@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-3.0.0.tgz#90093aa3106277d8a77a5910dbae71747e15a200" + integrity sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ== + +is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== + +is-fullwidth-code-point@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" + integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== + +is-glob@^4.0.1, is-glob@~4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" + integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== + dependencies: + is-extglob "^2.1.1" + +is-inside-container@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-inside-container/-/is-inside-container-1.0.0.tgz#e81fba699662eb31dbdaf26766a61d4814717ea4" + integrity sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA== + dependencies: + is-docker "^3.0.0" + +is-network-error@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-network-error/-/is-network-error-1.1.0.tgz#d26a760e3770226d11c169052f266a4803d9c997" + integrity sha512-tUdRRAnhT+OtCZR/LxZelH/C7QtjtFrTu5tXCA8pl55eTUElUHT+GPYV8MBMBvea/j+NxQqVt3LbWMRir7Gx9g== + +is-number@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" + integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== + +is-plain-obj@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" + integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== + +is-plain-obj@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-3.0.0.tgz#af6f2ea14ac5a646183a5bbdb5baabbc156ad9d7" + integrity sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA== + +is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== + dependencies: + isobject "^3.0.1" + +is-stream@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.1.tgz#fac1e3d53b97ad5a9d0ae9cef2389f5810a5c077" + integrity sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg== + +is-unicode-supported@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7" + integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw== + +is-wsl@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-3.1.0.tgz#e1c657e39c10090afcbedec61720f6b924c3cbd2" + integrity sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw== + dependencies: + is-inside-container "^1.0.0" + +isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ== + +isbinaryfile@^4.0.8: + version "4.0.10" + resolved "https://registry.yarnpkg.com/isbinaryfile/-/isbinaryfile-4.0.10.tgz#0c5b5e30c2557a2f06febd37b7322946aaee42b3" + integrity sha512-iHrqe5shvBUcFbmZq9zOQHBoeOhZJu6RQGrDpBgenUm/Am+F3JM2MgQj+rK3Z601fzrL5gLZWtAPH2OBaSVcyw== + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw== + +isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg== + +jackspeak@^2.3.6: + version "2.3.6" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-2.3.6.tgz#647ecc472238aee4b06ac0e461acc21a8c505ca8" + integrity sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ== + dependencies: + "@isaacs/cliui" "^8.0.2" + optionalDependencies: + "@pkgjs/parseargs" "^0.11.0" + +jest-worker@^27.4.5: + version "27.5.1" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-27.5.1.tgz#8d146f0900e8973b106b6f73cc1e9a8cb86f8db0" + integrity sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg== + dependencies: + "@types/node" "*" + merge-stream "^2.0.0" + supports-color "^8.0.0" + +js-yaml@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" + integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== + dependencies: + argparse "^2.0.1" + +json-parse-even-better-errors@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" + integrity sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w== + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json-schema-traverse@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" + integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== + +jsonfile@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb" + integrity sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg== + optionalDependencies: + graceful-fs "^4.1.6" + +karma-chrome-launcher@3.2.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-3.2.0.tgz#eb9c95024f2d6dfbb3748d3415ac9b381906b9a9" + integrity sha512-rE9RkUPI7I9mAxByQWkGJFXfFD6lE4gC5nPuZdobf/QdTEJI6EU4yIay/cfU/xV4ZxlM5JiTv7zWYgA64NpS5Q== + dependencies: + which "^1.2.1" + +karma-mocha@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/karma-mocha/-/karma-mocha-2.0.1.tgz#4b0254a18dfee71bdbe6188d9a6861bf86b0cd7d" + integrity sha512-Tzd5HBjm8his2OA4bouAsATYEpZrp9vC7z5E5j4C5Of5Rrs1jY67RAwXNcVmd/Bnk1wgvQRou0zGVLey44G4tQ== + dependencies: + minimist "^1.2.3" + +karma-sourcemap-loader@0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/karma-sourcemap-loader/-/karma-sourcemap-loader-0.4.0.tgz#b01d73f8f688f533bcc8f5d273d43458e13b5488" + integrity sha512-xCRL3/pmhAYF3I6qOrcn0uhbQevitc2DERMPH82FMnG+4WReoGcGFZb1pURf2a5apyrOHRdvD+O6K7NljqKHyA== + dependencies: + graceful-fs "^4.2.10" + +karma-webpack@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/karma-webpack/-/karma-webpack-5.0.1.tgz#4eafd31bbe684a747a6e8f3e4ad373e53979ced4" + integrity sha512-oo38O+P3W2mSPCSUrQdySSPv1LvPpXP+f+bBimNomS5sW+1V4SuhCuW8TfJzV+rDv921w2fDSDw0xJbPe6U+kQ== + dependencies: + glob "^7.1.3" + minimatch "^9.0.3" + webpack-merge "^4.1.5" + +karma@6.4.3: + version "6.4.3" + resolved "https://registry.yarnpkg.com/karma/-/karma-6.4.3.tgz#763e500f99597218bbb536de1a14acc4ceea7ce8" + integrity sha512-LuucC/RE92tJ8mlCwqEoRWXP38UMAqpnq98vktmS9SznSoUPPUJQbc91dHcxcunROvfQjdORVA/YFviH+Xci9Q== + dependencies: + "@colors/colors" "1.5.0" + body-parser "^1.19.0" + braces "^3.0.2" + chokidar "^3.5.1" + connect "^3.7.0" + di "^0.0.1" + dom-serialize "^2.2.1" + glob "^7.1.7" + graceful-fs "^4.2.6" + http-proxy "^1.18.1" + isbinaryfile "^4.0.8" + lodash "^4.17.21" + log4js "^6.4.1" + mime "^2.5.2" + minimatch "^3.0.4" + mkdirp "^0.5.5" + qjobs "^1.2.0" + range-parser "^1.2.1" + rimraf "^3.0.2" + socket.io "^4.7.2" + source-map "^0.6.1" + tmp "^0.2.1" + ua-parser-js "^0.7.30" + yargs "^16.1.1" + +kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + +launch-editor@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/launch-editor/-/launch-editor-2.6.1.tgz#f259c9ef95cbc9425620bbbd14b468fcdb4ffe3c" + integrity sha512-eB/uXmFVpY4zezmGp5XtU21kwo7GBbKB+EQ+UZeWtGb9yAM5xt/Evk+lYH3eRNAtId+ej4u7TYPFZ07w4s7rRw== + dependencies: + picocolors "^1.0.0" + shell-quote "^1.8.1" + +loader-runner@^4.2.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" + integrity sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg== + +locate-path@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" + integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g== + dependencies: + p-locate "^4.1.0" + +locate-path@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" + integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw== + dependencies: + p-locate "^5.0.0" + +lodash@^4.17.15, lodash@^4.17.21: + version "4.17.21" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" + integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== + +log-symbols@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503" + integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg== + dependencies: + chalk "^4.1.0" + is-unicode-supported "^0.1.0" + +log4js@^6.4.1: + version "6.9.1" + resolved "https://registry.yarnpkg.com/log4js/-/log4js-6.9.1.tgz#aba5a3ff4e7872ae34f8b4c533706753709e38b6" + integrity sha512-1somDdy9sChrr9/f4UlzhdaGfDR2c/SaD2a4T7qEkG4jTS57/B3qmnjLYePwQ8cqWnUHZI0iAKxMBpCZICiZ2g== + dependencies: + date-format "^4.0.14" + debug "^4.3.4" + flatted "^3.2.7" + rfdc "^1.3.0" + streamroller "^3.1.5" + +lru-cache@^10.2.0: + version "10.2.2" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.2.tgz#48206bc114c1252940c41b25b41af5b545aca878" + integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== + +media-typer@0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" + integrity sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ== + +memfs@^4.6.0: + version "4.9.2" + resolved "https://registry.yarnpkg.com/memfs/-/memfs-4.9.2.tgz#42e7b48207268dad8c9c48ea5d4952c5d3840433" + integrity sha512-f16coDZlTG1jskq3mxarwB+fGRrd0uXWt+o1WIhRfOwbXQZqUDsTVxQBFK9JjRQHblg8eAG2JSbprDXKjc7ijQ== + dependencies: + "@jsonjoy.com/json-pack" "^1.0.3" + "@jsonjoy.com/util" "^1.1.2" + sonic-forest "^1.0.0" + tslib "^2.0.0" + +merge-descriptors@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/merge-descriptors/-/merge-descriptors-1.0.1.tgz#b00aaa556dd8b44568150ec9d1b953f3f90cbb61" + integrity sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w== + +merge-stream@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60" + integrity sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w== + +methods@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee" + integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w== + +micromatch@^4.0.2: + version "4.0.5" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" + integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== + dependencies: + braces "^3.0.2" + picomatch "^2.3.1" + +mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": + version "1.52.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" + integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== + +mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34: + version "2.1.35" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" + integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== + dependencies: + mime-db "1.52.0" + +mime@1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-1.6.0.tgz#32cd9e5c64553bd58d19a568af452acff04981b1" + integrity sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg== + +mime@^2.5.2: + version "2.6.0" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.6.0.tgz#a2a682a95cd4d0cb1d6257e28f83da7e35800367" + integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== + +mimic-fn@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" + integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== + +minimalistic-assert@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" + integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== + +minimatch@5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b" + integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g== + dependencies: + brace-expansion "^2.0.1" + +minimatch@^3.0.4, minimatch@^3.1.1: + version "3.1.2" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" + integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== + dependencies: + brace-expansion "^1.1.7" + +minimatch@^5.0.1: + version "5.1.6" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.6.tgz#1cfcb8cf5522ea69952cd2af95ae09477f122a96" + integrity sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g== + dependencies: + brace-expansion "^2.0.1" + +minimatch@^9.0.1, minimatch@^9.0.3: + version "9.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.4.tgz#8e49c731d1749cbec05050ee5145147b32496a51" + integrity sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw== + dependencies: + brace-expansion "^2.0.1" + +minimist@^1.2.3, minimist@^1.2.6: + version "1.2.8" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c" + integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA== + +"minipass@^5.0.0 || ^6.0.2 || ^7.0.0", minipass@^7.0.4: + version "7.1.0" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-7.1.0.tgz#b545f84af94e567386770159302ca113469c80b8" + integrity sha512-oGZRv2OT1lO2UF1zUcwdTb3wqUwI0kBGTgt/T7OdSj6M6N5m3o5uPf0AIW6lVxGGoiWUR7e2AwTE+xiwK8WQig== + +mkdirp@^0.5.5: + version "0.5.6" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" + integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== + dependencies: + minimist "^1.2.6" + +mocha@10.3.0: + version "10.3.0" + resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.3.0.tgz#0e185c49e6dccf582035c05fa91084a4ff6e3fe9" + integrity sha512-uF2XJs+7xSLsrmIvn37i/wnc91nw7XjOQB8ccyx5aEgdnohr7n+rEiZP23WkCYHjilR6+EboEnbq/ZQDz4LSbg== + dependencies: + ansi-colors "4.1.1" + browser-stdout "1.3.1" + chokidar "3.5.3" + debug "4.3.4" + diff "5.0.0" + escape-string-regexp "4.0.0" + find-up "5.0.0" + glob "8.1.0" + he "1.2.0" + js-yaml "4.1.0" + log-symbols "4.1.0" + minimatch "5.0.1" + ms "2.1.3" + serialize-javascript "6.0.0" + strip-json-comments "3.1.1" + supports-color "8.1.1" + workerpool "6.2.1" + yargs "16.2.0" + yargs-parser "20.2.4" + yargs-unparser "2.0.0" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A== + +ms@2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" + integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + +ms@2.1.3: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + +multicast-dns@^7.2.5: + version "7.2.5" + resolved "https://registry.yarnpkg.com/multicast-dns/-/multicast-dns-7.2.5.tgz#77eb46057f4d7adbd16d9290fa7299f6fa64cced" + integrity sha512-2eznPJP8z2BFLX50tf0LuODrpINqP1RVIm/CObbTcBRITQgmC/TjcREF1NeTBzIcR5XO/ukWo+YHOjBbFwIupg== + dependencies: + dns-packet "^5.2.2" + thunky "^1.0.2" + +negotiator@0.6.3: + version "0.6.3" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" + integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== + +neo-async@^2.6.2: + version "2.6.2" + resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" + integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== + +node-forge@^1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" + integrity sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA== + +node-releases@^2.0.14: + version "2.0.14" + resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.14.tgz#2ffb053bceb8b2be8495ece1ab6ce600c4461b0b" + integrity sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw== + +normalize-path@^3.0.0, normalize-path@~3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +npm-run-path@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" + integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== + dependencies: + path-key "^3.0.0" + +object-assign@^4: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg== + +object-inspect@^1.13.1: + version "1.13.1" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.1.tgz#b96c6109324ccfef6b12216a956ca4dc2ff94bc2" + integrity sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ== + +obuf@^1.0.0, obuf@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/obuf/-/obuf-1.1.2.tgz#09bea3343d41859ebd446292d11c9d4db619084e" + integrity sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg== + +on-finished@2.4.1, on-finished@^2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" + integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== + dependencies: + ee-first "1.1.1" + +on-finished@~2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" + integrity sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww== + dependencies: + ee-first "1.1.1" + +on-headers@~1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.2.tgz#772b0ae6aaa525c399e489adfad90c403eb3c28f" + integrity sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA== + +once@^1.3.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w== + dependencies: + wrappy "1" + +onetime@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" + integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== + dependencies: + mimic-fn "^2.1.0" + +open@^10.0.3: + version "10.1.0" + resolved "https://registry.yarnpkg.com/open/-/open-10.1.0.tgz#a7795e6e5d519abe4286d9937bb24b51122598e1" + integrity sha512-mnkeQ1qP5Ue2wd+aivTD3NHd/lZ96Lu0jgf0pwktLPtx6cTZiH7tyeGRRHs0zX0rbrahXPnXlUnbeXyaBBuIaw== + dependencies: + default-browser "^5.2.1" + define-lazy-prop "^3.0.0" + is-inside-container "^1.0.0" + is-wsl "^3.1.0" + +p-limit@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-limit@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b" + integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ== + dependencies: + yocto-queue "^0.1.0" + +p-locate@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07" + integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A== + dependencies: + p-limit "^2.2.0" + +p-locate@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834" + integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw== + dependencies: + p-limit "^3.0.2" + +p-retry@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/p-retry/-/p-retry-6.2.0.tgz#8d6df01af298750009691ce2f9b3ad2d5968f3bd" + integrity sha512-JA6nkq6hKyWLLasXQXUrO4z8BUZGUt/LjlJxx8Gb2+2ntodU/SS63YZ8b0LUTbQ8ZB9iwOfhEPhg4ykKnn2KsA== + dependencies: + "@types/retry" "0.12.2" + is-network-error "^1.0.0" + retry "^0.13.1" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +parseurl@~1.3.2, parseurl@~1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" + integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== + +path-exists@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" + integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w== + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== + +path-key@^3.0.0, path-key@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" + integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== + +path-parse@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" + integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== + +path-scurry@^1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.10.2.tgz#8f6357eb1239d5fa1da8b9f70e9c080675458ba7" + integrity sha512-7xTavNy5RQXnsjANvVvMkEjvloOinkAjv/Z6Ildz9v2RinZ4SBKTWFOVRbaF8p0vpHnyjV/UwNDdKuUv6M5qcA== + dependencies: + lru-cache "^10.2.0" + minipass "^5.0.0 || ^6.0.2 || ^7.0.0" + +path-to-regexp@0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" + integrity sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ== + +picocolors@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" + integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== + +picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: + version "2.3.1" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" + integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== + +pkg-dir@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3" + integrity sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ== + dependencies: + find-up "^4.0.0" + +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + +proxy-addr@~2.0.7: + version "2.0.7" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" + integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== + dependencies: + forwarded "0.2.0" + ipaddr.js "1.9.1" + +punycode@^2.1.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" + integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== + +qjobs@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/qjobs/-/qjobs-1.2.0.tgz#c45e9c61800bd087ef88d7e256423bdd49e5d071" + integrity sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg== + +qs@6.11.0: + version "6.11.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" + integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q== + dependencies: + side-channel "^1.0.4" + +randombytes@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + +range-parser@^1.2.1, range-parser@~1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" + integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== + +raw-body@2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.2.tgz#99febd83b90e08975087e8f1f9419a149366b68a" + integrity sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA== + dependencies: + bytes "3.1.2" + http-errors "2.0.0" + iconv-lite "0.4.24" + unpipe "1.0.0" + +readable-stream@^2.0.1: + version "2.3.8" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" + integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + +readable-stream@^3.0.6: + version "3.6.2" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" + integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readdirp@~3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" + integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== + dependencies: + picomatch "^2.2.1" + +rechoir@^0.8.0: + version "0.8.0" + resolved "https://registry.yarnpkg.com/rechoir/-/rechoir-0.8.0.tgz#49f866e0d32146142da3ad8f0eff352b3215ff22" + integrity sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ== + dependencies: + resolve "^1.20.0" + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q== + +require-from-string@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" + integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== + +requires-port@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/requires-port/-/requires-port-1.0.0.tgz#925d2601d39ac485e091cf0da5c6e694dc3dcaff" + integrity sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ== + +resolve-cwd@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-3.0.0.tgz#0f0075f1bb2544766cf73ba6a6e2adfebcb13f2d" + integrity sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg== + dependencies: + resolve-from "^5.0.0" + +resolve-from@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" + integrity sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw== + +resolve@^1.20.0: + version "1.22.8" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.8.tgz#b6c87a9f2aa06dfab52e3d70ac8cde321fa5a48d" + integrity sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw== + dependencies: + is-core-module "^2.13.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + +retry@^0.13.1: + version "0.13.1" + resolved "https://registry.yarnpkg.com/retry/-/retry-0.13.1.tgz#185b1587acf67919d63b357349e03537b2484658" + integrity sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg== + +rfdc@^1.3.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.1.tgz#2b6d4df52dffe8bb346992a10ea9451f24373a8f" + integrity sha512-r5a3l5HzYlIC68TpmYKlxWjmOP6wiPJ1vWv2HeLhNsRZMrCkxeqxiHlQ21oXmQ4F3SiryXBHhAD7JZqvOJjFmg== + +rimraf@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" + integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== + dependencies: + glob "^7.1.3" + +rimraf@^5.0.5: + version "5.0.5" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-5.0.5.tgz#9be65d2d6e683447d2e9013da2bf451139a61ccf" + integrity sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A== + dependencies: + glob "^10.3.7" + +run-applescript@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/run-applescript/-/run-applescript-7.0.0.tgz#e5a553c2bffd620e169d276c1cd8f1b64778fbeb" + integrity sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A== + +safe-buffer@5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + +safe-buffer@5.2.1, safe-buffer@>=5.1.0, safe-buffer@^5.1.0, safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +"safer-buffer@>= 2.1.2 < 3", "safer-buffer@>= 2.1.2 < 3.0.0": + version "2.1.2" + resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" + integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== + +schema-utils@^3.1.1, schema-utils@^3.2.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.3.0.tgz#f50a88877c3c01652a15b622ae9e9795df7a60fe" + integrity sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg== + dependencies: + "@types/json-schema" "^7.0.8" + ajv "^6.12.5" + ajv-keywords "^3.5.2" + +schema-utils@^4.0.0, schema-utils@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-4.2.0.tgz#70d7c93e153a273a805801882ebd3bff20d89c8b" + integrity sha512-L0jRsrPpjdckP3oPug3/VxNKt2trR8TcabrM6FOAAlvC/9Phcmm+cuAgTlxBqdBR1WJx7Naj9WHw+aOmheSVbw== + dependencies: + "@types/json-schema" "^7.0.9" + ajv "^8.9.0" + ajv-formats "^2.1.1" + ajv-keywords "^5.1.0" + +select-hose@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/select-hose/-/select-hose-2.0.0.tgz#625d8658f865af43ec962bfc376a37359a4994ca" + integrity sha512-mEugaLK+YfkijB4fx0e6kImuJdCIt2LxCRcbEYPqRGCs4F2ogyfZU5IAZRdjCP8JPq2AtdNoC/Dux63d9Kiryg== + +selfsigned@^2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-2.4.1.tgz#560d90565442a3ed35b674034cec4e95dceb4ae0" + integrity sha512-th5B4L2U+eGLq1TVh7zNRGBapioSORUeymIydxgFpwww9d2qyKvtuPU2jJuHvYAwwqi2Y596QBL3eEqcPEYL8Q== + dependencies: + "@types/node-forge" "^1.3.0" + node-forge "^1" + +send@0.18.0: + version "0.18.0" + resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be" + integrity sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg== + dependencies: + debug "2.6.9" + depd "2.0.0" + destroy "1.2.0" + encodeurl "~1.0.2" + escape-html "~1.0.3" + etag "~1.8.1" + fresh "0.5.2" + http-errors "2.0.0" + mime "1.6.0" + ms "2.1.3" + on-finished "2.4.1" + range-parser "~1.2.1" + statuses "2.0.1" + +serialize-javascript@6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" + integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag== + dependencies: + randombytes "^2.1.0" + +serialize-javascript@^6.0.1: + version "6.0.2" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.2.tgz#defa1e055c83bf6d59ea805d8da862254eb6a6c2" + integrity sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g== + dependencies: + randombytes "^2.1.0" + +serve-index@^1.9.1: + version "1.9.1" + resolved "https://registry.yarnpkg.com/serve-index/-/serve-index-1.9.1.tgz#d3768d69b1e7d82e5ce050fff5b453bea12a9239" + integrity sha512-pXHfKNP4qujrtteMrSBb0rc8HJ9Ms/GrXwcUtUtD5s4ewDJI8bT3Cz2zTVRMKtri49pLx2e0Ya8ziP5Ya2pZZw== + dependencies: + accepts "~1.3.4" + batch "0.6.1" + debug "2.6.9" + escape-html "~1.0.3" + http-errors "~1.6.2" + mime-types "~2.1.17" + parseurl "~1.3.2" + +serve-static@1.15.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.15.0.tgz#faaef08cffe0a1a62f60cad0c4e513cff0ac9540" + integrity sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g== + dependencies: + encodeurl "~1.0.2" + escape-html "~1.0.3" + parseurl "~1.3.3" + send "0.18.0" + +set-function-length@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" + integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== + dependencies: + define-data-property "^1.1.4" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + gopd "^1.0.1" + has-property-descriptors "^1.0.2" + +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ== + +setprototypeof@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" + integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== + +shallow-clone@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3" + integrity sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA== + dependencies: + kind-of "^6.0.2" + +shebang-command@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" + integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== + dependencies: + shebang-regex "^3.0.0" + +shebang-regex@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" + integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== + +shell-quote@^1.8.1: + version "1.8.1" + resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.8.1.tgz#6dbf4db75515ad5bac63b4f1894c3a154c766680" + integrity sha512-6j1W9l1iAs/4xYBI1SYOVZyFcCis9b4KCLQ8fgAGG07QvzaRLVVRQvAy85yNmmZSjYjg4MWh4gNvlPujU/5LpA== + +side-channel@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.6.tgz#abd25fb7cd24baf45466406b1096b7831c9215f2" + integrity sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA== + dependencies: + call-bind "^1.0.7" + es-errors "^1.3.0" + get-intrinsic "^1.2.4" + object-inspect "^1.13.1" + +signal-exit@^3.0.3: + version "3.0.7" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" + integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== + +signal-exit@^4.0.1: + version "4.1.0" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" + integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== + +socket.io-adapter@~2.5.2: + version "2.5.4" + resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-2.5.4.tgz#4fdb1358667f6d68f25343353bd99bd11ee41006" + integrity sha512-wDNHGXGewWAjQPt3pyeYBtpWSq9cLE5UW1ZUPL/2eGK9jtse/FpXib7epSTsz0Q0m+6sg6Y4KtcFTlah1bdOVg== + dependencies: + debug "~4.3.4" + ws "~8.11.0" + +socket.io-parser@~4.2.4: + version "4.2.4" + resolved "https://registry.yarnpkg.com/socket.io-parser/-/socket.io-parser-4.2.4.tgz#c806966cf7270601e47469ddeec30fbdfda44c83" + integrity sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew== + dependencies: + "@socket.io/component-emitter" "~3.1.0" + debug "~4.3.1" + +socket.io@^4.7.2: + version "4.7.5" + resolved "https://registry.yarnpkg.com/socket.io/-/socket.io-4.7.5.tgz#56eb2d976aef9d1445f373a62d781a41c7add8f8" + integrity sha512-DmeAkF6cwM9jSfmp6Dr/5/mfMwb5Z5qRrSXLpo3Fq5SqyU8CMF15jIN4ZhfSwu35ksM1qmHZDQ/DK5XTccSTvA== + dependencies: + accepts "~1.3.4" + base64id "~2.0.0" + cors "~2.8.5" + debug "~4.3.2" + engine.io "~6.5.2" + socket.io-adapter "~2.5.2" + socket.io-parser "~4.2.4" + +sockjs@^0.3.24: + version "0.3.24" + resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.24.tgz#c9bc8995f33a111bea0395ec30aa3206bdb5ccce" + integrity sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ== + dependencies: + faye-websocket "^0.11.3" + uuid "^8.3.2" + websocket-driver "^0.7.4" + +sonic-forest@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/sonic-forest/-/sonic-forest-1.0.3.tgz#81363af60017daba39b794fce24627dc412563cb" + integrity sha512-dtwajos6IWMEWXdEbW1IkEkyL2gztCAgDplRIX+OT5aRKnEd5e7r7YCxRgXZdhRP1FBdOBf8axeTPhzDv8T4wQ== + dependencies: + tree-dump "^1.0.0" + +source-map-js@^1.0.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.0.tgz#16b809c162517b5b8c3e7dcd315a2a5c2612b2af" + integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg== + +source-map-loader@5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/source-map-loader/-/source-map-loader-5.0.0.tgz#f593a916e1cc54471cfc8851b905c8a845fc7e38" + integrity sha512-k2Dur7CbSLcAH73sBcIkV5xjPV4SzqO1NJ7+XaQl8if3VODDUj3FNchNGpqgJSKbvUfJuhVdv8K2Eu8/TNl2eA== + dependencies: + iconv-lite "^0.6.3" + source-map-js "^1.0.2" + +source-map-support@~0.5.20: + version "0.5.21" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" + integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map@^0.6.0, source-map@^0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +spdy-transport@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdy-transport/-/spdy-transport-3.0.0.tgz#00d4863a6400ad75df93361a1608605e5dcdcf31" + integrity sha512-hsLVFE5SjA6TCisWeJXFKniGGOpBgMLmerfO2aCyCU5s7nJ/rpAepqmFifv/GCbSbueEeAJJnmSQ2rKC/g8Fcw== + dependencies: + debug "^4.1.0" + detect-node "^2.0.4" + hpack.js "^2.1.6" + obuf "^1.1.2" + readable-stream "^3.0.6" + wbuf "^1.7.3" + +spdy@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/spdy/-/spdy-4.0.2.tgz#b74f466203a3eda452c02492b91fb9e84a27677b" + integrity sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA== + dependencies: + debug "^4.1.0" + handle-thing "^2.0.0" + http-deceiver "^1.2.7" + select-hose "^2.0.0" + spdy-transport "^3.0.0" + +statuses@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" + integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== + +"statuses@>= 1.4.0 < 2", statuses@~1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" + integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== + +streamroller@^3.1.5: + version "3.1.5" + resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-3.1.5.tgz#1263182329a45def1ffaef58d31b15d13d2ee7ff" + integrity sha512-KFxaM7XT+irxvdqSP1LGLgNWbYN7ay5owZ3r/8t77p+EtSUAfUgtl7be3xtqtOmGUl9K9YPO2ca8133RlTjvKw== + dependencies: + date-format "^4.0.14" + debug "^4.3.4" + fs-extra "^8.1.0" + +"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0: + version "4.2.3" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^5.0.1, string-width@^5.1.2: + version "5.1.2" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" + integrity sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA== + dependencies: + eastasianwidth "^0.2.0" + emoji-regex "^9.2.2" + strip-ansi "^7.0.1" + +string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + +"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^7.0.1: + version "7.1.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" + integrity sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ== + dependencies: + ansi-regex "^6.0.1" + +strip-final-newline@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" + integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== + +strip-json-comments@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== + +supports-color@8.1.1, supports-color@^8.0.0: + version "8.1.1" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c" + integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q== + dependencies: + has-flag "^4.0.0" + +supports-color@^7.1.0: + version "7.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da" + integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw== + dependencies: + has-flag "^4.0.0" + +supports-preserve-symlinks-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" + integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== + +tapable@^2.1.1, tapable@^2.2.0: + version "2.2.1" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" + integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== + +terser-webpack-plugin@^5.3.10: + version "5.3.10" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz#904f4c9193c6fd2a03f693a2150c62a92f40d199" + integrity sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w== + dependencies: + "@jridgewell/trace-mapping" "^0.3.20" + jest-worker "^27.4.5" + schema-utils "^3.1.1" + serialize-javascript "^6.0.1" + terser "^5.26.0" + +terser@^5.26.0: + version "5.31.0" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.31.0.tgz#06eef86f17007dbad4593f11a574c7f5eb02c6a1" + integrity sha512-Q1JFAoUKE5IMfI4Z/lkE/E6+SwgzO+x4tq4v1AyBLRj8VSYvRO6A/rQrPg1yud4g0En9EKI1TvFRF2tQFcoUkg== + dependencies: + "@jridgewell/source-map" "^0.3.3" + acorn "^8.8.2" + commander "^2.20.0" + source-map-support "~0.5.20" + +thingies@^1.20.0: + version "1.21.0" + resolved "https://registry.yarnpkg.com/thingies/-/thingies-1.21.0.tgz#e80fbe58fd6fdaaab8fad9b67bd0a5c943c445c1" + integrity sha512-hsqsJsFMsV+aD4s3CWKk85ep/3I9XzYV/IXaSouJMYIoDlgyi11cBhsqYe9/geRfB0YIikBQg6raRaM+nIMP9g== + +thunky@^1.0.2: + version "1.1.0" + resolved "https://registry.yarnpkg.com/thunky/-/thunky-1.1.0.tgz#5abaf714a9405db0504732bbccd2cedd9ef9537d" + integrity sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA== + +tmp@^0.2.1: + version "0.2.3" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.3.tgz#eb783cc22bc1e8bebd0671476d46ea4eb32a79ae" + integrity sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w== + +to-regex-range@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" + integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== + dependencies: + is-number "^7.0.0" + +toidentifier@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== + +tree-dump@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/tree-dump/-/tree-dump-1.0.1.tgz#b448758da7495580e6b7830d6b7834fca4c45b96" + integrity sha512-WCkcRBVPSlHHq1dc/px9iOfqklvzCbdRwvlNfxGZsrHqf6aZttfPrd7DJTt6oR10dwUfpFFQeVTkPbBIZxX/YA== + +tslib@^2.0.0: + version "2.6.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" + integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== + +type-is@~1.6.18: + version "1.6.18" + resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" + integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== + dependencies: + media-typer "0.3.0" + mime-types "~2.1.24" + +typescript@5.4.3: + version "5.4.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.3.tgz#5c6fedd4c87bee01cd7a528a30145521f8e0feff" + integrity sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg== + +ua-parser-js@^0.7.30: + version "0.7.37" + resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.37.tgz#e464e66dac2d33a7a1251d7d7a99d6157ec27832" + integrity sha512-xV8kqRKM+jhMvcHWUKthV9fNebIzrNy//2O9ZwWcfiBFR5f25XVZPLlEajk/sf3Ra15V92isyQqnIEXRDaZWEA== + +undici-types@~5.26.4: + version "5.26.5" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" + integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== + +universalify@^0.1.0: + version "0.1.2" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" + integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== + +unpipe@1.0.0, unpipe@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" + integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== + +update-browserslist-db@^1.0.13: + version "1.0.15" + resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.15.tgz#60ed9f8cba4a728b7ecf7356f641a31e3a691d97" + integrity sha512-K9HWH62x3/EalU1U6sjSZiylm9C8tgq2mSvshZpqc7QE69RaA2qjhkW2HlNA0tFpEbtyFz7HTqbSdN4MSwUodA== + dependencies: + escalade "^3.1.2" + picocolors "^1.0.0" + +uri-js@^4.2.2, uri-js@^4.4.1: + version "4.4.1" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" + integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== + dependencies: + punycode "^2.1.0" + +util-deprecate@^1.0.1, util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== + +utils-merge@1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" + integrity sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA== + +uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + +vary@^1, vary@~1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" + integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== + +void-elements@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/void-elements/-/void-elements-2.0.1.tgz#c066afb582bb1cb4128d60ea92392e94d5e9dbec" + integrity sha512-qZKX4RnBzH2ugr8Lxa7x+0V6XD9Sb/ouARtiasEQCHB1EVU4NXtmHsDDrx1dO4ne5fc3J6EW05BP1Dl0z0iung== + +watchpack@^2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.4.1.tgz#29308f2cac150fa8e4c92f90e0ec954a9fed7fff" + integrity sha512-8wrBCMtVhqcXP2Sup1ctSkga6uc2Bx0IIvKyT7yTFier5AXHooSI+QyQQAtTb7+E0IUCCKyTFmXqdqgum2XWGg== + dependencies: + glob-to-regexp "^0.4.1" + graceful-fs "^4.1.2" + +wbuf@^1.1.0, wbuf@^1.7.3: + version "1.7.3" + resolved "https://registry.yarnpkg.com/wbuf/-/wbuf-1.7.3.tgz#c1d8d149316d3ea852848895cb6a0bfe887b87df" + integrity sha512-O84QOnr0icsbFGLS0O3bI5FswxzRr8/gHwWkDlQFskhSPryQXvrTMxjxGP4+iWYoauLoBvfDpkrOauZ+0iZpDA== + dependencies: + minimalistic-assert "^1.0.0" + +webpack-cli@5.1.4: + version "5.1.4" + resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-5.1.4.tgz#c8e046ba7eaae4911d7e71e2b25b776fcc35759b" + integrity sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg== + dependencies: + "@discoveryjs/json-ext" "^0.5.0" + "@webpack-cli/configtest" "^2.1.1" + "@webpack-cli/info" "^2.0.2" + "@webpack-cli/serve" "^2.0.5" + colorette "^2.0.14" + commander "^10.0.1" + cross-spawn "^7.0.3" + envinfo "^7.7.3" + fastest-levenshtein "^1.0.12" + import-local "^3.0.2" + interpret "^3.1.1" + rechoir "^0.8.0" + webpack-merge "^5.7.3" + +webpack-dev-middleware@^7.1.0: + version "7.2.1" + resolved "https://registry.yarnpkg.com/webpack-dev-middleware/-/webpack-dev-middleware-7.2.1.tgz#2af00538b6e4eda05f5afdd5d711dbebc05958f7" + integrity sha512-hRLz+jPQXo999Nx9fXVdKlg/aehsw1ajA9skAneGmT03xwmyuhvF93p6HUKKbWhXdcERtGTzUCtIQr+2IQegrA== + dependencies: + colorette "^2.0.10" + memfs "^4.6.0" + mime-types "^2.1.31" + on-finished "^2.4.1" + range-parser "^1.2.1" + schema-utils "^4.0.0" + +webpack-dev-server@5.0.4: + version "5.0.4" + resolved "https://registry.yarnpkg.com/webpack-dev-server/-/webpack-dev-server-5.0.4.tgz#cb6ea47ff796b9251ec49a94f24a425e12e3c9b8" + integrity sha512-dljXhUgx3HqKP2d8J/fUMvhxGhzjeNVarDLcbO/EWMSgRizDkxHQDZQaLFL5VJY9tRBj2Gz+rvCEYYvhbqPHNA== + dependencies: + "@types/bonjour" "^3.5.13" + "@types/connect-history-api-fallback" "^1.5.4" + "@types/express" "^4.17.21" + "@types/serve-index" "^1.9.4" + "@types/serve-static" "^1.15.5" + "@types/sockjs" "^0.3.36" + "@types/ws" "^8.5.10" + ansi-html-community "^0.0.8" + bonjour-service "^1.2.1" + chokidar "^3.6.0" + colorette "^2.0.10" + compression "^1.7.4" + connect-history-api-fallback "^2.0.0" + default-gateway "^6.0.3" + express "^4.17.3" + graceful-fs "^4.2.6" + html-entities "^2.4.0" + http-proxy-middleware "^2.0.3" + ipaddr.js "^2.1.0" + launch-editor "^2.6.1" + open "^10.0.3" + p-retry "^6.2.0" + rimraf "^5.0.5" + schema-utils "^4.2.0" + selfsigned "^2.4.1" + serve-index "^1.9.1" + sockjs "^0.3.24" + spdy "^4.0.2" + webpack-dev-middleware "^7.1.0" + ws "^8.16.0" + +webpack-merge@^4.1.5: + version "4.2.2" + resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.2.2.tgz#a27c52ea783d1398afd2087f547d7b9d2f43634d" + integrity sha512-TUE1UGoTX2Cd42j3krGYqObZbOD+xF7u28WB7tfUordytSjbWTIjK/8V0amkBfTYN4/pB/GIDlJZZ657BGG19g== + dependencies: + lodash "^4.17.15" + +webpack-merge@^5.7.3: + version "5.10.0" + resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-5.10.0.tgz#a3ad5d773241e9c682803abf628d4cd62b8a4177" + integrity sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA== + dependencies: + clone-deep "^4.0.1" + flat "^5.0.2" + wildcard "^2.0.0" + +webpack-sources@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" + integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== + +webpack@5.91.0: + version "5.91.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.91.0.tgz#ffa92c1c618d18c878f06892bbdc3373c71a01d9" + integrity sha512-rzVwlLeBWHJbmgTC/8TvAcu5vpJNII+MelQpylD4jNERPwpBJOE2lEcko1zJX3QJeLjTTAnQxn/OJ8bjDzVQaw== + dependencies: + "@types/eslint-scope" "^3.7.3" + "@types/estree" "^1.0.5" + "@webassemblyjs/ast" "^1.12.1" + "@webassemblyjs/wasm-edit" "^1.12.1" + "@webassemblyjs/wasm-parser" "^1.12.1" + acorn "^8.7.1" + acorn-import-assertions "^1.9.0" + browserslist "^4.21.10" + chrome-trace-event "^1.0.2" + enhanced-resolve "^5.16.0" + es-module-lexer "^1.2.1" + eslint-scope "5.1.1" + events "^3.2.0" + glob-to-regexp "^0.4.1" + graceful-fs "^4.2.11" + json-parse-even-better-errors "^2.3.1" + loader-runner "^4.2.0" + mime-types "^2.1.27" + neo-async "^2.6.2" + schema-utils "^3.2.0" + tapable "^2.1.1" + terser-webpack-plugin "^5.3.10" + watchpack "^2.4.1" + webpack-sources "^3.2.3" + +websocket-driver@>=0.5.1, websocket-driver@^0.7.4: + version "0.7.4" + resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.4.tgz#89ad5295bbf64b480abcba31e4953aca706f5760" + integrity sha512-b17KeDIQVjvb0ssuSDF2cYXSg2iztliJ4B9WdsuB6J952qCPKmnVq4DyW5motImXHDC1cBT/1UezrJVsKw5zjg== + dependencies: + http-parser-js ">=0.5.1" + safe-buffer ">=5.1.0" + websocket-extensions ">=0.1.1" + +websocket-extensions@>=0.1.1: + version "0.1.4" + resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" + integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== + +which@^1.2.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +which@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" + integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== + dependencies: + isexe "^2.0.0" + +wildcard@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.1.tgz#5ab10d02487198954836b6349f74fff961e10f67" + integrity sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ== + +workerpool@6.2.1: + version "6.2.1" + resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" + integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== + +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrap-ansi@^8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214" + integrity sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ== + dependencies: + ansi-styles "^6.1.0" + string-width "^5.0.1" + strip-ansi "^7.0.1" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ== + +ws@^8.16.0: + version "8.17.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.0.tgz#d145d18eca2ed25aaf791a183903f7be5e295fea" + integrity sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow== + +ws@~8.11.0: + version "8.11.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.11.0.tgz#6a0d36b8edfd9f96d8b25683db2f8d7de6e8e143" + integrity sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg== + +y18n@^5.0.5: + version "5.0.8" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55" + integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA== + +yargs-parser@20.2.4: + version "20.2.4" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54" + integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA== + +yargs-parser@^20.2.2: + version "20.2.9" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" + integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== + +yargs-unparser@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb" + integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA== + dependencies: + camelcase "^6.0.0" + decamelize "^4.0.0" + flat "^5.0.2" + is-plain-obj "^2.1.0" + +yargs@16.2.0, yargs@^16.1.1: + version "16.2.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" + integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== + dependencies: + cliui "^7.0.2" + escalade "^3.1.1" + get-caller-file "^2.0.5" + require-directory "^2.1.1" + string-width "^4.2.0" + y18n "^5.0.5" + yargs-parser "^20.2.2" + +yocto-queue@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b" + integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== diff --git a/pubnub-core/pubnub-core-api/build.gradle.kts b/pubnub-core/pubnub-core-api/build.gradle.kts index f9ba0e4a8..ed999f5b9 100644 --- a/pubnub-core/pubnub-core-api/build.gradle.kts +++ b/pubnub-core/pubnub-core-api/build.gradle.kts @@ -2,13 +2,53 @@ plugins { alias(libs.plugins.benmanes.versions) id("pubnub.shared") id("pubnub.dokka") + kotlin("multiplatform") } -dependencies { - api(libs.retrofit2) - api(libs.okhttp) - api(libs.okhttp.logging) - api(libs.json) - api(libs.gson) - implementation(libs.slf4j) +kotlin { + js() { + browser { + } + binaries.executable() + } + jvmToolchain(8) + jvm { + compilations.all { + compilerOptions.configure { + javaParameters.set(true) + } + } + } + + listOf( + iosArm64(), +// iosX64(), + iosSimulatorArm64(), + ).forEach { + it.binaries { + framework { + baseName = "PubNubKMP" + isStatic = true + } + } + } + + sourceSets { + val commonMain by getting { + dependencies { + + } + } + + val jvmMain by getting { + dependencies { + api(libs.retrofit2) + api(libs.okhttp) + api(libs.okhttp.logging) + api(libs.json) + api(libs.gson) + implementation(libs.slf4j) + } + } + } } diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt new file mode 100644 index 000000000..262ff5695 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt @@ -0,0 +1,6 @@ +package com.pubnub.api + +expect abstract class JsonElement +//expect class JsonObject + +expect annotation class SerializedName(val value: String, val alternate: Array = []) \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/PubNubError.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubError.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/PubNubError.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubError.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt new file mode 100644 index 000000000..26ef408d4 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt @@ -0,0 +1,17 @@ +package com.pubnub.api + +/** + * Custom exception wrapper for errors occurred during execution or processing of a PubNub API operation. + * + * @property errorMessage The error message received from the server, if any. + * @property pubnubError The appropriate matching PubNub error. + * @property jso The error json received from the server, if any. + * @property statusCode HTTP status code. + * @property affectedCall A reference to the affected call. Useful for calling [retry][Endpoint.retry]. + */ +expect class PubNubException(pubnubError: PubNubError) : Exception { + constructor(errorMessage: String?) + companion object { + fun from(e: Throwable): PubNubException + } +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/UserId.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/UserId.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/UserId.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/UserId.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/callbacks/Listener.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/callbacks/Listener.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/callbacks/Listener.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/callbacks/Listener.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt similarity index 97% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt index 3a923255f..dcec07d41 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt @@ -2,8 +2,8 @@ package com.pubnub.api.endpoints.remoteaction import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNOperationType +import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result -import java.util.function.Consumer interface ExtendedRemoteAction : RemoteAction { /** diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNHeartbeatNotificationOptions.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNHeartbeatNotificationOptions.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNHeartbeatNotificationOptions.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNHeartbeatNotificationOptions.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNLogVerbosity.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNLogVerbosity.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNLogVerbosity.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNLogVerbosity.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNOperationType.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNOperationType.kt new file mode 100644 index 000000000..17b4e3fb8 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNOperationType.kt @@ -0,0 +1,121 @@ +package com.pubnub.api.enums + +sealed class PNOperationType(open val queryParam: String? = null) { + open class PublishOperation : PNOperationType("pub") + + open class HistoryOperation : PNOperationType("hist") + + open class PresenceOperation : PNOperationType("pres") + + open class ChannelGroupOperation : PNOperationType("cg") + + open class PushNotificationsOperation : PNOperationType("push") + + open class PAMOperation : PNOperationType("pam") + + open class MessageCountsOperation : PNOperationType("mc") + + open class SignalsOperation : PNOperationType("sig") + + open class ObjectsOperation : PNOperationType("obj") + + open class PAMV3Operation : PNOperationType("pamv3") + + open class MessageActionsOperation : PNOperationType("msga") + + open class TimeOperation : PNOperationType("time") + + object FileOperation : PNOperationType("file") + + object SpaceOperation : PNOperationType("obj") + + object UserOperation : PNOperationType("obj") + + object MembershipOperation : PNOperationType("obj") + + object PNSubscribeOperation : PNOperationType() + + object PNDisconnectOperation : PNOperationType() + + object PNPublishOperation : PublishOperation() + + object PNHistoryOperation : HistoryOperation() + + object PNFetchMessagesOperation : HistoryOperation() + + object PNDeleteMessagesOperation : HistoryOperation() + + object PNUnsubscribeOperation : PresenceOperation() + + object PNWhereNowOperation : PresenceOperation() + + object PNHereNowOperation : PresenceOperation() + + object PNHeartbeatOperation : PresenceOperation() + + object PNSetStateOperation : PresenceOperation() + + object PNGetState : PresenceOperation() + + object PNAddChannelsToGroupOperation : ChannelGroupOperation() + + object PNRemoveChannelsFromGroupOperation : ChannelGroupOperation() + + object PNChannelGroupsOperation : ChannelGroupOperation() + + object PNRemoveGroupOperation : ChannelGroupOperation() + + object PNChannelsForGroupOperation : ChannelGroupOperation() + + object PNPushNotificationEnabledChannelsOperation : PushNotificationsOperation() + + object PNAddPushNotificationsOnChannelsOperation : PushNotificationsOperation() + + object PNRemovePushNotificationsFromChannelsOperation : PushNotificationsOperation() + + object PNRemoveAllPushNotificationsOperation : PushNotificationsOperation() + + object PNAccessManagerAudit : PAMOperation() + + object PNAccessManagerGrant : PAMOperation() + + object PNMessageCountOperation : MessageCountsOperation() + + object PNSignalOperation : SignalsOperation() + + object PNSetUUIDMetadataOperation : ObjectsOperation() + + object PNGetUUIDMetadataOperation : ObjectsOperation() + + object PNGetAllUUIDMetadataOperation : ObjectsOperation() + + object PNRemoveUUIDMetadataOperation : ObjectsOperation() + + object PNSetChannelMetadataOperation : ObjectsOperation() + + object PNGetChannelMetadataOperation : ObjectsOperation() + + object PNGetAllChannelsMetadataOperation : ObjectsOperation() + + object PNRemoveChannelMetadataOperation : ObjectsOperation() + + object PNGetMembershipsOperation : ObjectsOperation() + + object PNSetMembershipsOperation : ObjectsOperation() + + object PNUpdateMembershipsOperation : ObjectsOperation() + + object PNManageMemberships : ObjectsOperation() + + object PNAccessManagerGrantToken : PAMV3Operation() + + object PNAccessManagerRevokeToken : PAMV3Operation() + + object PNAddMessageAction : MessageActionsOperation() + + object PNGetMessageActions : MessageActionsOperation() + + object PNDeleteMessageAction : MessageActionsOperation() + + object PNTimeOperation : TimeOperation() +} diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNPushType.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt similarity index 81% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNPushType.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt index 8f76fdc48..db2126477 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNPushType.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt @@ -1,7 +1,5 @@ package com.pubnub.api.enums -import java.util.Locale - enum class PNPushType(s: String) { APNS("apns"), MPNS("mpns"), @@ -13,7 +11,7 @@ enum class PNPushType(s: String) { private val value: String = s fun toParamString(): String { - return value.lowercase(Locale.US) + return value.lowercase() } override fun toString(): String { diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNReconnectionPolicy.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNReconnectionPolicy.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNReconnectionPolicy.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNReconnectionPolicy.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNStatusCategory.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNStatusCategory.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNStatusCategory.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNStatusCategory.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/TokenBitmask.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/TokenBitmask.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/TokenBitmask.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/TokenBitmask.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/PNBoundedPage.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNBoundedPage.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/PNBoundedPage.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNBoundedPage.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/PNPublishResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNPublishResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/PNPublishResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNPublishResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/PNStatus.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt similarity index 98% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/PNStatus.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt index 0896dfcce..8153d4501 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/PNStatus.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt @@ -2,6 +2,7 @@ package com.pubnub.api.models.consumer import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNStatusCategory +import kotlin.jvm.JvmName class PNStatus( val category: PNStatusCategory, diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/PNTimeResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNTimeResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/PNTimeResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNTimeResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNGrantTokenResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNGrantTokenResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNGrantTokenResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNGrantTokenResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNToken.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNToken.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNToken.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNToken.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/channel_group/PNChannelGroupsResults.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/channel_group/PNChannelGroupsResults.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/channel_group/PNChannelGroupsResults.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/channel_group/PNChannelGroupsResults.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNDeleteFileResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDeleteFileResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNDeleteFileResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDeleteFileResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNDownloadableFile.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadableFile.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNDownloadableFile.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadableFile.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNFile.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFile.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNFile.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFile.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNFileUploadResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUploadResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNFileUploadResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUploadResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNFileUrlResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUrlResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNFileUrlResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUrlResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNListFilesResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNListFilesResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNListFilesResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNListFilesResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNPublishFileMessageResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNPublishFileMessageResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNPublishFileMessageResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNPublishFileMessageResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/PNDeleteMessagesResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNDeleteMessagesResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/PNDeleteMessagesResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNDeleteMessagesResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt similarity index 98% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt index 580020c2e..531bfbad9 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.history -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement import com.pubnub.api.PubNubError import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.PNFetchMessageItem.Action diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt similarity index 92% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt index f5eec6306..aa0f1b512 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.history -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement import com.pubnub.api.PubNubError /** @@ -14,7 +14,11 @@ class PNHistoryResult( val messages: List, val startTimetoken: Long, val endTimetoken: Long, -) +) { + companion object { + const val MAX_COUNT = 100 + } +} /** * Encapsulates a message in terms of a history entry. diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/PNMessageCountResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNMessageCountResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/history/PNMessageCountResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNMessageCountResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/message_actions/PNAddMessageActionResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNAddMessageActionResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/message_actions/PNAddMessageActionResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNAddMessageActionResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt similarity index 90% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt index 8daa0e8f6..d475a0d6b 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.message_actions -import com.google.gson.annotations.SerializedName +import com.pubnub.api.SerializedName import com.pubnub.api.models.consumer.PNBoundedPage /** diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt similarity index 98% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt index 2cddeecf2..cf20c9914 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt @@ -1,5 +1,7 @@ package com.pubnub.api.models.consumer.message_actions +import kotlin.jvm.JvmField + /** * Concrete implementation of a message action. * diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/message_actions/PNRemoveMessageActionResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNRemoveMessageActionResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/message_actions/PNRemoveMessageActionResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNRemoveMessageActionResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/PNPage.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNPage.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/PNPage.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNPage.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt similarity index 89% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt index 5eeb3c08d..852e37412 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt @@ -6,7 +6,7 @@ data class PNUUIDMetadata( val externalId: String?, val profileUrl: String?, val email: String?, - val custom: Any?, + val custom: Map?, val updated: String?, val eTag: String?, val type: String?, diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt similarity index 87% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt index 531f1ea49..55b51d06b 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.presence -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement /** * Result of the GetPresenceState operation. diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt similarity index 97% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt index 80b0ddc3b..30e6a07cb 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.presence -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement /** * Result of the HereNow operation. diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt similarity index 86% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt index 1d9169050..b4ca42e8b 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.presence -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement /** * Result of the [PubNubImpl.setPresenceState] operation. diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt similarity index 96% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt index bc14c9d70..543e56c0f 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.pubsub -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement interface PubSubResult : PNEvent { override val channel: String diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt similarity index 83% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt index 7380b655c..1bb614d2b 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.pubsub -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement /** * @property message The actual message content diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/PNEvent.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNEvent.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/PNEvent.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNEvent.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt similarity index 87% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt index dcac5826c..3a42c0c2f 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.pubsub -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement import com.pubnub.api.PubNubError /** @@ -15,7 +15,10 @@ class PNMessageResult( if (this === other) { return true } - if (javaClass != other?.javaClass) { + if (other == null) { + return false + } + if (this::class != other::class) { return false } diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt similarity index 96% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt index 4abbcebbf..fd0d7ea63 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.pubsub -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement /** * Wrapper around a presence event. @@ -42,7 +42,10 @@ class PNPresenceEventResult( if (this === other) { return true } - if (javaClass != other?.javaClass) { + if (other == null) { + return false + } + if (this::class != other::class) { return false } diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt similarity index 88% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt index b7ded3480..90362ad42 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.pubsub -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement /** * Wrapper around a received signal. diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt similarity index 93% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt index 0c3ea490c..0af2c12a7 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.pubsub.files -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement import com.pubnub.api.PubNubError import com.pubnub.api.models.consumer.files.PNDownloadableFile import com.pubnub.api.models.consumer.pubsub.PNEvent @@ -20,7 +20,10 @@ class PNFileEventResult( if (this === other) { return true } - if (javaClass != other?.javaClass) { + if (other == null) { + return false + } + if (this::class != other::class) { return false } diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt similarity index 93% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt index 3df071551..bc3c7618d 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt @@ -22,7 +22,10 @@ class PNMessageActionResult( if (this === other) { return true } - if (javaClass != other?.javaClass) { + if (other == null) { + return false + } + if (this::class != other::class) { return false } diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt similarity index 85% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt index 5ee4abe47..d5dd426fb 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt @@ -1,6 +1,6 @@ package com.pubnub.api.models.consumer.pubsub.objects -import com.google.gson.JsonElement +import com.pubnub.api.JsonElement data class ObjectPayload( val source: String, diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/PNPushAddChannelResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushAddChannelResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/PNPushAddChannelResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushAddChannelResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/PNPushListProvisionsResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushListProvisionsResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/PNPushListProvisionsResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushListProvisionsResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveAllChannelsResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveAllChannelsResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveAllChannelsResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveAllChannelsResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveChannelResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveChannelResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveChannelResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveChannelResult.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt similarity index 98% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt index 95d87c051..6e82fa09b 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt @@ -1,7 +1,6 @@ package com.pubnub.api.models.consumer.push.payload import com.pubnub.api.enums.PNPushEnvironment -import java.util.Locale class PushPayloadHelper { var commonPayload: Map? = null @@ -99,7 +98,7 @@ class PushPayloadHelper { return mutableMapOf().apply { topic?.let { put("topic", it) } excludeDevices?.let { put("excluded_devices", it) } - environment?.let { put("environment", it.name.lowercase(Locale.getDefault())) } + environment?.let { put("environment", it.name.lowercase()) } } } } diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadSerializer.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadSerializer.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadSerializer.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadSerializer.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/retry/RetryConfiguration.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt similarity index 88% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/retry/RetryConfiguration.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt index d713d0980..0331277dc 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/retry/RetryConfiguration.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt @@ -1,7 +1,8 @@ package com.pubnub.api.retry -import org.jetbrains.annotations.TestOnly -import org.slf4j.LoggerFactory +//import org.jetbrains.annotations.TestOnly +//import org.slf4j.LoggerFactory +import kotlin.jvm.JvmSynthetic import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds @@ -31,7 +32,7 @@ sealed class RetryConfiguration { val excludedOperations: List = emptyList(), isInternal: Boolean = false, ) : RetryConfiguration() { - private val log = LoggerFactory.getLogger(this.javaClass.simpleName + "-" + "RetryConfiguration") +// private val log = LoggerFactory.getLogger(this.javaClass.simpleName + "-" + "RetryConfiguration") constructor( delayInSec: Int = MIN_DELAY, @@ -47,11 +48,11 @@ sealed class RetryConfiguration { init { if (!isInternal) { if (delayInSec < MIN_DELAY.seconds) { - log.trace("Provided delay is less than $MIN_DELAY, setting it to $MIN_DELAY") +// log.trace("Provided delay is less than $MIN_DELAY, setting it to $MIN_DELAY") delayInSec = MIN_DELAY.seconds } if (maxRetryNumber > MAX_RETRIES) { - log.trace("Provided maxRetryNumber is greater than $MAX_RETRIES, setting it to $MAX_RETRIES") +// log.trace("Provided maxRetryNumber is greater than $MAX_RETRIES, setting it to $MAX_RETRIES") maxRetryNumber = MAX_RETRIES } } @@ -59,7 +60,7 @@ sealed class RetryConfiguration { companion object { @JvmSynthetic - @TestOnly +// @TestOnly internal fun createForTest( delayInSec: Duration = MIN_DELAY.seconds, maxRetryNumber: Int = MAX_RETRIES, @@ -88,7 +89,7 @@ sealed class RetryConfiguration { val excludedOperations: List = emptyList(), isInternal: Boolean = false, ) : RetryConfiguration() { - private val log = LoggerFactory.getLogger(this.javaClass.simpleName + "-" + "RetryConfiguration") +// private val log = LoggerFactory.getLogger(this.javaClass.simpleName + "-" + "RetryConfiguration") constructor( minDelayInSec: Int = MIN_DELAY, @@ -124,14 +125,14 @@ sealed class RetryConfiguration { maxRetryNumber = maxRetryNumber.coerceAtMost(MAX_RETRIES) if (minDelayInSec != originalMinDelayInSec || maxDelayInSec != originalMaxDelayInSec || maxRetryNumber != originalMaxRetryNumber) { - log.trace("Adjusted values: minDelayInSec=$minDelayInSec, maxDelayInSec=$maxDelayInSec, maxRetryNumber=$maxRetryNumber") +// log.trace("Adjusted values: minDelayInSec=$minDelayInSec, maxDelayInSec=$maxDelayInSec, maxRetryNumber=$maxRetryNumber") } } } companion object { @JvmSynthetic - @TestOnly +// @TestOnly internal fun createForTest( minDelayInSec: Duration = MIN_DELAY.seconds, maxDelayInSec: Duration = MAX_DELAY.seconds, diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/retry/RetryableEndpointGroup.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryableEndpointGroup.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/retry/RetryableEndpointGroup.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryableEndpointGroup.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/BaseEventEmitter.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventEmitter.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/BaseEventEmitter.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventEmitter.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/BaseEventListener.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventListener.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/BaseEventListener.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventListener.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/BaseStatusEmitter.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusEmitter.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/BaseStatusEmitter.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusEmitter.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/BaseStatusListener.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusListener.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/BaseStatusListener.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusListener.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt new file mode 100644 index 000000000..d3288c08b --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt @@ -0,0 +1,5 @@ +package com.pubnub.api.v2.callbacks + +expect fun interface Consumer { + fun accept(p: T) +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt new file mode 100644 index 000000000..0a2e3cf8e --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt @@ -0,0 +1,233 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license. + */ +@file:JvmName("Results") + +package com.pubnub.api.v2.callbacks + +import com.pubnub.api.PubNubException +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.InvocationKind +import kotlin.contracts.contract +import kotlin.jvm.JvmField +import kotlin.jvm.JvmName +import kotlin.jvm.JvmStatic +import kotlin.jvm.JvmSynthetic + +/** + * A discriminated union that encapsulates a successful outcome with a value of type [T] + * or a failure with a [PubNubException]. + */ +class Result +@PublishedApi +internal constructor( + @PublishedApi + @get:JvmSynthetic + internal val value: Any?, +) { + // discovery + + /** + * Returns `true` if this instance represents a successful outcome. + * In this case [isFailure] returns `false`. + */ + public val isSuccess: Boolean get() = value !is Failure + + /** + * Returns `true` if this instance represents a failed outcome. + * In this case [isSuccess] returns `false`. + */ + public val isFailure: Boolean get() = value is Failure + + // value & exception retrieval + + /** + * Returns the encapsulated value if this instance represents [success][Result.isSuccess] or `null` + * if it is [failure][Result.isFailure]. + * + * This function is a shorthand for `getOrElse { null }` (see [getOrElse]) or + * `fold(onSuccess = { it }, onFailure = { null })` (see [fold]). + */ + @Suppress("UNCHECKED_CAST") + public inline fun getOrNull(): T? = + when { + isFailure -> null + else -> value as T + } + + /** + * Returns the encapsulated [PubNubException] exception if this instance represents [failure][isFailure] or `null` + * if it is [success][isSuccess]. + * + * This function is a shorthand for `fold(onSuccess = { null }, onFailure = { it })` (see [fold]). + */ + public fun exceptionOrNull(): PubNubException? = + when (value) { + is Failure -> value.exception + else -> null + } + + /** + * Returns a string `Success(v)` if this instance represents [success][Result.isSuccess] + * where `v` is a string representation of the value or a string `Failure(x)` if + * it is [failure][isFailure] where `x` is a string representation of the exception. + */ + public override fun toString(): String = + when (value) { + is Failure -> value.toString() // "Failure($exception)" + else -> "Success($value)" + } + + public inline fun onFailure(action: Consumer): Result { + exceptionOrNull()?.let { action.accept(it) } + return this + } + + @Suppress("UNCHECKED_CAST") + public inline fun onSuccess(action: Consumer): Result { + if (isSuccess) { + action.accept(value as T) + } + return this + } + + // companion with constructors + + /** + * Companion object for [Result] class that contains its constructor functions + * [success] and [failure]. + */ + public companion object { + /** + * Returns an instance that encapsulates the given [value] as successful value. + */ + @JvmStatic + public fun success(value: T): Result = Result(value) + + /** + * Returns an instance that encapsulates the given [PubNubException] [exception] as failure. + */ + @JvmStatic + public fun failure(exception: PubNubException): Result = Result(createFailure(exception)) + + @JvmStatic + public fun failure(exception: Throwable): Result = Result(createFailure(PubNubException.from(exception))) + } + + internal class Failure( + @JvmField + val exception: PubNubException, + ) { + override fun equals(other: Any?): Boolean = other is Failure && exception == other.exception + + override fun hashCode(): Int = exception.hashCode() + + override fun toString(): String = "Failure($exception)" + } +} + +/** + * Creates an instance of internal marker [Result.Failure] class to + * make sure that this class is not exposed in ABI. + */ +private fun createFailure(exception: PubNubException): Any = Result.Failure(exception) + +/** + * Throws exception if the result is failure. This internal function minimizes + * inlined bytecode for [getOrThrow] and makes sure that in the future we can + * add some exception-augmenting logic here (if needed). + */ +private fun Result<*>.throwOnFailure() { + if (value is Result.Failure) { + throw value.exception + } +} + +// -- extensions --- + +/** + * Returns the encapsulated value if this instance represents [success][Result.isSuccess] or throws the encapsulated [PubNubException] + * if it is [failure][Result.isFailure]. + * + * This function is a shorthand for `getOrElse { throw it }` (see [getOrElse]). + */ +public fun Result.getOrThrow(): T { + throwOnFailure() + return value as T +} + +/** + * Returns the encapsulated value if this instance represents [success][Result.isSuccess] or the + * result of [onFailure] function for the encapsulated [PubNubException] exception if it is [failure][Result.isFailure]. + * + * Note, that this function rethrows any [Throwable] exception thrown by [onFailure] function. + * + * This function is a shorthand for `fold(onSuccess = { it }, onFailure = onFailure)` (see [fold]). + */ +@OptIn(ExperimentalContracts::class) +public inline fun Result.getOrElse(onFailure: (exception: PubNubException) -> R): R { + contract { + callsInPlace(onFailure, InvocationKind.AT_MOST_ONCE) + } + return when (val exception = exceptionOrNull()) { + null -> value as T + else -> onFailure(exception) + } +} + +/** + * Returns the encapsulated value if this instance represents [success][Result.isSuccess] or the + * [defaultValue] if it is [failure][Result.isFailure]. + * + * This function is a shorthand for `getOrElse { defaultValue }` (see [getOrElse]). + */ +public inline fun Result.getOrDefault(defaultValue: R): R { + if (isFailure) { + return defaultValue + } + return value as T +} + + +/** + * Returns the result of [onSuccess] for the encapsulated value if this instance represents [success][Result.isSuccess] + * or the result of [onFailure] function for the encapsulated [Throwable] exception if it is [failure][Result.isFailure]. + * + * Note, that this function rethrows any [Throwable] exception thrown by [onSuccess] or by [onFailure] function. + */ +//@InlineOnly +public inline fun Result.fold( + onSuccess: (value: T) -> R, + onFailure: (exception: Throwable) -> R +): R { +// contract { +// callsInPlace(onSuccess, InvocationKind.AT_MOST_ONCE) +// callsInPlace(onFailure, InvocationKind.AT_MOST_ONCE) +// } + return when (val exception = exceptionOrNull()) { + null -> onSuccess(value as T) + else -> onFailure(exception) + } +} + +// transformation + +/** + * Returns the encapsulated result of the given [transform] function applied to the encapsulated value + * if this instance represents [success][Result.isSuccess] or the + * original encapsulated [Throwable] exception if it is [failure][Result.isFailure]. + * + * Note, that this function rethrows any [Throwable] exception thrown by [transform] function. + * See [mapCatching] for an alternative that encapsulates exceptions. + */ +//@InlineOnly +public inline fun Result.map(transform: (value: T) -> R): Result { +// contract { +// callsInPlace(transform, InvocationKind.AT_MOST_ONCE) +// } + return when { + isSuccess -> Result.success(transform(value as T)) + else -> Result(value) + } +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/entities/BaseChannel.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannel.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/entities/BaseChannel.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannel.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/entities/BaseChannelGroup.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelGroup.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/entities/BaseChannelGroup.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelGroup.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/entities/BaseChannelMetadata.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelMetadata.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/entities/BaseChannelMetadata.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelMetadata.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/entities/BaseUserMetadata.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseUserMetadata.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/entities/BaseUserMetadata.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseUserMetadata.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/entities/Subscribable.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Subscribable.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/entities/Subscribable.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Subscribable.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt similarity index 96% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt index e51aeeae0..11f452a2f 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt @@ -15,4 +15,5 @@ import com.pubnub.api.v2.callbacks.BaseEventListener * This class implements the [AutoCloseable] interface to help you release resources by calling [unsubscribe] * and removing all listeners on [close]. Remember to always call [close] when you no longer need this Subscription. */ +@OptIn(ExperimentalStdlibApi::class) interface BaseSubscription : BaseEventEmitter, SubscribeCapable, AutoCloseable diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscriptionSet.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscriptionSet.kt similarity index 97% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscriptionSet.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscriptionSet.kt index 17c1f1ffe..42bc039f3 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscriptionSet.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscriptionSet.kt @@ -3,6 +3,7 @@ package com.pubnub.api.v2.subscriptions import com.pubnub.api.v2.callbacks.BaseEventEmitter import com.pubnub.api.v2.callbacks.BaseEventListener +@OptIn(ExperimentalStdlibApi::class) interface BaseSubscriptionSet< EvLis : BaseEventListener, Subscription : BaseSubscription, diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/SubscribeCapable.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscribeCapable.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/SubscribeCapable.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscribeCapable.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt similarity index 98% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt index 0097a24c3..d50f205ee 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt @@ -1,6 +1,7 @@ package com.pubnub.api.v2.subscriptions import com.pubnub.api.models.consumer.pubsub.PNEvent +import kotlin.jvm.JvmStatic /** * SubscriptionOptions is a mechanism used for supplying optional modifiers for subscriptions. diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt new file mode 100644 index 000000000..e9a2fdbee --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt @@ -0,0 +1,7 @@ +package com.pubnub.api + +actual abstract class JsonElement +actual annotation class SerializedName actual constructor( + actual val value: String, + actual val alternate: Array +) \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt new file mode 100644 index 000000000..6c24c4f11 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt @@ -0,0 +1,27 @@ +package com.pubnub.api + +/** + * Custom exception wrapper for errors occurred during execution or processing of a PubNub API operation. + * + * @property errorMessage The error message received from the server, if any. + * @property pubnubError The appropriate matching PubNub error. + * @property jso The error json received from the server, if any. + * @property statusCode HTTP status code. + * @property affectedCall A reference to the affected call. Useful for calling [retry][Endpoint.retry]. + */ +actual class PubNubException() : Exception() { + + actual constructor(pubnubError: PubNubError): this() { + TODO("Not yet implemented") + } + + actual constructor(errorMessage: String?) : this() { + TODO("Not yet implemented") + } + + actual companion object { + actual fun from(e: Throwable): PubNubException { + TODO("Not yet implemented") + } + } +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt new file mode 100644 index 000000000..0c836d68c --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt @@ -0,0 +1,5 @@ +package com.pubnub.api.v2.callbacks + +actual fun interface Consumer { + actual fun accept(p: T) +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt new file mode 100644 index 000000000..197867a18 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt @@ -0,0 +1,6 @@ +@file:Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") + +package com.pubnub.api + +actual abstract class JsonElement +actual annotation class SerializedName actual constructor(actual val value: String, actual val alternate: Array) \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt new file mode 100644 index 000000000..117e84624 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt @@ -0,0 +1,25 @@ +package com.pubnub.api + +/** + * Custom exception wrapper for errors occurred during execution or processing of a PubNub API operation. + * + * @property errorMessage The error message received from the server, if any. + * @property pubnubError The appropriate matching PubNub error. + * @property jso The error json received from the server, if any. + * @property statusCode HTTP status code. + * @property affectedCall A reference to the affected call. Useful for calling [retry][Endpoint.retry]. + */ +actual class PubNubException actual constructor(errorMessage: String?): Exception(errorMessage) { + + actual constructor(pubnubError: PubNubError) : this(pubnubError.message) + + actual companion object { + actual fun from(e: Throwable): PubNubException { + return if (e is PubNubException) { + e + } else { + PubNubException(e.message) + } + } + } +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt new file mode 100644 index 000000000..0c836d68c --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt @@ -0,0 +1,5 @@ +package com.pubnub.api.v2.callbacks + +actual fun interface Consumer { + actual fun accept(p: T) +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/BasePubNub.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/BasePubNub.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt new file mode 100644 index 000000000..976b37a91 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt @@ -0,0 +1,8 @@ +package com.pubnub.api + +import com.google.gson.JsonElement +import com.google.gson.annotations.SerializedName + +actual typealias JsonElement = JsonElement + +actual typealias SerializedName = SerializedName \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/PubNubException.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt similarity index 86% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/PubNubException.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt index a12843f5e..7d11ecc5e 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/PubNubException.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt @@ -13,7 +13,7 @@ import retrofit2.Call * @property statusCode HTTP status code. * @property affectedCall A reference to the affected call. Useful for calling [retry][Endpoint.retry]. */ -data class PubNubException( +actual data class PubNubException( val errorMessage: String? = null, val pubnubError: PubNubError? = null, val jso: String? = null, @@ -34,7 +34,9 @@ data class PubNubException( val clientRequest: Request, ) - constructor(pubnubError: PubNubError) : this( + actual constructor(errorMessage: String?) : this(errorMessage, pubnubError = null) + + actual constructor(pubnubError: PubNubError) : this( errorMessage = pubnubError.message, pubnubError = pubnubError, ) @@ -44,8 +46,8 @@ data class PubNubException( pubnubError = pubnubError, ) - companion object { - fun from(e: Throwable): PubNubException = + actual companion object { + actual fun from(e: Throwable): PubNubException = if (e is PubNubException) { e } else { diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/crypto/CryptoModule.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/CryptoModule.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/crypto/CryptoModule.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/CryptoModule.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/crypto/cryptor/Cryptor.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/cryptor/Cryptor.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/crypto/cryptor/Cryptor.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/cryptor/Cryptor.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/crypto/data/EncryptedData.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedData.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/crypto/data/EncryptedData.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedData.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/crypto/data/EncryptedStreamData.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedStreamData.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/crypto/data/EncryptedStreamData.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedStreamData.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/endpoints/HasOverridableConfig.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/HasOverridableConfig.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/endpoints/HasOverridableConfig.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/HasOverridableConfig.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/endpoints/remoteaction/ComposableRemoteAction.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/ComposableRemoteAction.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/endpoints/remoteaction/ComposableRemoteAction.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/ComposableRemoteAction.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/endpoints/remoteaction/MappingRemoteAction.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/MappingRemoteAction.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/endpoints/remoteaction/MappingRemoteAction.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/MappingRemoteAction.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt similarity index 98% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt index 6676013f5..2be27a649 100644 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt @@ -5,4 +5,4 @@ import java.io.InputStream data class PNDownloadFileResult( val fileName: String, val byteStream: InputStream?, -) +) \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/BasePNConfiguration.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfiguration.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/BasePNConfiguration.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfiguration.kt diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/BasePNConfigurationOverride.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfigurationOverride.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/BasePNConfigurationOverride.kt rename to pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfigurationOverride.kt diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt new file mode 100644 index 000000000..bdcbd4ec7 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt @@ -0,0 +1,5 @@ +package com.pubnub.api.v2.callbacks + +import java.util.function.Consumer + +actual typealias Consumer = Consumer \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNOperationType.kt b/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNOperationType.kt deleted file mode 100644 index 5fb561ba2..000000000 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/enums/PNOperationType.kt +++ /dev/null @@ -1,362 +0,0 @@ -package com.pubnub.api.enums - -sealed class PNOperationType(open val queryParam: String? = null) { - open class PublishOperation : PNOperationType("pub") - - open class HistoryOperation : PNOperationType("hist") - - open class PresenceOperation : PNOperationType("pres") - - open class ChannelGroupOperation : PNOperationType("cg") - - open class PushNotificationsOperation : PNOperationType("push") - - open class PAMOperation : PNOperationType("pam") - - open class MessageCountsOperation : PNOperationType("mc") - - open class SignalsOperation : PNOperationType("sig") - - open class ObjectsOperation : PNOperationType("obj") - - open class PAMV3Operation : PNOperationType("pamv3") - - open class MessageActionsOperation : PNOperationType("msga") - - open class TimeOperation : PNOperationType("time") - - object FileOperation : PNOperationType("file") - - object SpaceOperation : PNOperationType("obj") - - object UserOperation : PNOperationType("obj") - - object MembershipOperation : PNOperationType("obj") - - object PNSubscribeOperation : PNOperationType() - - object PNDisconnectOperation : PNOperationType() - - object PNPublishOperation : PublishOperation() - - object PNHistoryOperation : HistoryOperation() - - object PNFetchMessagesOperation : HistoryOperation() - - object PNDeleteMessagesOperation : HistoryOperation() - - object PNUnsubscribeOperation : PresenceOperation() - - object PNWhereNowOperation : PresenceOperation() - - object PNHereNowOperation : PresenceOperation() - - object PNHeartbeatOperation : PresenceOperation() - - object PNSetStateOperation : PresenceOperation() - - object PNGetState : PresenceOperation() - - object PNAddChannelsToGroupOperation : ChannelGroupOperation() - - object PNRemoveChannelsFromGroupOperation : ChannelGroupOperation() - - object PNChannelGroupsOperation : ChannelGroupOperation() - - object PNRemoveGroupOperation : ChannelGroupOperation() - - object PNChannelsForGroupOperation : ChannelGroupOperation() - - object PNPushNotificationEnabledChannelsOperation : PushNotificationsOperation() - - object PNAddPushNotificationsOnChannelsOperation : PushNotificationsOperation() - - object PNRemovePushNotificationsFromChannelsOperation : PushNotificationsOperation() - - object PNRemoveAllPushNotificationsOperation : PushNotificationsOperation() - - object PNAccessManagerAudit : PAMOperation() - - object PNAccessManagerGrant : PAMOperation() - - object PNMessageCountOperation : MessageCountsOperation() - - object PNSignalOperation : SignalsOperation() - - object PNSetUUIDMetadataOperation : ObjectsOperation() - - object PNGetUUIDMetadataOperation : ObjectsOperation() - - object PNGetAllUUIDMetadataOperation : ObjectsOperation() - - object PNRemoveUUIDMetadataOperation : ObjectsOperation() - - object PNSetChannelMetadataOperation : ObjectsOperation() - - object PNGetChannelMetadataOperation : ObjectsOperation() - - object PNGetAllChannelsMetadataOperation : ObjectsOperation() - - object PNRemoveChannelMetadataOperation : ObjectsOperation() - - object PNGetMembershipsOperation : ObjectsOperation() - - object PNSetMembershipsOperation : ObjectsOperation() - - object PNUpdateMembershipsOperation : ObjectsOperation() - - object PNManageMemberships : ObjectsOperation() - - object PNAccessManagerGrantToken : PAMV3Operation() - - object PNAccessManagerRevokeToken : PAMV3Operation() - - object PNAddMessageAction : MessageActionsOperation() - - object PNGetMessageActions : MessageActionsOperation() - - object PNDeleteMessageAction : MessageActionsOperation() - - object PNTimeOperation : TimeOperation() - - override fun toString(): String { - return this.javaClass.simpleName - } - - companion object { - @kotlin.jvm.JvmField - val FileOperation: FileOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$FileOperation").getField("INSTANCE") - .get(null) as FileOperation - - @kotlin.jvm.JvmField - val SpaceOperation: SpaceOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$SpaceOperation").getField("INSTANCE") - .get(null) as SpaceOperation - - @kotlin.jvm.JvmField - val UserOperation: UserOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$UserOperation").getField("INSTANCE") - .get(null) as UserOperation - - @kotlin.jvm.JvmField - val MembershipOperation: MembershipOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$MembershipOperation").getField("INSTANCE") - .get(null) as MembershipOperation - - @kotlin.jvm.JvmField - val PNSubscribeOperation: PNSubscribeOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNSubscribeOperation").getField("INSTANCE") - .get(null) as PNSubscribeOperation - - @kotlin.jvm.JvmField - val PNDisconnectOperation: PNDisconnectOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNDisconnectOperation").getField("INSTANCE") - .get(null) as PNDisconnectOperation - - @kotlin.jvm.JvmField - val PNPublishOperation: PNPublishOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNPublishOperation").getField("INSTANCE") - .get(null) as PNPublishOperation - - @kotlin.jvm.JvmField - val PNHistoryOperation: PNHistoryOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNHistoryOperation").getField("INSTANCE") - .get(null) as PNHistoryOperation - - @kotlin.jvm.JvmField - val PNFetchMessagesOperation: PNFetchMessagesOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNFetchMessagesOperation").getField("INSTANCE") - .get(null) as PNFetchMessagesOperation - - @kotlin.jvm.JvmField - val PNDeleteMessagesOperation: PNDeleteMessagesOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNDeleteMessagesOperation").getField("INSTANCE") - .get(null) as PNDeleteMessagesOperation - - @kotlin.jvm.JvmField - val PNUnsubscribeOperation: PNUnsubscribeOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNUnsubscribeOperation").getField("INSTANCE") - .get(null) as PNUnsubscribeOperation - - @kotlin.jvm.JvmField - val PNWhereNowOperation: PNWhereNowOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNWhereNowOperation").getField("INSTANCE") - .get(null) as PNWhereNowOperation - - @kotlin.jvm.JvmField - val PNHereNowOperation: PNHereNowOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNHereNowOperation").getField("INSTANCE") - .get(null) as PNHereNowOperation - - @kotlin.jvm.JvmField - val PNHeartbeatOperation: PNHeartbeatOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNHeartbeatOperation").getField("INSTANCE") - .get(null) as PNHeartbeatOperation - - @kotlin.jvm.JvmField - val PNSetStateOperation: PNSetStateOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNSetStateOperation").getField("INSTANCE") - .get(null) as PNSetStateOperation - - @kotlin.jvm.JvmField - val PNGetState: PNGetState = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNGetState").getField("INSTANCE") - .get(null) as PNGetState - - @kotlin.jvm.JvmField - val PNAddChannelsToGroupOperation: PNAddChannelsToGroupOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNAddChannelsToGroupOperation").getField("INSTANCE") - .get(null) as PNAddChannelsToGroupOperation - - @kotlin.jvm.JvmField - val PNRemoveChannelsFromGroupOperation: PNRemoveChannelsFromGroupOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNRemoveChannelsFromGroupOperation") - .getField("INSTANCE").get(null) as PNRemoveChannelsFromGroupOperation - - @kotlin.jvm.JvmField - val PNChannelGroupsOperation: PNChannelGroupsOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNChannelGroupsOperation").getField("INSTANCE") - .get(null) as PNChannelGroupsOperation - - @kotlin.jvm.JvmField - val PNRemoveGroupOperation: PNRemoveGroupOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNRemoveGroupOperation").getField("INSTANCE") - .get(null) as PNRemoveGroupOperation - - @kotlin.jvm.JvmField - val PNChannelsForGroupOperation: PNChannelsForGroupOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNChannelsForGroupOperation").getField("INSTANCE") - .get(null) as PNChannelsForGroupOperation - - @kotlin.jvm.JvmField - val PNPushNotificationEnabledChannelsOperation: PNPushNotificationEnabledChannelsOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNPushNotificationEnabledChannelsOperation") - .getField("INSTANCE").get(null) as PNPushNotificationEnabledChannelsOperation - - @kotlin.jvm.JvmField - val PNAddPushNotificationsOnChannelsOperation: PNAddPushNotificationsOnChannelsOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNAddPushNotificationsOnChannelsOperation") - .getField("INSTANCE").get(null) as PNAddPushNotificationsOnChannelsOperation - - @kotlin.jvm.JvmField - val PNRemovePushNotificationsFromChannelsOperation: PNRemovePushNotificationsFromChannelsOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNRemovePushNotificationsFromChannelsOperation") - .getField("INSTANCE").get(null) as PNRemovePushNotificationsFromChannelsOperation - - @kotlin.jvm.JvmField - val PNRemoveAllPushNotificationsOperation: PNRemoveAllPushNotificationsOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNRemoveAllPushNotificationsOperation") - .getField("INSTANCE").get(null) as PNRemoveAllPushNotificationsOperation - - @kotlin.jvm.JvmField - val PNAccessManagerAudit: PNAccessManagerAudit = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNAccessManagerAudit").getField("INSTANCE") - .get(null) as PNAccessManagerAudit - - @kotlin.jvm.JvmField - val PNAccessManagerGrant: PNAccessManagerGrant = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNAccessManagerGrant").getField("INSTANCE") - .get(null) as PNAccessManagerGrant - - @kotlin.jvm.JvmField - val PNMessageCountOperation: PNMessageCountOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNMessageCountOperation").getField("INSTANCE") - .get(null) as PNMessageCountOperation - - @kotlin.jvm.JvmField - val PNSignalOperation: PNSignalOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNSignalOperation").getField("INSTANCE") - .get(null) as PNSignalOperation - - @kotlin.jvm.JvmField - val PNSetUUIDMetadataOperation: PNSetUUIDMetadataOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNSetUUIDMetadataOperation").getField("INSTANCE") - .get(null) as PNSetUUIDMetadataOperation - - @kotlin.jvm.JvmField - val PNGetUUIDMetadataOperation: PNGetUUIDMetadataOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNGetUUIDMetadataOperation").getField("INSTANCE") - .get(null) as PNGetUUIDMetadataOperation - - @kotlin.jvm.JvmField - val PNGetAllUUIDMetadataOperation: PNGetAllUUIDMetadataOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNGetAllUUIDMetadataOperation").getField("INSTANCE") - .get(null) as PNGetAllUUIDMetadataOperation - - @kotlin.jvm.JvmField - val PNRemoveUUIDMetadataOperation: PNRemoveUUIDMetadataOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNRemoveUUIDMetadataOperation").getField("INSTANCE") - .get(null) as PNRemoveUUIDMetadataOperation - - @kotlin.jvm.JvmField - val PNSetChannelMetadataOperation: PNSetChannelMetadataOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNSetChannelMetadataOperation").getField("INSTANCE") - .get(null) as PNSetChannelMetadataOperation - - @kotlin.jvm.JvmField - val PNGetChannelMetadataOperation: PNGetChannelMetadataOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNGetChannelMetadataOperation").getField("INSTANCE") - .get(null) as PNGetChannelMetadataOperation - - @kotlin.jvm.JvmField - val PNGetAllChannelsMetadataOperation: PNGetAllChannelsMetadataOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNGetAllChannelsMetadataOperation") - .getField("INSTANCE").get(null) as PNGetAllChannelsMetadataOperation - - @kotlin.jvm.JvmField - val PNRemoveChannelMetadataOperation: PNRemoveChannelMetadataOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNRemoveChannelMetadataOperation").getField("INSTANCE") - .get(null) as PNRemoveChannelMetadataOperation - - @kotlin.jvm.JvmField - val PNGetMembershipsOperation: PNGetMembershipsOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNGetMembershipsOperation").getField("INSTANCE") - .get(null) as PNGetMembershipsOperation - - @kotlin.jvm.JvmField - val PNSetMembershipsOperation: PNSetMembershipsOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNSetMembershipsOperation").getField("INSTANCE") - .get(null) as PNSetMembershipsOperation - - @kotlin.jvm.JvmField - val PNUpdateMembershipsOperation: PNUpdateMembershipsOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNUpdateMembershipsOperation").getField("INSTANCE") - .get(null) as PNUpdateMembershipsOperation - - @kotlin.jvm.JvmField - val PNManageMemberships: PNManageMemberships = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNManageMemberships").getField("INSTANCE") - .get(null) as PNManageMemberships - - @kotlin.jvm.JvmField - val PNAccessManagerGrantToken: PNAccessManagerGrantToken = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNAccessManagerGrantToken").getField("INSTANCE") - .get(null) as PNAccessManagerGrantToken - - @kotlin.jvm.JvmField - val PNAccessManagerRevokeToken: PNAccessManagerRevokeToken = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNAccessManagerRevokeToken").getField("INSTANCE") - .get(null) as PNAccessManagerRevokeToken - - @kotlin.jvm.JvmField - val PNAddMessageAction: PNAddMessageAction = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNAddMessageAction").getField("INSTANCE") - .get(null) as PNAddMessageAction - - @kotlin.jvm.JvmField - val PNGetMessageActions: PNGetMessageActions = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNGetMessageActions").getField("INSTANCE") - .get(null) as PNGetMessageActions - - @kotlin.jvm.JvmField - val PNDeleteMessageAction: PNDeleteMessageAction = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNDeleteMessageAction").getField("INSTANCE") - .get(null) as PNDeleteMessageAction - - @kotlin.jvm.JvmField - val PNTimeOperation: PNTimeOperation = - Class.forName("com.pubnub.api.enums.PNOperationType\$PNTimeOperation").getField("INSTANCE") - .get(null) as PNTimeOperation - } -} diff --git a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/Result.kt b/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/Result.kt deleted file mode 100644 index 946e2a451..000000000 --- a/pubnub-core/pubnub-core-api/src/main/kotlin/com/pubnub/api/v2/callbacks/Result.kt +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license. - */ -@file:JvmName("Results") - -package com.pubnub.api.v2.callbacks - -import com.pubnub.api.PubNubException -import java.util.function.Consumer -import kotlin.contracts.ExperimentalContracts -import kotlin.contracts.InvocationKind -import kotlin.contracts.contract - -/** - * A discriminated union that encapsulates a successful outcome with a value of type [T] - * or a failure with a [PubNubException]. - */ -class Result - @PublishedApi - internal constructor( - @PublishedApi - @get:JvmSynthetic - internal val value: Any?, - ) { - // discovery - - /** - * Returns `true` if this instance represents a successful outcome. - * In this case [isFailure] returns `false`. - */ - public val isSuccess: Boolean get() = value !is Failure - - /** - * Returns `true` if this instance represents a failed outcome. - * In this case [isSuccess] returns `false`. - */ - public val isFailure: Boolean get() = value is Failure - - // value & exception retrieval - - /** - * Returns the encapsulated value if this instance represents [success][Result.isSuccess] or `null` - * if it is [failure][Result.isFailure]. - * - * This function is a shorthand for `getOrElse { null }` (see [getOrElse]) or - * `fold(onSuccess = { it }, onFailure = { null })` (see [fold]). - */ - @Suppress("UNCHECKED_CAST") - public inline fun getOrNull(): T? = - when { - isFailure -> null - else -> value as T - } - - /** - * Returns the encapsulated [PubNubException] exception if this instance represents [failure][isFailure] or `null` - * if it is [success][isSuccess]. - * - * This function is a shorthand for `fold(onSuccess = { null }, onFailure = { it })` (see [fold]). - */ - public fun exceptionOrNull(): PubNubException? = - when (value) { - is Failure -> value.exception - else -> null - } - - /** - * Returns a string `Success(v)` if this instance represents [success][Result.isSuccess] - * where `v` is a string representation of the value or a string `Failure(x)` if - * it is [failure][isFailure] where `x` is a string representation of the exception. - */ - public override fun toString(): String = - when (value) { - is Failure -> value.toString() // "Failure($exception)" - else -> "Success($value)" - } - - public inline fun onFailure(action: Consumer): Result { - exceptionOrNull()?.let { action.accept(it) } - return this - } - - @Suppress("UNCHECKED_CAST") - public inline fun onSuccess(action: Consumer): Result { - if (isSuccess) { - action.accept(value as T) - } - return this - } - - // companion with constructors - - /** - * Companion object for [Result] class that contains its constructor functions - * [success] and [failure]. - */ - public companion object { - /** - * Returns an instance that encapsulates the given [value] as successful value. - */ - @JvmStatic - public fun success(value: T): Result = Result(value) - - /** - * Returns an instance that encapsulates the given [PubNubException] [exception] as failure. - */ - @JvmStatic - public fun failure(exception: PubNubException): Result = Result(createFailure(exception)) - } - - internal class Failure( - @JvmField - val exception: PubNubException, - ) { - override fun equals(other: Any?): Boolean = other is Failure && exception == other.exception - - override fun hashCode(): Int = exception.hashCode() - - override fun toString(): String = "Failure($exception)" - } - } - -/** - * Creates an instance of internal marker [Result.Failure] class to - * make sure that this class is not exposed in ABI. - */ -private fun createFailure(exception: PubNubException): Any = Result.Failure(exception) - -/** - * Throws exception if the result is failure. This internal function minimizes - * inlined bytecode for [getOrThrow] and makes sure that in the future we can - * add some exception-augmenting logic here (if needed). - */ -private fun Result<*>.throwOnFailure() { - if (value is Result.Failure) { - throw value.exception - } -} - -// -- extensions --- - -/** - * Returns the encapsulated value if this instance represents [success][Result.isSuccess] or throws the encapsulated [PubNubException] - * if it is [failure][Result.isFailure]. - * - * This function is a shorthand for `getOrElse { throw it }` (see [getOrElse]). - */ -public fun Result.getOrThrow(): T { - throwOnFailure() - return value as T -} - -/** - * Returns the encapsulated value if this instance represents [success][Result.isSuccess] or the - * result of [onFailure] function for the encapsulated [PubNubException] exception if it is [failure][Result.isFailure]. - * - * Note, that this function rethrows any [Throwable] exception thrown by [onFailure] function. - * - * This function is a shorthand for `fold(onSuccess = { it }, onFailure = onFailure)` (see [fold]). - */ -@OptIn(ExperimentalContracts::class) -public inline fun Result.getOrElse(onFailure: (exception: PubNubException) -> R): R { - contract { - callsInPlace(onFailure, InvocationKind.AT_MOST_ONCE) - } - return when (val exception = exceptionOrNull()) { - null -> value as T - else -> onFailure(exception) - } -} - -/** - * Returns the encapsulated value if this instance represents [success][Result.isSuccess] or the - * [defaultValue] if it is [failure][Result.isFailure]. - * - * This function is a shorthand for `getOrElse { defaultValue }` (see [getOrElse]). - */ -public inline fun Result.getOrDefault(defaultValue: R): R { - if (isFailure) { - return defaultValue - } - return value as T -} diff --git a/pubnub-core/pubnub-core-impl/build.gradle.kts b/pubnub-core/pubnub-core-impl/build.gradle.kts index 9d81ee351..8e30fef21 100644 --- a/pubnub-core/pubnub-core-impl/build.gradle.kts +++ b/pubnub-core/pubnub-core-impl/build.gradle.kts @@ -2,7 +2,9 @@ import com.pubnub.gradle.tasks.GenerateVersionTask plugins { alias(libs.plugins.benmanes.versions) - id("pubnub.shared") + id("pubnub.java-library") + id("pubnub.kotlin-library") + id("pubnub.test") } val generateVersion = diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt index 27ac67467..9040bd819 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt @@ -7,6 +7,7 @@ import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.access_manager.v3.PNToken +import com.pubnub.api.models.consumer.history.PNHistoryResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.v2.BasePNConfiguration @@ -522,7 +523,7 @@ class PubNubCore internal constructor( channel: String, start: Long? = null, end: Long? = null, - count: Int = HistoryEndpoint.MAX_COUNT, + count: Int = PNHistoryResult.MAX_COUNT, reverse: Boolean = false, includeTimetoken: Boolean = false, includeMeta: Boolean = false, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryEndpoint.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryEndpoint.kt index a7c516158..c139b040d 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryEndpoint.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryEndpoint.kt @@ -27,15 +27,11 @@ class HistoryEndpoint internal constructor( override val includeTimetoken: Boolean, override val includeMeta: Boolean, ) : EndpointCore(pubnub), HistoryInterface { - companion object { - const val MAX_COUNT = 100 - } - private val countParam: Int = - if (count in 1..MAX_COUNT) { + if (count in 1..PNHistoryResult.MAX_COUNT) { count } else { - MAX_COUNT + PNHistoryResult.MAX_COUNT } override fun validateParams() { diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileEndpoint.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileEndpoint.kt index 15d440e92..5d78d2f62 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileEndpoint.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileEndpoint.kt @@ -18,7 +18,7 @@ class DeleteFileEndpoint( private val fileName: String, private val fileId: String, pubNub: PubNubCore, -) : EndpointCore(pubNub), DeleteFileInterface { +) : EndpointCore(pubNub), DeleteFileInterface { @Throws(PubNubException::class) override fun validateParams() { if (channel.isEmpty()) { diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileInterface.kt index aa1b14f09..a9210aca9 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileInterface.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileInterface.kt @@ -3,4 +3,4 @@ package com.pubnub.internal.endpoints.files import com.pubnub.api.models.consumer.files.PNDeleteFileResult import com.pubnub.internal.EndpointInterface -interface DeleteFileInterface : EndpointInterface +interface DeleteFileInterface : EndpointInterface diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/step/EventEngineSteps.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/step/EventEngineSteps.kt index 671570a34..2b21d1f35 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/step/EventEngineSteps.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/step/EventEngineSteps.kt @@ -26,7 +26,7 @@ class EventEngineSteps(private val state: EventEngineState) { @Given("a linear reconnection policy with {int} retries") fun a_linear_reconnection_policy_with_retries(maxRetries: Int) { state.configuration.retryConfiguration = - @Suppress("INVISIBLE_MEMBER") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") RetryConfiguration.Linear.createForTest(delayInSec = 1.milliseconds, maxRetryNumber = maxRetries, isInternal = true) } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableCallbackTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableCallbackTest.kt index b1668d053..13acbf1ab 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableCallbackTest.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableCallbackTest.kt @@ -107,7 +107,7 @@ class RetryableCallbackTest { // given val success = AtomicBoolean() - @Suppress("INVISIBLE_MEMBER") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") val retryableCallback = getRetryableCallback( retryConfiguration = @@ -146,7 +146,7 @@ class RetryableCallbackTest { @Test fun `should retry onResponse when exponential retryConfiguration is set and retryable error 500 occurs`() { // given - @Suppress("INVISIBLE_MEMBER") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") val retryConfiguration = RetryConfiguration.Exponential.createForTest( minDelayInSec = 10.milliseconds, @@ -183,7 +183,7 @@ class RetryableCallbackTest { @Test fun `should retry onFailure when exponential retryConfiguration is set and SocketTimeoutException`() { // given - @Suppress("INVISIBLE_MEMBER") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") val retryConfiguration = RetryConfiguration.Exponential.createForTest( minDelayInSec = 10.milliseconds, @@ -219,7 +219,7 @@ class RetryableCallbackTest { @Test fun `should retry onFailure and fail when exponential retryConfiguration is set and UnknownHostException`() { // given - @Suppress("INVISIBLE_MEMBER") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") val retryConfiguration = RetryConfiguration.Exponential.createForTest( minDelayInSec = 10.milliseconds, diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableRestCallerTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableRestCallerTest.kt index 6cd3de561..c802e3d13 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableRestCallerTest.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableRestCallerTest.kt @@ -300,7 +300,7 @@ class RetryableRestCallerTest { @Test fun `should retry successfully when linear retryConfiguration is set and response is not successful and http error is 500 and endpoint is not excluded from retryConfiguration`() { // given - @Suppress("INVISIBLE_MEMBER") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") val retryConfiguration = RetryConfiguration.Linear.createForTest(delayInSec = 10.milliseconds, maxRetryNumber = 3, isInternal = true) val retryableRestCaller = getRetryableRestCaller(retryConfiguration = retryConfiguration) @@ -323,7 +323,7 @@ class RetryableRestCallerTest { @Test fun `should retry successfully when exponential retryConfiguration is set and response is not successful and http error is 500 and endpoint is not excluded from retryConfiguration`() { // given - @Suppress("INVISIBLE_MEMBER") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") val retryConfiguration = RetryConfiguration.Exponential.createForTest( minDelayInSec = 10.milliseconds, @@ -352,7 +352,7 @@ class RetryableRestCallerTest { @Test fun `should retry successfully when linear retryConfiguration is set and SocketTimeoutException is thrown`() { // given - @Suppress("INVISIBLE_MEMBER") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") val retryConfiguration = RetryConfiguration.Linear.createForTest(delayInSec = 10.milliseconds, maxRetryNumber = 2, isInternal = true) val retryableRestCaller = getRetryableRestCaller(retryConfiguration = retryConfiguration) @@ -373,7 +373,7 @@ class RetryableRestCallerTest { @Test fun `should retry and throw exception when linear retryConfiguration is set and UnknownHostException is thrown`() { // given - @Suppress("INVISIBLE_MEMBER") + @Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") val retryConfiguration = RetryConfiguration.Linear.createForTest(delayInSec = 10.milliseconds, maxRetryNumber = 2, isInternal = true) val retryableRestCaller = getRetryableRestCaller(retryConfiguration = retryConfiguration) diff --git a/pubnub-gson/build.gradle.kts b/pubnub-gson/build.gradle.kts index 4864fd15b..4b8dd2eee 100644 --- a/pubnub-gson/build.gradle.kts +++ b/pubnub-gson/build.gradle.kts @@ -2,7 +2,7 @@ plugins { checkstyle alias(libs.plugins.benmanes.versions) alias(libs.plugins.lombok) - id("pubnub.shared") + id("pubnub.java-library") id("pubnub.dokka") } diff --git a/pubnub-gson/pubnub-gson-api/build.gradle.kts b/pubnub-gson/pubnub-gson-api/build.gradle.kts index 8e04630df..1e2c29c06 100644 --- a/pubnub-gson/pubnub-gson-api/build.gradle.kts +++ b/pubnub-gson/pubnub-gson-api/build.gradle.kts @@ -2,7 +2,8 @@ plugins { checkstyle alias(libs.plugins.benmanes.versions) alias(libs.plugins.lombok) - id("pubnub.shared") + id("pubnub.java-library") + id("pubnub.kotlin-library") id("pubnub.dokka") } diff --git a/pubnub-gson/pubnub-gson-impl/build.gradle.kts b/pubnub-gson/pubnub-gson-impl/build.gradle.kts index 76eee4851..da7edd6ef 100644 --- a/pubnub-gson/pubnub-gson-impl/build.gradle.kts +++ b/pubnub-gson/pubnub-gson-impl/build.gradle.kts @@ -2,7 +2,9 @@ plugins { checkstyle alias(libs.plugins.benmanes.versions) alias(libs.plugins.lombok) - id("pubnub.shared") + id("pubnub.java-library") + id("pubnub.kotlin-library") + id("pubnub.test") id("pubnub.dokka") id("pubnub.integration-test") } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/HistoryImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/HistoryImpl.java index f6f08ca89..e08854df8 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/HistoryImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/HistoryImpl.java @@ -18,7 +18,7 @@ public class HistoryImpl extends IdentityMappingEndpoint implem private Long start; private Long end; private boolean reverse; - private int count = HistoryEndpoint.MAX_COUNT; + private int count = PNHistoryResult.MAX_COUNT; private boolean includeTimetoken; private boolean includeMeta; diff --git a/pubnub-kotlin/build.gradle.kts b/pubnub-kotlin/build.gradle.kts index 7f2ff2c42..c6059f2d6 100644 --- a/pubnub-kotlin/build.gradle.kts +++ b/pubnub-kotlin/build.gradle.kts @@ -1,6 +1,6 @@ plugins { alias(libs.plugins.benmanes.versions) - id("pubnub.shared") + id("pubnub.kotlin-library") id("pubnub.dokka") } diff --git a/pubnub-kotlin/pubnub-kotlin-api/PubNubKMP.podspec b/pubnub-kotlin/pubnub-kotlin-api/PubNubKMP.podspec new file mode 100644 index 000000000..d7f20235f --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/PubNubKMP.podspec @@ -0,0 +1,54 @@ +Pod::Spec.new do |spec| + spec.name = 'PubNubKMP' + spec.version = '1.0' + spec.homepage = 'Link to a Kotlin/Native module homepage' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = 'Some description for a Kotlin/Native module' + spec.vendored_frameworks = 'build/cocoapods/framework/PubNubKMP.framework' + spec.libraries = 'c++' + spec.ios.deployment_target = '14' + spec.dependency 'PubNubSwift' + + if !Dir.exist?('build/cocoapods/framework/PubNubKMP.framework') || Dir.empty?('build/cocoapods/framework/PubNubKMP.framework') + raise " + + Kotlin framework 'PubNubKMP' doesn't exist yet, so a proper Xcode project can't be generated. + 'pod install' should be executed after running ':generateDummyFramework' Gradle task: + + ./gradlew :pubnub-kotlin:pubnub-kotlin-api:generateDummyFramework + + Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" + end + + spec.xcconfig = { + 'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO', + } + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':pubnub-kotlin:pubnub-kotlin-api', + 'PRODUCT_MODULE_NAME' => 'PubNubKMP', + } + + spec.script_phases = [ + { + :name => 'Build PubNubKMP', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index 342a675b1..442c3315e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -1,11 +1,106 @@ +import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType + plugins { alias(libs.plugins.benmanes.versions) id("pubnub.shared") id("pubnub.dokka") + kotlin("multiplatform") + kotlin("native.cocoapods") } -dependencies { - api(project(":pubnub-core:pubnub-core-api")) - implementation(project(":pubnub-core:pubnub-core-impl")) - implementation(libs.slf4j) -} +kotlin { + jvmToolchain(8) + js { + browser { + } + binaries.executable() + } + jvm { + compilations.all { + compileTaskProvider.configure { + compilerOptions { + freeCompilerArgs.add("-Xexpect-actual-classes") + javaParameters.set(true) + } + } + } + } + + listOf( + iosArm64(), +// iosX64(), + iosSimulatorArm64(), + ).forEach { + it.binaries { + framework { + baseName = "PubNubKMP" + isStatic = true + } + } + } + + cocoapods { + ios.deploymentTarget = "14" + + // Required properties + // Specify the required Pod version here. Otherwise, the Gradle project version is used. + version = "1.0" + summary = "Some description for a Kotlin/Native module" + homepage = "Link to a Kotlin/Native module homepage" + + // Optional properties + // Configure the Pod name here instead of changing the Gradle project name + name = "PubNubKMP" + + // Maps custom Xcode configuration to NativeBuildType + xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG + xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE + +// podfile = project.file(project.file("Sample Chat app/Podfile")) + + framework { + // Required properties + // Framework name configuration. Use this property instead of deprecated 'frameworkName' + baseName = "PubNubKMP" + + // Optional properties + // Specify the framework linking type. It's dynamic by default. + isStatic = true + export(project(":pubnub-core:pubnub-core-api")) + transitiveExport = true + } + + pod("PubNubSwift") { + source = git("https://github.com/pubnub/swift") { + branch = "feat/kmp" + } +// headers = "PubNub/PubNub.h" +// source = path(project.file("swift")) +// version = "7.1.0" + + moduleName = "PubNub" + extraOpts += listOf("-compiler-option", "-fmodules") + } + } + + sourceSets { + val commonMain by getting { + dependencies { + api(project(":pubnub-core:pubnub-core-api")) + } + } + + val commonTest by getting { + dependencies { + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0-RC.2") + } + } + + val jvmMain by getting { + dependencies { + implementation(project(":pubnub-core:pubnub-core-impl")) + implementation(libs.slf4j) + } + } + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/Endpoint.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/Endpoint.kt new file mode 100644 index 000000000..53a898005 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/Endpoint.kt @@ -0,0 +1,8 @@ +package com.pubnub.api + +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result + +expect interface Endpoint { + fun async(callback: Consumer>) +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt new file mode 100644 index 000000000..ddaae2572 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt @@ -0,0 +1,447 @@ +package com.pubnub.api + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.endpoints.DeleteMessages +import com.pubnub.api.endpoints.FetchMessages +import com.pubnub.api.endpoints.MessageCounts +import com.pubnub.api.endpoints.Time +import com.pubnub.api.endpoints.access.GrantToken +import com.pubnub.api.endpoints.access.RevokeToken +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.GetFileUrl +import com.pubnub.api.endpoints.files.ListFiles +import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.message_actions.AddMessageAction +import com.pubnub.api.endpoints.message_actions.GetMessageActions +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +import com.pubnub.api.endpoints.objects.member.GetChannelMembers +import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +import com.pubnub.api.endpoints.objects.membership.GetMemberships +import com.pubnub.api.endpoints.objects.membership.ManageMemberships +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +import com.pubnub.api.endpoints.presence.GetState +import com.pubnub.api.endpoints.presence.HereNow +import com.pubnub.api.endpoints.presence.SetState +import com.pubnub.api.endpoints.presence.WhereNow +import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.endpoints.push.AddChannelsToPush +import com.pubnub.api.endpoints.push.ListPushProvisions +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions +import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNMemberKey +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.member.MemberInput +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener + +expect fun createPubNub(config: PNConfiguration): PubNub + +expect fun createEventListener( + pubnub: PubNub, + onMessage: (PubNub, PNMessageResult) -> Unit = { _, _ -> }, + onPresence: (PubNub, PNPresenceEventResult) -> Unit = { _, _ -> }, + onSignal: (PubNub, PNSignalResult) -> Unit = { _, _ -> }, + onMessageAction: (PubNub, PNMessageActionResult) -> Unit = { _, _ -> }, + onObjects: (PubNub, PNObjectEventResult) -> Unit = { _, _ -> }, + onFile: (PubNub, PNFileEventResult) -> Unit = { _, _ -> }, +): EventListener + +expect fun createStatusListener( + pubnub: PubNub, + onStatus: (PubNub, PNStatus) -> Unit = { _, _ -> }, +): StatusListener + +expect interface PubNub { + val configuration: PNConfiguration + fun addListener(listener: EventListener) + fun addListener(listener: StatusListener) + fun removeListener(listener: Listener) + fun removeAllListeners()//region api + fun publish( + channel: String, + message: Any, + meta: Any? = null, + shouldStore: Boolean? = null, + usePost: Boolean = false, + replicate: Boolean = true, + ttl: Int? = null, + ): Publish + + fun fire( + channel: String, + message: Any, + meta: Any? = null, + usePost: Boolean = false, + ttl: Int? = null, + ): Publish + + fun signal( + channel: String, + message: Any, + ): Signal + + fun getSubscribedChannels(): List + fun getSubscribedChannelGroups(): List + fun addPushNotificationsOnChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String? = null, + environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, + ): AddChannelsToPush + + fun auditPushChannelProvisions( + pushType: PNPushType, + deviceId: String, + topic: String? = null, + environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, + ): ListPushProvisions + + fun removePushNotificationsFromChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String? = null, + environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, + ): RemoveChannelsFromPush + + fun removeAllPushNotificationsFromDeviceWithPushToken( + pushType: PNPushType, + deviceId: String, + topic: String? = null, + environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, + ): RemoveAllPushChannelsForDevice + + fun fetchMessages( + channels: List, + page: PNBoundedPage = PNBoundedPage(), + includeUUID: Boolean = true, + includeMeta: Boolean = false, + includeMessageActions: Boolean = false, + includeMessageType: Boolean = true, + ): FetchMessages + + fun deleteMessages( + channels: List, + start: Long? = null, + end: Long? = null, + ): DeleteMessages + + fun messageCounts( + channels: List, + channelsTimetoken: List, + ): MessageCounts + + fun hereNow( + channels: List = emptyList(), + channelGroups: List = emptyList(), + includeState: Boolean = false, + includeUUIDs: Boolean = true, + ): HereNow + + fun whereNow(uuid: String = configuration.userId.value): WhereNow + fun setPresenceState( + channels: List = listOf(), + channelGroups: List = listOf(), + state: Any, + uuid: String = configuration.userId.value, + ): SetState + + fun getPresenceState( + channels: List = listOf(), + channelGroups: List = listOf(), + uuid: String = configuration.userId.value, + ): GetState + + fun presence( + channels: List = emptyList(), + channelGroups: List = emptyList(), + connected: Boolean = false, + ) + + fun addMessageAction( + channel: String, + messageAction: PNMessageAction, + ): AddMessageAction + + fun removeMessageAction( + channel: String, + messageTimetoken: Long, + actionTimetoken: Long, + ): RemoveMessageAction + + fun getMessageActions( + channel: String, + page: PNBoundedPage = PNBoundedPage(), + ): GetMessageActions + + fun addChannelsToChannelGroup( + channels: List, + channelGroup: String, + ): AddChannelChannelGroup + + fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup + fun removeChannelsFromChannelGroup( + channels: List, + channelGroup: String, + ): RemoveChannelChannelGroup + + fun listAllChannelGroups(): ListAllChannelGroup + fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup + + fun grantToken( + ttl: Int, + meta: Any? = null, + authorizedUUID: String? = null, + channels: List = emptyList(), + channelGroups: List = emptyList(), + uuids: List = emptyList(), + ): GrantToken + + fun grantToken( + ttl: Int, + meta: Any? = null, + authorizedUserId: UserId? = null, + spacesPermissions: List = emptyList(), + usersPermissions: List = emptyList(), + ): GrantToken + + fun revokeToken(token: String): RevokeToken + fun time(): Time + fun getAllChannelMetadata( + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + ): GetAllChannelMetadata + + fun getChannelMetadata( + channel: String, + includeCustom: Boolean = false, + ): GetChannelMetadata + + fun setChannelMetadata( + channel: String, + name: String? = null, + description: String? = null, + custom: Any? = null, + includeCustom: Boolean = false, + type: String? = null, + status: String? = null, + ): SetChannelMetadata + + fun removeChannelMetadata(channel: String): RemoveChannelMetadata + fun getAllUUIDMetadata( + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + ): GetAllUUIDMetadata + + fun getUUIDMetadata( + uuid: String? = null, + includeCustom: Boolean = false, + ): GetUUIDMetadata + + fun setUUIDMetadata( + uuid: String? = null, + name: String? = null, + externalId: String? = null, + profileUrl: String? = null, + email: String? = null, + custom: CustomObject? = null, + includeCustom: Boolean = false, + type: String? = null, + status: String? = null, + ): SetUUIDMetadata + + fun removeUUIDMetadata(uuid: String? = null): RemoveUUIDMetadata + fun getMemberships( + uuid: String? = null, + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + includeChannelDetails: PNChannelDetailsLevel? = null, + ): GetMemberships + + fun setMemberships( + channels: List, + uuid: String? = null, + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + includeChannelDetails: PNChannelDetailsLevel? = null, + ): ManageMemberships + + fun removeMemberships( + channels: List, + uuid: String? = null, + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + includeChannelDetails: PNChannelDetailsLevel? = null, + ): ManageMemberships + + fun manageMemberships( + channelsToSet: List, + channelsToRemove: List, + uuid: String? = null, + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + includeChannelDetails: PNChannelDetailsLevel? = null, + ): ManageMemberships + + fun getChannelMembers( + channel: String, + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + includeUUIDDetails: PNUUIDDetailsLevel? = null, + ): GetChannelMembers + + fun setChannelMembers( + channel: String, + uuids: List, + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + includeUUIDDetails: PNUUIDDetailsLevel? = null, + ): ManageChannelMembers + + fun removeChannelMembers( + channel: String, + uuids: List, + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + includeUUIDDetails: PNUUIDDetailsLevel? = null, + ): ManageChannelMembers + + fun manageChannelMembers( + channel: String, + uuidsToSet: Collection, + uuidsToRemove: Collection, + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + includeUUIDDetails: PNUUIDDetailsLevel? = null, + ): ManageChannelMembers + + // + fun listFiles( + channel: String, + limit: Int? = null, + next: PNPage.PNNext? = null, + ): ListFiles + + fun getFileUrl( + channel: String, + fileName: String, + fileId: String, + ): GetFileUrl + + // fun downloadFile( +// channel: String, +// fileName: String, +// fileId: String, +// cipherKey: String? = null, +// ): Endpoint // TODO inputstream + fun deleteFile( + channel: String, + fileName: String, + fileId: String, + ): DeleteFile + + fun publishFileMessage( + channel: String, + fileName: String, + fileId: String, + message: Any? = null, + meta: Any? = null, + ttl: Int? = null, + shouldStore: Boolean? = null, + ): PublishFileMessage + + fun subscribe( + channels: List = emptyList(), + channelGroups: List = emptyList(), + withPresence: Boolean = false, + withTimetoken: Long = 0L, + ) + + fun unsubscribe( + channels: List = emptyList(), + channelGroups: List = emptyList(), + ) + + fun setToken(token: String?) +} + +expect class CustomObject + +expect fun createCustomObject(map: Map): CustomObject diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/SpaceId.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/SpaceId.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/SpaceId.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/SpaceId.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt new file mode 100644 index 000000000..f0bd9c7a4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult + +/** + * @see [com.pubnub.api.PubNub.deleteMessages] + */ +expect interface DeleteMessages : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt new file mode 100644 index 000000000..6e3706447 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.history.PNFetchMessagesResult + +/** + * @see [PubNub.fetchMessages] + */ +expect interface FetchMessages : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt new file mode 100644 index 000000000..31b56a358 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.history.PNMessageCountResult + +/** + * @see [PubNub.messageCounts] + */ +expect interface MessageCounts : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/Time.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/Time.kt similarity index 76% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/Time.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/Time.kt index babc12504..abb353d19 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/Time.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/Time.kt @@ -6,4 +6,4 @@ import com.pubnub.api.models.consumer.PNTimeResult /** * @see [PubNub.time] */ -interface Time : Endpoint +expect interface Time : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt new file mode 100644 index 000000000..eacb620c9 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt @@ -0,0 +1,7 @@ +package com.pubnub.api.endpoints.access + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult + +expect interface GrantToken : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt similarity index 61% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt index 2dc6d8139..701fbbade 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt @@ -2,4 +2,4 @@ package com.pubnub.api.endpoints.access import com.pubnub.api.Endpoint -interface RevokeToken : Endpoint +expect interface RevokeToken : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt new file mode 100644 index 000000000..92fde21aa --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.channel_groups + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult + +/** + * @see [PubNub.addChannelsToChannelGroup] + */ +expect interface AddChannelChannelGroup : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt new file mode 100644 index 000000000..f2b0337e6 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.channel_groups + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult + +/** + * @see [PubNub.listChannelsForChannelGroup] + */ +expect interface AllChannelsChannelGroup : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt new file mode 100644 index 000000000..c8421da68 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.channel_groups + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult + +/** + * @see [PubNub.deleteChannelGroup] + */ +expect interface DeleteChannelGroup : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt similarity index 72% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt index 3727db1d9..0860718f0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt @@ -6,4 +6,4 @@ import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult /** * @see [PubNub.listAllChannelGroups] */ -interface ListAllChannelGroup : Endpoint +expect interface ListAllChannelGroup : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt new file mode 100644 index 000000000..4bbb27471 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.channel_groups + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult + +/** + * @see [PubNub.removeChannelsFromChannelGroup] + */ +expect interface RemoveChannelChannelGroup : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt similarity index 74% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt index ff839e5cd..b9d662890 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt @@ -6,4 +6,4 @@ import com.pubnub.api.models.consumer.files.PNDeleteFileResult /** * @see [PubNub.deleteFile] */ -interface DeleteFile : Endpoint +expect interface DeleteFile : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt similarity index 75% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt index 4a678768f..fe58a6221 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt @@ -6,4 +6,4 @@ import com.pubnub.api.models.consumer.files.PNFileUrlResult /** * @see [PubNub.getFileUrl] */ -interface GetFileUrl : Endpoint +expect interface GetFileUrl : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt similarity index 75% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt index b7a87b5d6..ad5b26b24 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt @@ -6,4 +6,4 @@ import com.pubnub.api.models.consumer.files.PNListFilesResult /** * @see [PubNub.listFiles] */ -interface ListFiles : Endpoint +expect interface ListFiles : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt similarity index 71% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt index 2cd508dfd..1fccf9263 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult /** * @see [PubNub.publishFileMessage] */ -interface PublishFileMessage : - Endpoint +expect interface PublishFileMessage : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt new file mode 100644 index 000000000..805693dd9 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.message_actions + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult + +/** + * @see [PubNub.addMessageAction] + */ +expect interface AddMessageAction : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt new file mode 100644 index 000000000..9578456b0 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.message_actions + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult + +/** + * @see [PubNub.getMessageActions] + */ +expect interface GetMessageActions : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt new file mode 100644 index 000000000..7419e1518 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.message_actions + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult + +/** + * @see [PubNub.removeMessageAction] + */ +expect interface RemoveMessageAction : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt new file mode 100644 index 000000000..f1ec80946 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult + +/** + * @see [PubNub.getAllChannelMetadata] + */ +expect interface GetAllChannelMetadata : + Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt similarity index 74% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt index 0feac71b2..9001d76cd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult /** * @see [PubNub.getChannelMetadata] */ -interface GetChannelMetadata : - Endpoint +expect interface GetChannelMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt similarity index 67% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt index 0ba88162d..fcdefef90 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt @@ -3,5 +3,4 @@ package com.pubnub.api.endpoints.objects.channel import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -interface RemoveChannelMetadata : - Endpoint +expect interface RemoveChannelMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt similarity index 74% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt index 009dc458a..2d0ed08e6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult /** * @see [PubNub.setChannelMetadata] */ -interface SetChannelMetadata : - Endpoint +expect interface SetChannelMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt similarity index 74% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt index 6c8a889fe..16da70b9c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult /** * @see [PubNub.getChannelMembers] */ -interface GetChannelMembers : - Endpoint +expect interface GetChannelMembers : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt similarity index 74% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt index 43fdecc57..c47b6034c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult /** * @see [PubNub.manageChannelMembers] */ -interface ManageChannelMembers : - Endpoint +expect interface ManageChannelMembers : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt similarity index 74% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt index f82198caf..add1d26f5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArra /** * @see [PubNub.getMemberships] */ -interface GetMemberships : - Endpoint +expect interface GetMemberships : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt similarity index 73% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt index a9528b05e..2c43038d1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArra /** * @see [PubNub.manageMemberships] */ -interface ManageMemberships : - Endpoint +expect interface ManageMemberships : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt similarity index 73% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt index 2445f469e..d42c784e3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult /** * @see [PubNub.getAllUUIDMetadata] */ -interface GetAllUUIDMetadata : - Endpoint +expect interface GetAllUUIDMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt new file mode 100644 index 000000000..93e76b3bf --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.objects.uuid + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult + +/** + * @see [PubNub.getUUIDMetadata] + */ +expect interface GetUUIDMetadata : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt new file mode 100644 index 000000000..b30d322af --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt @@ -0,0 +1,7 @@ +package com.pubnub.api.endpoints.objects.uuid + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult + +expect interface RemoveUUIDMetadata : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt similarity index 74% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt index 152822954..6470a9a2a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult /** * @see [PubNub.setUUIDMetadata] */ -interface SetUUIDMetadata : - Endpoint +expect interface SetUUIDMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt new file mode 100644 index 000000000..ed2fdb6d3 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.presence + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNGetStateResult + +/** + * @see [PubNub.getPresenceState] + */ +expect interface GetState : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt new file mode 100644 index 000000000..eabef86a0 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.presence + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNHereNowResult + +/** + * @see [PubNub.hereNow] + */ +expect interface HereNow : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt new file mode 100644 index 000000000..4f4c61dc6 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.presence + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNSetStateResult + +/** + * @see [PubNub.setPresenceState] + */ +expect interface SetState : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt new file mode 100644 index 000000000..a810bfb49 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.presence + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNWhereNowResult + +/** + * @see [PubNub.whereNow] + */ +expect interface WhereNow : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt new file mode 100644 index 000000000..ddf89abf8 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.pubsub + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.PNPublishResult + +/** + * @see [PubNub.publish] + */ +expect interface Publish : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt new file mode 100644 index 000000000..81e9b6569 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.pubsub + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.PNPublishResult + +/** + * @see [PubNub.signal] + */ +expect interface Signal : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt similarity index 73% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt index 709be9dd9..0c3b0fb7e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt @@ -6,4 +6,4 @@ import com.pubnub.api.models.consumer.push.PNPushAddChannelResult /** * @see [PubNub.addPushNotificationsOnChannels] */ -interface AddChannelsToPush : Endpoint +expect interface AddChannelsToPush : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt similarity index 72% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt index 0a92ec63c..10c046b19 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt @@ -6,4 +6,4 @@ import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult /** * @see [PubNub.auditPushChannelProvisions] */ -interface ListPushProvisions : Endpoint +expect interface ListPushProvisions : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt similarity index 71% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt index d66bf4482..bd391522c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt @@ -6,4 +6,4 @@ import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult /** * @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken] */ -interface RemoveAllPushChannelsForDevice : Endpoint +expect interface RemoveAllPushChannelsForDevice : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt similarity index 72% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt index 8c8be617a..569d60054 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt @@ -6,4 +6,4 @@ import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult /** * @see [PubNub.removePushNotificationsFromChannels] */ -interface RemoveChannelsFromPush : Endpoint +expect interface RemoveChannelsFromPush : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResults.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResults.kt similarity index 50% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResults.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResults.kt index 41df4dba7..c985a7ff6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResults.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResults.kt @@ -1,7 +1,5 @@ package com.pubnub.api.models.consumer.access_manager -import com.pubnub.internal.PubNubCore - /** * Result of the [PubNubCore.grant] operation * @@ -18,27 +16,7 @@ class PNAccessManagerGrantResult( val subscribeKey: String, val channels: Map?>, val channelGroups: Map?>, -) { - companion object { - fun from(result: com.pubnub.internal.models.consumer.access_manager.PNAccessManagerGrantResult): PNAccessManagerGrantResult { - with(result) { - return PNAccessManagerGrantResult( - level, - ttl, - subscribeKey, - channels.toApi(), - channelGroups.toApi(), - ) - } - } - } -} - -private fun Map?>.toApi(): Map?> { - return mapValues { - it.value?.mapValues { PNAccessManagerKeyData.from(it.value) } - } -} +) open class PNAccessManagerKeyData { /** @@ -63,20 +41,6 @@ open class PNAccessManagerKeyData { var getEnabled: Boolean = false var updateEnabled: Boolean = false var joinEnabled: Boolean = false - - companion object { - fun from(value: com.pubnub.internal.models.consumer.access_manager.PNAccessManagerKeyData): PNAccessManagerKeyData { - return PNAccessManagerKeyData().apply { - this.readEnabled = value.readEnabled - this.manageEnabled = value.manageEnabled - this.writeEnabled = value.writeEnabled - this.deleteEnabled = value.deleteEnabled - this.getEnabled = value.getEnabled - this.updateEnabled = value.updateEnabled - this.joinEnabled = value.joinEnabled - } - } - } } class PNAccessManagerKeysData { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/sum/SpacePermissions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/sum/SpacePermissions.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/sum/SpacePermissions.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/sum/SpacePermissions.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/sum/UserPermissions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/sum/UserPermissions.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/sum/UserPermissions.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/sum/UserPermissions.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/ChannelGrant.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/ChannelGrant.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/ChannelGrant.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/ChannelGrant.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/ChannelGroupGrant.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/ChannelGroupGrant.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/ChannelGroupGrant.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/ChannelGroupGrant.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/Grants.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/Grants.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/Grants.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/Grants.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/UUIDGrant.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/UUIDGrant.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/access_manager/v3/UUIDGrant.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/UUIDGrant.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt new file mode 100644 index 000000000..5cea2920b --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt @@ -0,0 +1,3 @@ +package com.pubnub.api.models.consumer.objects + +data class PNRemoveMetadataResult(val status: Int) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/PNSortKey.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNSortKey.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/PNSortKey.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNSortKey.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInput.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInput.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInput.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInput.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt similarity index 53% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt index 7e4b46786..213e2a629 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt @@ -1,7 +1,6 @@ package com.pubnub.api.models.consumer.objects.member import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -import com.pubnub.internal.models.consumer.objects.member.PNMember data class PNMember( val uuid: PNUUIDMetadata?, @@ -17,16 +16,4 @@ data class PNMember( ) : MemberInput { override val uuid: String = uuidId } - - companion object { - fun from(data: PNMember): com.pubnub.api.models.consumer.objects.member.PNMember { - return com.pubnub.api.models.consumer.objects.member.PNMember( - data.uuid, - data.custom, - data.updated, - data.eTag, - data.status, - ) - } - } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMemberArrayResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMemberArrayResult.kt new file mode 100644 index 000000000..fcd77c2b8 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMemberArrayResult.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.models.consumer.objects.member + +import com.pubnub.api.models.consumer.objects.PNPage + +data class PNMemberArrayResult( + val status: Int, + val data: Collection, + val totalCount: Int?, + val next: PNPage.PNNext?, + val prev: PNPage.PNPrev?, +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/member/PNUUIDDetailsLevel.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNUUIDDetailsLevel.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/member/PNUUIDDetailsLevel.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNUUIDDetailsLevel.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/membership/ChannelMembershipInput.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/ChannelMembershipInput.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/membership/ChannelMembershipInput.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/ChannelMembershipInput.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelDetailsLevel.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelDetailsLevel.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelDetailsLevel.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelDetailsLevel.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt similarity index 59% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt index 54a81c4d9..f52a83922 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt @@ -9,18 +9,6 @@ data class PNChannelMembership( val eTag: String, val status: String?, ) { - companion object { - fun from(data: com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership): PNChannelMembership { - return PNChannelMembership( - data.channel, - data.custom, - data.updated, - data.eTag, - data.status, - ) - } - } - data class Partial( val channelId: String, override val custom: Any? = null, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipArrayResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipArrayResult.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipArrayResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipArrayResult.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt new file mode 100644 index 000000000..9a8475fff --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.models.consumer.objects.uuid + +import com.pubnub.api.models.consumer.objects.PNPage + +data class PNUUIDMetadataArrayResult( + val status: Int, + val data: Collection, + val totalCount: Int?, + val next: PNPage.PNNext?, + val prev: PNPage.PNPrev?, +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt new file mode 100644 index 000000000..0ab32b35c --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt @@ -0,0 +1,6 @@ +package com.pubnub.api.models.consumer.objects.uuid + +data class PNUUIDMetadataResult( + val status: Int, + val data: PNUUIDMetadata?, +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNWhereNowResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNWhereNowResult.kt similarity index 67% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNWhereNowResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNWhereNowResult.kt index 76d22ae70..aad23b68c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/presence/PNWhereNowResult.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNWhereNowResult.kt @@ -1,9 +1,7 @@ package com.pubnub.api.models.consumer.presence -import com.pubnub.internal.PubNubCore - /** - * Result of the [PubNubCore.whereNow] operation. + * Result of the [com.pubnub.api.PubNub.whereNow] operation. * * @property channels List of channels where a UUID is present. */ diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt new file mode 100644 index 000000000..1d36eaef3 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt @@ -0,0 +1,19 @@ +@file:Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") + +package com.pubnub.api.v2 + +import com.pubnub.api.UserId + +expect interface PNConfiguration { + val userId: UserId + val subscribeKey: String + val publishKey: String + val secretKey: String + val authKey: String + val cryptoModule: CryptoModule? + +} + +expect interface CryptoModule + +expect fun createPNConfiguration(userId: UserId, subscribeKey: String): PNConfiguration \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt new file mode 100644 index 000000000..514a82487 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt @@ -0,0 +1,7 @@ +package com.pubnub.api.v2.callbacks + +/** + * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time + * network. + */ +expect interface EventListener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt new file mode 100644 index 000000000..e8294d9d9 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.v2.callbacks + +import com.pubnub.api.PubNub +import com.pubnub.api.models.consumer.PNStatus + +/** + * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for + * PubNub connection status changes. + */ +expect interface StatusListener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt new file mode 100644 index 000000000..78d22393a --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt @@ -0,0 +1,10 @@ +package com.pubnub.kmp + +sealed interface Optional { + class Value(val value: T) : Optional + class Absent : Optional + fun onValue(action: (T)->Unit) : Optional = this.apply { (this as? Value)?.let { action(it.value)} } + fun onAbsent(action: ()->Unit) : Optional = this.apply { if (this is Absent) { action() }} +} + +fun T?.toOptional(): Optional = this?.let { Optional.Value(it) } ?: Optional.Absent() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt new file mode 100644 index 000000000..f7bef87b4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt @@ -0,0 +1,8 @@ +package com.pubnub.api + +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result + +actual interface Endpoint { + actual fun async(callback: Consumer>) +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt new file mode 100644 index 000000000..4696b7563 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt @@ -0,0 +1,444 @@ +package com.pubnub.api + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.endpoints.DeleteMessages +import com.pubnub.api.endpoints.FetchMessages +import com.pubnub.api.endpoints.MessageCounts +import com.pubnub.api.endpoints.Time +import com.pubnub.api.endpoints.access.GrantToken +import com.pubnub.api.endpoints.access.RevokeToken +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.GetFileUrl +import com.pubnub.api.endpoints.files.ListFiles +import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.message_actions.AddMessageAction +import com.pubnub.api.endpoints.message_actions.GetMessageActions +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +import com.pubnub.api.endpoints.objects.member.GetChannelMembers +import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +import com.pubnub.api.endpoints.objects.membership.GetMemberships +import com.pubnub.api.endpoints.objects.membership.ManageMemberships +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +import com.pubnub.api.endpoints.presence.GetState +import com.pubnub.api.endpoints.presence.HereNow +import com.pubnub.api.endpoints.presence.SetState +import com.pubnub.api.endpoints.presence.WhereNow +import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.endpoints.push.AddChannelsToPush +import com.pubnub.api.endpoints.push.ListPushProvisions +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions +import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNMemberKey +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.member.MemberInput +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener + +actual interface PubNub { + actual val configuration: PNConfiguration + actual fun addListener(listener: EventListener) + actual fun addListener(listener: StatusListener) + actual fun removeListener(listener: Listener) + actual fun removeAllListeners() + actual fun publish( + channel: String, + message: Any, + meta: Any?, + shouldStore: Boolean?, + usePost: Boolean, + replicate: Boolean, + ttl: Int? + ): Publish + + actual fun fire( + channel: String, + message: Any, + meta: Any?, + usePost: Boolean, + ttl: Int? + ): Publish + + actual fun signal(channel: String, message: Any): Signal + actual fun getSubscribedChannels(): List + actual fun getSubscribedChannelGroups(): List + actual fun addPushNotificationsOnChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): AddChannelsToPush + + actual fun auditPushChannelProvisions( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): ListPushProvisions + + actual fun removePushNotificationsFromChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): RemoveChannelsFromPush + + actual fun removeAllPushNotificationsFromDeviceWithPushToken( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): RemoveAllPushChannelsForDevice + + actual fun fetchMessages( + channels: List, + page: PNBoundedPage, + includeUUID: Boolean, + includeMeta: Boolean, + includeMessageActions: Boolean, + includeMessageType: Boolean + ): FetchMessages + + actual fun deleteMessages( + channels: List, + start: Long?, + end: Long? + ): DeleteMessages + + actual fun messageCounts( + channels: List, + channelsTimetoken: List + ): MessageCounts + + actual fun hereNow( + channels: List, + channelGroups: List, + includeState: Boolean, + includeUUIDs: Boolean + ): HereNow + + actual fun whereNow(uuid: String): WhereNow + actual fun setPresenceState( + channels: List, + channelGroups: List, + state: Any, + uuid: String + ): SetState + + actual fun getPresenceState( + channels: List, + channelGroups: List, + uuid: String + ): GetState + + actual fun presence( + channels: List, + channelGroups: List, + connected: Boolean + ) + + actual fun addMessageAction( + channel: String, + messageAction: PNMessageAction + ): AddMessageAction + + actual fun removeMessageAction( + channel: String, + messageTimetoken: Long, + actionTimetoken: Long + ): RemoveMessageAction + + actual fun getMessageActions( + channel: String, + page: PNBoundedPage + ): GetMessageActions + + actual fun addChannelsToChannelGroup( + channels: List, + channelGroup: String + ): AddChannelChannelGroup + + actual fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup + actual fun removeChannelsFromChannelGroup( + channels: List, + channelGroup: String + ): RemoveChannelChannelGroup + + actual fun listAllChannelGroups(): ListAllChannelGroup + actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup + actual fun grantToken( + ttl: Int, + meta: Any?, + authorizedUUID: String?, + channels: List, + channelGroups: List, + uuids: List + ): GrantToken + + actual fun grantToken( + ttl: Int, + meta: Any?, + authorizedUserId: UserId?, + spacesPermissions: List, + usersPermissions: List + ): GrantToken + + actual fun revokeToken(token: String): RevokeToken + actual fun time(): Time + actual fun getAllChannelMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllChannelMetadata + + actual fun getChannelMetadata( + channel: String, + includeCustom: Boolean + ): GetChannelMetadata + + actual fun setChannelMetadata( + channel: String, + name: String?, + description: String?, + custom: Any?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetChannelMetadata + + actual fun removeChannelMetadata(channel: String): RemoveChannelMetadata + actual fun getAllUUIDMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllUUIDMetadata + + actual fun getUUIDMetadata( + uuid: String?, + includeCustom: Boolean + ): GetUUIDMetadata + + actual fun setUUIDMetadata( + uuid: String?, + name: String?, + externalId: String?, + profileUrl: String?, + email: String?, + custom: CustomObject?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetUUIDMetadata + + actual fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata + actual fun getMemberships( + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): GetMemberships + + actual fun setMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships + + actual fun removeMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships + + actual fun manageMemberships( + channelsToSet: List, + channelsToRemove: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships + + actual fun getChannelMembers( + channel: String, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): GetChannelMembers + + actual fun setChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers + + actual fun removeChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers + + actual fun manageChannelMembers( + channel: String, + uuidsToSet: Collection, + uuidsToRemove: Collection, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers + + actual fun listFiles( + channel: String, + limit: Int?, + next: PNPage.PNNext? + ): ListFiles + + actual fun getFileUrl( + channel: String, + fileName: String, + fileId: String + ): GetFileUrl + + actual fun deleteFile( + channel: String, + fileName: String, + fileId: String + ): DeleteFile + + actual fun publishFileMessage( + channel: String, + fileName: String, + fileId: String, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean? + ): PublishFileMessage + + actual fun subscribe( + channels: List, + channelGroups: List, + withPresence: Boolean, + withTimetoken: Long + ) + + actual fun unsubscribe( + channels: List, + channelGroups: List + ) + + actual fun setToken(token: String?) + +} + +actual fun createStatusListener( + pubnub: PubNub, + onStatus: (PubNub, PNStatus) -> Unit +): StatusListener { + TODO("Not yet implemented") +} + +actual fun createEventListener( + pubnub: PubNub, + onMessage: (PubNub, PNMessageResult) -> Unit, + onPresence: (PubNub, PNPresenceEventResult) -> Unit, + onSignal: (PubNub, PNSignalResult) -> Unit, + onMessageAction: (PubNub, PNMessageActionResult) -> Unit, + onObjects: (PubNub, PNObjectEventResult) -> Unit, + onFile: (PubNub, PNFileEventResult) -> Unit +): EventListener { + TODO("Not yet implemented") +} + +actual class CustomObject + +actual fun createCustomObject(map: Map): CustomObject { + TODO("Not yet implemented") +} + +actual fun createPubNub(config: PNConfiguration): PubNub { + return PubNubImpl(config) +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt new file mode 100644 index 000000000..31d0cd3c2 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -0,0 +1,485 @@ +package com.pubnub.api + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.endpoints.DeleteMessages +import com.pubnub.api.endpoints.FetchMessages +import com.pubnub.api.endpoints.MessageCounts +import com.pubnub.api.endpoints.Time +import com.pubnub.api.endpoints.access.GrantToken +import com.pubnub.api.endpoints.access.RevokeToken +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.GetFileUrl +import com.pubnub.api.endpoints.files.ListFiles +import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.message_actions.AddMessageAction +import com.pubnub.api.endpoints.message_actions.GetMessageActions +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +import com.pubnub.api.endpoints.objects.member.GetChannelMembers +import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +import com.pubnub.api.endpoints.objects.membership.GetMemberships +import com.pubnub.api.endpoints.objects.membership.ManageMemberships +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +import com.pubnub.api.endpoints.presence.GetState +import com.pubnub.api.endpoints.presence.HereNow +import com.pubnub.api.endpoints.presence.SetState +import com.pubnub.api.endpoints.presence.WhereNow +import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.endpoints.push.AddChannelsToPush +import com.pubnub.api.endpoints.push.ListPushProvisions +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions +import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNMemberKey +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.member.MemberInput +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener + +class PubNubImpl(override val configuration: PNConfiguration) : PubNub { + +// val swiftPubNub = cocoapods.PubNubSwift. + + override fun addListener(listener: EventListener) { + TODO("Not yet implemented") + } + + override fun addListener(listener: StatusListener) { + TODO("Not yet implemented") + } + + override fun removeListener(listener: Listener) { + TODO("Not yet implemented") + } + + override fun removeAllListeners() { + TODO("Not yet implemented") + } + + override fun publish( + channel: String, + message: Any, + meta: Any?, + shouldStore: Boolean?, + usePost: Boolean, + replicate: Boolean, + ttl: Int? + ): Publish { + TODO("Not yet implemented") + } + + override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { + TODO("Not yet implemented") + } + + override fun signal(channel: String, message: Any): Signal { + TODO("Not yet implemented") + } + + override fun getSubscribedChannels(): List { + TODO("Not yet implemented") + } + + override fun getSubscribedChannelGroups(): List { + TODO("Not yet implemented") + } + + override fun addPushNotificationsOnChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): AddChannelsToPush { + TODO("Not yet implemented") + } + + override fun auditPushChannelProvisions( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): ListPushProvisions { + TODO("Not yet implemented") + } + + override fun removePushNotificationsFromChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): RemoveChannelsFromPush { + TODO("Not yet implemented") + } + + override fun removeAllPushNotificationsFromDeviceWithPushToken( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): RemoveAllPushChannelsForDevice { + TODO("Not yet implemented") + } + + override fun fetchMessages( + channels: List, + page: PNBoundedPage, + includeUUID: Boolean, + includeMeta: Boolean, + includeMessageActions: Boolean, + includeMessageType: Boolean + ): FetchMessages { + TODO("Not yet implemented") + } + + override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { + TODO("Not yet implemented") + } + + override fun messageCounts(channels: List, channelsTimetoken: List): MessageCounts { + TODO("Not yet implemented") + } + + override fun hereNow( + channels: List, + channelGroups: List, + includeState: Boolean, + includeUUIDs: Boolean + ): HereNow { + TODO("Not yet implemented") + } + + override fun whereNow(uuid: String): WhereNow { + TODO("Not yet implemented") + } + + override fun setPresenceState( + channels: List, + channelGroups: List, + state: Any, + uuid: String + ): SetState { + TODO("Not yet implemented") + } + + override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { + TODO("Not yet implemented") + } + + override fun presence(channels: List, channelGroups: List, connected: Boolean) { + TODO("Not yet implemented") + } + + override fun addMessageAction(channel: String, messageAction: PNMessageAction): AddMessageAction { + TODO("Not yet implemented") + } + + override fun removeMessageAction( + channel: String, + messageTimetoken: Long, + actionTimetoken: Long + ): RemoveMessageAction { + TODO("Not yet implemented") + } + + override fun getMessageActions(channel: String, page: PNBoundedPage): GetMessageActions { + TODO("Not yet implemented") + } + + override fun addChannelsToChannelGroup(channels: List, channelGroup: String): AddChannelChannelGroup { + TODO("Not yet implemented") + } + + override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { + TODO("Not yet implemented") + } + + override fun removeChannelsFromChannelGroup( + channels: List, + channelGroup: String + ): RemoveChannelChannelGroup { + TODO("Not yet implemented") + } + + override fun listAllChannelGroups(): ListAllChannelGroup { + TODO("Not yet implemented") + } + + override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { + TODO("Not yet implemented") + } + + override fun grantToken( + ttl: Int, + meta: Any?, + authorizedUUID: String?, + channels: List, + channelGroups: List, + uuids: List + ): GrantToken { + TODO("Not yet implemented") + } + + override fun grantToken( + ttl: Int, + meta: Any?, + authorizedUserId: UserId?, + spacesPermissions: List, + usersPermissions: List + ): GrantToken { + TODO("Not yet implemented") + } + + override fun revokeToken(token: String): RevokeToken { + TODO("Not yet implemented") + } + + override fun time(): Time { + TODO("Not yet implemented") + } + + override fun getAllChannelMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllChannelMetadata { + TODO("Not yet implemented") + } + + override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { + TODO("Not yet implemented") + } + + override fun setChannelMetadata( + channel: String, + name: String?, + description: String?, + custom: Any?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetChannelMetadata { + TODO("Not yet implemented") + } + + override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { + TODO("Not yet implemented") + } + + override fun getAllUUIDMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllUUIDMetadata { + TODO("Not yet implemented") + } + + override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { + TODO("Not yet implemented") + } + + override fun setUUIDMetadata( + uuid: String?, + name: String?, + externalId: String?, + profileUrl: String?, + email: String?, + custom: CustomObject?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetUUIDMetadata { + TODO("Not yet implemented") + } + + override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { + TODO("Not yet implemented") + } + + override fun getMemberships( + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): GetMemberships { + TODO("Not yet implemented") + } + + override fun setMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships { + TODO("Not yet implemented") + } + + override fun removeMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships { + TODO("Not yet implemented") + } + + override fun manageMemberships( + channelsToSet: List, + channelsToRemove: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships { + TODO("Not yet implemented") + } + + override fun getChannelMembers( + channel: String, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): GetChannelMembers { + TODO("Not yet implemented") + } + + override fun setChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers { + TODO("Not yet implemented") + } + + override fun removeChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers { + TODO("Not yet implemented") + } + + override fun manageChannelMembers( + channel: String, + uuidsToSet: Collection, + uuidsToRemove: Collection, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers { + TODO("Not yet implemented") + } + + override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { + TODO("Not yet implemented") + } + + override fun getFileUrl(channel: String, fileName: String, fileId: String): GetFileUrl { + TODO("Not yet implemented") + } + + override fun deleteFile(channel: String, fileName: String, fileId: String): DeleteFile { + TODO("Not yet implemented") + } + + override fun publishFileMessage( + channel: String, + fileName: String, + fileId: String, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean? + ): PublishFileMessage { + TODO("Not yet implemented") + } + + override fun subscribe( + channels: List, + channelGroups: List, + withPresence: Boolean, + withTimetoken: Long + ) { + TODO("Not yet implemented") + } + + override fun unsubscribe(channels: List, channelGroups: List) { + TODO("Not yet implemented") + } + + override fun setToken(token: String?) { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt new file mode 100644 index 000000000..780e50eaf --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult + +/** + * @see [com.pubnub.api.PubNub.deleteMessages] + */ +actual interface DeleteMessages : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt new file mode 100644 index 000000000..5b9e811c1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.history.PNFetchMessagesResult + +/** + * @see [PubNub.fetchMessages] + */ +actual interface FetchMessages : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt new file mode 100644 index 000000000..c6e9ea3a5 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.history.PNMessageCountResult + +/** + * @see [PubNub.messageCounts] + */ +actual interface MessageCounts : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt new file mode 100644 index 000000000..89eb3e7e4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.PNTimeResult + +/** + * @see [PubNub.time] + */ +actual interface Time : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt new file mode 100644 index 000000000..0f81aa098 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt @@ -0,0 +1,7 @@ +package com.pubnub.api.endpoints.access + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult + +actual interface GrantToken : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt new file mode 100644 index 000000000..68574fb0e --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt @@ -0,0 +1,5 @@ +package com.pubnub.api.endpoints.access + +import com.pubnub.api.Endpoint + +actual interface RevokeToken : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt new file mode 100644 index 000000000..605ea25d5 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.channel_groups + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult + +/** + * @see [PubNub.addChannelsToChannelGroup] + */ +actual interface AddChannelChannelGroup : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt new file mode 100644 index 000000000..e92a2e4cb --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.channel_groups + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult + +/** + * @see [PubNub.listChannelsForChannelGroup] + */ +actual interface AllChannelsChannelGroup : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt new file mode 100644 index 000000000..a480015a4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.channel_groups + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult + +/** + * @see [PubNub.deleteChannelGroup] + */ +actual interface DeleteChannelGroup : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt new file mode 100644 index 000000000..64cc91e1e --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.channel_groups + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult + +/** + * @see [PubNub.listAllChannelGroups] + */ +actual interface ListAllChannelGroup : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt new file mode 100644 index 000000000..300aee3a9 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.channel_groups + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult + +/** + * @see [PubNub.removeChannelsFromChannelGroup] + */ +actual interface RemoveChannelChannelGroup : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt new file mode 100644 index 000000000..df58b5133 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNDeleteFileResult + +/** + * @see [PubNub.deleteFile] + */ +actual interface DeleteFile : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt new file mode 100644 index 000000000..b15d6b85d --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNFileUrlResult + +/** + * @see [PubNub.getFileUrl] + */ +actual interface GetFileUrl : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt new file mode 100644 index 000000000..d6afdd889 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNListFilesResult + +/** + * @see [PubNub.listFiles] + */ +actual interface ListFiles : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt new file mode 100644 index 000000000..eeed730c4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult + +/** + * @see [PubNub.publishFileMessage] + */ +actual interface PublishFileMessage : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt new file mode 100644 index 000000000..ec6a14aa2 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.message_actions + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult + +/** + * @see [PubNub.addMessageAction] + */ +actual interface AddMessageAction : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt new file mode 100644 index 000000000..100ae5fe4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.message_actions + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult + +/** + * @see [PubNub.getMessageActions] + */ +actual interface GetMessageActions : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt new file mode 100644 index 000000000..71dfe0644 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.message_actions + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult + +/** + * @see [PubNub.removeMessageAction] + */ +actual interface RemoveMessageAction : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt new file mode 100644 index 000000000..51a8b8d90 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult + +/** + * @see [PubNub.getAllChannelMetadata] + */ +actual interface GetAllChannelMetadata : + Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt new file mode 100644 index 000000000..26a269e4a --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult + +/** + * @see [PubNub.getChannelMetadata] + */ +actual interface GetChannelMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt new file mode 100644 index 000000000..f6acb81da --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt @@ -0,0 +1,6 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult + +actual interface RemoveChannelMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt new file mode 100644 index 000000000..1ab95a261 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult + +/** + * @see [PubNub.setChannelMetadata] + */ +actual interface SetChannelMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt new file mode 100644 index 000000000..cf41affdd --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.member + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult + +/** + * @see [PubNub.getChannelMembers] + */ +actual interface GetChannelMembers : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt new file mode 100644 index 000000000..6f27c02af --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.member + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult + +/** + * @see [PubNub.manageChannelMembers] + */ +actual interface ManageChannelMembers : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt new file mode 100644 index 000000000..8cec56fd6 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.membership + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult + +/** + * @see [PubNub.getMemberships] + */ +actual interface GetMemberships : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt new file mode 100644 index 000000000..a7af4557b --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.membership + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult + +/** + * @see [PubNub.manageMemberships] + */ +actual interface ManageMemberships : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt new file mode 100644 index 000000000..67faf7dd0 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.uuid + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult + +/** + * @see [PubNub.getAllUUIDMetadata] + */ +actual interface GetAllUUIDMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt new file mode 100644 index 000000000..dd2440021 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.objects.uuid + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult + +/** + * @see [PubNub.getUUIDMetadata] + */ +actual interface GetUUIDMetadata : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt new file mode 100644 index 000000000..e6f986fd1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt @@ -0,0 +1,7 @@ +package com.pubnub.api.endpoints.objects.uuid + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult + +actual interface RemoveUUIDMetadata : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt new file mode 100644 index 000000000..ed963f67b --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.uuid + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult + +/** + * @see [PubNub.setUUIDMetadata] + */ +actual interface SetUUIDMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt new file mode 100644 index 000000000..db440e6c6 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.presence + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNGetStateResult + +/** + * @see [PubNub.getPresenceState] + */ +actual interface GetState : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt new file mode 100644 index 000000000..ad2a76aae --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.presence + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNHereNowResult + +/** + * @see [PubNub.hereNow] + */ +actual interface HereNow : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt new file mode 100644 index 000000000..9325e0785 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.presence + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNSetStateResult + +/** + * @see [PubNub.setPresenceState] + */ +actual interface SetState : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt new file mode 100644 index 000000000..f20e29771 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.presence + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNWhereNowResult + +/** + * @see [PubNub.whereNow] + */ +actual interface WhereNow : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt new file mode 100644 index 000000000..0f9eb3ff3 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.pubsub + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.PNPublishResult + +/** + * @see [PubNub.publish] + */ +actual interface Publish : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt new file mode 100644 index 000000000..64235d7de --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.pubsub + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.PNPublishResult + +/** + * @see [PubNub.signal] + */ +actual interface Signal : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt new file mode 100644 index 000000000..12aef0b7d --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushAddChannelResult + +/** + * @see [PubNub.addPushNotificationsOnChannels] + */ +actual interface AddChannelsToPush : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt new file mode 100644 index 000000000..63496da48 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult + +/** + * @see [PubNub.auditPushChannelProvisions] + */ +actual interface ListPushProvisions : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt new file mode 100644 index 000000000..f88e4e04f --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult + +/** + * @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken] + */ +actual interface RemoveAllPushChannelsForDevice : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt new file mode 100644 index 000000000..e17227963 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult + +/** + * @see [PubNub.removePushNotificationsFromChannels] + */ +actual interface RemoveChannelsFromPush : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt new file mode 100644 index 000000000..482daa36a --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt @@ -0,0 +1,33 @@ +package com.pubnub.api.v2 + +import com.pubnub.api.UserId + +actual interface PNConfiguration { + actual val userId: UserId + actual val subscribeKey: String + actual val publishKey: String + actual val secretKey: String + actual val authKey: String + actual val cryptoModule: CryptoModule? + +} + +actual interface CryptoModule + +actual fun createPNConfiguration( + userId: UserId, + subscribeKey: String +): PNConfiguration { + return object : PNConfiguration { + override val userId: UserId = userId + override val subscribeKey: String = subscribeKey + override val publishKey: String + get() = TODO("Not yet implemented") + override val secretKey: String + get() = TODO("Not yet implemented") + override val authKey: String + get() = TODO("Not yet implemented") + override val cryptoModule: CryptoModule? + get() = TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt new file mode 100644 index 000000000..86277e0fd --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -0,0 +1,7 @@ +package com.pubnub.api.v2.callbacks + +/** + * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time + * network. + */ +actual interface EventListener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt new file mode 100644 index 000000000..7415353a5 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt @@ -0,0 +1,7 @@ +package com.pubnub.api.v2.callbacks + +/** + * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for + * PubNub connection status changes. + */ +actual interface StatusListener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt new file mode 100644 index 000000000..aab770dda --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt @@ -0,0 +1,1662 @@ +@file:Suppress( + "INTERFACE_WITH_SUPERCLASS", + "OVERRIDING_FINAL_MEMBER", + "RETURN_TYPE_MISMATCH_ON_OVERRIDE", + "CONFLICTING_OVERLOADS" +) + +import PubNub.ChannelMembershipObject +import PubNub.ChannelMetadataObject +import PubNub.GetAllMetadataParameters +import PubNub.GetChannelMembersParameters +import PubNub.GetChannelMetadataParameters +import PubNub.GetMembershipsParametersv2 +import PubNub.GetUUIDMetadataParameters +import PubNub.MessageAction +import PubNub.MessageEvent +import PubNub.PubnubStatus +import PubNub.RemoveChannelMembersParameters +import PubNub.RemoveChannelMetadataParameters +import PubNub.RemoveMembershipsParameters +import PubNub.RemoveUUIDMetadataParameters +import PubNub.SetChannelMembersParameters +import PubNub.SetChannelMetadataParameters +import PubNub.SetMembershipsParameters +import PubNub.SetUUIDMetadataParameters +import PubNub.UUIDMembershipObject +import PubNub.UUIDMetadataObject +import com.pubnub.api.JsonElement +import com.pubnub.kmp.Optional +import org.khronos.webgl.ArrayBuffer +import org.w3c.files.Blob +import org.w3c.files.File +import kotlin.js.Date +import kotlin.js.Json +import kotlin.js.Promise + +typealias PubnubData = MessageEvent + +typealias SetUUIDMetadataResponse = ObjectsResponse + +typealias RemoveUUIDMetadataResponse = ObjectsResponse + +typealias GetAllUUIDMetadataResponse = PagedObjectsResponse + +typealias GetUUIDMetadataResponse = ObjectsResponse + +typealias SetChannelMetadataResponse = ObjectsResponse + +typealias RemoveChannelMetadataResponse = ObjectsResponse + +typealias GetAllChannelMetadataResponse = PagedObjectsResponse + +typealias GetChannelMetadataResponse = ObjectsResponse + +typealias ManageChannelMembersResponse = PagedObjectsResponse + +typealias ManageMembershipsResponse = PagedObjectsResponse + +typealias Callback = (status: PubnubStatus, response: ResponseType) -> Unit + +typealias StatusCallback = (status: PubnubStatus) -> Unit + +external interface ObjectsResponse { + var status: Number + var data: DataType +} + +external interface PagedObjectsResponse : ObjectsResponse> { + var prev: String? + get() = definedExternally + set(value) = definedExternally + var next: String? + get() = definedExternally + set(value) = definedExternally + var totalCount: Number? + get() = definedExternally + set(value) = definedExternally +} + +external interface ObjectsFunctions { + fun setUUIDMetadata(params: SetUUIDMetadataParameters, callback: Callback) + fun setUUIDMetadata(params: SetUUIDMetadataParameters): Promise + fun removeUUIDMetadata(callback: Callback) + fun removeUUIDMetadata(params: RemoveUUIDMetadataParameters = definedExternally): Promise + fun removeUUIDMetadata(): Promise + fun removeUUIDMetadata(params: RemoveUUIDMetadataParameters, callback: Callback) + fun getAllUUIDMetadata(callback: Callback) + fun getAllUUIDMetadata(params: GetAllMetadataParameters = definedExternally): Promise + fun getAllUUIDMetadata(): Promise + fun getAllUUIDMetadata(params: GetAllMetadataParameters, callback: Callback) + fun getUUIDMetadata(callback: Callback) + fun getUUIDMetadata(params: GetUUIDMetadataParameters = definedExternally): Promise + fun getUUIDMetadata(): Promise + fun getUUIDMetadata(params: GetUUIDMetadataParameters, callback: Callback) + fun setChannelMetadata(params: SetChannelMetadataParameters, callback: Callback) + fun setChannelMetadata(params: SetChannelMetadataParameters): Promise + fun removeChannelMetadata( + params: RemoveChannelMetadataParameters, + callback: Callback + ) + + fun removeChannelMetadata(params: RemoveChannelMetadataParameters): Promise + fun getAllChannelMetadata(callback: Callback) + fun getAllChannelMetadata(params: GetAllMetadataParameters = definedExternally): Promise + fun getAllChannelMetadata(): Promise + fun getAllChannelMetadata(params: GetAllMetadataParameters, callback: Callback) + fun getChannelMetadata(params: GetChannelMetadataParameters, callback: Callback) + fun getChannelMetadata(params: GetChannelMetadataParameters): Promise + fun getMemberships(callback: Callback) + fun getMemberships(params: GetMembershipsParametersv2 = definedExternally): Promise + fun getMemberships(): Promise + fun getMemberships(params: GetMembershipsParametersv2, callback: Callback) + fun setMemberships(params: SetMembershipsParameters, callback: Callback) + fun setMemberships(params: SetMembershipsParameters): Promise + fun removeMemberships(params: RemoveMembershipsParameters, callback: Callback) + fun removeMemberships(params: RemoveMembershipsParameters): Promise + fun getChannelMembers(params: GetChannelMembersParameters, callback: Callback) + fun getChannelMembers(params: GetChannelMembersParameters): Promise + fun setChannelMembers(params: SetChannelMembersParameters, callback: Callback) + fun setChannelMembers(params: SetChannelMembersParameters): Promise + fun removeChannelMembers(params: RemoveChannelMembersParameters, callback: Callback) + fun removeChannelMembers(params: RemoveChannelMembersParameters): Promise +} + +external interface AddMessageActionResult { + var data: MessageAction +} + +external interface RemoveMessageActionResult { + var data: Any +} + +open external class PubNub(config: Any /* UUID | UserId */) { + open var channelGroups: ChannelGroups + open var push: Push + open fun setUUID(uuid: String) + open fun getUUID(): String + open fun setAuthKey(authKey: String) + open fun setFilterExpression(filterExpression: String) + open fun getFilterExpression(): String + open fun publish(params: PublishParameters, callback: Callback) + open fun publish(params: PublishParameters): Promise + open fun fire(params: FireParameters, callback: Callback) + open fun fire(params: FireParameters): Promise + open fun signal(params: SignalParameters, callback: Callback) + open fun signal(params: SignalParameters): Promise + open fun history(params: HistoryParameters, callback: Callback) + open fun history(params: HistoryParameters): Promise + open fun fetchMessages(params: FetchMessagesParameters, callback: Callback) + open fun fetchMessages(params: FetchMessagesParameters): Promise + open fun deleteMessages(params: DeleteMessagesParameters, callback: StatusCallback) + open fun deleteMessages(params: DeleteMessagesParameters): Promise + open fun messageCounts(params: MessageCountsParameters, callback: Callback) + open fun messageCounts(params: MessageCountsParameters): Promise + open fun subscribe(params: SubscribeParameters) + open fun unsubscribe(params: UnsubscribeParameters) + open fun unsubscribeAll() + open fun stop() + open fun reconnect() + open fun addListener(params: ListenerParameters) + open fun addListener(params: StatusListenerParameters) + open fun removeListener(params: ListenerParameters) + open fun getSubscribedChannels(): Array + open fun getSubscribedChannelGroups(): Array + open fun hereNow(params: HereNowParameters, callback: Callback) + open fun hereNow(params: HereNowParameters): Promise + open fun whereNow(params: WhereNowParameters, callback: Callback) + open fun whereNow(params: WhereNowParameters): Promise + open fun getState(params: GetStateParameters, callback: Callback) + open fun getState(params: GetStateParameters): Promise + open fun setState(params: SetStateParameters, callback: Callback) + open fun setState(params: SetStateParameters): Promise + open fun grant(params: GrantParameters, callback: StatusCallback) + open fun grant(params: GrantParameters): Promise + open fun grantToken(params: GrantTokenParameters, callback: Callback) + open fun grantToken(params: GrantTokenParameters): Promise + open fun setToken(params: String?) + open fun getToken(): String? + open fun parseToken(params: String): ParsedGrantToken + open fun revokeToken(params: String, callback: Callback) + open fun revokeToken(params: String): Promise + open fun listFiles(params: ListFilesParameters, callback: Callback) + open fun listFiles(params: ListFilesParameters): Promise + open fun sendFile(params: SendFileParameters, callback: Callback) + open fun sendFile(params: SendFileParameters): Promise + open fun downloadFile(params: DownloadFileParameters, callback: Callback) + open fun downloadFile(params: DownloadFileParameters): Promise + open fun getFileUrl(params: FileInputParameters): String + open fun deleteFile(params: FileInputParameters, callback: StatusCallback) + open fun deleteFile(params: FileInputParameters): Promise + open fun publishFile(params: PublishFileParameters, callback: Callback) + open fun publishFile(params: PublishFileParameters): Promise + open var objects: ObjectsFunctions + open fun addMessageAction(params: AddMessageActionParameters, callback: Callback) + open fun addMessageAction(params: AddMessageActionParameters): Promise + open fun removeMessageAction(params: RemoveMessageActionParameters, callback: Callback) + open fun removeMessageAction(params: RemoveMessageActionParameters): Promise + open fun getMessageActions(params: GetMessageActionsParameters, callback: Callback) + open fun getMessageActions(params: GetMessageActionsParameters): Promise + open fun encrypt( + data: String, + customCipherKey: String = definedExternally, + options: CryptoParameters = definedExternally + ): String + + open fun decrypt( + data: String?, + customCipherKey: String = definedExternally, + options: CryptoParameters = definedExternally + ): Any + + open fun decrypt(data: String?): Any + open fun decrypt(data: String?, customCipherKey: String = definedExternally): Any + open fun decrypt( + data: Any?, + customCipherKey: String = definedExternally, + options: CryptoParameters = definedExternally + ): Any + + open fun decrypt(data: Any?): Any + open fun decrypt(data: Any?, customCipherKey: String = definedExternally): Any + open fun time(): Promise + open fun time(callback: Callback) + interface KeepAliveSettings { + var keepAliveMsecs: Number? + get() = definedExternally + set(value) = definedExternally + var freeSocketKeepAliveTimeout: Number? + get() = definedExternally + set(value) = definedExternally + var timeout: Number? + get() = definedExternally + set(value) = definedExternally + var maxSockets: Number? + get() = definedExternally + set(value) = definedExternally + var maxFreeSockets: Number? + get() = definedExternally + set(value) = definedExternally + } + + interface PNConfiguration : Partial { + var userId: String + var subscribeKey: String + var publishKey: String? + var cipherKey: String? + var authKey: String? + var logVerbosity: Boolean? + var ssl: Boolean? + var origin: dynamic /* String? | Array? */ + var presenceTimeout: Number? + var heartbeatInterval: Number? + var restore: Boolean? + var keepAlive: Boolean? + var keepAliveSettings: KeepAliveSettings? + var subscribeRequestTimeout: Number? + var suppressLeaveEvents: Boolean? + var secretKey: String? + var requestMessageCountThreshold: Number? + var autoNetworkDetection: Boolean? + var listenToBrowserNetworkEvents: Boolean? + var useRandomIVs: Boolean? + var dedupeOnSubscribe: Boolean? + var cryptoModule: CryptoModule? + var retryConfiguration: dynamic /* LinearRetryPolicyConfiguration? | ExponentialRetryPolicyConfiguration? */ + var enableEventEngine: Boolean? + var maintainPresenceState: Boolean? + } + + interface MessageEvent { + var channel: String + var subscription: String + var timetoken: String + var message: Any + var publisher: String + var error: String? + get() = definedExternally + set(value) = definedExternally + var actualChannel: String + var subscribedChannel: String + var userMetadata: Any? + get() = definedExternally + set(value) = definedExternally + } + + interface StatusEvent { + var category: String + var operation: String + var affectedChannels: Array + var subscribedChannels: Array + var affectedChannelGroups: Array + var lastTimetoken: dynamic /* Number | String */ + get() = definedExternally + set(value) = definedExternally + var currentTimetoken: dynamic /* Number | String */ + get() = definedExternally + set(value) = definedExternally + var statusCode: Number? + } + + interface PresenceEvent { + var action: String /* "join" | "leave" | "state-change" | "timeout" */ + var channel: String + var occupancy: Number + var state: Any? + get() = definedExternally + set(value) = definedExternally + var subscription: String + var timestamp: Number + var timetoken: String + var uuid: String + var actualChannel: String + var subscribedChannel: String + } + + interface SignalEvent { + var channel: String + var subscription: String + var timetoken: String + var message: Any + var publisher: String + } + + interface MessageActionEvent { + var channel: String + var publisher: String + var subscription: String? + get() = definedExternally + set(value) = definedExternally + var timetoken: String + var event: String + var data: MessageAction + } + + interface `T$5` { + var id: String + var name: String + var url: String + } + + interface FileEvent { + var channel: String + var subscription: String + var publisher: String + var timetoken: String + var message: Any + var file: `T$5` + var userMetadata: Any? + get() = definedExternally + set(value) = definedExternally + } + + interface `T$6` { + var event: String /* "set" | "delete" */ + var type: String /* "uuid" | "channel" | "membership" */ + var data: Any? + } + + interface BaseObjectsEvent { + var channel: String + var message: `T$6` + var subscription: String? + var publisher: String? + get() = definedExternally + set(value) = definedExternally + var timetoken: Number + } + + interface `T$7` { + var event: String /* "set" */ + var type: String /* "uuid" */ + var data: UUIDMetadataObject + } + + interface SetUUIDMetadataEvent : BaseObjectsEvent + interface HasId { + var id: String + } + + interface `T$9` { + var event: String /* "delete" */ + var type: String /* "uuid" */ + var data: HasId + } + + interface RemoveUUIDMetadataEvent : BaseObjectsEvent + interface `T$10` { + var event: String /* "set" */ + var type: String /* "channel" */ + var data: ChannelMetadataObject + } + + interface SetChannelMetadataEvent : BaseObjectsEvent + interface `T$11` { + var event: String /* "delete" */ + var type: String /* "channel" */ + var data: HasId + } + + interface RemoveChannelMetadataEvent : BaseObjectsEvent + interface `T$12` { + var channel: HasId + var uuid: HasId + var custom: CustomObject? + var updated: String + var eTag: String + } + + interface `T$13` { + var event: String /* "set" */ + var type: String /* "membership" */ + var data: `T$12` + } + + interface SetMembershipEvent : BaseObjectsEvent + interface `T$14` { + var channel: HasId + var uuid: HasId + } + + interface `T$15` { + var event: String /* "delete" */ + var type: String /* "membership" */ + var data: `T$14` + } + + interface RemoveMembershipEvent : BaseObjectsEvent + interface PublishParameters { + var message: Any + var channel: String + var storeInHistory: Boolean? + get() = definedExternally + set(value) = definedExternally + var sendByPost: Boolean? + get() = definedExternally + set(value) = definedExternally + var meta: Any? + get() = definedExternally + set(value) = definedExternally + var ttl: Number? + get() = definedExternally + set(value) = definedExternally + } + + interface PublishResponse { + var timetoken: Number + } + + interface SignalParameters { + var message: Any + var channel: String + } + + interface SignalResponse { + var timetoken: Number + } + + interface HistoryParameters { + var channel: String + var count: Number + var stringifiedTimeToken: Boolean? + get() = definedExternally + set(value) = definedExternally + var includeTimetoken: Boolean? + get() = definedExternally + set(value) = definedExternally + var reverse: Boolean? + get() = definedExternally + set(value) = definedExternally + var start: dynamic /* String? | Number? */ + get() = definedExternally + set(value) = definedExternally + var end: dynamic /* String? | Number? */ + get() = definedExternally + set(value) = definedExternally + var includeMeta: Boolean? + get() = definedExternally + set(value) = definedExternally + } + + interface HistoryMessage { + var entry: Any + var timetoken: dynamic /* String? | Number? */ + get() = definedExternally + set(value) = definedExternally + var meta: Any? + get() = definedExternally + set(value) = definedExternally + } + + interface HistoryResponse { + var endTimeToken: dynamic /* String? | Number? */ + get() = definedExternally + set(value) = definedExternally + var startTimeToken: dynamic /* String? | Number? */ + get() = definedExternally + set(value) = definedExternally + var messages: Array + } + + interface FetchMessagesParameters { + var channels: Array + var count: Number? + var stringifiedTimeToken: Boolean? + var start: dynamic /* String? | Number? */ + var end: dynamic /* String? | Number? */ + var withMessageActions: Boolean? + var includeMessageType: Boolean? + var includeUUID: Boolean? + var includeMeta: Boolean? + var includeMessageActions: Boolean? + } + + interface Action { + var uuid: String + var actionTimetoken: dynamic /* String | Number */ + get() = definedExternally + set(value) = definedExternally + } + + interface ActionContentToAction : JsMap> + interface ActionTypeToActions : JsMap + + interface FetchMessageItem { + var channel: String + var message: JsonElement + var timetoken: dynamic /* String | Number */ + var messageType: dynamic /* String? | Number? */ + var uuid: String + var error: String? + var meta: Json? + var actions: ActionTypeToActions? + } + + interface ChannelsToFetchMessageItemsMap : JsMap> + + interface Page { + var url: String + var start: String + var max: Number + } + + interface FetchMessagesResponse { + var channels: ChannelsToFetchMessageItemsMap + var more: Page? + get() = definedExternally + set(value) = definedExternally + } + + interface DeleteMessagesParameters { + var channel: String + var start: dynamic /* String? | Number? */ + get() = definedExternally + set(value) = definedExternally + var end: dynamic /* String? | Number? */ + get() = definedExternally + set(value) = definedExternally + } + + interface MessageCountsParameters { + var channels: Array + var channelTimetokens: dynamic /* Array | Array */ + get() = definedExternally + set(value) = definedExternally + } + + interface `T$22` { + @nativeGetter + operator fun get(channel: String): Number? + + @nativeSetter + operator fun set(channel: String, value: Number) + } + + interface MessageCountsResponse { + var channels: `T$22` + } + + interface Push { + fun addChannels(params: PushChannelParameters, callback: StatusCallback) + fun addChannels(params: PushChannelParameters): Promise + fun listChannels(params: PushDeviceParameters, callback: Callback) + fun listChannels(params: PushDeviceParameters): Promise + fun removeChannels(params: PushChannelParameters, callback: StatusCallback) + fun removeChannels(params: PushChannelParameters): Promise + fun deleteDevice(params: PushDeviceParameters, callback: StatusCallback) + fun deleteDevice(params: PushDeviceParameters): Promise + } + + interface PushChannelParameters { + var channels: Array + var device: String + var pushGateway: String + var environment: String? + get() = definedExternally + set(value) = definedExternally + var topic: String? + get() = definedExternally + set(value) = definedExternally + } + + interface PushDeviceParameters { + var device: String + var pushGateway: String + var environment: String? + get() = definedExternally + set(value) = definedExternally + var topic: String? + get() = definedExternally + set(value) = definedExternally + } + + interface PushListChannelsResponse { + var channels: Array + } + + interface PubnubStatus { + var error: Boolean + var category: String? + get() = definedExternally + set(value) = definedExternally + var operation: String + var statusCode: Number + var errorData: Error? + get() = definedExternally + set(value) = definedExternally + } + + interface FireParameters { + var message: Any + var channel: String + var sendByPost: Boolean? + get() = definedExternally + set(value) = definedExternally + var meta: Any? + get() = definedExternally + set(value) = definedExternally + } + + interface SubscribeParameters { + var channels: Array? + get() = definedExternally + set(value) = definedExternally + var channelGroups: Array? + get() = definedExternally + set(value) = definedExternally + var withPresence: Boolean? + get() = definedExternally + set(value) = definedExternally + var timetoken: Number? + get() = definedExternally + set(value) = definedExternally + } + + interface UnsubscribeParameters { + var channels: Array? + get() = definedExternally + set(value) = definedExternally + var channelGroups: Array? + get() = definedExternally + set(value) = definedExternally + } + + interface ChannelGroups { + fun addChannels(params: AddChannelParameters, callback: StatusCallback) + fun addChannels(params: AddChannelParameters): Promise + fun removeChannels(params: RemoveChannelParameters, callback: StatusCallback) + fun removeChannels(params: RemoveChannelParameters): Promise + fun listChannels(params: ListChannelsParameters, callback: Callback) + fun listChannels(params: ListChannelsParameters): Promise + fun listGroups(callback: Callback) + fun listGroups(): Promise + fun deleteGroup(params: DeleteGroupParameters, callback: StatusCallback) + fun deleteGroup(params: DeleteGroupParameters): Promise + } + + interface AddChannelParameters { + var channels: Array + var channelGroup: String + } + + interface RemoveChannelParameters { + var channels: Array + var channelGroup: String + } + + interface ListChannelsParameters { + var channelGroup: String + } + + interface DeleteGroupParameters { + var channelGroup: String + } + + interface ListAllGroupsResponse { + var groups: Array + } + + interface ListChannelsResponse { + var channels: Array + } + + interface ObjectsListener { + @nativeInvoke + operator fun invoke(objectsEvent: SetUUIDMetadataEvent) + + @nativeInvoke + operator fun invoke(objectsEvent: RemoveUUIDMetadataEvent) + + @nativeInvoke + operator fun invoke(objectsEvent: SetChannelMetadataEvent) + + @nativeInvoke + operator fun invoke(objectsEvent: RemoveChannelMetadataEvent) + + @nativeInvoke + operator fun invoke(objectsEvent: SetMembershipEvent) + + @nativeInvoke + operator fun invoke(objectsEvent: RemoveMembershipEvent) + } + + interface ListenerParameters { + val message: ((messageEvent: MessageEvent) -> Unit)? + val presence: ((presenceEvent: PresenceEvent) -> Unit)? + val signal: ((signalEvent: SignalEvent) -> Unit)? + val messageAction: ((messageActionEvent: MessageActionEvent) -> Unit)? + val file: ((fileEvent: FileEvent) -> Unit)? + val objects: ObjectsListener? + get() = definedExternally + } + + interface StatusListenerParameters { + val status: ((statusEvent: StatusEvent) -> Unit)? + } + + interface HereNowParameters { + var channels: Array? + get() = definedExternally + set(value) = definedExternally + var channelGroups: Array? + get() = definedExternally + set(value) = definedExternally + var includeUUIDs: Boolean? + get() = definedExternally + set(value) = definedExternally + var includeState: Boolean? + get() = definedExternally + set(value) = definedExternally + } + + interface HereNowOccupantData { + var uuid: String + var state: Any? + get() = definedExternally + set(value) = definedExternally + } + + interface HereNowChannelData { + var name: String + var occupancy: Number + var occupants: Array + } + + interface ChannelsToHereNowChannelData : JsMap + + interface HereNowResponse { + var totalChannels: Number + var totalOccupancy: Number + var channels: ChannelsToHereNowChannelData + } + + interface WhereNowParameters { + var uuid: String? + get() = definedExternally + set(value) = definedExternally + } + + interface WhereNowResponse { + var channels: Array + } + + interface SetStateParameters { + var channels: Array? + get() = definedExternally + set(value) = definedExternally + var channelGroups: Array? + get() = definedExternally + set(value) = definedExternally + var state: Any? + get() = definedExternally + set(value) = definedExternally + } + + interface SetStateResponse { + var state: Any + } + + interface GetStateParameters { + var uuid: String? + get() = definedExternally + set(value) = definedExternally + var channels: Array? + get() = definedExternally + set(value) = definedExternally + var channelGroups: Array? + get() = definedExternally + set(value) = definedExternally + } + + interface GetStateResponse { + var channels: Json + } + + interface GrantParameters { + var channels: Array? + get() = definedExternally + set(value) = definedExternally + var channelGroups: Array? + get() = definedExternally + set(value) = definedExternally + var uuids: Array? + get() = definedExternally + set(value) = definedExternally + var authKeys: Array? + get() = definedExternally + set(value) = definedExternally + var ttl: Number? + get() = definedExternally + set(value) = definedExternally + var read: Boolean? + get() = definedExternally + set(value) = definedExternally + var write: Boolean? + get() = definedExternally + set(value) = definedExternally + var manage: Boolean? + get() = definedExternally + set(value) = definedExternally + var delete: Boolean? + get() = definedExternally + set(value) = definedExternally + var get: Boolean? + get() = definedExternally + set(value) = definedExternally + var join: Boolean? + get() = definedExternally + set(value) = definedExternally + var update: Boolean? + get() = definedExternally + set(value) = definedExternally + } + + interface `T$26` { + @nativeGetter + operator fun get(key: String): GrantTokenPermissions? + + @nativeSetter + operator fun set(key: String, value: GrantTokenPermissions) + } + + interface `T$27` { + var channels: `T$26`? + get() = definedExternally + set(value) = definedExternally + var groups: `T$26`? + get() = definedExternally + set(value) = definedExternally + var uuids: `T$26`? + get() = definedExternally + set(value) = definedExternally + } + + interface GrantTokenParameters { + var ttl: Number + var authorized_uuid: String? + get() = definedExternally + set(value) = definedExternally + var resources: `T$27`? + get() = definedExternally + set(value) = definedExternally + var patterns: `T$27`? + get() = definedExternally + set(value) = definedExternally + var meta: Json? + get() = definedExternally + set(value) = definedExternally + } + + interface ParsedGrantToken : GrantTokenParameters { + var version: Number + var timestamp: Number + var signature: Any + } + + interface GrantTokenPermissions { + var read: Boolean? + get() = definedExternally + set(value) = definedExternally + var write: Boolean? + get() = definedExternally + set(value) = definedExternally + var manage: Boolean? + get() = definedExternally + set(value) = definedExternally + var delete: Boolean? + get() = definedExternally + set(value) = definedExternally + var get: Boolean? + get() = definedExternally + set(value) = definedExternally + var join: Boolean? + get() = definedExternally + set(value) = definedExternally + var update: Boolean? + get() = definedExternally + set(value) = definedExternally + } + + interface RevokeTokenResponse { + var status: Number + var data: Any? + } + + interface ActionParam { + var type: String + var value: String + } + + interface AddMessageActionParameters { + var channel: String + var messageTimetoken: String + var action: ActionParam + } + + interface MessageAction { + var type: String + var value: String + var uuid: String + var actionTimetoken: String + var messageTimetoken: String + } + + interface RemoveMessageActionParameters { + var channel: String + var messageTimetoken: String + var actionTimetoken: String + } + + interface GetMessageActionsParameters { + var channel: String + var start: String? + get() = definedExternally + set(value) = definedExternally + var end: String? + get() = definedExternally + set(value) = definedExternally + var limit: Number? + get() = definedExternally + set(value) = definedExternally + } + + interface GetMessageActionsResponse { + var data: Array + var start: String? + get() = definedExternally + set(value) = definedExternally + var end: String? + get() = definedExternally + set(value) = definedExternally + } + + interface ListFilesParameters { + var channel: String + var limit: Number? + get() = definedExternally + set(value) = definedExternally + var next: String? + get() = definedExternally + set(value) = definedExternally + } + + interface SendFileParameters { + var channel: String + var file: dynamic /* StreamFileInput | BufferFileInput | UriFileInput */ + get() = definedExternally + set(value) = definedExternally + var message: Any? + get() = definedExternally + set(value) = definedExternally + var cipherKey: String? + get() = definedExternally + set(value) = definedExternally + var storeInHistory: Boolean? + get() = definedExternally + set(value) = definedExternally + var ttl: Number? + get() = definedExternally + set(value) = definedExternally + var meta: Any? + get() = definedExternally + set(value) = definedExternally + } + + interface StreamFileInput { + var stream: Any + var name: String + var mimeType: String? + get() = definedExternally + set(value) = definedExternally + } + + interface BufferFileInput { + var data: Any + var name: String + var mimeType: String? + get() = definedExternally + set(value) = definedExternally + } + + interface UriFileInput { + var uri: String + var name: String + var mimeType: String? + get() = definedExternally + set(value) = definedExternally + } + + interface DownloadFileParameters { + var channel: String + var id: String + var name: String + var cipherKey: String? + get() = definedExternally + set(value) = definedExternally + } + + interface FileInputParameters { + var channel: String + var id: String + var name: String + } + + interface PublishFileParameters { + var channel: String + var message: Any? + get() = definedExternally + set(value) = definedExternally + var fileId: String + var fileName: String + var storeInHistory: Boolean? + get() = definedExternally + set(value) = definedExternally + var ttl: Number? + get() = definedExternally + set(value) = definedExternally + var meta: Any? + get() = definedExternally + set(value) = definedExternally + } + + interface `T$29` { + var name: String + var id: String + var size: Number + var created: String + } + + interface ListFilesResponse { + var status: Number + var data: Array<`T$29`> + var next: String + var count: Number + } + + interface SendFileResponse { + var timetoken: String + var name: String + var id: String + } + + interface DeleteFileResponse { + var status: Number + } + + interface PublishFileResponse { + var timetoken: String + } +// interface ObjectCustom { +// @nativeGetter +// operator fun get(key: String): dynamic /* String? | Number? | Boolean? */ +// @nativeSetter +// operator fun set(key: String, value: String) +// @nativeSetter +// operator fun set(key: String, value: Number) +// @nativeSetter +// operator fun set(key: String, value: Boolean) +// } + + interface CustomObject : JsMap + + interface v2ObjectDataOmitId { + var eTag: String + var updated: String + var custom: CustomObject? + get() = definedExternally + set(value) = definedExternally + } + + interface v2ObjectData { + var id: String + var eTag: String + var updated: String + var custom: CustomObject? + get() = definedExternally + set(value) = definedExternally + } + + interface ObjectParam { + var custom: CustomObject? + get() = definedExternally + set(value) = definedExternally + } + + interface UUIDMetadataFieldsNullable { + var name: String? + var externalId: String? + var profileUrl: String? + var email: String? + var status: String? + var type: String? + } + + interface UUIDMetadata : ObjectParam, UUIDMetadataFieldsNullable, Partial + interface UUIDMetadataObject : v2ObjectData, UUIDMetadataFieldsNullable + interface `T$30` { + var customFields: Boolean? + get() = definedExternally + set(value) = definedExternally + } + + interface SetUUIDMetadataParameters { + var uuid: String? + get() = definedExternally + set(value) = definedExternally + var data: UUIDMetadata + var include: `T$30`? + get() = definedExternally + set(value) = definedExternally + } + + interface RemoveUUIDMetadataParameters { + var uuid: String? + get() = definedExternally + set(value) = definedExternally + } + + interface `T$31` { + var totalCount: Boolean? + get() = definedExternally + set(value) = definedExternally + var customFields: Boolean? + get() = definedExternally + set(value) = definedExternally + } + + interface MetadataPage { + var next: String? + get() = definedExternally + set(value) = definedExternally + var prev: String? + get() = definedExternally + set(value) = definedExternally + } + + interface GetAllMetadataParameters { + var include: `T$31`? + get() = definedExternally + set(value) = definedExternally + var filter: String? + get() = definedExternally + set(value) = definedExternally + var sort: Any? + get() = definedExternally + set(value) = definedExternally + var limit: Number? + get() = definedExternally + set(value) = definedExternally + var page: MetadataPage? + get() = definedExternally + set(value) = definedExternally + } + + interface GetUUIDMetadataParameters { + var uuid: String? + get() = definedExternally + set(value) = definedExternally + var include: `T$30`? + get() = definedExternally + set(value) = definedExternally + } + + interface ChannelMetadataFieldsPartial { + var name: Optional + var description: Optional + var status: Optional + var type: Optional + } + + interface ChannelMetadataFieldsNullable { + var name: String? + var description: String? + var status: String? + var type: String? + } + + interface ChannelMetadata : ObjectParam, ChannelMetadataFieldsPartial + interface ChannelMetadataObject : v2ObjectData, ChannelMetadataFieldsNullable + interface SetChannelMetadataParameters { + var channel: String + var data: ChannelMetadata + var include: `T$30`? + get() = definedExternally + set(value) = definedExternally + } + + interface RemoveChannelMetadataParameters { + var channel: String + } + + interface `T$33` { + var customFields: Boolean + } + + interface GetChannelMetadataParameters { + var channel: String + var include: `T$33`? + get() = definedExternally + set(value) = definedExternally + } + + interface HasStatus { + var status: String? + get() = definedExternally + set(value) = definedExternally + } + + interface UUIDMembershipObject : v2ObjectDataOmitId { + var uuid: UUIDMetadataObject /* UUIDMetadataObject & HasStatus | HasId */ + var status: String? + get() = definedExternally + set(value) = definedExternally + } + + interface ChannelMembershipObject : v2ObjectDataOmitId { + var channel: dynamic /* ChannelMetadataObject & HasStatus | HasId */ + get() = definedExternally + set(value) = definedExternally + var status: String? + get() = definedExternally + set(value) = definedExternally + } + + interface IncludeOptions { + var totalCount: Boolean? + get() = definedExternally + set(value) = definedExternally + var customFields: Boolean? + get() = definedExternally + set(value) = definedExternally + var UUIDFields: Boolean? + get() = definedExternally + set(value) = definedExternally + var customUUIDFields: Boolean? + get() = definedExternally + set(value) = definedExternally + var statusField: Boolean? + get() = definedExternally + set(value) = definedExternally + var UUIDStatusField: Boolean? + get() = definedExternally + set(value) = definedExternally + var UUIDTypeField: Boolean? + get() = definedExternally + set(value) = definedExternally + } + + interface UUIDMembersParameters { + var include: IncludeOptions? + get() = definedExternally + set(value) = definedExternally + var filter: String? + get() = definedExternally + set(value) = definedExternally + var sort: Map? + get() = definedExternally + set(value) = definedExternally + var limit: Number? + get() = definedExternally + set(value) = definedExternally + var page: MetadataPage? + get() = definedExternally + set(value) = definedExternally + } + + interface `T$36` { + var totalCount: Boolean? + get() = definedExternally + set(value) = definedExternally + var customFields: Boolean? + get() = definedExternally + set(value) = definedExternally + var channelFields: Boolean? + get() = definedExternally + set(value) = definedExternally + var customChannelFields: Boolean? + get() = definedExternally + set(value) = definedExternally + var statusField: Boolean? + get() = definedExternally + set(value) = definedExternally + var channelStatusField: Boolean? + get() = definedExternally + set(value) = definedExternally + var channelTypeField: Boolean? + get() = definedExternally + set(value) = definedExternally + } + + interface ChannelMembersParameters { + var include: `T$36`? + get() = definedExternally + set(value) = definedExternally + var filter: String? + get() = definedExternally + set(value) = definedExternally + var sort: Any? + get() = definedExternally + set(value) = definedExternally + var limit: Number? + get() = definedExternally + set(value) = definedExternally + var page: MetadataPage? + get() = definedExternally + set(value) = definedExternally + } + + interface GetChannelMembersParameters : UUIDMembersParameters { + var channel: String + } + + interface GetMembershipsParametersv2 : ChannelMembersParameters { + var uuid: String? + get() = definedExternally + set(value) = definedExternally + } + + interface SetCustom { + var id: String + var custom: CustomObject? + get() = definedExternally + set(value) = definedExternally + } + + interface SetMembershipsParameters : ChannelMembersParameters { + var uuid: String? + get() = definedExternally + set(value) = definedExternally + var channels: Array? + get() = definedExternally + set(value) = definedExternally + } + + interface RemoveMembershipsParameters : ChannelMembersParameters { + var uuid: String? + get() = definedExternally + set(value) = definedExternally + var channels: Array + } + + interface SetChannelMembersParameters : UUIDMembersParameters { + var channel: String + var uuids: Array + } + + interface RemoveChannelMembersParameters : UUIDMembersParameters { + var channel: String + var uuids: Array + } + + interface CryptoParameters { + var encryptKey: Boolean? + get() = definedExternally + set(value) = definedExternally + var keyEncoding: String? + get() = definedExternally + set(value) = definedExternally + var keyLength: Number? + get() = definedExternally + set(value) = definedExternally + var mode: String? + get() = definedExternally + set(value) = definedExternally + } + + interface FetchTimeResponse { + var timetoken: Number + } + + interface APNS2Configuration { + var collapseId: String? + get() = definedExternally + set(value) = definedExternally + var expirationDate: Date? + get() = definedExternally + set(value) = definedExternally + var targets: Array + } + + interface APNS2Target { + var topic: String + var environment: String? /* "development" | "production" */ + get() = definedExternally + set(value) = definedExternally + var excludedDevices: Array? + get() = definedExternally + set(value) = definedExternally + } + + interface BaseNotificationPayload { + var subtitle: String? + get() = definedExternally + set(value) = definedExternally + var payload: Any? + var badge: Number? + get() = definedExternally + set(value) = definedExternally + var sound: String? + get() = definedExternally + set(value) = definedExternally + var title: String? + get() = definedExternally + set(value) = definedExternally + var body: String? + get() = definedExternally + set(value) = definedExternally + } + + interface APNSNotificationPayload : BaseNotificationPayload { + var configurations: Array + var apnsPushType: String? + get() = definedExternally + set(value) = definedExternally + var isSilent: Boolean + } + + interface MPNSNotificationPayload : BaseNotificationPayload { + var backContent: String? + get() = definedExternally + set(value) = definedExternally + var backTitle: String? + get() = definedExternally + set(value) = definedExternally + var count: Number? + get() = definedExternally + set(value) = definedExternally + var type: String? + get() = definedExternally + set(value) = definedExternally + } + + interface FCMNotificationPayload : BaseNotificationPayload { + var isSilent: Boolean + var icon: String? + get() = definedExternally + set(value) = definedExternally + var tag: String? + get() = definedExternally + set(value) = definedExternally + } + + interface `T$37` { + var apns: Any? + var mpns: Any? + var fcm: Any? + } + + interface NotificationsPayload { + var payload: `T$37` + var debugging: Boolean + var subtitle: String? + get() = definedExternally + set(value) = definedExternally + var badge: Number? + get() = definedExternally + set(value) = definedExternally + var sound: String? + get() = definedExternally + set(value) = definedExternally + var title: String? + get() = definedExternally + set(value) = definedExternally + var body: String? + get() = definedExternally + set(value) = definedExternally + var apns: APNSNotificationPayload + var mpns: MPNSNotificationPayload + var fcm: FCMNotificationPayload + fun buildPayload(platforms: Array): Any? + } + + open class CryptoModule(configuration: CryptoModuleConfiguration) { + open var defaultCryptor: dynamic /* Cryptor | LegacyCryptor */ + open var cryptors: Array */> + open fun encrypt(data: ArrayBuffer): ArrayBuffer + open fun encrypt(data: String): ArrayBuffer + open fun decrypt(data: ArrayBuffer): dynamic /* ArrayBuffer | String */ + open fun decrypt(data: String): dynamic /* ArrayBuffer | String */ + open fun encryptFile(file: PubNubFileType, fd: PubNubFileType): Promise + open fun decryptFile(file: PubNubFileType, fd: PubNubFileType): Promise + + companion object { + fun legacyCryptoModule(configuration: CryptorConfiguration): CryptoModule + fun aesCbcCryptoModule(configuration: CryptorConfiguration): CryptoModule + fun withDefaultCryptor(defaultCryptor: Cryptor): CryptoModule + fun withDefaultCryptor(defaultCryptor: LegacyCryptor): CryptoModule + } + } + + interface PubNubFileType { + var data: dynamic /* File | Blob */ + get() = definedExternally + set(value) = definedExternally + var name: String + var mimeType: String + fun create(config: Any): PubNubFileType + fun toArrayBuffer(): ArrayBuffer + fun toBlob(): Blob + override fun toString(): String + fun toFile(): File + } + + interface CryptorConfiguration { + var cipherKey: String + var useRandomIVs: Boolean? + get() = definedExternally + set(value) = definedExternally + } + + interface CryptoModuleConfiguration { + var default: dynamic /* Cryptor | LegacyCryptor */ + get() = definedExternally + set(value) = definedExternally + var cryptors: Array */>? + get() = definedExternally + set(value) = definedExternally + } + + interface EncryptedDataType { + var data: ArrayBuffer + var metadata: ArrayBuffer? + } + + interface LegacyCryptor + + companion object { + var CATEGORIES: Any + var OPERATIONS: Any + fun generateUUID(): String + var LinearRetryPolicy: Any + var ExponentialRetryPolicy: Any + fun notificationPayload(title: String, body: String): NotificationsPayload + } +} + +external interface Partial + +external interface UUID { + var uuid: String +} + +external interface UserId { + var userId: String +} + +external interface Cryptor + +external interface Categories { + var PNNetworkUpCategory: String + var PNNetworkDownCategory: String + var PNNetworkIssuesCategory: String + var PNTimeoutCategory: String + var PNBadRequestCategory: String + var PNAccessDeniedCategory: String + var PNUnknownCategory: String + var PNReconnectedCategory: String + var PNConnectedCategory: String + var PNRequestMessageCountExceedCategory: String + var PNMalformedResponseCategory: String + var PNDisconnectedUnexpectedlyCategory: String + var PNConnectionErrorCategory: String +} + +external interface Operations { + var PNTimeOperation: String + var PNHistoryOperation: String + var PNDeleteMessagesOperation: String + var PNFetchMessagesOperation: String + var PNMessageCountsOperation: String + var PNSubscribeOperation: String + var PNUnsubscribeOperation: String + var PNPublishOperation: String + var PNPushNotificationEnabledChannelsOperation: String + var PNRemoveAllPushNotificationsOperation: String + var PNWhereNowOperation: String + var PNSetStateOperation: String + var PNHereNowOperation: String + var PNGetStateOperation: String + var PNHeartbeatOperation: String + var PNChannelGroupsOperation: String + var PNRemoveGroupOperation: String + var PNChannelsForGroupOperation: String + var PNAddChannelsToGroupOperation: String + var PNRemoveChannelsFromGroupOperation: String + var PNAccessManagerGrant: String + var PNAccessManagerAudit: String + var PNCreateUserOperation: String + var PNUpdateUserOperation: String + var PNDeleteUserOperation: String + var PNGetUsersOperation: String + var PNCreateSpaceOperation: String + var PNUpdateSpaceOperation: String + var PNDeleteSpaceOperation: String + var PNGetSpacesOperation: String + var PNGetMembershipsOperation: String + var PNGetMembersOperation: String + var PNUpdateMembershipsOperation: String + var PNAddMessageActionOperation: String + var PNRemoveMessageActionOperation: String + var PNGetMessageActionsOperation: String +} + +external interface LinearRetryPolicyConfiguration { + var delay: Number + var maximumRetry: Number +} + +external interface ExponentialRetryPolicyConfiguration { + var minimumDelay: Number + var maximumDelay: Number + var maximumRetry: Number +} + +external interface JsMap + +fun entriesOf(jsObject: JsMap): List> = + (js("Object.entries") as (dynamic) -> Array>) + .invoke(jsObject) + .map { entry -> entry[0] as String to entry[1] } + +fun JsMap.toMap(): Map = + entriesOf(this).toMap() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt new file mode 100644 index 000000000..f7bef87b4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt @@ -0,0 +1,8 @@ +package com.pubnub.api + +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result + +actual interface Endpoint { + actual fun async(callback: Consumer>) +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt new file mode 100644 index 000000000..f02106346 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt @@ -0,0 +1,20 @@ +package com.pubnub.api + +import com.pubnub.api.v2.callbacks.Consumer +import kotlin.js.Promise +import com.pubnub.api.v2.callbacks.Result as Result + +open class EndpointImpl(private val promiseFactory: () -> Promise, private val responseMapping: (T) -> U): + Endpoint { + + override fun async(callback: Consumer>) { + promiseFactory().then( + onFulfilled = { response: T -> + callback.accept(Result.success(responseMapping(response))) + }, + onRejected = { throwable -> + callback.accept(Result.failure(throwable)) + } + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt new file mode 100644 index 000000000..ff4df2d54 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt @@ -0,0 +1,477 @@ +package com.pubnub.api + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.endpoints.DeleteMessages +import com.pubnub.api.endpoints.FetchMessages +import com.pubnub.api.endpoints.MessageCounts +import com.pubnub.api.endpoints.Time +import com.pubnub.api.endpoints.access.GrantToken +import com.pubnub.api.endpoints.access.RevokeToken +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.GetFileUrl +import com.pubnub.api.endpoints.files.ListFiles +import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.message_actions.AddMessageAction +import com.pubnub.api.endpoints.message_actions.GetMessageActions +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +import com.pubnub.api.endpoints.objects.member.GetChannelMembers +import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +import com.pubnub.api.endpoints.objects.membership.GetMemberships +import com.pubnub.api.endpoints.objects.membership.ManageMemberships +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +import com.pubnub.api.endpoints.presence.GetState +import com.pubnub.api.endpoints.presence.HereNow +import com.pubnub.api.endpoints.presence.SetState +import com.pubnub.api.endpoints.presence.WhereNow +import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.endpoints.push.AddChannelsToPush +import com.pubnub.api.endpoints.push.ListPushProvisions +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions +import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.files.PNDownloadableFile +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNMemberKey +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.member.MemberInput +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.models.consumer.pubsub.BasePubSubResult +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener +import PubNub as PubNubJs + +actual fun createPubNub(config: PNConfiguration): PubNub { + return PubNubImpl(config) +} + +actual interface PubNub { + + actual val configuration: PNConfiguration + actual fun addListener(listener: EventListener) + actual fun addListener(listener: StatusListener) + actual fun removeListener(listener: Listener) + actual fun removeAllListeners() + actual fun publish( + channel: String, + message: Any, + meta: Any?, + shouldStore: Boolean?, + usePost: Boolean, + replicate: Boolean, + ttl: Int? + ): Publish + + actual fun fire( + channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int? + ): Publish + + actual fun signal(channel: String, message: Any): Signal + actual fun getSubscribedChannels(): List + actual fun getSubscribedChannelGroups(): List + actual fun addPushNotificationsOnChannels( + pushType: PNPushType, channels: List, deviceId: String, topic: String?, environment: PNPushEnvironment + ): AddChannelsToPush + + actual fun auditPushChannelProvisions( + pushType: PNPushType, deviceId: String, topic: String?, environment: PNPushEnvironment + ): ListPushProvisions + + actual fun removePushNotificationsFromChannels( + pushType: PNPushType, channels: List, deviceId: String, topic: String?, environment: PNPushEnvironment + ): RemoveChannelsFromPush + + actual fun removeAllPushNotificationsFromDeviceWithPushToken( + pushType: PNPushType, deviceId: String, topic: String?, environment: PNPushEnvironment + ): RemoveAllPushChannelsForDevice + + actual fun fetchMessages( + channels: List, + page: PNBoundedPage, + includeUUID: Boolean, + includeMeta: Boolean, + includeMessageActions: Boolean, + includeMessageType: Boolean + ): FetchMessages + + actual fun deleteMessages( + channels: List, start: Long?, end: Long? + ): DeleteMessages + + actual fun messageCounts( + channels: List, channelsTimetoken: List + ): MessageCounts + + actual fun hereNow( + channels: List, channelGroups: List, includeState: Boolean, includeUUIDs: Boolean + ): HereNow + + actual fun whereNow(uuid: String): WhereNow + actual fun setPresenceState( + channels: List, channelGroups: List, state: Any, uuid: String + ): SetState + + actual fun getPresenceState( + channels: List, channelGroups: List, uuid: String + ): GetState + + actual fun presence( + channels: List, channelGroups: List, connected: Boolean + ) + + actual fun addMessageAction( + channel: String, messageAction: PNMessageAction + ): AddMessageAction + + actual fun removeMessageAction( + channel: String, messageTimetoken: Long, actionTimetoken: Long + ): RemoveMessageAction + + actual fun getMessageActions( + channel: String, page: PNBoundedPage + ): GetMessageActions + + actual fun addChannelsToChannelGroup( + channels: List, channelGroup: String + ): AddChannelChannelGroup + + actual fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup + actual fun removeChannelsFromChannelGroup( + channels: List, channelGroup: String + ): RemoveChannelChannelGroup + + actual fun listAllChannelGroups(): ListAllChannelGroup + actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup + actual fun grantToken( + ttl: Int, + meta: Any?, + authorizedUUID: String?, + channels: List, + channelGroups: List, + uuids: List + ): GrantToken + + actual fun grantToken( + ttl: Int, + meta: Any?, + authorizedUserId: UserId?, + spacesPermissions: List, + usersPermissions: List + ): GrantToken + + actual fun revokeToken(token: String): RevokeToken + actual fun time(): Time + actual fun getAllChannelMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllChannelMetadata + + actual fun getChannelMetadata( + channel: String, includeCustom: Boolean + ): GetChannelMetadata + + actual fun setChannelMetadata( + channel: String, + name: String?, + description: String?, + custom: Any?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetChannelMetadata + + actual fun removeChannelMetadata(channel: String): RemoveChannelMetadata + actual fun getAllUUIDMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllUUIDMetadata + + actual fun getUUIDMetadata( + uuid: String?, includeCustom: Boolean + ): GetUUIDMetadata + + actual fun setUUIDMetadata( + uuid: String?, + name: String?, + externalId: String?, + profileUrl: String?, + email: String?, + custom: CustomObject?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetUUIDMetadata + + actual fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata + actual fun getMemberships( + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): GetMemberships + + actual fun setMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships + + actual fun removeMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships + + actual fun manageMemberships( + channelsToSet: List, + channelsToRemove: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships + + actual fun getChannelMembers( + channel: String, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): GetChannelMembers + + actual fun setChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers + + actual fun removeChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers + + actual fun manageChannelMembers( + channel: String, + uuidsToSet: Collection, + uuidsToRemove: Collection, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers + + actual fun listFiles( + channel: String, limit: Int?, next: PNPage.PNNext? + ): ListFiles + + actual fun getFileUrl( + channel: String, fileName: String, fileId: String + ): GetFileUrl + + actual fun deleteFile( + channel: String, fileName: String, fileId: String + ): DeleteFile + + actual fun publishFileMessage( + channel: String, fileName: String, fileId: String, message: Any?, meta: Any?, ttl: Int?, shouldStore: Boolean? + ): PublishFileMessage + + actual fun subscribe( + channels: List, channelGroups: List, withPresence: Boolean, withTimetoken: Long + ) + + actual fun unsubscribe( + channels: List, channelGroups: List + ) + + actual fun setToken(token: String?) + +} + +actual fun createEventListener( + pubnub: PubNub, + onMessage: (PubNub, PNMessageResult) -> Unit, + onPresence: (PubNub, PNPresenceEventResult) -> Unit, + onSignal: (PubNub, PNSignalResult) -> Unit, + onMessageAction: (PubNub, PNMessageActionResult) -> Unit, + onObjects: (PubNub, PNObjectEventResult) -> Unit, + onFile: (PubNub, PNFileEventResult) -> Unit +): EventListener { + val listener = object : PubNubJs.ListenerParameters { + override val message: (PubNubJs.MessageEvent) -> Unit = { messageEvent -> + onMessage(pubnub, PNMessageResult( + BasePubSubResult( + messageEvent.channel, + messageEvent.subscription, + messageEvent.timetoken.toLong(), + messageEvent.userMetadata as? JsonElement, // TODO kmp + messageEvent.publisher + ), + messageEvent.message as JsonElement, // TODO kmp + null //TODO kmp error + )) + } + override val presence: ((presenceEvent: PubNubJs.PresenceEvent) -> Unit) = { presenceEvent -> + onPresence(pubnub, PNPresenceEventResult( + presenceEvent.action, + presenceEvent.uuid, + presenceEvent.timestamp.toLong(), + presenceEvent.occupancy.toInt(), + presenceEvent.state.asDynamic(), //TODO kmp + presenceEvent.channel, + presenceEvent.subscription, + presenceEvent.timetoken.toLong(), + )) + + } + override val signal: ((signalEvent: PubNubJs.SignalEvent) -> Unit) = { signalEvent -> + onSignal(pubnub, PNSignalResult( + BasePubSubResult( + signalEvent.channel, + signalEvent.subscription, + signalEvent.timetoken.toLong(), + null, + signalEvent.publisher + ), + signalEvent.message as JsonElement, // TODO kmp + )) + } + + override val messageAction: ((messageActionEvent: PubNubJs.MessageActionEvent) -> Unit) = { messageActionEvent -> + onMessageAction(pubnub, PNMessageActionResult( + BasePubSubResult( + messageActionEvent.channel, + messageActionEvent.subscription, + messageActionEvent.timetoken.toLong(), + null, + messageActionEvent.publisher + ), + messageActionEvent.event, + PNMessageAction( + messageActionEvent.data.type, + messageActionEvent.data.value, + messageActionEvent.data.messageTimetoken.toLong() + ).apply { + actionTimetoken = messageActionEvent.data.messageTimetoken.toLong() + } + )) + } + override val file: ((fileEvent: PubNubJs.FileEvent) -> Unit) = { fileEvent -> + onFile(pubnub, PNFileEventResult( + fileEvent.channel, + fileEvent.timetoken.toLong(), + fileEvent.publisher, + fileEvent.message, + PNDownloadableFile(fileEvent.file.id, fileEvent.file.name, fileEvent.file.url), + fileEvent.message as JsonElement, //TODO kmp + fileEvent.subscription, + null // TODO kmp error + ) ) + } + } + return listener +} + +actual fun createStatusListener( + pubnub: PubNub, + onStatus: (PubNub, PNStatus) -> Unit +): StatusListener { + return object : PubNubJs.StatusListenerParameters { + override val status: ((statusEvent: PubNubJs.StatusEvent) -> Unit) = { statusEvent -> + onStatus(pubnub, PNStatus( + enumValueOf(statusEvent.category), //TODO parse category + null, + statusEvent.currentTimetoken.toString().toLong(), + statusEvent.affectedChannels.toList(), + statusEvent.affectedChannelGroups.toList() + )) + } + } +} + +class CustomObjectImpl(map: Map = emptyMap()) : Map by map + +actual typealias CustomObject = CustomObjectImpl + +actual fun createCustomObject(map: Map): CustomObject { + return CustomObjectImpl(map) +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt new file mode 100644 index 000000000..831501ade --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -0,0 +1,564 @@ +package com.pubnub.api + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.endpoints.DeleteMessages +import com.pubnub.api.endpoints.FetchMessages +import com.pubnub.api.endpoints.FetchMessagesImpl +import com.pubnub.api.endpoints.MessageCounts +import com.pubnub.api.endpoints.Time +import com.pubnub.api.endpoints.access.GrantToken +import com.pubnub.api.endpoints.access.RevokeToken +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroupImpl +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroupImpl +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroupImpl +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroupImpl +import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.GetFileUrl +import com.pubnub.api.endpoints.files.ListFiles +import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.message_actions.AddMessageAction +import com.pubnub.api.endpoints.message_actions.AddMessageActionImpl +import com.pubnub.api.endpoints.message_actions.GetMessageActions +import com.pubnub.api.endpoints.message_actions.GetMessageActionImpl +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.endpoints.message_actions.RemoveMessageActionImpl +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +import com.pubnub.api.endpoints.objects.member.GetChannelMembers +import com.pubnub.api.endpoints.objects.member.GetChannelMembersImpl +import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +import com.pubnub.api.endpoints.objects.membership.GetMemberships +import com.pubnub.api.endpoints.objects.membership.ManageMemberships +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadataImpl +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadataImpl +import com.pubnub.api.endpoints.presence.GetState +import com.pubnub.api.endpoints.presence.HereNow +import com.pubnub.api.endpoints.presence.HereNowImpl +import com.pubnub.api.endpoints.presence.SetState +import com.pubnub.api.endpoints.presence.WhereNow +import com.pubnub.api.endpoints.presence.WhereNowImpl +import com.pubnub.api.endpoints.pubsub.FireImpl +import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.PublishImpl +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.endpoints.pubsub.SignalImpl +import com.pubnub.api.endpoints.push.AddChannelsToPush +import com.pubnub.api.endpoints.push.ListPushProvisions +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions +import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNMemberKey +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.member.MemberInput +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.kmp.Optional +import com.pubnub.kmp.toOptional + +import PubNub as PubNubJs + +class PubNubImpl(override val configuration: PNConfiguration) : PubNub { + override fun addListener(listener: EventListener) { + TODO("Not yet implemented") + } + + override fun addListener(listener: StatusListener) { + TODO("Not yet implemented") + } + + override fun removeListener(listener: Listener) { + TODO("Not yet implemented") + } + + override fun removeAllListeners() { + TODO("Not yet implemented") + } + + override fun publish( + channel: String, + message: Any, + meta: Any?, + shouldStore: Boolean?, + usePost: Boolean, + replicate: Boolean, + ttl: Int? + ): Publish { + TODO("Not yet implemented") + } + + override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { + TODO("Not yet implemented") + } + + override fun signal(channel: String, message: Any): Signal { + TODO("Not yet implemented") + } + + override fun getSubscribedChannels(): List { + TODO("Not yet implemented") + } + + override fun getSubscribedChannelGroups(): List { + TODO("Not yet implemented") + } + + override fun addPushNotificationsOnChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): AddChannelsToPush { + TODO("Not yet implemented") + } + + override fun auditPushChannelProvisions( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): ListPushProvisions { + TODO("Not yet implemented") + } + + override fun removePushNotificationsFromChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): RemoveChannelsFromPush { + TODO("Not yet implemented") + } + + override fun removeAllPushNotificationsFromDeviceWithPushToken( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): RemoveAllPushChannelsForDevice { + TODO("Not yet implemented") + } + + override fun fetchMessages( + channels: List, + page: PNBoundedPage, + includeUUID: Boolean, + includeMeta: Boolean, + includeMessageActions: Boolean, + includeMessageType: Boolean + ): FetchMessages { + TODO("Not yet implemented") + } + + override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { + TODO("Not yet implemented") + } + + override fun messageCounts(channels: List, channelsTimetoken: List): MessageCounts { + TODO("Not yet implemented") + } + + override fun hereNow( + channels: List, + channelGroups: List, + includeState: Boolean, + includeUUIDs: Boolean + ): HereNow { + TODO("Not yet implemented") + } + + override fun whereNow(uuid: String): WhereNow { + TODO("Not yet implemented") + } + + override fun setPresenceState( + channels: List, + channelGroups: List, + state: Any, + uuid: String + ): SetState { + TODO("Not yet implemented") + } + + override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { + TODO("Not yet implemented") + } + + override fun presence(channels: List, channelGroups: List, connected: Boolean) { + TODO("Not yet implemented") + } + + override fun addMessageAction(channel: String, messageAction: PNMessageAction): AddMessageAction { + TODO("Not yet implemented") + } + + override fun removeMessageAction( + channel: String, + messageTimetoken: Long, + actionTimetoken: Long + ): RemoveMessageAction { + TODO("Not yet implemented") + } + + override fun getMessageActions(channel: String, page: PNBoundedPage): GetMessageActions { + TODO("Not yet implemented") + } + + override fun addChannelsToChannelGroup(channels: List, channelGroup: String): AddChannelChannelGroup { + TODO("Not yet implemented") + } + + override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { + TODO("Not yet implemented") + } + + override fun removeChannelsFromChannelGroup( + channels: List, + channelGroup: String + ): RemoveChannelChannelGroup { + TODO("Not yet implemented") + } + + override fun listAllChannelGroups(): ListAllChannelGroup { + TODO("Not yet implemented") + } + + override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { + TODO("Not yet implemented") + } + + override fun grantToken( + ttl: Int, + meta: Any?, + authorizedUUID: String?, + channels: List, + channelGroups: List, + uuids: List + ): GrantToken { + TODO("Not yet implemented") + } + + override fun grantToken( + ttl: Int, + meta: Any?, + authorizedUserId: UserId?, + spacesPermissions: List, + usersPermissions: List + ): GrantToken { + TODO("Not yet implemented") + } + + override fun revokeToken(token: String): RevokeToken { + TODO("Not yet implemented") + } + + override fun time(): Time { + TODO("Not yet implemented") + } + + override fun getAllChannelMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllChannelMetadata { + TODO("Not yet implemented") + } + + override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { + TODO("Not yet implemented") + } + + override fun setChannelMetadata( + channel: String, + name: String?, + description: String?, + custom: Any?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetChannelMetadata { + TODO("Not yet implemented") + } + + override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { + TODO("Not yet implemented") + } + + override fun getAllUUIDMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllUUIDMetadata { + TODO("Not yet implemented") + } + + override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { + TODO("Not yet implemented") + } + + override fun setUUIDMetadata( + uuid: String?, + name: String?, + externalId: String?, + profileUrl: String?, + email: String?, + custom: CustomObject?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetUUIDMetadata { + TODO("Not yet implemented") + } + + override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { + TODO("Not yet implemented") + } + + override fun getMemberships( + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): GetMemberships { + TODO("Not yet implemented") + } + + override fun setMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships { + TODO("Not yet implemented") + } + + override fun removeMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships { + TODO("Not yet implemented") + } + + override fun manageMemberships( + channelsToSet: List, + channelsToRemove: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel? + ): ManageMemberships { + TODO("Not yet implemented") + } + + override fun getChannelMembers( + channel: String, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): GetChannelMembers { + TODO("Not yet implemented") + } + + override fun setChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers { + TODO("Not yet implemented") + } + + override fun removeChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers { + TODO("Not yet implemented") + } + + override fun manageChannelMembers( + channel: String, + uuidsToSet: Collection, + uuidsToRemove: Collection, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel? + ): ManageChannelMembers { + TODO("Not yet implemented") + } + + override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { + TODO("Not yet implemented") + } + + override fun getFileUrl(channel: String, fileName: String, fileId: String): GetFileUrl { + TODO("Not yet implemented") + } + + override fun deleteFile(channel: String, fileName: String, fileId: String): DeleteFile { + TODO("Not yet implemented") + } + + override fun publishFileMessage( + channel: String, + fileName: String, + fileId: String, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean? + ): PublishFileMessage { + TODO("Not yet implemented") + } + + override fun subscribe( + channels: List, + channelGroups: List, + withPresence: Boolean, + withTimetoken: Long + ) { + TODO("Not yet implemented") + } + + override fun unsubscribe(channels: List, channelGroups: List) { + TODO("Not yet implemented") + } + + override fun setToken(token: String?) { + TODO("Not yet implemented") + } +} + +fun UUIDMetadata( + name: Optional, + externalId: Optional, + profileUrl: Optional, + email: Optional, + status: Optional, + type: Optional, + custom: Optional?> +): PubNubJs.UUIDMetadata { + val result: PubNubJs.UUIDMetadata = createJsObject() + name.onValue { result.name = it } + externalId.onValue { result.externalId = it } + profileUrl.onValue { result.profileUrl = it } + email.onValue { result.email = it } + status.onValue { result.status = it } + type.onValue { result.type = it } + custom.onValue { result.custom = it?.toJsObject() } + return result +} + +fun Map.toJsObject(): PubNubJs.CustomObject { + val custom = createJsObject { } + entries.forEach { + custom[it.key] = it.value + } + @Suppress("UnsafeCastFromDynamic") + return custom +} + +fun createJsObject(configure: T.() -> Unit = {}): T = js("({})") as T + +fun PNConfiguration.toJs(): PubNubJs.PNConfiguration { + val config: PubNubJs.PNConfiguration = createJsObject() + config.userId = userId.value + config.subscribeKey = subscribeKey + config.publishKey = publishKey + config.cipherKey +// config.authKeys: String? +// config.logVerbosity: Boolean? +// config.ssl: Boolean? +// config.origin: dynamic /* String? | Array? */ +// config.presenceTimeout: Number? +// config.heartbeatInterval: Number? +// config.restore: Boolean? +// config.keepAlive: Boolean? +// config.keepAliveSettings: KeepAliveSettings? +// config.subscribeRequestTimeout: Number? +// config.suppressLeaveEvents: Boolean? +// config.secretKey: String? +// config.requestMessageCountThreshold: Number? +// config.autoNetworkDetection: Boolean? +// config.listenToBrowserNetworkEvents: Boolean? +// config.useRandomIVs: Boolean? +// config.dedupeOnSubscribe: Boolean? +// config.cryptoModule: CryptoModule? +// config.retryConfiguration: dynamic /* LinearRetryPolicyConfiguration? | ExponentialRetryPolicyConfiguration? */ +// config.enableEventEngine: Boolean? +// config.maintainPresenceState: Boolean? + return config +} + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt new file mode 100644 index 000000000..780e50eaf --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult + +/** + * @see [com.pubnub.api.PubNub.deleteMessages] + */ +actual interface DeleteMessages : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt new file mode 100644 index 000000000..830477c95 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.endpoints + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.history.PNFetchMessagesResult + +/** + * @see [PubNub.fetchMessages] + */ +actual interface FetchMessages : Endpoint + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt new file mode 100644 index 000000000..c6e9ea3a5 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.history.PNMessageCountResult + +/** + * @see [PubNub.messageCounts] + */ +actual interface MessageCounts : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt new file mode 100644 index 000000000..89eb3e7e4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.PNTimeResult + +/** + * @see [PubNub.time] + */ +actual interface Time : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt new file mode 100644 index 000000000..0f81aa098 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt @@ -0,0 +1,7 @@ +package com.pubnub.api.endpoints.access + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult + +actual interface GrantToken : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt new file mode 100644 index 000000000..68574fb0e --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt @@ -0,0 +1,5 @@ +package com.pubnub.api.endpoints.access + +import com.pubnub.api.Endpoint + +actual interface RevokeToken : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt new file mode 100644 index 000000000..40559bd2c --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.endpoints.channel_groups + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult + +/** + * @see [PubNub.addChannelsToChannelGroup] + */ +actual interface AddChannelChannelGroup : Endpoint + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt new file mode 100644 index 000000000..820b22f61 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.endpoints.channel_groups + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult + +/** + * @see [PubNub.listChannelsForChannelGroup] + */ +actual interface AllChannelsChannelGroup : Endpoint + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt new file mode 100644 index 000000000..a480015a4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.channel_groups + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult + +/** + * @see [PubNub.deleteChannelGroup] + */ +actual interface DeleteChannelGroup : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt new file mode 100644 index 000000000..e6b896fcf --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.endpoints.channel_groups + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult + +/** + * @see [PubNub.listAllChannelGroups] + */ +actual interface ListAllChannelGroup : Endpoint + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt new file mode 100644 index 000000000..cd72984e8 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.channel_groups + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult + +/** + * @see [PubNub.removeChannelsFromChannelGroup] + */ +actual interface RemoveChannelChannelGroup : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt new file mode 100644 index 000000000..df58b5133 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNDeleteFileResult + +/** + * @see [PubNub.deleteFile] + */ +actual interface DeleteFile : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt new file mode 100644 index 000000000..b15d6b85d --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNFileUrlResult + +/** + * @see [PubNub.getFileUrl] + */ +actual interface GetFileUrl : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt new file mode 100644 index 000000000..d6afdd889 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNListFilesResult + +/** + * @see [PubNub.listFiles] + */ +actual interface ListFiles : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt new file mode 100644 index 000000000..eeed730c4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult + +/** + * @see [PubNub.publishFileMessage] + */ +actual interface PublishFileMessage : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt new file mode 100644 index 000000000..a4685777a --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.endpoints.message_actions + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult + +/** + * @see [PubNub.addMessageAction] + */ +actual interface AddMessageAction : Endpoint + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt new file mode 100644 index 000000000..8894b0f54 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.message_actions + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult + +/** + * @see [PubNub.getMessageActions] + */ +actual interface GetMessageActions : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt new file mode 100644 index 000000000..a204f7876 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.endpoints.message_actions + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult + +/** + * @see [PubNub.removeMessageAction] + */ +actual interface RemoveMessageAction : Endpoint + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt new file mode 100644 index 000000000..51a8b8d90 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult + +/** + * @see [PubNub.getAllChannelMetadata] + */ +actual interface GetAllChannelMetadata : + Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt new file mode 100644 index 000000000..26a269e4a --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult + +/** + * @see [PubNub.getChannelMetadata] + */ +actual interface GetChannelMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt new file mode 100644 index 000000000..f6acb81da --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt @@ -0,0 +1,6 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult + +actual interface RemoveChannelMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt new file mode 100644 index 000000000..1ab95a261 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult + +/** + * @see [PubNub.setChannelMetadata] + */ +actual interface SetChannelMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt new file mode 100644 index 000000000..bf5080f34 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.objects.member + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult + +/** + * @see [PubNub.getChannelMembers] + */ +actual interface GetChannelMembers : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt new file mode 100644 index 000000000..29cc33420 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt @@ -0,0 +1,14 @@ +package com.pubnub.api.endpoints.objects.member + +import PubNub +import RemoveMessageActionResult +import com.pubnub.api.Endpoint +import com.pubnub.api.EndpointImpl +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult + +/** + * @see [PubNub.manageChannelMembers] + */ +actual interface ManageChannelMembers : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt new file mode 100644 index 000000000..8cec56fd6 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.membership + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult + +/** + * @see [PubNub.getMemberships] + */ +actual interface GetMemberships : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt new file mode 100644 index 000000000..a7af4557b --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.membership + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult + +/** + * @see [PubNub.manageMemberships] + */ +actual interface ManageMemberships : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt new file mode 100644 index 000000000..67faf7dd0 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.uuid + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult + +/** + * @see [PubNub.getAllUUIDMetadata] + */ +actual interface GetAllUUIDMetadata : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt new file mode 100644 index 000000000..dd2440021 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.objects.uuid + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult + +/** + * @see [PubNub.getUUIDMetadata] + */ +actual interface GetUUIDMetadata : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt new file mode 100644 index 000000000..c0e273261 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt @@ -0,0 +1,18 @@ +package com.pubnub.api.endpoints.objects.uuid + +import PubNub +import RemoveUUIDMetadataResponse +import SetUUIDMetadataResponse +import com.pubnub.api.Endpoint +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult + +actual interface RemoveUUIDMetadata : Endpoint + +class RemoveUUIDMetadataImpl(pubnub: PubNub, params: PubNub.RemoveUUIDMetadataParameters) : RemoveUUIDMetadata, + EndpointImpl(promiseFactory = { pubnub.objects.removeUUIDMetadata(params) }, + responseMapping = { + PNRemoveMetadataResult(it.status.toInt()) + }) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt new file mode 100644 index 000000000..70a316cef --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.endpoints.objects.uuid + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult + +/** + * @see [PubNub.setUUIDMetadata] + */ +actual interface SetUUIDMetadata : Endpoint + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt new file mode 100644 index 000000000..db440e6c6 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.presence + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNGetStateResult + +/** + * @see [PubNub.getPresenceState] + */ +actual interface GetState : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt new file mode 100644 index 000000000..4891f36dd --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.endpoints.presence + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNHereNowResult + +/** + * @see [PubNub.hereNow] + */ +actual interface HereNow : Endpoint + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt new file mode 100644 index 000000000..9325e0785 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.presence + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNSetStateResult + +/** + * @see [PubNub.setPresenceState] + */ +actual interface SetState : Endpoint { +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt new file mode 100644 index 000000000..71f074007 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.endpoints.presence + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.presence.PNWhereNowResult + +/** + * @see [PubNub.whereNow] + */ +actual interface WhereNow : Endpoint + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt new file mode 100644 index 000000000..90903c4e1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.pubsub + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.PNPublishResult + +/** + * @see [PubNub.publish] + */ +actual interface Publish : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt new file mode 100644 index 000000000..69279ef4a --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.endpoints.pubsub + +import PubNub +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.PNPublishResult + +/** + * @see [PubNub.signal] + */ +actual interface Signal : Endpoint + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt new file mode 100644 index 000000000..12aef0b7d --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushAddChannelResult + +/** + * @see [PubNub.addPushNotificationsOnChannels] + */ +actual interface AddChannelsToPush : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt new file mode 100644 index 000000000..63496da48 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult + +/** + * @see [PubNub.auditPushChannelProvisions] + */ +actual interface ListPushProvisions : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt new file mode 100644 index 000000000..f88e4e04f --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult + +/** + * @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken] + */ +actual interface RemoveAllPushChannelsForDevice : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt new file mode 100644 index 000000000..e17227963 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult + +/** + * @see [PubNub.removePushNotificationsFromChannels] + */ +actual interface RemoveChannelsFromPush : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt new file mode 100644 index 000000000..668a06247 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt @@ -0,0 +1,37 @@ +package com.pubnub.api.v2 + +import com.pubnub.api.UserId +import com.pubnub.api.enums.PNHeartbeatNotificationOptions +import com.pubnub.api.enums.PNLogVerbosity +import com.pubnub.api.retry.RetryConfiguration + +actual interface PNConfiguration { + actual val userId: UserId + actual val subscribeKey: String + actual val publishKey: String + actual val secretKey: String + actual val authKey: String + actual val cryptoModule: CryptoModule? +} + +actual fun createPNConfiguration( + userId: UserId, + subscribeKey: String +): PNConfiguration { + return object : PNConfiguration { + override val userId: UserId + get() = userId + override val subscribeKey: String + get() = subscribeKey + override val publishKey: String + get() = "" + override val secretKey: String + get() = TODO("Not yet implemented") + override val authKey: String + get() = TODO("Not yet implemented") + override val cryptoModule: CryptoModule? + get() = TODO("Not yet implemented") + } +} + +actual interface CryptoModule \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt new file mode 100644 index 000000000..d9f833448 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt @@ -0,0 +1,8 @@ +package com.pubnub.api.v2.callbacks + +/** + * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time + * network. + */ +//actual interface EventListener +actual typealias EventListener = PubNub.ListenerParameters \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt new file mode 100644 index 000000000..1802b3a90 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.v2.callbacks + +import com.pubnub.api.PubNub +import com.pubnub.api.models.consumer.PNStatus + +import PubNub as PubNubJs + +/** + * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for + * PubNub connection status changes. + */ +actual typealias StatusListener = PubNubJs.StatusListenerParameters \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/Endpoint.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/Endpoint.kt similarity index 95% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/Endpoint.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/Endpoint.kt index d2a562856..bd4b65ec4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/Endpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/Endpoint.kt @@ -4,7 +4,7 @@ import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.PNConfigurationOverride -interface Endpoint : ExtendedRemoteAction { +actual interface Endpoint : ExtendedRemoteAction { /** * Allows to override certain configuration options (see [PNConfigurationOverride.Builder]) for this request only. * @@ -31,3 +31,4 @@ interface Endpoint : ExtendedRemoteAction { */ fun overrideConfiguration(configuration: PNConfiguration): Endpoint } + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/PNConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PNConfiguration.kt similarity index 99% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/PNConfiguration.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PNConfiguration.kt index 8b1798d39..9bcc6a23e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/PNConfiguration.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PNConfiguration.kt @@ -5,7 +5,7 @@ import com.pubnub.api.enums.PNHeartbeatNotificationOptions import com.pubnub.api.enums.PNLogVerbosity import com.pubnub.api.enums.PNReconnectionPolicy import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.api.v2.BasePNConfiguration +import com.pubnub.api.v2.PNConfiguration import com.pubnub.internal.v2.BasePNConfigurationImpl import com.pubnub.internal.v2.BasePNConfigurationImpl.Companion.MINIMUM_PRESENCE_TIMEOUT import okhttp3.Authenticator @@ -21,7 +21,7 @@ import javax.net.ssl.X509ExtendedTrustManager message = "Use `com.pubnub.api.v2.PNConfiguration.builder` instead.", replaceWith = ReplaceWith("com.pubnub.api.v2.PNConfiguration.builder(userId, subscribeKey)"), ) -class PNConfiguration(override var userId: UserId) : BasePNConfiguration { +class PNConfiguration(override var userId: UserId) : PNConfiguration { private val configuration = BasePNConfigurationImpl(userId) private val log = LoggerFactory.getLogger("PNConfiguration") diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.jvm.kt new file mode 100644 index 000000000..cc0be70aa --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.jvm.kt @@ -0,0 +1,69 @@ +package com.pubnub.api + +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener + +actual fun createPubNub(config: PNConfiguration): PubNub { + return PubNub.create(config) +} + +actual fun createEventListener( + pubnub: PubNub, + onMessage: (PubNub, PNMessageResult) -> Unit, + onPresence: (PubNub, PNPresenceEventResult) -> Unit, + onSignal: (PubNub, PNSignalResult) -> Unit, + onMessageAction: (PubNub, PNMessageActionResult) -> Unit, + onObjects: (PubNub, PNObjectEventResult) -> Unit, + onFile: (PubNub, PNFileEventResult) -> Unit +): EventListener { + return object : EventListener { + override fun message(pubnub: PubNub, result: PNMessageResult) { + onMessage(pubnub, result) + } + + override fun presence(pubnub: PubNub, result: PNPresenceEventResult) { + onPresence(pubnub, result) + } + + override fun signal(pubnub: PubNub, result: PNSignalResult) { + onSignal(pubnub, result) + } + + override fun messageAction(pubnub: PubNub, result: PNMessageActionResult) { + onMessageAction(pubnub, result) + } + + override fun objects(pubnub: PubNub, result: PNObjectEventResult) { + onObjects(pubnub, result) + } + + override fun file(pubnub: PubNub, result: PNFileEventResult) { + onFile(pubnub, result) + } + } +} + +actual typealias CustomObject = Any + +actual fun createCustomObject(map: Map): CustomObject { + return map +} + +actual fun createStatusListener( + pubnub: PubNub, + onStatus: (PubNub, PNStatus) -> Unit +): StatusListener { + return object : StatusListener { + override fun status(pubnub: PubNub, status: PNStatus) { + onStatus(pubnub, status) + } + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt similarity index 87% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/PubNub.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index 39a4f0243..f71ded501 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -53,6 +53,7 @@ import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.history.PNHistoryResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNMemberKey @@ -63,7 +64,6 @@ import com.pubnub.api.models.consumer.objects.member.MemberInput import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.api.v2.BasePNConfiguration import com.pubnub.api.v2.callbacks.EventEmitter import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener @@ -76,7 +76,7 @@ import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.internal.BasePubNubImpl import java.io.InputStream -interface PubNub : +actual interface PubNub : BasePubNub, EventEmitter { companion object { @@ -85,21 +85,38 @@ interface PubNub : * @param configuration the configuration to use * @return the PubNub client */ - fun create(configuration: BasePNConfiguration): PubNub { + fun create(configuration: com.pubnub.api.v2.PNConfiguration): PubNub { return Class.forName( "com.pubnub.internal.PubNubImpl", - ).getConstructor(BasePNConfiguration::class.java).newInstance(configuration) as PubNub + ).getConstructor(com.pubnub.api.v2.PNConfiguration::class.java).newInstance(configuration) as PubNub } + @Deprecated(message = "Use `create` with the new PNConfiguration.Builder instead", + replaceWith = ReplaceWith("create(userId, subscribeKey, builder)") + ) fun create( userId: UserId, builder: PNConfiguration.() -> Unit, ): PubNub { return Class.forName( "com.pubnub.internal.PubNubImpl", - ).getConstructor(BasePNConfiguration::class.java).newInstance(PNConfiguration(userId).apply(builder)) as PubNub + ).getConstructor(com.pubnub.api.v2.PNConfiguration::class.java).newInstance(PNConfiguration(userId).apply(builder)) as PubNub } + fun create( + userId: UserId, + subscribeKey: String, + builder: com.pubnub.api.v2.PNConfiguration.Builder.() -> Unit, + ): PubNub { + return Class.forName( + "com.pubnub.internal.PubNubImpl", + ).getConstructor(com.pubnub.api.v2.PNConfiguration::class.java) + .newInstance( + com.pubnub.api.v2.PNConfiguration.builder(userId, subscribeKey, builder).build() + ) as PubNub + } + + /** * Generates random UUID to use. You should set a unique UUID to identify the user or the device * that connects to PubNub. @@ -112,7 +129,7 @@ interface PubNub : * Modifying the values in this configuration is not advised, as it may lead * to undefined behavior. */ - val configuration: BasePNConfiguration + actual val configuration: com.pubnub.api.v2.PNConfiguration /** * Add a legacy listener for both client status and events. @@ -168,14 +185,14 @@ interface PubNub : * - If ttl isn't specified, then expiration of the message defaults * back to the expiry value for the key. */ - fun publish( + actual fun publish( channel: String, message: Any, - meta: Any? = null, - shouldStore: Boolean? = null, - usePost: Boolean = false, - replicate: Boolean = true, - ttl: Int? = null, + meta: Any?, + shouldStore: Boolean?, + usePost: Boolean, + replicate: Boolean, + ttl: Int?, ): Publish /** @@ -208,12 +225,12 @@ interface PubNub : * - If ttl isn't specified, then expiration of the message defaults * back to the expiry value for the key. */ - fun fire( + actual fun fire( channel: String, message: Any, - meta: Any? = null, - usePost: Boolean = false, - ttl: Int? = null, + meta: Any?, + usePost: Boolean, + ttl: Int?, ): Publish /** @@ -226,7 +243,7 @@ interface PubNub : * @param channel The channel which the signal will be sent to. * @param message The payload which will be serialized and sent. */ - fun signal( + actual fun signal( channel: String, message: Any, ): Signal @@ -236,14 +253,14 @@ interface PubNub : * * @return A list of channels the client is currently subscribed to. */ - fun getSubscribedChannels(): List + actual fun getSubscribedChannels(): List /** * Queries the local subscribe loop for channel groups currently in the mix. * * @return A list of channel groups the client is currently subscribed to. */ - fun getSubscribedChannelGroups(): List + actual fun getSubscribedChannelGroups(): List /** * Enable push notifications on provided set of channels. @@ -257,12 +274,12 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - fun addPushNotificationsOnChannels( + actual fun addPushNotificationsOnChannels( pushType: PNPushType, channels: List, deviceId: String, - topic: String? = null, - environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, + topic: String?, + environment: PNPushEnvironment, ): AddChannelsToPush /** @@ -275,11 +292,11 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - fun auditPushChannelProvisions( + actual fun auditPushChannelProvisions( pushType: PNPushType, deviceId: String, - topic: String? = null, - environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, + topic: String?, + environment: PNPushEnvironment, ): ListPushProvisions /** @@ -293,12 +310,12 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - fun removePushNotificationsFromChannels( + actual fun removePushNotificationsFromChannels( pushType: PNPushType, channels: List, deviceId: String, - topic: String? = null, - environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, + topic: String?, + environment: PNPushEnvironment, ): RemoveChannelsFromPush /** @@ -311,11 +328,11 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - fun removeAllPushNotificationsFromDeviceWithPushToken( + actual fun removeAllPushNotificationsFromDeviceWithPushToken( pushType: PNPushType, deviceId: String, - topic: String? = null, - environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, + topic: String?, + environment: PNPushEnvironment, ): RemoveAllPushChannelsForDevice /** @@ -356,7 +373,7 @@ interface PubNub : channel: String, start: Long? = null, end: Long? = null, - count: Int = com.pubnub.internal.endpoints.HistoryEndpoint.MAX_COUNT, + count: Int = PNHistoryResult.MAX_COUNT, reverse: Boolean = false, includeTimetoken: Boolean = false, includeMeta: Boolean = false, @@ -454,13 +471,13 @@ interface PubNub : * @param includeMessageType Whether to include message type in response. * Defaults to `false`. */ - fun fetchMessages( + actual fun fetchMessages( channels: List, - page: PNBoundedPage = PNBoundedPage(), - includeUUID: Boolean = true, - includeMeta: Boolean = false, - includeMessageActions: Boolean = false, - includeMessageType: Boolean = true, + page: PNBoundedPage, + includeUUID: Boolean, + includeMeta: Boolean, + includeMessageActions: Boolean, + includeMessageType: Boolean, ): FetchMessages /** @@ -476,10 +493,10 @@ interface PubNub : * @param start Timetoken delimiting the start of time slice (exclusive) to delete messages from. * @param end Time token delimiting the end of time slice (inclusive) to delete messages from. */ - fun deleteMessages( + actual fun deleteMessages( channels: List, - start: Long? = null, - end: Long? = null, + start: Long?, + end: Long?, ): DeleteMessages /** @@ -492,7 +509,7 @@ interface PubNub : * Specify a single timetoken to apply it to all channels. * Otherwise, the list of timetokens must be the same length as the list of channels. */ - fun messageCounts( + actual fun messageCounts( channels: List, channelsTimetoken: List, ): MessageCounts @@ -510,11 +527,11 @@ interface PubNub : * @param includeUUIDs Whether the response should include UUIDs od connected clients. * Defaults to `true`. */ - fun hereNow( - channels: List = emptyList(), - channelGroups: List = emptyList(), - includeState: Boolean = false, - includeUUIDs: Boolean = true, + actual fun hereNow( + channels: List, + channelGroups: List, + includeState: Boolean, + includeUUIDs: Boolean, ): HereNow /** @@ -523,7 +540,7 @@ interface PubNub : * @param uuid UUID of the user to get its current channel subscriptions. Defaults to the UUID of the client. * @see [PNConfiguration.uuid] */ - fun whereNow(uuid: String = configuration.userId.value): WhereNow + actual fun whereNow(uuid: String): WhereNow /** * Set state information specific to a subscriber UUID. @@ -545,11 +562,11 @@ interface PubNub : * @param uuid UUID of the user to set the state for. Defaults to the UUID of the client. * @see [PNConfiguration.uuid] */ - fun setPresenceState( - channels: List = listOf(), - channelGroups: List = listOf(), + actual fun setPresenceState( + channels: List, + channelGroups: List, state: Any, - uuid: String = configuration.userId.value, + uuid: String, ): SetState /** @@ -562,10 +579,10 @@ interface PubNub : * @param uuid UUID of the user to get the state from. Defaults to the UUID of the client. * @see [PNConfiguration.uuid] */ - fun getPresenceState( - channels: List = listOf(), - channelGroups: List = listOf(), - uuid: String = configuration.userId.value, + actual fun getPresenceState( + channels: List, + channelGroups: List, + uuid: String, ): GetState /** @@ -577,10 +594,10 @@ interface PubNub : * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. */ - fun presence( - channels: List = emptyList(), - channelGroups: List = emptyList(), - connected: Boolean = false, + actual fun presence( + channels: List, + channelGroups: List, + connected: Boolean, ) /** @@ -590,7 +607,7 @@ interface PubNub : * @param messageAction The message action object containing the message action's type, * value and the publish timetoken of the original message. */ - fun addMessageAction( + actual fun addMessageAction( channel: String, messageAction: PNMessageAction, ): AddMessageAction @@ -602,7 +619,7 @@ interface PubNub : * @param messageTimetoken The publish timetoken of the original message. * @param actionTimetoken The publish timetoken of the message action to be removed. */ - fun removeMessageAction( + actual fun removeMessageAction( channel: String, messageTimetoken: Long, actionTimetoken: Long, @@ -640,9 +657,9 @@ interface PubNub : * @param channel Channel to fetch message actions from. * @param page The paging object used for pagination. @see [PNBoundedPage] */ - fun getMessageActions( + actual fun getMessageActions( channel: String, - page: PNBoundedPage = PNBoundedPage(), + page: PNBoundedPage, ): GetMessageActions /** @@ -651,7 +668,7 @@ interface PubNub : * @param channels The channels to add to the channel group. * @param channelGroup The channel group to add the channels to. */ - fun addChannelsToChannelGroup( + actual fun addChannelsToChannelGroup( channels: List, channelGroup: String, ): AddChannelChannelGroup @@ -661,7 +678,7 @@ interface PubNub : * * @param channelGroup Channel group to fetch the belonging channels. */ - fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup + actual fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup /** * Removes channels from a channel group. @@ -669,7 +686,7 @@ interface PubNub : * @param channelGroup The channel group to remove channels from * @param channels The channels to remove from the channel group. */ - fun removeChannelsFromChannelGroup( + actual fun removeChannelsFromChannelGroup( channels: List, channelGroup: String, ): RemoveChannelChannelGroup @@ -677,14 +694,14 @@ interface PubNub : /** * Lists all registered channel groups for the subscribe key. */ - fun listAllChannelGroups(): ListAllChannelGroup + actual fun listAllChannelGroups(): ListAllChannelGroup /** * Removes the channel group. * * @param channelGroup The channel group to remove. */ - fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup + actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup /** * This function establishes access permissions for PubNub Access Manager (PAM) by setting the `read` or `write` @@ -728,33 +745,33 @@ interface PubNub : * It's possible to grant permissions to multiple [channelGroups] simultaneously. */ fun grant( - read: Boolean = false, - write: Boolean = false, - manage: Boolean = false, - delete: Boolean = false, - ttl: Int = -1, - authKeys: List = emptyList(), - channels: List = emptyList(), - channelGroups: List = emptyList(), - uuids: List = emptyList(), + read: Boolean, + write: Boolean, + manage: Boolean, + delete: Boolean, + ttl: Int, + authKeys: List, + channels: List, + channelGroups: List, + uuids: List, ): Grant /** * See [grant] */ fun grant( - read: Boolean = false, - write: Boolean = false, - manage: Boolean = false, - delete: Boolean = false, - get: Boolean = false, - update: Boolean = false, - join: Boolean = false, - ttl: Int = -1, - authKeys: List = emptyList(), - channels: List = emptyList(), - channelGroups: List = emptyList(), - uuids: List = emptyList(), + read: Boolean, + write: Boolean, + manage: Boolean, + delete: Boolean, + get: Boolean, + update: Boolean, + join: Boolean, + ttl: Int, + authKeys: List, + channels: List, + channelGroups: List, + uuids: List, ): Grant /** @@ -776,13 +793,13 @@ interface PubNub : * @param uuids List of all uuid grants */ - fun grantToken( + actual fun grantToken( ttl: Int, - meta: Any? = null, - authorizedUUID: String? = null, - channels: List = emptyList(), - channelGroups: List = emptyList(), - uuids: List = emptyList(), + meta: Any?, + authorizedUUID: String?, + channels: List, + channelGroups: List, + uuids: List, ): GrantToken /** @@ -801,12 +818,12 @@ interface PubNub : * @param spacesPermissions List of all space grants * @param usersPermissions List of all userId grants */ - fun grantToken( + actual fun grantToken( ttl: Int, - meta: Any? = null, - authorizedUserId: UserId? = null, - spacesPermissions: List = emptyList(), - usersPermissions: List = emptyList(), + meta: Any?, + authorizedUserId: UserId?, + spacesPermissions: List, + usersPermissions: List, ): GrantToken /** @@ -814,12 +831,12 @@ interface PubNub : * * @param token Existing token with embedded permissions. */ - fun revokeToken(token: String): RevokeToken + actual fun revokeToken(token: String): RevokeToken /** * Returns a 17 digit precision Unix epoch from the server. */ - fun time(): Time + actual fun time(): Time /** * Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each. @@ -839,13 +856,13 @@ interface PubNub : * Default is `false`. * @param includeCustom Include respective additional fields in the response. */ - fun getAllChannelMetadata( - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, + actual fun getAllChannelMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, ): GetAllChannelMetadata /** @@ -854,9 +871,9 @@ interface PubNub : * @param channel Channel name. * @param includeCustom Include respective additional fields in the response. */ - fun getChannelMetadata( + actual fun getChannelMetadata( channel: String, - includeCustom: Boolean = false, + includeCustom: Boolean, ): GetChannelMetadata /** @@ -868,14 +885,14 @@ interface PubNub : * @param custom Object with supported data types. * @param includeCustom Include respective additional fields in the response. */ - fun setChannelMetadata( + actual fun setChannelMetadata( channel: String, - name: String? = null, - description: String? = null, - custom: Any? = null, - includeCustom: Boolean = false, - type: String? = null, - status: String? = null, + name: String?, + description: String?, + custom: Any?, + includeCustom: Boolean, + type: String?, + status: String?, ): SetChannelMetadata /** @@ -883,7 +900,7 @@ interface PubNub : * * @param channel Channel name. */ - fun removeChannelMetadata(channel: String): RemoveChannelMetadata + actual fun removeChannelMetadata(channel: String): RemoveChannelMetadata /** * Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each. @@ -903,13 +920,13 @@ interface PubNub : * Default is `false`. * @param includeCustom Include respective additional fields in the response. */ - fun getAllUUIDMetadata( - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, + actual fun getAllUUIDMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, ): GetAllUUIDMetadata /** @@ -918,9 +935,9 @@ interface PubNub : * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. * @param includeCustom Include respective additional fields in the response. */ - fun getUUIDMetadata( - uuid: String? = null, - includeCustom: Boolean = false, + actual fun getUUIDMetadata( + uuid: String?, + includeCustom: Boolean, ): GetUUIDMetadata /** @@ -934,16 +951,16 @@ interface PubNub : * @param custom Object with supported data types. * @param includeCustom Include respective additional fields in the response. */ - fun setUUIDMetadata( - uuid: String? = null, - name: String? = null, - externalId: String? = null, - profileUrl: String? = null, - email: String? = null, - custom: Any? = null, - includeCustom: Boolean = false, - type: String? = null, - status: String? = null, + actual fun setUUIDMetadata( + uuid: String?, + name: String?, + externalId: String?, + profileUrl: String?, + email: String?, + custom: Any?, + includeCustom: Boolean, + type: String?, + status: String?, ): SetUUIDMetadata /** @@ -951,7 +968,7 @@ interface PubNub : * * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. */ - fun removeUUIDMetadata(uuid: String? = null): RemoveUUIDMetadata + actual fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata /** * The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions. @@ -973,15 +990,15 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - fun getMemberships( - uuid: String? = null, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeChannelDetails: PNChannelDetailsLevel? = null, + actual fun getMemberships( + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, ): GetMemberships /** @@ -1031,16 +1048,16 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - fun setMemberships( + actual fun setMemberships( channels: List, - uuid: String? = null, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeChannelDetails: PNChannelDetailsLevel? = null, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, ): ManageMemberships /** @@ -1064,16 +1081,16 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - fun removeMemberships( + actual fun removeMemberships( channels: List, - uuid: String? = null, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeChannelDetails: PNChannelDetailsLevel? = null, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, ): ManageMemberships /** @@ -1098,17 +1115,17 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - fun manageMemberships( + actual fun manageMemberships( channelsToSet: List, channelsToRemove: List, - uuid: String? = null, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeChannelDetails: PNChannelDetailsLevel? = null, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, ): ManageMemberships /** @@ -1156,15 +1173,15 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - fun getChannelMembers( + actual fun getChannelMembers( channel: String, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, ): GetChannelMembers /** @@ -1214,16 +1231,16 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - fun setChannelMembers( + actual fun setChannelMembers( channel: String, uuids: List, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, ): ManageChannelMembers /** @@ -1272,16 +1289,16 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - fun removeChannelMembers( + actual fun removeChannelMembers( channel: String, uuids: List, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, ): ManageChannelMembers /** @@ -1306,17 +1323,17 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - fun manageChannelMembers( + actual fun manageChannelMembers( channel: String, uuidsToSet: Collection, uuidsToRemove: Collection, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, ): ManageChannelMembers /** @@ -1363,10 +1380,10 @@ interface PubNub : * @param limit Number of files to return. Minimum value is 1, and maximum is 100. Default value is 100. * @param next Previously-returned cursor bookmark for fetching the next page. @see [PNPage.PNNext] */ - fun listFiles( + actual fun listFiles( channel: String, - limit: Int? = null, - next: PNPage.PNNext? = null, + limit: Int?, + next: PNPage.PNNext?, ): ListFiles /** @@ -1376,7 +1393,7 @@ interface PubNub : * @param fileName Name under which the uploaded file is stored. * @param fileId Unique identifier for the file, assigned during upload. */ - fun getFileUrl( + actual fun getFileUrl( channel: String, fileName: String, fileId: String, @@ -1405,7 +1422,7 @@ interface PubNub : * @param fileName Name under which the uploaded file is stored. * @param fileId Unique identifier for the file, assigned during upload. */ - fun deleteFile( + actual fun deleteFile( channel: String, fileName: String, fileId: String, @@ -1435,14 +1452,14 @@ interface PubNub : * If not specified, then the history configuration of the key is used. * */ - fun publishFileMessage( + actual fun publishFileMessage( channel: String, fileName: String, fileId: String, - message: Any? = null, - meta: Any? = null, - ttl: Int? = null, - shouldStore: Boolean? = null, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, ): PublishFileMessage /** @@ -1463,11 +1480,11 @@ interface PubNub : * @param withPresence Also subscribe to related presence channel. * @param withTimetoken A timetoken to start the subscribe loop from. */ - fun subscribe( - channels: List = emptyList(), - channelGroups: List = emptyList(), - withPresence: Boolean = false, - withTimetoken: Long = 0L, + actual fun subscribe( + channels: List, + channelGroups: List, + withPresence: Boolean, + withTimetoken: Long, ) /** @@ -1487,8 +1504,8 @@ interface PubNub : * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. */ - fun unsubscribe( - channels: List = emptyList(), - channelGroups: List = emptyList(), + actual fun unsubscribe( + channels: List, + channelGroups: List, ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/callbacks/SubscribeCallback.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/callbacks/SubscribeCallback.kt similarity index 99% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/callbacks/SubscribeCallback.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/callbacks/SubscribeCallback.kt index 1278683ea..8c52c47b4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/callbacks/SubscribeCallback.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/callbacks/SubscribeCallback.kt @@ -9,4 +9,4 @@ import com.pubnub.api.v2.callbacks.StatusListener * * Setting explicit [StatusListener] and/or [EventListener] should be preferred. */ -abstract class SubscribeCallback : StatusListener, EventListener +abstract class SubscribeCallback : StatusListener, EventListener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt similarity index 79% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt index 101b93675..2d943abc4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt @@ -6,7 +6,7 @@ import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult /** * @see [com.pubnub.api.PubNub.deleteMessages] */ -interface DeleteMessages : Endpoint { +actual interface DeleteMessages : Endpoint { val channels: List val start: Long? val end: Long? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/FetchMessages.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt similarity index 86% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/FetchMessages.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt index 440697fba..461e0478f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/FetchMessages.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt @@ -7,7 +7,7 @@ import com.pubnub.api.models.consumer.history.PNFetchMessagesResult /** * @see [PubNub.fetchMessages] */ -interface FetchMessages : Endpoint { +actual interface FetchMessages : Endpoint { val channels: List val page: PNBoundedPage val includeUUID: Boolean diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/History.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/History.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/History.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/History.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/MessageCounts.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt similarity index 78% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/MessageCounts.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt index a2a56301c..c15b8c2e2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/MessageCounts.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt @@ -6,7 +6,7 @@ import com.pubnub.api.models.consumer.history.PNMessageCountResult /** * @see [PubNub.messageCounts] */ -interface MessageCounts : Endpoint { +actual interface MessageCounts : Endpoint { val channels: List val channelsTimetoken: List } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/Time.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/Time.kt new file mode 100644 index 000000000..efa9cea26 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/Time.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.PNTimeResult + +/** + * @see [PubNub.time] + */ +actual interface Time : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/access/Grant.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/access/Grant.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/access/Grant.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/access/Grant.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt similarity index 73% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt index 29d531a1a..9f73a9895 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt @@ -3,6 +3,6 @@ package com.pubnub.api.endpoints.access import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult -interface GrantToken : Endpoint { +actual interface GrantToken : Endpoint { val ttl: Int } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt new file mode 100644 index 000000000..2196e6142 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt @@ -0,0 +1,5 @@ +package com.pubnub.api.endpoints.access + +import com.pubnub.api.Endpoint + +actual interface RevokeToken : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt similarity index 76% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt index b3a76ef64..05800fc91 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt @@ -6,7 +6,7 @@ import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelRes /** * @see [PubNub.addChannelsToChannelGroup] */ -interface AddChannelChannelGroup : Endpoint { +actual interface AddChannelChannelGroup : Endpoint { val channelGroup: String val channels: List } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt similarity index 73% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt index dbcd0a888..ba95d2a4e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt @@ -6,6 +6,6 @@ import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsRe /** * @see [PubNub.listChannelsForChannelGroup] */ -interface AllChannelsChannelGroup : Endpoint { +actual interface AllChannelsChannelGroup : Endpoint { val channelGroup: String } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt similarity index 74% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt index 14a48ba4c..7fb796914 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt @@ -6,6 +6,6 @@ import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupRe /** * @see [PubNub.deleteChannelGroup] */ -interface DeleteChannelGroup : Endpoint { +actual interface DeleteChannelGroup : Endpoint { val channelGroup: String } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt new file mode 100644 index 000000000..6e9ad86eb --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.channel_groups + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult + +/** + * @see [PubNub.listAllChannelGroups] + */ +actual interface ListAllChannelGroup : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt similarity index 75% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt index ea652f101..0def8759b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt @@ -6,7 +6,7 @@ import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannel /** * @see [PubNub.removeChannelsFromChannelGroup] */ -interface RemoveChannelChannelGroup : Endpoint { +actual interface RemoveChannelChannelGroup : Endpoint { val channelGroup: String val channels: List } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt new file mode 100644 index 000000000..c2eb3c09c --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNDeleteFileResult + +/** + * @see [PubNub.deleteFile] + */ +actual interface DeleteFile : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt new file mode 100644 index 000000000..2e52bf2f7 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNFileUrlResult + +/** + * @see [PubNub.getFileUrl] + */ +actual interface GetFileUrl : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt new file mode 100644 index 000000000..8317a3103 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNListFilesResult + +/** + * @see [PubNub.listFiles] + */ +actual interface ListFiles : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt new file mode 100644 index 000000000..acab631fd --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult + +/** + * @see [PubNub.publishFileMessage] + */ +actual interface PublishFileMessage : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/SendFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/files/SendFile.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt similarity index 82% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt index 2402dbec3..20cc5f327 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt @@ -7,8 +7,7 @@ import com.pubnub.api.models.consumer.message_actions.PNMessageAction /** * @see [PubNub.addMessageAction] */ -interface AddMessageAction : - Endpoint { +actual interface AddMessageAction : Endpoint { val channel: String val messageAction: PNMessageAction } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt similarity index 80% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt index c1e677b6e..f1e7f5495 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt @@ -7,8 +7,7 @@ import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult /** * @see [PubNub.getMessageActions] */ -interface GetMessageActions : - Endpoint { +actual interface GetMessageActions : Endpoint { val channel: String val page: PNBoundedPage } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt similarity index 89% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt index 4c3680280..779ed51de 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt @@ -6,7 +6,7 @@ import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResul /** * @see [PubNub.removeMessageAction] */ -interface RemoveMessageAction : +actual interface RemoveMessageAction : Endpoint { val channel: String val messageTimetoken: Long diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt similarity index 86% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt index da8554f15..232f243c8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt @@ -6,5 +6,5 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResu /** * @see [PubNub.getAllChannelMetadata] */ -interface GetAllChannelMetadata : +actual interface GetAllChannelMetadata : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt new file mode 100644 index 000000000..813332a70 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult + +/** + * @see [PubNub.getChannelMetadata] + */ +actual interface GetChannelMetadata : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt new file mode 100644 index 000000000..6513e3545 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt @@ -0,0 +1,6 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult + +actual interface RemoveChannelMetadata : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt new file mode 100644 index 000000000..f85e7f2ff --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.channel + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult + +/** + * @see [PubNub.setChannelMetadata] + */ +actual interface SetChannelMetadata : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt new file mode 100644 index 000000000..dbcc9b56e --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.member + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult + +/** + * @see [PubNub.getChannelMembers] + */ +actual interface GetChannelMembers : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt new file mode 100644 index 000000000..78b4b59d4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.member + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult + +/** + * @see [PubNub.manageChannelMembers] + */ +actual interface ManageChannelMembers : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt new file mode 100644 index 000000000..688f01445 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.membership + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult + +/** + * @see [PubNub.getMemberships] + */ +actual interface GetMemberships : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt new file mode 100644 index 000000000..f93494de5 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.membership + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult + +/** + * @see [PubNub.manageMemberships] + */ +actual interface ManageMemberships : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt new file mode 100644 index 000000000..e013dd743 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.uuid + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult + +/** + * @see [PubNub.getAllUUIDMetadata] + */ +actual interface GetAllUUIDMetadata : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt similarity index 75% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt index a735d3488..3c947884f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt @@ -6,7 +6,6 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult /** * @see [PubNub.getUUIDMetadata] */ -interface GetUUIDMetadata : - Endpoint { +actual interface GetUUIDMetadata : Endpoint { val uuid: String } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt similarity index 70% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt index fc3c004fc..b089f0936 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt @@ -3,7 +3,6 @@ package com.pubnub.api.endpoints.objects.uuid import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -interface RemoveUUIDMetadata : - Endpoint { +actual interface RemoveUUIDMetadata : Endpoint { val uuid: String? } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt new file mode 100644 index 000000000..0216f93fe --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.objects.uuid + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult + +/** + * @see [PubNub.setUUIDMetadata] + */ +actual interface SetUUIDMetadata : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/GetState.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt similarity index 82% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/GetState.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt index e9d1877e3..71e047b7b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/GetState.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt @@ -6,7 +6,7 @@ import com.pubnub.api.models.consumer.presence.PNGetStateResult /** * @see [PubNub.getPresenceState] */ -interface GetState : Endpoint { +actual interface GetState : Endpoint { val channels: List val channelGroups: List val uuid: String diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt similarity index 84% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt index 9cbe230de..6594e1616 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt @@ -6,7 +6,7 @@ import com.pubnub.api.models.consumer.presence.PNHereNowResult /** * @see [PubNub.hereNow] */ -interface HereNow : Endpoint { +actual interface HereNow : Endpoint { val channels: List val channelGroups: List val includeState: Boolean diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/SetState.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt similarity index 83% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/SetState.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt index d6d82b308..a6798d8db 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/SetState.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt @@ -6,7 +6,7 @@ import com.pubnub.api.models.consumer.presence.PNSetStateResult /** * @see [PubNub.setPresenceState] */ -interface SetState : Endpoint { +actual interface SetState : Endpoint { val channels: List val channelGroups: List val state: Any diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt similarity index 77% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt index 04e08396f..b042cfe8a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt @@ -6,6 +6,6 @@ import com.pubnub.api.models.consumer.presence.PNWhereNowResult /** * @see [PubNub.whereNow] */ -interface WhereNow : Endpoint { +actual interface WhereNow : Endpoint { val uuid: String } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt similarity index 85% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt index 45294bbef..adc729da5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt @@ -6,7 +6,7 @@ import com.pubnub.api.models.consumer.PNPublishResult /** * @see [PubNub.publish] */ -interface Publish : Endpoint { +actual interface Publish : Endpoint { val message: Any val channel: String val meta: Any? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt similarity index 79% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt index da297d2ff..688958801 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt @@ -6,7 +6,7 @@ import com.pubnub.api.models.consumer.PNPublishResult /** * @see [PubNub.signal] */ -interface Signal : Endpoint { +actual interface Signal : Endpoint { val channel: String val message: Any } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt new file mode 100644 index 000000000..dc967b265 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushAddChannelResult + +/** + * @see [PubNub.addPushNotificationsOnChannels] + */ +actual interface AddChannelsToPush : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt new file mode 100644 index 000000000..2b02a22ca --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult + +/** + * @see [PubNub.auditPushChannelProvisions] + */ +actual interface ListPushProvisions : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt new file mode 100644 index 000000000..7137ab2d5 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult + +/** + * @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken] + */ +actual interface RemoveAllPushChannelsForDevice : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt new file mode 100644 index 000000000..dc50d0cc7 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.push + +import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult + +/** + * @see [PubNub.removePushNotificationsFromChannels] + */ +actual interface RemoveChannelsFromPush : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt new file mode 100644 index 000000000..5af0c54ae --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt @@ -0,0 +1,13 @@ +package com.pubnub.api.v2 + +import com.pubnub.api.UserId +import com.pubnub.api.crypto.CryptoModule + +actual fun createPNConfiguration( + userId: UserId, + subscribeKey: String +): PNConfiguration { + return PNConfiguration.builder(userId, subscribeKey).build() +} + +actual typealias CryptoModule = CryptoModule \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/PNConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt similarity index 98% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/PNConfiguration.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt index 5b43f6b67..7964a87a0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/PNConfiguration.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt @@ -16,7 +16,7 @@ import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509ExtendedTrustManager -interface PNConfiguration : BasePNConfiguration { +actual interface PNConfiguration : BasePNConfiguration { companion object { @JvmStatic fun builder( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt similarity index 98% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt index 15405d192..f16513c2b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt @@ -12,7 +12,7 @@ import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -interface EventListener : BaseEventListener { +actual interface EventListener : BaseEventListener { /** * Receive messages at subscribed channels. * @@ -84,4 +84,4 @@ interface EventListener : BaseEventListener { pubnub: PubNub, result: PNFileEventResult, ) {} -} +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/callbacks/StatusEmitter.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusEmitter.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/callbacks/StatusEmitter.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusEmitter.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt similarity index 94% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt index b3c6d2522..f134453d5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt @@ -7,7 +7,7 @@ import com.pubnub.api.models.consumer.PNStatus * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for * PubNub connection status changes. */ -interface StatusListener : BaseStatusListener { +actual interface StatusListener : BaseStatusListener { /** * Receive status updates from the PubNub client, such as: * * [PNStatusCategory.PNConnectedCategory], @@ -26,4 +26,4 @@ interface StatusListener : BaseStatusListener { pubnub: PubNub, status: PNStatus, ) -} +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/entities/Channel.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/Channel.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/entities/Channel.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/Channel.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt deleted file mode 100644 index 5660b3ba2..000000000 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.pubnub.api.models.consumer.objects - -import com.pubnub.internal.models.consumer.objects.PNRemoveMetadataResult - -data class PNRemoveMetadataResult(val status: Int) { - companion object { - fun from(data: PNRemoveMetadataResult): com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult { - return com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult(data.status) - } - } -} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/member/PNMemberArrayResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/member/PNMemberArrayResult.kt deleted file mode 100644 index 7dd599957..000000000 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/member/PNMemberArrayResult.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.pubnub.api.models.consumer.objects.member - -import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult - -data class PNMemberArrayResult( - val status: Int, - val data: Collection, - val totalCount: Int?, - val next: PNPage.PNNext?, - val prev: PNPage.PNPrev?, -) { - companion object { - fun from(data: PNMemberArrayResult): com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult { - return PNMemberArrayResult( - data.status, - data.data.map(PNMember::from), - data.totalCount, - data.next, - data.prev, - ) - } - } -} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt deleted file mode 100644 index 3e9c772e0..000000000 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.pubnub.api.models.consumer.objects.uuid - -import com.pubnub.api.models.consumer.objects.PNPage - -data class PNUUIDMetadataArrayResult( - val status: Int, - val data: Collection, - val totalCount: Int?, - val next: PNPage.PNNext?, - val prev: PNPage.PNPrev?, -) { - companion object { - fun from(data: com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataArrayResult): PNUUIDMetadataArrayResult { - return PNUUIDMetadataArrayResult( - data.status, - data.data, - data.totalCount, - data.next, - data.prev, - ) - } - } -} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt deleted file mode 100644 index e6e060401..000000000 --- a/pubnub-kotlin/pubnub-kotlin-api/src/main/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.pubnub.api.models.consumer.objects.uuid - -import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataResult - -data class PNUUIDMetadataResult( - val status: Int, - val data: PNUUIDMetadata?, -) { - companion object { - fun from(data: PNUUIDMetadataResult): com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult { - return com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult( - data.status, - data.data, - ) - } - } -} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-impl/build.gradle.kts index a816b5684..17a77976a 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-impl/build.gradle.kts @@ -1,6 +1,7 @@ plugins { alias(libs.plugins.benmanes.versions) - id("pubnub.shared") + id("pubnub.kotlin-library") + id("pubnub.test") id("pubnub.integration-test") } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/HeartbeatIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/HeartbeatIntegrationTest.kt index b9af72301..594f45f47 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/HeartbeatIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/HeartbeatIntegrationTest.kt @@ -2,6 +2,7 @@ package com.pubnub.api.integration import com.pubnub.api.PubNub import com.pubnub.api.UserId +import com.pubnub.api.callbacks.SubscribeCallback import com.pubnub.api.enums.PNStatusCategory import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult @@ -42,7 +43,7 @@ class HeartbeatIntegrationTest : BaseIntegrationTest() { } observer.addListener( - object : com.pubnub.api.callbacks.SubscribeCallback() { + object : SubscribeCallback() { override fun status( pubnub: PubNub, status: PNStatus, diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt index b59056bbb..1b7314018 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt @@ -75,7 +75,6 @@ import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.api.v2.BasePNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener import com.pubnub.api.v2.entities.BaseChannel @@ -117,7 +116,7 @@ import java.io.InputStream private const val PNSDK_PUBNUB_KOTLIN = "PubNub-Kotlin" class PubNubImpl( - override val configuration: BasePNConfiguration, + override val configuration: com.pubnub.api.v2.PNConfiguration, ) : BasePubNubImpl( configuration, PNSDK_PUBNUB_KOTLIN, diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantImpl.kt index e511a9ed0..a564e474a 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantImpl.kt @@ -3,6 +3,7 @@ package com.pubnub.internal.endpoints.access import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction import com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult +import com.pubnub.api.models.consumer.access_manager.PNAccessManagerKeyData import com.pubnub.internal.DelegatingEndpoint import com.pubnub.internal.PubNubImpl @@ -18,6 +19,36 @@ class GrantImpl internal constructor(grant: GrantEndpoint) : override fun convertAction( remoteAction: ExtendedRemoteAction, ): ExtendedRemoteAction { - return MappingRemoteAction(remoteAction, PNAccessManagerGrantResult.Companion::from) + return MappingRemoteAction(remoteAction, ::from) } } + +fun from(result: com.pubnub.internal.models.consumer.access_manager.PNAccessManagerGrantResult): PNAccessManagerGrantResult { + with(result) { + return PNAccessManagerGrantResult( + level, + ttl, + subscribeKey, + channels.toApi(), + channelGroups.toApi(), + ) + } +} + +private fun Map?>.toApi(): Map?> { + return mapValues { + it.value?.mapValues { from(it.value) } + } +} + +fun from(value: com.pubnub.internal.models.consumer.access_manager.PNAccessManagerKeyData): PNAccessManagerKeyData { + return PNAccessManagerKeyData().apply { + this.readEnabled = value.readEnabled + this.manageEnabled = value.manageEnabled + this.writeEnabled = value.writeEnabled + this.deleteEnabled = value.deleteEnabled + this.getEnabled = value.getEnabled + this.updateEnabled = value.updateEnabled + this.joinEnabled = value.joinEnabled + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileImpl.kt index 7c3d7dadd..8cfcb6a3e 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileImpl.kt @@ -11,4 +11,4 @@ import com.pubnub.internal.PubNubImpl class DeleteFileImpl internal constructor(deleteFile: DeleteFileInterface) : DeleteFileInterface by deleteFile, DeleteFile, - EndpointImpl(deleteFile) + EndpointImpl(deleteFile) diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataImpl.kt index 5ff0a9b8c..732ef8833 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataImpl.kt @@ -4,6 +4,7 @@ import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult import com.pubnub.internal.DelegatingEndpoint +import com.pubnub.internal.models.from class RemoveChannelMetadataImpl internal constructor(removeChannelMetadata: RemoveChannelMetadataEndpoint) : DelegatingEndpoint( @@ -14,6 +15,6 @@ class RemoveChannelMetadataImpl internal constructor(removeChannelMetadata: Remo override fun convertAction( remoteAction: ExtendedRemoteAction, ): ExtendedRemoteAction { - return MappingRemoteAction(remoteAction, PNRemoveMetadataResult::from) + return MappingRemoteAction(remoteAction, ::from) } } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersImpl.kt index b3999ef8e..5b24553a6 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersImpl.kt @@ -5,6 +5,7 @@ import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction import com.pubnub.internal.DelegatingEndpoint import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.internal.models.from /** * @see [PubNubImpl.getChannelMembers] @@ -20,7 +21,7 @@ class GetChannelMembersImpl internal constructor(getChannelMembers: GetChannelMe ): ExtendedRemoteAction { return MappingRemoteAction( remoteAction, - com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult::from, + ::from, ) } } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersImpl.kt index f7d74aaae..582356e99 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersImpl.kt @@ -5,6 +5,7 @@ import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction import com.pubnub.internal.DelegatingEndpoint import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.internal.models.from /** * @see [PubNubImpl.manageChannelMembers] @@ -20,7 +21,7 @@ class ManageChannelMembersImpl internal constructor(manageChannelMembers: Manage ): ExtendedRemoteAction { return MappingRemoteAction( remoteAction, - com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult::from, + ::from, ) } } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt index 9ffb1af4d..512cef1fe 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt @@ -5,6 +5,7 @@ import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction import com.pubnub.internal.DelegatingEndpoint import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataArrayResult +import com.pubnub.internal.models.from /** * @see [PubNubImpl.getAllUUIDMetadata] @@ -20,7 +21,7 @@ class GetAllUUIDMetadataImpl internal constructor(getAllUUIDMetadata: GetAllUUID ): ExtendedRemoteAction { return MappingRemoteAction( remoteAction, - com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult.Companion::from, + ::from, ) } } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataImpl.kt index c62bde4bb..a294bc755 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataImpl.kt @@ -5,6 +5,7 @@ import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.internal.DelegatingEndpoint import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.models.from import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataResult as PNUUIDMetadataResultInternal /** @@ -17,6 +18,6 @@ class GetUUIDMetadataImpl internal constructor(getUUIDMetadata: GetUUIDMetadataE override fun convertAction( remoteAction: ExtendedRemoteAction, ): ExtendedRemoteAction { - return MappingRemoteAction(remoteAction, PNUUIDMetadataResult.Companion::from) + return MappingRemoteAction(remoteAction, ::from) } } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt index 6dd3685b7..494bcd94f 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt @@ -4,6 +4,7 @@ import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult import com.pubnub.internal.DelegatingEndpoint +import com.pubnub.internal.models.from class RemoveUUIDMetadataImpl internal constructor(removeUUIDMetadata: RemoveUUIDMetadataEndpoint) : DelegatingEndpoint( @@ -14,6 +15,6 @@ class RemoveUUIDMetadataImpl internal constructor(removeUUIDMetadata: RemoveUUID override fun convertAction( remoteAction: ExtendedRemoteAction, ): ExtendedRemoteAction { - return MappingRemoteAction(remoteAction, PNRemoveMetadataResult.Companion::from) + return MappingRemoteAction(remoteAction, ::from) } } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataImpl.kt index 2e6366b66..4d9c20c8c 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataImpl.kt @@ -5,6 +5,7 @@ import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction import com.pubnub.internal.DelegatingEndpoint import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.internal.models.from /** * @see [PubNubImpl.setUUIDMetadata] @@ -18,6 +19,6 @@ class SetUUIDMetadataImpl internal constructor(setUUIDMetadata: SetUUIDMetadataE override fun convertAction( remoteAction: ExtendedRemoteAction, ): ExtendedRemoteAction { - return MappingRemoteAction(remoteAction, com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult::from) + return MappingRemoteAction(remoteAction, ::from) } } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/Converters.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/Converters.kt index 846f172d5..14662b545 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/Converters.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/Converters.kt @@ -19,15 +19,18 @@ import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNMemberKey import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult import com.pubnub.api.models.consumer.objects.PNSortKey import com.pubnub.api.models.consumer.objects.SortField import com.pubnub.api.models.consumer.objects.member.MemberInput +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult import com.pubnub.api.models.consumer.presence.PNWhereNowResult import com.pubnub.api.models.consumer.pubsub.BasePubSubResult import com.pubnub.internal.SpaceId @@ -333,17 +336,17 @@ internal fun PNSortKey.toInternal(): com.pubnub.internal.models.consumer.objects.PNSortKey { @Suppress("UNCHECKED_CAST") val sortKey: T2 = - when (this.key) { + when (val key = this.key) { is PNKey -> { - com.pubnub.internal.models.consumer.objects.PNKey.valueOf(this.key.name) as T2 + com.pubnub.internal.models.consumer.objects.PNKey.valueOf(key.name) as T2 } is PNMembershipKey -> { - com.pubnub.internal.models.consumer.objects.PNMembershipKey.valueOf(this.key.name) as T2 + com.pubnub.internal.models.consumer.objects.PNMembershipKey.valueOf(key.name) as T2 } is PNMemberKey -> { - com.pubnub.internal.models.consumer.objects.PNMemberKey.valueOf(this.key.name) as T2 + com.pubnub.internal.models.consumer.objects.PNMemberKey.valueOf(key.name) as T2 } else -> { @@ -401,7 +404,7 @@ private fun MemberInput.toInternal(): com.pubnub.internal.models.consumer.object fun com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult.toApi(): PNChannelMembershipArrayResult { return PNChannelMembershipArrayResult( status = status, - data = data.map(PNChannelMembership.Companion::from), + data = data.map(::from), totalCount = totalCount, next = next, prev = prev, @@ -411,3 +414,54 @@ fun com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipAr fun com.pubnub.internal.models.consumer.presence.PNWhereNowResult.toApi(): PNWhereNowResult { return PNWhereNowResult(channels) } + +fun from(data: com.pubnub.internal.models.consumer.objects.PNRemoveMetadataResult): PNRemoveMetadataResult { + return PNRemoveMetadataResult(data.status) +} + +fun from(data: com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult): com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult { + return PNMemberArrayResult( + data.status, + data.data.map(::from), + data.totalCount, + data.next, + data.prev, + ) +} + +fun from(data: com.pubnub.internal.models.consumer.objects.member.PNMember): com.pubnub.api.models.consumer.objects.member.PNMember { + return com.pubnub.api.models.consumer.objects.member.PNMember( + data.uuid, + data.custom, + data.updated, + data.eTag, + data.status, + ) +} + +fun from(data: com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership): PNChannelMembership { + return PNChannelMembership( + data.channel, + data.custom, + data.updated, + data.eTag, + data.status, + ) +} + +fun from(data: com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataArrayResult): PNUUIDMetadataArrayResult { + return PNUUIDMetadataArrayResult( + data.status, + data.data, + data.totalCount, + data.next, + data.prev, + ) +} + +fun from(data: com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataResult): com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult { + return com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult( + data.status, + data.data, + ) +} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt index b02475694..c0f0923cf 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt @@ -1,6 +1,7 @@ package com.pubnub.internal.v2.callbacks import com.pubnub.api.PubNub +import com.pubnub.api.callbacks.SubscribeCallback import com.pubnub.api.models.consumer.PNStatus import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test @@ -9,14 +10,14 @@ internal class DelegatingSubscribeCallbackTest { @Test fun testEquals() { val statusListener = - object : com.pubnub.api.callbacks.SubscribeCallback() { + object : SubscribeCallback() { override fun status( pubnub: PubNub, status: PNStatus, ) {} } val otherStatusListener = - object : com.pubnub.api.callbacks.SubscribeCallback() { + object : SubscribeCallback() { override fun status( pubnub: PubNub, status: PNStatus, diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts new file mode 100644 index 000000000..1c9cf62d1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -0,0 +1,41 @@ +plugins { + alias(libs.plugins.benmanes.versions) + id("pubnub.shared") + kotlin("multiplatform") +} + +kotlin { + jvmToolchain(8) + js { + browser { + } + binaries.executable() + } + jvm { + compilations.all { + compileTaskProvider.configure { + compilerOptions { + freeCompilerArgs.add("-Xexpect-actual-classes") + javaParameters.set(true) + } + } + } + } + + sourceSets { + val commonMain by getting { + dependencies { + api(project(":pubnub-kotlin:pubnub-kotlin-api")) + api(project(":pubnub-core:pubnub-core-api")) + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0-RC.2") + } + } + + val jvmMain by getting { + dependencies { + implementation(project(":pubnub-core:pubnub-core-impl")) + implementation(libs.slf4j) + } + } + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt new file mode 100644 index 000000000..df412f80e --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt @@ -0,0 +1,1182 @@ +//import com.pubnub.api.CustomObject +//import com.pubnub.api.PubNub +//import com.pubnub.api.UserId +//import com.pubnub.api.callbacks.Listener +//import com.pubnub.api.endpoints.DeleteMessages +//import com.pubnub.api.endpoints.FetchMessages +//import com.pubnub.api.endpoints.MessageCounts +//import com.pubnub.api.endpoints.Time +//import com.pubnub.api.endpoints.access.GrantToken +//import com.pubnub.api.endpoints.access.RevokeToken +//import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +//import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +//import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +//import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +//import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +//import com.pubnub.api.endpoints.files.DeleteFile +//import com.pubnub.api.endpoints.files.GetFileUrl +//import com.pubnub.api.endpoints.files.ListFiles +//import com.pubnub.api.endpoints.files.PublishFileMessage +//import com.pubnub.api.endpoints.message_actions.AddMessageAction +//import com.pubnub.api.endpoints.message_actions.GetMessageActions +//import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +//import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +//import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +//import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +//import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +//import com.pubnub.api.endpoints.objects.member.GetChannelMembers +//import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +//import com.pubnub.api.endpoints.objects.membership.GetMemberships +//import com.pubnub.api.endpoints.objects.membership.ManageMemberships +//import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +//import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +//import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +//import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +//import com.pubnub.api.endpoints.presence.GetState +//import com.pubnub.api.endpoints.presence.HereNow +//import com.pubnub.api.endpoints.presence.SetState +//import com.pubnub.api.endpoints.presence.WhereNow +//import com.pubnub.api.endpoints.pubsub.Publish +//import com.pubnub.api.endpoints.pubsub.Signal +//import com.pubnub.api.endpoints.push.AddChannelsToPush +//import com.pubnub.api.endpoints.push.ListPushProvisions +//import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +//import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +//import com.pubnub.api.enums.PNPushEnvironment +//import com.pubnub.api.enums.PNPushType +//import com.pubnub.api.models.consumer.PNBoundedPage +//import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions +//import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions +//import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +//import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +//import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +//import com.pubnub.api.models.consumer.message_actions.PNMessageAction +//import com.pubnub.api.models.consumer.objects.PNKey +//import com.pubnub.api.models.consumer.objects.PNMemberKey +//import com.pubnub.api.models.consumer.objects.PNMembershipKey +//import com.pubnub.api.models.consumer.objects.PNPage +//import com.pubnub.api.models.consumer.objects.PNSortKey +//import com.pubnub.api.models.consumer.objects.member.MemberInput +//import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +//import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +//import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +//import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +//import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +//import com.pubnub.api.v2.PNConfiguration +//import com.pubnub.api.v2.callbacks.EventListener +//import com.pubnub.api.v2.callbacks.StatusListener +//import com.pubnub.test.createEndpoint +//import kotlinx.datetime.Clock +// +////package com.pubnub.test +//// +////import com.pubnub.api.Endpoint +////import com.pubnub.api.JsonElement +////import com.pubnub.api.PubNub +////import com.pubnub.api.UserId +////import com.pubnub.api.callbacks.Listener +////import com.pubnub.api.endpoints.pubsub.Publish +////import com.pubnub.api.enums.PNPushEnvironment +////import com.pubnub.api.enums.PNPushType +////import com.pubnub.api.models.consumer.PNBoundedPage +////import com.pubnub.api.models.consumer.PNPublishResult +////import com.pubnub.api.models.consumer.PNTimeResult +////import com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult +////import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions +////import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions +////import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +////import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +////import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult +////import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +////import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult +////import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult +////import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult +////import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult +////import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult +////import com.pubnub.api.models.consumer.files.PNDeleteFileResult +////import com.pubnub.api.models.consumer.files.PNFileUrlResult +////import com.pubnub.api.models.consumer.files.PNListFilesResult +////import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult +////import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult +////import com.pubnub.api.models.consumer.history.PNFetchMessagesResult +////import com.pubnub.api.models.consumer.history.PNMessageCountResult +////import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult +////import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult +////import com.pubnub.api.models.consumer.message_actions.PNMessageAction +////import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult +////import com.pubnub.api.models.consumer.objects.PNKey +////import com.pubnub.api.models.consumer.objects.PNMemberKey +////import com.pubnub.api.models.consumer.objects.PNMembershipKey +////import com.pubnub.api.models.consumer.objects.PNPage +////import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult +////import com.pubnub.api.models.consumer.objects.PNSortKey +////import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult +////import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult +////import com.pubnub.api.models.consumer.objects.member.MemberInput +////import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +////import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +////import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +////import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +////import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult +////import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +////import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult +////import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +////import com.pubnub.api.models.consumer.presence.PNGetStateResult +////import com.pubnub.api.models.consumer.presence.PNHereNowResult +////import com.pubnub.api.models.consumer.presence.PNSetStateResult +////import com.pubnub.api.models.consumer.presence.PNWhereNowResult +////import com.pubnub.api.models.consumer.pubsub.BasePubSubResult +////import com.pubnub.api.models.consumer.pubsub.PNMessageResult +////import com.pubnub.api.models.consumer.push.PNPushAddChannelResult +////import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult +////import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult +////import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult +////import com.pubnub.api.v2.PNConfiguration +////import com.pubnub.api.v2.callbacks.EventListener +////import com.pubnub.api.v2.callbacks.StatusListener +//// +////import kotlinx.datetime.Clock +//// +////expect fun createEndpoint(action: () -> T): Endpoint +//// +//class FakePubNub(override val configuration: PNConfiguration) : PubNub { +// override fun addListener(listener: EventListener) { +// TODO("Not yet implemented") +// } +// +// override fun addListener(listener: StatusListener) { +// TODO("Not yet implemented") +// } +// +// override fun removeListener(listener: Listener) { +// TODO("Not yet implemented") +// } +// +// override fun removeAllListeners() { +// TODO("Not yet implemented") +// } +// +// override fun publish( +// channel: String, +// message: Any, +// meta: Any?, +// shouldStore: Boolean?, +// usePost: Boolean, +// replicate: Boolean, +// ttl: Int? +// ): Publish { +// TODO("Not yet implemented") +// } +// +// override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { +// TODO("Not yet implemented") +// } +// +// override fun signal(channel: String, message: Any): Signal { +// TODO("Not yet implemented") +// } +// +// override fun getSubscribedChannels(): List { +// TODO("Not yet implemented") +// } +// +// override fun getSubscribedChannelGroups(): List { +// TODO("Not yet implemented") +// } +// +// override fun addPushNotificationsOnChannels( +// pushType: PNPushType, +// channels: List, +// deviceId: String, +// topic: String?, +// environment: PNPushEnvironment +// ): AddChannelsToPush { +// TODO("Not yet implemented") +// } +// +// override fun auditPushChannelProvisions( +// pushType: PNPushType, +// deviceId: String, +// topic: String?, +// environment: PNPushEnvironment +// ): ListPushProvisions { +// TODO("Not yet implemented") +// } +// +// override fun removePushNotificationsFromChannels( +// pushType: PNPushType, +// channels: List, +// deviceId: String, +// topic: String?, +// environment: PNPushEnvironment +// ): RemoveChannelsFromPush { +// TODO("Not yet implemented") +// } +// +// override fun removeAllPushNotificationsFromDeviceWithPushToken( +// pushType: PNPushType, +// deviceId: String, +// topic: String?, +// environment: PNPushEnvironment +// ): RemoveAllPushChannelsForDevice { +// TODO("Not yet implemented") +// } +// +// override fun fetchMessages( +// channels: List, +// page: PNBoundedPage, +// includeUUID: Boolean, +// includeMeta: Boolean, +// includeMessageActions: Boolean, +// includeMessageType: Boolean +// ): FetchMessages { +// TODO("Not yet implemented") +// } +// +// override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { +// TODO("Not yet implemented") +// } +// +// override fun messageCounts(channels: List, channelsTimetoken: List): MessageCounts { +// TODO("Not yet implemented") +// } +// +// override fun hereNow( +// channels: List, +// channelGroups: List, +// includeState: Boolean, +// includeUUIDs: Boolean +// ): HereNow { +// TODO("Not yet implemented") +// } +// +// override fun whereNow(uuid: String): WhereNow { +// TODO("Not yet implemented") +// } +// +// override fun setPresenceState( +// channels: List, +// channelGroups: List, +// state: Any, +// uuid: String +// ): SetState { +// TODO("Not yet implemented") +// } +// +// override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { +// TODO("Not yet implemented") +// } +// +// override fun presence(channels: List, channelGroups: List, connected: Boolean) { +// TODO("Not yet implemented") +// } +// +// override fun addMessageAction(channel: String, messageAction: PNMessageAction): AddMessageAction { +// TODO("Not yet implemented") +// } +// +// override fun removeMessageAction( +// channel: String, +// messageTimetoken: Long, +// actionTimetoken: Long +// ): RemoveMessageAction { +// TODO("Not yet implemented") +// } +// +// override fun getMessageActions(channel: String, page: PNBoundedPage): GetMessageActions { +// TODO("Not yet implemented") +// } +// +// override fun addChannelsToChannelGroup(channels: List, channelGroup: String): AddChannelChannelGroup { +// TODO("Not yet implemented") +// } +// +// override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { +// TODO("Not yet implemented") +// } +// +// override fun removeChannelsFromChannelGroup( +// channels: List, +// channelGroup: String +// ): RemoveChannelChannelGroup { +// TODO("Not yet implemented") +// } +// +// override fun listAllChannelGroups(): ListAllChannelGroup { +// TODO("Not yet implemented") +// } +// +// override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { +// TODO("Not yet implemented") +// } +// +// override fun grantToken( +// ttl: Int, +// meta: Any?, +// authorizedUUID: String?, +// channels: List, +// channelGroups: List, +// uuids: List +// ): GrantToken { +// TODO("Not yet implemented") +// } +// +// override fun grantToken( +// ttl: Int, +// meta: Any?, +// authorizedUserId: UserId?, +// spacesPermissions: List, +// usersPermissions: List +// ): GrantToken { +// TODO("Not yet implemented") +// } +// +// override fun revokeToken(token: String): RevokeToken { +// TODO("Not yet implemented") +// } +// +// override fun time(): Time { +// TODO("Not yet implemented") +// } +// +// override fun getAllChannelMetadata( +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean +// ): GetAllChannelMetadata { +// TODO("Not yet implemented") +// } +// +// override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { +// TODO("Not yet implemented") +// } +// +// override fun setChannelMetadata( +// channel: String, +// name: String?, +// description: String?, +// custom: Any?, +// includeCustom: Boolean, +// type: String?, +// status: String? +// ): SetChannelMetadata { +// TODO("Not yet implemented") +// } +// +// override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { +// TODO("Not yet implemented") +// } +// +// override fun getAllUUIDMetadata( +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean +// ): GetAllUUIDMetadata { +// TODO("Not yet implemented") +// } +// +// override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { +// TODO("Not yet implemented") +// } +// +// override fun setUUIDMetadata( +// uuid: String?, +// name: String?, +// externalId: String?, +// profileUrl: String?, +// email: String?, +// custom: CustomObject?, +// includeCustom: Boolean, +// type: String?, +// status: String? +// ): SetUUIDMetadata { +// return createEndpoint { +// val actualUuid = uuid ?: configuration.userId.value +// val result = userMetadata.compute(actualUuid) { a: String, b: PNUUIDMetadata? -> +// PNUUIDMetadata( +// actualUuid, +// name ?: b?.name, +// externalId ?: b?.externalId, +// profileUrl ?: b?.profileUrl, +// email ?: b?.email, +// custom ?: b?.custom, +// Clock.System.now().toString(), +// null, +// type ?: b?.type, +// status ?: b?.status +// ) +// } +// PNUUIDMetadataResult( +// 200, +// if (!includeCustom) { +// result?.copy(custom = null) +// } else { +// result +// } +// ) +// } +// } +// +// override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { +// TODO("Not yet implemented") +// } +// +// override fun getMemberships( +// uuid: String?, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeChannelDetails: PNChannelDetailsLevel? +// ): GetMemberships { +// TODO("Not yet implemented") +// } +// +// override fun setMemberships( +// channels: List, +// uuid: String?, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeChannelDetails: PNChannelDetailsLevel? +// ): ManageMemberships { +// TODO("Not yet implemented") +// } +// +// override fun removeMemberships( +// channels: List, +// uuid: String?, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeChannelDetails: PNChannelDetailsLevel? +// ): ManageMemberships { +// TODO("Not yet implemented") +// } +// +// override fun manageMemberships( +// channelsToSet: List, +// channelsToRemove: List, +// uuid: String?, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeChannelDetails: PNChannelDetailsLevel? +// ): ManageMemberships { +// TODO("Not yet implemented") +// } +// +// override fun getChannelMembers( +// channel: String, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeUUIDDetails: PNUUIDDetailsLevel? +// ): GetChannelMembers { +// TODO("Not yet implemented") +// } +// +// override fun setChannelMembers( +// channel: String, +// uuids: List, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeUUIDDetails: PNUUIDDetailsLevel? +// ): ManageChannelMembers { +// TODO("Not yet implemented") +// } +// +// override fun removeChannelMembers( +// channel: String, +// uuids: List, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeUUIDDetails: PNUUIDDetailsLevel? +// ): ManageChannelMembers { +// TODO("Not yet implemented") +// } +// +// override fun manageChannelMembers( +// channel: String, +// uuidsToSet: Collection, +// uuidsToRemove: Collection, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeUUIDDetails: PNUUIDDetailsLevel? +// ): ManageChannelMembers { +// TODO("Not yet implemented") +// } +// +// override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { +// TODO("Not yet implemented") +// } +// +// override fun getFileUrl(channel: String, fileName: String, fileId: String): GetFileUrl { +// TODO("Not yet implemented") +// } +// +// override fun deleteFile(channel: String, fileName: String, fileId: String): DeleteFile { +// TODO("Not yet implemented") +// } +// +// override fun publishFileMessage( +// channel: String, +// fileName: String, +// fileId: String, +// message: Any?, +// meta: Any?, +// ttl: Int?, +// shouldStore: Boolean? +// ): PublishFileMessage { +// TODO("Not yet implemented") +// } +// +// override fun subscribe( +// channels: List, +// channelGroups: List, +// withPresence: Boolean, +// withTimetoken: Long +// ) { +// TODO("Not yet implemented") +// } +// +// override fun unsubscribe(channels: List, channelGroups: List) { +// TODO("Not yet implemented") +// } +// +// override fun setToken(token: String?) { +// TODO("Not yet implemented") +// } +// +//} +//// +//// val messages: MutableList = mutableListOf() +//// val userMetadata: MutableMap = mutableMapOf() +//// val channelMetadata: MutableMap = mutableMapOf() +//// +//// /** +//// * Remove a listener. +//// * +//// * @param listener The listener to be removed, previously added with [addListener]. +//// */ +//// override fun removeListener(listener: Listener) { +//// TODO("Not yet implemented") +//// } +//// +//// /** +//// * Removes all listeners. +//// */ +//// override fun removeAllListeners() { +//// TODO("Not yet implemented") +//// } +//// +//// override fun publish( +//// channel: String, +//// message: Any, +//// meta: Any?, +//// shouldStore: Boolean?, +//// usePost: Boolean, +//// replicate: Boolean, +//// ttl: Int? +//// ): Publish { +//// return createEndpoint { +//// val tt = Clock.System.now().toEpochMilliseconds() / 1000 +//// messages.add( +//// PNMessageResult( +//// BasePubSubResult(channel, null, tt, null, configuration.userId.value), +//// message as JsonElement, +//// null +//// ) +//// ) +//// PNPublishResult(tt) +//// } +//// // TODO emit message +//// } +//// +//// +//// override fun fire( +//// channel: String, +//// message: Any, +//// meta: Any?, +//// usePost: Boolean, +//// ttl: Int? +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun signal(channel: String, message: Any): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun getSubscribedChannels(): List { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun getSubscribedChannelGroups(): List { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun addPushNotificationsOnChannels( +//// pushType: PNPushType, +//// channels: List, +//// deviceId: String, +//// topic: String?, +//// environment: PNPushEnvironment +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun auditPushChannelProvisions( +//// pushType: PNPushType, +//// deviceId: String, +//// topic: String?, +//// environment: PNPushEnvironment +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun removePushNotificationsFromChannels( +//// pushType: PNPushType, +//// channels: List, +//// deviceId: String, +//// topic: String?, +//// environment: PNPushEnvironment +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun removeAllPushNotificationsFromDeviceWithPushToken( +//// pushType: PNPushType, +//// deviceId: String, +//// topic: String?, +//// environment: PNPushEnvironment +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun fetchMessages( +//// channels: List, +//// page: PNBoundedPage, +//// includeUUID: Boolean, +//// includeMeta: Boolean, +//// includeMessageActions: Boolean, +//// includeMessageType: Boolean +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun deleteMessages(channels: List, start: Long?, end: Long?): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun messageCounts(channels: List, channelsTimetoken: List): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun hereNow( +//// channels: List, +//// channelGroups: List, +//// includeState: Boolean, +//// includeUUIDs: Boolean +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun whereNow(uuid: String): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun setPresenceState( +//// channels: List, +//// channelGroups: List, +//// state: Any, +//// uuid: String +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun getPresenceState( +//// channels: List, +//// channelGroups: List, +//// uuid: String +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun presence(channels: List, channelGroups: List, connected: Boolean) { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun addMessageAction(channel: String, messageAction: PNMessageAction): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun removeMessageAction( +//// channel: String, +//// messageTimetoken: Long, +//// actionTimetoken: Long +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun getMessageActions(channel: String, page: PNBoundedPage): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun addChannelsToChannelGroup( +//// channels: List, +//// channelGroup: String +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun listChannelsForChannelGroup(channelGroup: String): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun removeChannelsFromChannelGroup( +//// channels: List, +//// channelGroup: String +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun listAllChannelGroups(): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun deleteChannelGroup(channelGroup: String): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun grant( +//// read: Boolean, +//// write: Boolean, +//// manage: Boolean, +//// delete: Boolean, +//// ttl: Int, +//// authKeys: List, +//// channels: List, +//// channelGroups: List, +//// uuids: List +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun grant( +//// read: Boolean, +//// write: Boolean, +//// manage: Boolean, +//// delete: Boolean, +//// get: Boolean, +//// update: Boolean, +//// join: Boolean, +//// ttl: Int, +//// authKeys: List, +//// channels: List, +//// channelGroups: List, +//// uuids: List +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun grantToken( +//// ttl: Int, +//// meta: Any?, +//// authorizedUUID: String?, +//// channels: List, +//// channelGroups: List, +//// uuids: List +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun grantToken( +//// ttl: Int, +//// meta: Any?, +//// authorizedUserId: UserId?, +//// spacesPermissions: List, +//// usersPermissions: List +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun revokeToken(token: String): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun time(): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun getAllChannelMetadata( +//// limit: Int?, +//// page: PNPage?, +//// filter: String?, +//// sort: Collection>, +//// includeCount: Boolean, +//// includeCustom: Boolean +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun getChannelMetadata(channel: String, includeCustom: Boolean): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun setChannelMetadata( +//// channel: String, +//// name: String?, +//// description: String?, +//// custom: Any?, +//// includeCustom: Boolean, +//// type: String?, +//// status: String? +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun removeChannelMetadata(channel: String): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun getAllUUIDMetadata( +//// limit: Int?, +//// page: PNPage?, +//// filter: String?, +//// sort: Collection>, +//// includeCount: Boolean, +//// includeCustom: Boolean +//// ): Endpoint { +//// return createEndpoint { +//// PNUUIDMetadataArrayResult(200, userMetadata.values, userMetadata.size, null, null) +//// } +//// } +//// +//// +//// override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): Endpoint { +//// return createEndpoint { +//// val actualUuid = uuid ?: configuration.userId.value +//// val result = userMetadata[actualUuid] +//// +//// PNUUIDMetadataResult( +//// 200, +//// if (!includeCustom) { +//// result?.copy(custom = null) +//// } else { +//// result +//// } +//// ) +//// } +//// } +//// +//// override fun setUUIDMetadata( +//// uuid: String?, +//// name: String?, +//// externalId: String?, +//// profileUrl: String?, +//// email: String?, +//// custom: Any?, +//// includeCustom: Boolean, +//// type: String?, +//// status: String? +//// ): Endpoint { +//// return createEndpoint { +//// val actualUuid = uuid ?: configuration.userId.value +//// val result = userMetadata.compute(actualUuid) { a: String, b: PNUUIDMetadata? -> +//// PNUUIDMetadata( +//// actualUuid, +//// name ?: b?.name, +//// externalId ?: b?.externalId, +//// profileUrl ?: b?.profileUrl, +//// email ?: b?.email, +//// custom ?: b?.custom, +//// Clock.System.now().toString(), +//// null, +//// type ?: b?.type, +//// status ?: b?.status +//// ) +//// } +//// PNUUIDMetadataResult( +//// 200, +//// if (!includeCustom) { +//// result?.copy(custom = null) +//// } else { +//// result +//// } +//// ) +//// } +//// } +//// +//// override fun removeUUIDMetadata(uuid: String?): Endpoint { +//// val actualUuid = uuid ?: configuration.userId.value +//// return createEndpoint { +//// userMetadata.remove(actualUuid) +//// PNRemoveMetadataResult(200) +//// } +//// } +//// +//// override fun getMemberships( +//// uuid: String?, +//// limit: Int?, +//// page: PNPage?, +//// filter: String?, +//// sort: Collection>, +//// includeCount: Boolean, +//// includeCustom: Boolean, +//// includeChannelDetails: PNChannelDetailsLevel? +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun setMemberships( +//// channels: List, +//// uuid: String?, +//// limit: Int?, +//// page: PNPage?, +//// filter: String?, +//// sort: Collection>, +//// includeCount: Boolean, +//// includeCustom: Boolean, +//// includeChannelDetails: PNChannelDetailsLevel? +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun removeMemberships( +//// channels: List, +//// uuid: String?, +//// limit: Int?, +//// page: PNPage?, +//// filter: String?, +//// sort: Collection>, +//// includeCount: Boolean, +//// includeCustom: Boolean, +//// includeChannelDetails: PNChannelDetailsLevel? +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun manageMemberships( +//// channelsToSet: List, +//// channelsToRemove: List, +//// uuid: String?, +//// limit: Int?, +//// page: PNPage?, +//// filter: String?, +//// sort: Collection>, +//// includeCount: Boolean, +//// includeCustom: Boolean, +//// includeChannelDetails: PNChannelDetailsLevel? +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun getChannelMembers( +//// channel: String, +//// limit: Int?, +//// page: PNPage?, +//// filter: String?, +//// sort: Collection>, +//// includeCount: Boolean, +//// includeCustom: Boolean, +//// includeUUIDDetails: PNUUIDDetailsLevel? +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun setChannelMembers( +//// channel: String, +//// uuids: List, +//// limit: Int?, +//// page: PNPage?, +//// filter: String?, +//// sort: Collection>, +//// includeCount: Boolean, +//// includeCustom: Boolean, +//// includeUUIDDetails: PNUUIDDetailsLevel? +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun removeChannelMembers( +//// channel: String, +//// uuids: List, +//// limit: Int?, +//// page: PNPage?, +//// filter: String?, +//// sort: Collection>, +//// includeCount: Boolean, +//// includeCustom: Boolean, +//// includeUUIDDetails: PNUUIDDetailsLevel? +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun manageChannelMembers( +//// channel: String, +//// uuidsToSet: Collection, +//// uuidsToRemove: Collection, +//// limit: Int?, +//// page: PNPage?, +//// filter: String?, +//// sort: Collection>, +//// includeCount: Boolean, +//// includeCustom: Boolean, +//// includeUUIDDetails: PNUUIDDetailsLevel? +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun getFileUrl(channel: String, fileName: String, fileId: String): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun deleteFile(channel: String, fileName: String, fileId: String): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun publishFileMessage( +//// channel: String, +//// fileName: String, +//// fileId: String, +//// message: Any?, +//// meta: Any?, +//// ttl: Int?, +//// shouldStore: Boolean? +//// ): Endpoint { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun subscribe( +//// channels: List, +//// channelGroups: List, +//// withPresence: Boolean, +//// withTimetoken: Long +//// ) { +//// TODO("Not yet implemented") +//// } +//// +//// +//// override fun unsubscribe(channels: List, channelGroups: List) { +//// TODO("Not yet implemented") +//// } +//// +//// override fun setToken(token: String?) { +//// TODO("Not yet implemented") +//// } +//// +//// override fun addListener(listener: EventListener) { +//// TODO("Not yet implemented") +//// } +//// +//// override fun addListener(listener: StatusListener) { +//// TODO("Not yet implemented") +//// } +////} +//// +//private fun MutableMap.compute( +// key: K, +// remappingFunction: (K, V?) -> V +//): V? { +// val oldValue: V? = get(key) +// +// val newValue: V = remappingFunction(key, oldValue) +// if (newValue == null) { +// // delete mapping +// if (oldValue != null || containsKey(key)) { +// // something to remove +// remove(key) +// return null +// } else { +// // nothing to do. Leave things as they were. +// return null +// } +// } else { +// // add or replace old mapping +// put(key, newValue) +// return newValue +// } +//} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/createEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/createEndpoint.kt new file mode 100644 index 000000000..8402c7a2a --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/createEndpoint.kt @@ -0,0 +1,5 @@ +package com.pubnub.test + +import com.pubnub.api.Endpoint + +expect fun createEndpoint(action: () -> T): Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt new file mode 100644 index 000000000..8ce17ea3f --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt @@ -0,0 +1,7 @@ +package com.pubnub.test + +import com.pubnub.api.Endpoint + +actual fun createEndpoint(action: () -> T): Endpoint { + TODO("Not yet implemented") +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt new file mode 100644 index 000000000..c3ecc3cdc --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt @@ -0,0 +1,45 @@ +package com.pubnub.test + +import com.pubnub.api.Endpoint +import com.pubnub.api.PubNubException +import com.pubnub.api.enums.PNOperationType +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.PNConfigurationOverride +import com.pubnub.api.v2.callbacks.Result +import java.util.function.Consumer + +actual fun createEndpoint(action: () -> T): Endpoint { + return object : Endpoint { + override fun overrideConfiguration(action: PNConfigurationOverride.Builder.() -> Unit): Endpoint { + TODO("Not yet implemented") + } + + override fun overrideConfiguration(configuration: PNConfiguration): Endpoint { + TODO("Not yet implemented") + } + + override fun operationType(): PNOperationType { + TODO("Not yet implemented") + } + + override fun sync(): T { + TODO("Not yet implemented") + } + + override fun retry() { + TODO("Not yet implemented") + } + + override fun silentCancel() { + TODO("Not yet implemented") + } + + override fun async(callback: Consumer>) { + try { + callback.accept(Result.success(action())) + } catch (e: PubNubException) { + callback.accept(Result.failure(e)) + } + } + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 099e80847..fd606fa16 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -18,6 +18,7 @@ include("pubnub-core:pubnub-core-impl") include("pubnub-kotlin") include("pubnub-kotlin:pubnub-kotlin-api") include("pubnub-kotlin:pubnub-kotlin-impl") +include("pubnub-kotlin:pubnub-kotlin-test") include("pubnub-gson") include("pubnub-gson:pubnub-gson-api") include("pubnub-gson:pubnub-gson-impl") From ec5ea3e3d01e1b2c86f2fb43f437a5296d057139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Fri, 17 May 2024 13:31:18 +0200 Subject: [PATCH 02/62] Change Any to Map for custom in PNChannelMetadata --- kotlin-js-store/yarn.lock | 359 +++++++++++++++++- .../objects/channel/PNChannelMetadata.kt | 2 +- .../com/pubnub/api/legacy/PubNubCoreTest.kt | 2 +- .../callbacks/DelegatingEventListenerTest.kt | 8 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 18 - .../pubnub-kotlin-test/PubNubKMPTest.podspec | 54 +++ 6 files changed, 416 insertions(+), 27 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-test/PubNubKMPTest.podspec diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 1a5ead1f0..4931b3612 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -104,6 +104,11 @@ resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz#821f8442f4175d8f0467b9daf26e3a18e2d02af2" integrity sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA== +"@tootallnate/quickjs-emscripten@^0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz#db4ecfd499a9765ab24002c3b696d02e6d32a12c" + integrity sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA== + "@types/body-parser@*": version "1.19.5" resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.5.tgz#04ce9a3b677dc8bd681a17da1ab9835dc9d3ede4" @@ -440,6 +445,20 @@ acorn@^8.7.1, acorn@^8.8.2: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== +agent-base@^7.0.2, agent-base@^7.1.0, agent-base@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.1.tgz#bdbded7dfb096b751a2a087eeeb9664725b2e317" + integrity sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA== + dependencies: + debug "^4.3.4" + +agentkeepalive@^3.5.2: + version "3.5.3" + resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-3.5.3.tgz#c210afce942b4287e2df2fbfe6c0d57eda2ce634" + integrity sha512-yqXL+k5rr8+ZRpOAntkaaRgWgE5o8ESAj5DyRmVTCSoZxXmqemb9Dd7T4i5UzwuERdLAJUy6XzR9zFVuf0kzkw== + dependencies: + humanize-ms "^1.2.1" + ajv-formats@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520" @@ -529,16 +548,38 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== +ast-types@^0.13.4: + version "0.13.4" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.13.4.tgz#ee0d77b343263965ecc3fb62da16e7222b2b6782" + integrity sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w== + dependencies: + tslib "^2.0.1" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + base64id@2.0.0, base64id@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== +basic-ftp@^5.0.2: + version "5.0.5" + resolved "https://registry.yarnpkg.com/basic-ftp/-/basic-ftp-5.0.5.tgz#14a474f5fffecca1f4f406f1c26b18f800225ac0" + integrity sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg== + batch@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" @@ -617,6 +658,22 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== +buffer@^5.4.3: + version "5.7.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" + integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.1.13" + +buffer@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + bundle-name@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/bundle-name/-/bundle-name-4.1.0.tgz#f3b96b34160d6431a19d7688135af7cfb8797889" @@ -655,6 +712,16 @@ caniuse-lite@^1.0.30001587: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001616.tgz#4342712750d35f71ebba9fcac65e2cf8870013c3" integrity sha512-RHVYKov7IcdNjVHJFNY/78RdG4oGVjbayxv8u5IO74Wv7Hlq4PnJE6mo/OjFijjVFNy5ijnCt6H3IIo4t+wfEw== +cbor-js@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/cbor-js/-/cbor-js-0.1.0.tgz#c80ce6120f387e8faa74370dfda21d965b8fc7f9" + integrity sha512-7sQ/TvDZPl7csT1Sif9G0+MA0I0JOVah8+wWlJVQdVEgIbCzlN/ab3x+uvMNsc34TUvO6osQTAmB2ls80JX6tw== + +cbor-sync@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/cbor-sync/-/cbor-sync-1.0.4.tgz#5a11a1ab75c2a14d1af1b237fd84aa8c1593662f" + integrity sha512-GWlXN4wiz0vdWWXBU71Dvc1q3aBo0HytqwAZnXF1wOwjqNnDWA1vZ1gDMFLlqohak31VQzmhiYfiCX5QSSfagA== + chalk@^4.1.0: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" @@ -733,6 +800,13 @@ colorette@^2.0.10, colorette@^2.0.14: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + commander@^10.0.1: version "10.0.1" resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" @@ -837,6 +911,11 @@ custom-event@~1.0.0: resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" integrity sha512-GAj5FOq0Hd+RsCGVJxZuKaIDXDf3h6GQoNEjFgbLLI/trgtavwUbSnZ5pVfg27DVCaWjIohryS0JFwIJyT2cMg== +data-uri-to-buffer@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz#8a58bb67384b261a38ef18bea1810cb01badd28b" + integrity sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw== + date-format@^4.0.14: version "4.0.14" resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.14.tgz#7a8e584434fb169a521c8b7aa481f355810d9400" @@ -849,7 +928,7 @@ debug@2.6.9: dependencies: ms "2.0.0" -debug@4.3.4, debug@^4.1.0, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2, debug@~4.3.4: +debug@4, debug@4.3.4, debug@^4.1.0, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2, debug@~4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== @@ -895,6 +974,20 @@ define-lazy-prop@^3.0.0: resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz#dbb19adfb746d7fc6d734a06b72f4a00d021255f" integrity sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg== +degenerator@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-5.0.1.tgz#9403bf297c6dad9a1ece409b37db27954f91f2f5" + integrity sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ== + dependencies: + ast-types "^0.13.4" + escodegen "^2.1.0" + esprima "^4.0.1" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + depd@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" @@ -1043,6 +1136,17 @@ escape-string-regexp@4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== +escodegen@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.1.0.tgz#ba93bbb7a43986d29d6041f99f5262da773e2e17" + integrity sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w== + dependencies: + esprima "^4.0.1" + estraverse "^5.2.0" + esutils "^2.0.2" + optionalDependencies: + source-map "~0.6.1" + eslint-scope@5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" @@ -1051,6 +1155,11 @@ eslint-scope@5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" +esprima@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + esrecurse@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" @@ -1068,6 +1177,11 @@ estraverse@^5.2.0: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== +esutils@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== + etag@~1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" @@ -1234,6 +1348,15 @@ foreground-child@^3.1.0: cross-spawn "^7.0.0" signal-exit "^4.0.1" +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + format-util@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271" @@ -1249,6 +1372,15 @@ fresh@0.5.2: resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== +fs-extra@^11.2.0: + version "11.2.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b" + integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs-extra@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" @@ -1294,6 +1426,16 @@ get-stream@^6.0.0: resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== +get-uri@^6.0.1: + version "6.0.3" + resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-6.0.3.tgz#0d26697bc13cf91092e519aa63aa60ee5b6f385a" + integrity sha512-BzUrJBS9EcUb4cFol8r4W3v1cPsSyajLSthNkz5BxbpDcHN5tIrM10E2eNvfnvBn3DaT3DUgx0OpsBKkaOpanw== + dependencies: + basic-ftp "^5.0.2" + data-uri-to-buffer "^6.0.2" + debug "^4.3.4" + fs-extra "^11.2.0" + glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -1437,6 +1579,14 @@ http-parser-js@>=0.5.1: resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.8.tgz#af23090d9ac4e24573de6f6aecc9d84a48bf20e3" integrity sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q== +http-proxy-agent@^7.0.0, http-proxy-agent@^7.0.1: + version "7.0.2" + resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz#9a8b1f246866c028509486585f62b8f2c18c270e" + integrity sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig== + dependencies: + agent-base "^7.1.0" + debug "^4.3.4" + http-proxy-middleware@^2.0.3: version "2.0.6" resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f" @@ -1457,11 +1607,26 @@ http-proxy@^1.18.1: follow-redirects "^1.0.0" requires-port "^1.0.0" +https-proxy-agent@^7.0.2, https-proxy-agent@^7.0.3: + version "7.0.4" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz#8e97b841a029ad8ddc8731f26595bad868cb4168" + integrity sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg== + dependencies: + agent-base "^7.0.2" + debug "4" + human-signals@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== +humanize-ms@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" + integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ== + dependencies: + ms "^2.0.0" + hyperdyperid@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/hyperdyperid/-/hyperdyperid-1.2.0.tgz#59668d323ada92228d2a869d3e474d5a33b69e6b" @@ -1481,6 +1646,11 @@ iconv-lite@^0.6.3: dependencies: safer-buffer ">= 2.1.2 < 3.0.0" +ieee754@^1.1.13, ieee754@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + import-local@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" @@ -1512,6 +1682,14 @@ interpret@^3.1.1: resolved "https://registry.yarnpkg.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4" integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ== +ip-address@^9.0.5: + version "9.0.5" + resolved "https://registry.yarnpkg.com/ip-address/-/ip-address-9.0.5.tgz#117a960819b08780c3bd1f14ef3c1cc1d3f3ea5a" + integrity sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g== + dependencies: + jsbn "1.1.0" + sprintf-js "^1.1.3" + ipaddr.js@1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" @@ -1654,6 +1832,11 @@ js-yaml@4.1.0: dependencies: argparse "^2.0.1" +jsbn@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-1.1.0.tgz#b01307cb29b618a1ed26ec79e911f803c4da0040" + integrity sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A== + json-parse-even-better-errors@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" @@ -1676,6 +1859,15 @@ jsonfile@^4.0.0: optionalDependencies: graceful-fs "^4.1.6" +jsonfile@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" + integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== + dependencies: + universalify "^2.0.0" + optionalDependencies: + graceful-fs "^4.1.6" + karma-chrome-launcher@3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-3.2.0.tgz#eb9c95024f2d6dfbb3748d3415ac9b381906b9a9" @@ -1749,6 +1941,11 @@ launch-editor@^2.6.1: picocolors "^1.0.0" shell-quote "^1.8.1" +lil-uuid@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/lil-uuid/-/lil-uuid-0.1.1.tgz#f9edcf23f00e42bf43f0f843d98d8b53f3341f16" + integrity sha512-GhWI8f61tBlMeqULZ1QWhFiiyFIFdPlg//S8Udq1wjq1FJhpFKTfnbduSxAQjueofeUtpr7UvQ/lIK/sKUF8dg== + loader-runner@^4.2.0: version "4.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" @@ -1797,6 +1994,11 @@ lru-cache@^10.2.0: resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.2.tgz#48206bc114c1252940c41b25b41af5b545aca878" integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== +lru-cache@^7.14.1: + version "7.18.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.18.3.tgz#f793896e0fd0e954a59dfdd82f0773808df6aa89" + integrity sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA== + media-typer@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" @@ -1840,7 +2042,7 @@ mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34: +mime-types@^2.1.12, mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34: version "2.1.35" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== @@ -1948,7 +2150,7 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@2.1.3: +ms@2.1.3, ms@^2.0.0: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -1971,6 +2173,18 @@ neo-async@^2.6.2: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== +netmask@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/netmask/-/netmask-2.0.2.tgz#8b01a07644065d536383835823bc52004ebac5e7" + integrity sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg== + +node-fetch@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + node-forge@^1: version "1.3.1" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" @@ -2093,6 +2307,28 @@ p-try@^2.0.0: resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== +pac-proxy-agent@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-7.0.1.tgz#6b9ddc002ec3ff0ba5fdf4a8a21d363bcc612d75" + integrity sha512-ASV8yU4LLKBAjqIPMbrgtaKIvxQri/yh2OpI+S6hVa9JRkUI3Y3NPFbfngDtY7oFtSMD3w31Xns89mDa3Feo5A== + dependencies: + "@tootallnate/quickjs-emscripten" "^0.23.0" + agent-base "^7.0.2" + debug "^4.3.4" + get-uri "^6.0.1" + http-proxy-agent "^7.0.0" + https-proxy-agent "^7.0.2" + pac-resolver "^7.0.0" + socks-proxy-agent "^8.0.2" + +pac-resolver@^7.0.0: + version "7.0.1" + resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-7.0.1.tgz#54675558ea368b64d210fd9c92a640b5f3b8abb6" + integrity sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg== + dependencies: + degenerator "^5.0.0" + netmask "^2.0.2" + parseurl@~1.3.2, parseurl@~1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" @@ -2161,7 +2397,42 @@ proxy-addr@~2.0.7: forwarded "0.2.0" ipaddr.js "1.9.1" -punycode@^2.1.0: +proxy-agent@^6.3.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-6.4.0.tgz#b4e2dd51dee2b377748aef8d45604c2d7608652d" + integrity sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ== + dependencies: + agent-base "^7.0.2" + debug "^4.3.4" + http-proxy-agent "^7.0.1" + https-proxy-agent "^7.0.3" + lru-cache "^7.14.1" + pac-proxy-agent "^7.0.1" + proxy-from-env "^1.1.0" + socks-proxy-agent "^8.0.2" + +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + +pubnub@8.1.0: + version "8.1.0" + resolved "https://registry.yarnpkg.com/pubnub/-/pubnub-8.1.0.tgz#d17e2925ce4a66e1b52b73bdeaee53f44237316e" + integrity sha512-f8T+vh414WayMNokKueOZykn3tosxF1ruu3KAM/4uLy1GzLWsL5/k46lGaxqVljkMtplM/8nJlbzA+/k8kkQ3A== + dependencies: + agentkeepalive "^3.5.2" + buffer "^6.0.3" + cbor-js "^0.1.0" + cbor-sync "^1.0.4" + form-data "^4.0.0" + lil-uuid "^0.1.1" + node-fetch "^2.7.0" + proxy-agent "^6.3.0" + react-native-url-polyfill "^2.0.0" + text-encoding "^0.7.0" + +punycode@^2.1.0, punycode@^2.1.1: version "2.3.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== @@ -2200,6 +2471,13 @@ raw-body@2.5.2: iconv-lite "0.4.24" unpipe "1.0.0" +react-native-url-polyfill@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/react-native-url-polyfill/-/react-native-url-polyfill-2.0.0.tgz#db714520a2985cff1d50ab2e66279b9f91ffd589" + integrity sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA== + dependencies: + whatwg-url-without-unicode "8.0.0-3" + readable-stream@^2.0.1: version "2.3.8" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" @@ -2470,6 +2748,11 @@ signal-exit@^4.0.1: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== +smart-buffer@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.2.0.tgz#6e1d71fa4f18c05f7d0ff216dd16a481d0e8d9ae" + integrity sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg== + socket.io-adapter@~2.5.2: version "2.5.4" resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-2.5.4.tgz#4fdb1358667f6d68f25343353bd99bd11ee41006" @@ -2508,6 +2791,23 @@ sockjs@^0.3.24: uuid "^8.3.2" websocket-driver "^0.7.4" +socks-proxy-agent@^8.0.2: + version "8.0.3" + resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-8.0.3.tgz#6b2da3d77364fde6292e810b496cb70440b9b89d" + integrity sha512-VNegTZKhuGq5vSD6XNKlbqWhyt/40CgoEw8XxD6dhnm8Jq9IEa3nIa4HwnM8XOqU0CdB0BwWVXusqiFXfHB3+A== + dependencies: + agent-base "^7.1.1" + debug "^4.3.4" + socks "^2.7.1" + +socks@^2.7.1: + version "2.8.3" + resolved "https://registry.yarnpkg.com/socks/-/socks-2.8.3.tgz#1ebd0f09c52ba95a09750afe3f3f9f724a800cb5" + integrity sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw== + dependencies: + ip-address "^9.0.5" + smart-buffer "^4.2.0" + sonic-forest@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/sonic-forest/-/sonic-forest-1.0.3.tgz#81363af60017daba39b794fce24627dc412563cb" @@ -2536,7 +2836,7 @@ source-map-support@~0.5.20: buffer-from "^1.0.0" source-map "^0.6.0" -source-map@^0.6.0, source-map@^0.6.1: +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== @@ -2564,6 +2864,11 @@ spdy@^4.0.2: select-hose "^2.0.0" spdy-transport "^3.0.0" +sprintf-js@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.3.tgz#4914b903a2f8b685d17fdf78a70e917e872e444a" + integrity sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA== + statuses@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" @@ -2684,6 +2989,11 @@ terser@^5.26.0: commander "^2.20.0" source-map-support "~0.5.20" +text-encoding@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.7.0.tgz#f895e836e45990624086601798ea98e8f36ee643" + integrity sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA== + thingies@^1.20.0: version "1.21.0" resolved "https://registry.yarnpkg.com/thingies/-/thingies-1.21.0.tgz#e80fbe58fd6fdaaab8fad9b67bd0a5c943c445c1" @@ -2711,12 +3021,17 @@ toidentifier@1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + tree-dump@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/tree-dump/-/tree-dump-1.0.1.tgz#b448758da7495580e6b7830d6b7834fca4c45b96" integrity sha512-WCkcRBVPSlHHq1dc/px9iOfqklvzCbdRwvlNfxGZsrHqf6aZttfPrd7DJTt6oR10dwUfpFFQeVTkPbBIZxX/YA== -tslib@^2.0.0: +tslib@^2.0.0, tslib@^2.0.1: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== @@ -2749,6 +3064,11 @@ universalify@^0.1.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== +universalify@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d" + integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw== + unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" @@ -2809,6 +3129,16 @@ wbuf@^1.1.0, wbuf@^1.7.3: dependencies: minimalistic-assert "^1.0.0" +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +webidl-conversions@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" + integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA== + webpack-cli@5.1.4: version "5.1.4" resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-5.1.4.tgz#c8e046ba7eaae4911d7e71e2b25b776fcc35759b" @@ -2941,6 +3271,23 @@ websocket-extensions@>=0.1.1: resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== +whatwg-url-without-unicode@8.0.0-3: + version "8.0.0-3" + resolved "https://registry.yarnpkg.com/whatwg-url-without-unicode/-/whatwg-url-without-unicode-8.0.0-3.tgz#ab6df4bf6caaa6c85a59f6e82c026151d4bb376b" + integrity sha512-HoKuzZrUlgpz35YO27XgD28uh/WJH4B0+3ttFqRo//lmq+9T/mIOJ6kqmINI9HpUpz1imRC/nR/lxKpJiv0uig== + dependencies: + buffer "^5.4.3" + punycode "^2.1.1" + webidl-conversions "^5.0.0" + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + which@^1.2.1: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt index f0441dbe6..764ab7424 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt @@ -4,7 +4,7 @@ data class PNChannelMetadata( val id: String, val name: String?, val description: String?, - val custom: Any?, + val custom: Map?, val updated: String?, val eTag: String?, val type: String?, diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt index 0559a66c1..e7021d6d6 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt @@ -66,7 +66,7 @@ class PubNubCoreTest : BaseTest() { fun getVersionAndTimeStamp() { val version = PubNubCore.SDK_VERSION val timeStamp = PubNubCore.timestamp() - assertEquals("9.1.1", version) + assertEquals("9.2-DEV", version) assertTrue(timeStamp > 0) } diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt index 4252f44c4..4d63fafa0 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt @@ -89,7 +89,13 @@ internal class DelegatingEventListenerTest { pn, PNObjectEventResult( BasePubSubResult("a", "b", 0L, null, null), - PNSetChannelMetadataEventMessage("a", "b", "c", "d", PNChannelMetadata("a", "b", null, "c", "d", null, null, null)), + PNSetChannelMetadataEventMessage( + "a", + "b", + "c", + "d", + PNChannelMetadata("a", "b", null, mapOf("c" to "c"), "d", null, null, null) + ), ), ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 831501ade..7dffe17d1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -3,56 +3,40 @@ package com.pubnub.api import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages import com.pubnub.api.endpoints.FetchMessages -import com.pubnub.api.endpoints.FetchMessagesImpl import com.pubnub.api.endpoints.MessageCounts import com.pubnub.api.endpoints.Time import com.pubnub.api.endpoints.access.GrantToken import com.pubnub.api.endpoints.access.RevokeToken import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup -import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup -import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup -import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup -import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroupImpl import com.pubnub.api.endpoints.files.DeleteFile import com.pubnub.api.endpoints.files.GetFileUrl import com.pubnub.api.endpoints.files.ListFiles import com.pubnub.api.endpoints.files.PublishFileMessage import com.pubnub.api.endpoints.message_actions.AddMessageAction -import com.pubnub.api.endpoints.message_actions.AddMessageActionImpl import com.pubnub.api.endpoints.message_actions.GetMessageActions -import com.pubnub.api.endpoints.message_actions.GetMessageActionImpl import com.pubnub.api.endpoints.message_actions.RemoveMessageAction -import com.pubnub.api.endpoints.message_actions.RemoveMessageActionImpl import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata import com.pubnub.api.endpoints.objects.member.GetChannelMembers -import com.pubnub.api.endpoints.objects.member.GetChannelMembersImpl import com.pubnub.api.endpoints.objects.member.ManageChannelMembers import com.pubnub.api.endpoints.objects.membership.GetMemberships import com.pubnub.api.endpoints.objects.membership.ManageMemberships import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadataImpl import com.pubnub.api.endpoints.presence.GetState import com.pubnub.api.endpoints.presence.HereNow -import com.pubnub.api.endpoints.presence.HereNowImpl import com.pubnub.api.endpoints.presence.SetState import com.pubnub.api.endpoints.presence.WhereNow -import com.pubnub.api.endpoints.presence.WhereNowImpl -import com.pubnub.api.endpoints.pubsub.FireImpl import com.pubnub.api.endpoints.pubsub.Publish -import com.pubnub.api.endpoints.pubsub.PublishImpl import com.pubnub.api.endpoints.pubsub.Signal -import com.pubnub.api.endpoints.pubsub.SignalImpl import com.pubnub.api.endpoints.push.AddChannelsToPush import com.pubnub.api.endpoints.push.ListPushProvisions import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice @@ -79,8 +63,6 @@ import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener import com.pubnub.kmp.Optional -import com.pubnub.kmp.toOptional - import PubNub as PubNubJs class PubNubImpl(override val configuration: PNConfiguration) : PubNub { diff --git a/pubnub-kotlin/pubnub-kotlin-test/PubNubKMPTest.podspec b/pubnub-kotlin/pubnub-kotlin-test/PubNubKMPTest.podspec new file mode 100644 index 000000000..5397baf96 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/PubNubKMPTest.podspec @@ -0,0 +1,54 @@ +Pod::Spec.new do |spec| + spec.name = 'PubNubKMPTest' + spec.version = '1.0' + spec.homepage = 'Link to a Kotlin/Native module homepage' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = 'Some description for a Kotlin/Native module' + spec.vendored_frameworks = 'build/cocoapods/framework/PubNubKMPTest.framework' + spec.libraries = 'c++' + spec.ios.deployment_target = '14' + spec.dependency 'PubNubSwift' + + if !Dir.exist?('build/cocoapods/framework/PubNubKMPTest.framework') || Dir.empty?('build/cocoapods/framework/PubNubKMPTest.framework') + raise " + + Kotlin framework 'PubNubKMPTest' doesn't exist yet, so a proper Xcode project can't be generated. + 'pod install' should be executed after running ':generateDummyFramework' Gradle task: + + ./gradlew :pubnub-kotlin:pubnub-kotlin-test:generateDummyFramework + + Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" + end + + spec.xcconfig = { + 'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO', + } + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':pubnub-kotlin:pubnub-kotlin-test', + 'PRODUCT_MODULE_NAME' => 'PubNubKMPTest', + } + + spec.script_phases = [ + { + :name => 'Build PubNubKMPTest', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file From 72a9aa295a388b615aa12968fc08d4d9523b0a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Mon, 20 May 2024 07:45:55 +0000 Subject: [PATCH 03/62] Add JS wrappers for some endpoints (#212) * Add JS wrappers for some endpoints * Fix exception due to non working expect/actual annotation * First tests for common code * Add Swift wrappers for some endpoints * Add unsubscribeAll * Allow running tests on iOS * Add back imports --------- Co-authored-by: jguz-pubnub --- kotlin-js-store/yarn.lock | 2 +- .../kotlin/com/pubnub/api/JsonElement.kt | 5 +- .../PNGetMessageActionsResult.kt | 11 +- .../kotlin/com/pubnub/api/JsonElement.ios.kt | 8 +- .../PNGetMessageActionsResult.ios.kt | 8 + .../kotlin/com/pubnub/api/JsonElement.js.kt | 5 +- .../PNGetMessageActionsResult.js.kt | 8 + .../kotlin/com/pubnub/api/JsonElement.jvm.kt | 9 +- .../PNGetMessageActionsResult.jvm.kt | 11 + .../com/pubnub/internal/EndpointCore.kt | 2 +- .../pubnub-kotlin-api/build.gradle.kts | 6 + .../kotlin/com/pubnub/api/PubNub.kt | 4 + .../com/pubnub/api/v2/PNConfiguration.kt | 2 +- .../kotlin/com/pubnub/api/Endpoint.ios.kt | 15 +- .../kotlin/com/pubnub/api/PubNub.ios.kt | 2 + .../kotlin/com/pubnub/api/PubNubImpl.kt | 63 +++++- .../api/endpoints/pubsub/Publish.ios.kt | 32 ++- .../pubnub/api/endpoints/pubsub/Signal.ios.kt | 24 ++- .../endpoints/push/AddChannelsToPush.ios.kt | 34 ++- .../com/pubnub/api/v2/PNConfiguration.ios.kt | 6 +- .../src/jsMain/kotlin/Pubnub.d.kt | 41 ++-- .../jsMain/kotlin/com/pubnub/api/PubNub.js.kt | 8 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 196 ++++++++++++++---- .../pubnub/api/endpoints/FetchMessagesImpl.kt | 34 +++ .../AddChannelChannelGroupImpl.kt | 12 ++ .../AllChannelsChannelGroupImpl.kt | 14 ++ .../channel_groups/ListAllChannelGroupImpl.kt | 15 ++ .../RemoveChannelChannelGroupImpl.kt | 13 ++ .../message_actions/AddMessageActionImpl.kt | 22 ++ .../message_actions/GetMessageActionImpl.kt | 27 +++ .../RemoveMessageActionImpl.kt | 13 ++ .../objects/member/GetChannelMembersImpl.kt | 42 ++++ .../objects/uuid/SetUUIDMetadataImpl.kt | 18 ++ .../api/endpoints/presence/HereNowImpl.kt | 32 +++ .../api/endpoints/presence/WhereNowImpl.kt | 14 ++ .../pubnub/api/endpoints/pubsub/FireImpl.kt | 12 ++ .../api/endpoints/pubsub/PublishImpl.kt | 12 ++ .../pubnub/api/endpoints/pubsub/SignalImpl.kt | 12 ++ .../com/pubnub/api/v2/PNConfiguration.js.kt | 8 +- .../src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt | 11 + .../com/pubnub/api/v2/PNConfiguration.jvm.kt | 7 +- .../pubnub-kotlin-test/build.gradle.kts | 64 +++++- .../kotlin/com.pubnub.test/createEndpoint.kt | 5 - .../kotlin/com/pubnub/api/PublishTest.kt | 47 +++++ .../com/pubnub/test/BaseIntegrationTest.kt | 39 ++++ .../kotlin/com.pubnub.test/FakePubNub.js.kt | 7 - .../kotlin/com.pubnub.test/FakePubNub.jvm.kt | 45 ---- 47 files changed, 859 insertions(+), 168 deletions(-) create mode 100644 pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.ios.kt create mode 100644 pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.js.kt create mode 100644 pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.jvm.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroupImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroupImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageActionImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNowImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/FireImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/PublishImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/SignalImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/createEndpoint.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 4931b3612..f8ef7df39 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -2828,7 +2828,7 @@ source-map-loader@5.0.0: iconv-lite "^0.6.3" source-map-js "^1.0.2" -source-map-support@~0.5.20: +source-map-support@0.5.21, source-map-support@~0.5.20: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt index 262ff5695..2579a8193 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt @@ -3,4 +3,7 @@ package com.pubnub.api expect abstract class JsonElement //expect class JsonObject -expect annotation class SerializedName(val value: String, val alternate: Array = []) \ No newline at end of file +expect fun JsonElement.asString(): String +//expect fun JsonElement.asNumber(): Number +//expect fun JsonElement.asMap(): Map +//expect fun JsonElement.asList(): List diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt index d475a0d6b..b0bf61340 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt @@ -1,6 +1,5 @@ package com.pubnub.api.models.consumer.message_actions -import com.pubnub.api.SerializedName import com.pubnub.api.models.consumer.PNBoundedPage /** @@ -9,9 +8,7 @@ import com.pubnub.api.models.consumer.PNBoundedPage * @property actions List of message actions for a certain message in a certain channel. * @property page Information about next page. When null there's no next page. */ -class PNGetMessageActionsResult( - @SerializedName("data") - val actions: List, - @SerializedName("more") - val page: PNBoundedPage?, -) +expect class PNGetMessageActionsResult(actions: List, page: PNBoundedPage?) { + val actions: List + val page: PNBoundedPage? +} diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt index e9a2fdbee..bf910f2b9 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt @@ -1,7 +1,7 @@ package com.pubnub.api actual abstract class JsonElement -actual annotation class SerializedName actual constructor( - actual val value: String, - actual val alternate: Array -) \ No newline at end of file + +actual fun JsonElement.asString(): String { + return TODO() +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.ios.kt new file mode 100644 index 000000000..f039ced59 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.ios.kt @@ -0,0 +1,8 @@ +package com.pubnub.api.models.consumer.message_actions + +import com.pubnub.api.models.consumer.PNBoundedPage + +actual class PNGetMessageActionsResult actual constructor( + actual val actions: List, + actual val page: PNBoundedPage?, +) diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt index 197867a18..fb08af7ff 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt @@ -3,4 +3,7 @@ package com.pubnub.api actual abstract class JsonElement -actual annotation class SerializedName actual constructor(actual val value: String, actual val alternate: Array) \ No newline at end of file + +actual fun JsonElement.asString(): String { + return this.toString() // todo ? +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.js.kt new file mode 100644 index 000000000..f039ced59 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.js.kt @@ -0,0 +1,8 @@ +package com.pubnub.api.models.consumer.message_actions + +import com.pubnub.api.models.consumer.PNBoundedPage + +actual class PNGetMessageActionsResult actual constructor( + actual val actions: List, + actual val page: PNBoundedPage?, +) diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt index 976b37a91..4dc18ea4b 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt @@ -1,8 +1,7 @@ package com.pubnub.api -import com.google.gson.JsonElement -import com.google.gson.annotations.SerializedName +actual typealias JsonElement = com.google.gson.JsonElement -actual typealias JsonElement = JsonElement - -actual typealias SerializedName = SerializedName \ No newline at end of file +actual fun JsonElement.asString(): String { + return this.asString +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.jvm.kt new file mode 100644 index 000000000..b03c50b2d --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.jvm.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.models.consumer.message_actions + +import com.google.gson.annotations.SerializedName +import com.pubnub.api.models.consumer.PNBoundedPage + +actual class PNGetMessageActionsResult actual constructor( + @SerializedName("data") + actual val actions: List, + @SerializedName("more") + actual val page: PNBoundedPage?, +) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt index 0bdb1d55d..f4dd224ce 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt @@ -6,6 +6,7 @@ import com.pubnub.api.PubNubException import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.api.v2.BasePNConfiguration import com.pubnub.api.v2.BasePNConfiguration.Companion.isValid +import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.internal.managers.RetrofitManager import com.pubnub.internal.retry.RetryableBase @@ -18,7 +19,6 @@ import java.io.IOException import java.net.ConnectException import java.net.SocketTimeoutException import java.net.UnknownHostException -import java.util.function.Consumer /** * Base class for all PubNub API operation implementations. diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index 442c3315e..13f88526f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -102,5 +102,11 @@ kotlin { implementation(libs.slf4j) } } + + val jsMain by getting { + dependencies { + implementation(npm("pubnub", "8.1.0")) + } + } } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt index ddaae2572..0149709bf 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt @@ -439,7 +439,11 @@ expect interface PubNub { channelGroups: List = emptyList(), ) + fun unsubscribeAll() + fun setToken(token: String?) + + fun destroy() } expect class CustomObject diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt index 1d36eaef3..0411fdd82 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt @@ -16,4 +16,4 @@ expect interface PNConfiguration { expect interface CryptoModule -expect fun createPNConfiguration(userId: UserId, subscribeKey: String): PNConfiguration \ No newline at end of file +expect fun createPNConfiguration(userId: UserId, subscribeKey: String, publishKey: String): PNConfiguration \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt index f7bef87b4..18f67a58b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt @@ -2,7 +2,20 @@ package com.pubnub.api import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import platform.Foundation.NSError actual interface Endpoint { actual fun async(callback: Consumer>) -} \ No newline at end of file +} + +fun Consumer>.onSuccessHandler(mapper: (T) -> U) : (T) -> Unit { + return fun(input: T) { accept(Result.success(mapper(input))) } +} + +fun Consumer>.onFailureHandler(mapper: (NSError?) -> Throwable = { error: NSError? -> + PubNubException(errorMessage = error?.localizedDescription) +} ): (NSError?) -> Unit { + return { error: NSError? -> + accept(Result.failure(mapper(error))) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt index 4696b7563..f25efdce5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt @@ -411,6 +411,8 @@ actual interface PubNub { ) actual fun setToken(token: String?) + actual fun destroy() + actual fun unsubscribeAll() } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 31d0cd3c2..4fdf024ab 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -36,8 +36,11 @@ import com.pubnub.api.endpoints.presence.HereNow import com.pubnub.api.endpoints.presence.SetState import com.pubnub.api.endpoints.presence.WhereNow import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.PublishImpl import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.endpoints.pubsub.SignalImpl import com.pubnub.api.endpoints.push.AddChannelsToPush +import com.pubnub.api.endpoints.push.AddChannelsToPushImpl import com.pubnub.api.endpoints.push.ListPushProvisions import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice import com.pubnub.api.endpoints.push.RemoveChannelsFromPush @@ -62,10 +65,16 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener +import kotlinx.cinterop.ExperimentalForeignApi class PubNubImpl(override val configuration: PNConfiguration) : PubNub { -// val swiftPubNub = cocoapods.PubNubSwift. + @OptIn(ExperimentalForeignApi::class) + private val pubNubObjC = cocoapods.PubNubSwift.PubNubObjC( + user = configuration.userId.value, + subKey = configuration.subscribeKey, + pubKey = configuration.publishKey + ) override fun addListener(listener: EventListener) { TODO("Not yet implemented") @@ -83,6 +92,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { TODO("Not yet implemented") } + @OptIn(ExperimentalForeignApi::class) + // TODO: replicate and usePost parameters are not present in Swift SDK override fun publish( channel: String, message: Any, @@ -92,25 +103,47 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { replicate: Boolean, ttl: Int? ): Publish { - TODO("Not yet implemented") - } - + return PublishImpl( + pubnub = pubNubObjC, + channel = channel, + message = message, + meta = meta, + shouldStore = shouldStore, + ttl = ttl + ) + } + + @OptIn(ExperimentalForeignApi::class) + // TODO: usePost parameter is not present in Swift SDK override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { - TODO("Not yet implemented") + return PublishImpl( + pubnub = pubNubObjC, + channel = channel, + message = message, + meta = meta, + shouldStore = false, + ttl = 0 + ) } + @OptIn(ExperimentalForeignApi::class) override fun signal(channel: String, message: Any): Signal { - TODO("Not yet implemented") + return SignalImpl(pubnub = pubNubObjC, channel = channel, message = message) } + @OptIn(ExperimentalForeignApi::class) override fun getSubscribedChannels(): List { - TODO("Not yet implemented") + return pubNubObjC.subscribedChannels() as List } + @OptIn(ExperimentalForeignApi::class) override fun getSubscribedChannelGroups(): List { - TODO("Not yet implemented") + return pubNubObjC.subscribedChannelGroups() as List } + // TODO: Missing pushType (PushService like APNS, GCM, etc) parameter + // TODO: Why do we need topic parameter here? + @OptIn(ExperimentalForeignApi::class) override fun addPushNotificationsOnChannels( pushType: PNPushType, channels: List, @@ -118,7 +151,11 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { topic: String?, environment: PNPushEnvironment ): AddChannelsToPush { - TODO("Not yet implemented") + return AddChannelsToPushImpl( + pubnub = pubNubObjC, + channels = channels, + deviceId = deviceId + ) } override fun auditPushChannelProvisions( @@ -482,4 +519,12 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { override fun setToken(token: String?) { TODO("Not yet implemented") } + + override fun destroy() { + TODO("Not yet implemented") + } + + override fun unsubscribeAll() { + TODO("Not yet implemented") + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt index 0f9eb3ff3..023511258 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt @@ -1,9 +1,39 @@ package com.pubnub.api.endpoints.pubsub +import cocoapods.PubNubSwift.PubNubObjC import com.pubnub.api.Endpoint +import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNPublishResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [PubNub.publish] */ -actual interface Publish : Endpoint \ No newline at end of file +actual interface Publish : Endpoint + +@OptIn(ExperimentalForeignApi::class) +open class PublishImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val message: Any, + private val meta: Any?, + private val shouldStore: Boolean?, + private val ttl: Int? +): Publish { + override fun async(callback: Consumer>) { + pubnub.publishWithChannel( + channel = channel, + message = message, + meta = meta, + shouldStore = if (shouldStore != null) NSNumber(bool = shouldStore) else null, + ttl = if (ttl != null) NSNumber(int = ttl) else null, + onResponse = callback.onSuccessHandler { PNPublishResult(it.toLong()) }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt index 64235d7de..3282f54fa 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt @@ -1,9 +1,31 @@ package com.pubnub.api.endpoints.pubsub +import cocoapods.PubNubSwift.PubNubObjC import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.PNPublishResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.signal] */ -actual interface Signal : Endpoint \ No newline at end of file +actual interface Signal : Endpoint + +@OptIn(ExperimentalForeignApi::class) +open class SignalImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val message: Any +): Signal { + override fun async(callback: Consumer>) { + pubnub.signalWithChannel( + channel = channel, + message = message, + onResponse = callback.onSuccessHandler { PNPublishResult(it.toLong()) }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt index 12aef0b7d..f796d28cb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt @@ -1,9 +1,41 @@ package com.pubnub.api.endpoints.push +import cocoapods.PubNubSwift.PubNubObjC import com.pubnub.api.Endpoint +import com.pubnub.api.PubNubException import com.pubnub.api.models.consumer.push.PNPushAddChannelResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSString +import platform.Foundation.NSUTF8StringEncoding +import platform.Foundation.dataUsingEncoding /** * @see [PubNub.addPushNotificationsOnChannels] */ -actual interface AddChannelsToPush : Endpoint \ No newline at end of file +actual interface AddChannelsToPush : Endpoint + +@OptIn(ExperimentalForeignApi::class) +open class AddChannelsToPushImpl( + private val pubnub: PubNubObjC, + private val channels: List, + private val deviceId: String +): AddChannelsToPush { + override fun async(callback: Consumer>) { + val deviceIdData = (deviceId as NSString).dataUsingEncoding(NSUTF8StringEncoding) + + if (deviceIdData != null) { + pubnub.addChannelsToPushNotificationsWithChannels( + channels = channels, + deviceId = deviceIdData, + onSuccess = callback.onSuccessHandler { PNPushAddChannelResult() }, + onFailure = callback.onFailureHandler() + ) + } else { + callback.accept(Result.failure(PubNubException(errorMessage = "Cannot decode $deviceId to NSData object"))) + } + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt index 482daa36a..3a3c1e10c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt @@ -16,13 +16,13 @@ actual interface CryptoModule actual fun createPNConfiguration( userId: UserId, - subscribeKey: String + subscribeKey: String, + publishKey: String ): PNConfiguration { return object : PNConfiguration { override val userId: UserId = userId override val subscribeKey: String = subscribeKey - override val publishKey: String - get() = TODO("Not yet implemented") + override val publishKey: String = publishKey override val secretKey: String get() = TODO("Not yet implemented") override val authKey: String diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt index aab770dda..bf52262b0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt @@ -5,16 +5,12 @@ "CONFLICTING_OVERLOADS" ) -import PubNub.ChannelMembershipObject -import PubNub.ChannelMetadataObject import PubNub.GetAllMetadataParameters import PubNub.GetChannelMembersParameters import PubNub.GetChannelMetadataParameters import PubNub.GetMembershipsParametersv2 import PubNub.GetUUIDMetadataParameters import PubNub.MessageAction -import PubNub.MessageEvent -import PubNub.PubnubStatus import PubNub.RemoveChannelMembersParameters import PubNub.RemoveChannelMetadataParameters import PubNub.RemoveMembershipsParameters @@ -23,9 +19,8 @@ import PubNub.SetChannelMembersParameters import PubNub.SetChannelMetadataParameters import PubNub.SetMembershipsParameters import PubNub.SetUUIDMetadataParameters -import PubNub.UUIDMembershipObject -import PubNub.UUIDMetadataObject import com.pubnub.api.JsonElement +import com.pubnub.kmp.JsMap import com.pubnub.kmp.Optional import org.khronos.webgl.ArrayBuffer import org.w3c.files.Blob @@ -34,31 +29,31 @@ import kotlin.js.Date import kotlin.js.Json import kotlin.js.Promise -typealias PubnubData = MessageEvent +typealias PubnubData = PubNub.MessageEvent -typealias SetUUIDMetadataResponse = ObjectsResponse +typealias SetUUIDMetadataResponse = ObjectsResponse typealias RemoveUUIDMetadataResponse = ObjectsResponse -typealias GetAllUUIDMetadataResponse = PagedObjectsResponse +typealias GetAllUUIDMetadataResponse = PagedObjectsResponse -typealias GetUUIDMetadataResponse = ObjectsResponse +typealias GetUUIDMetadataResponse = ObjectsResponse -typealias SetChannelMetadataResponse = ObjectsResponse +typealias SetChannelMetadataResponse = ObjectsResponse typealias RemoveChannelMetadataResponse = ObjectsResponse -typealias GetAllChannelMetadataResponse = PagedObjectsResponse +typealias GetAllChannelMetadataResponse = PagedObjectsResponse -typealias GetChannelMetadataResponse = ObjectsResponse +typealias GetChannelMetadataResponse = ObjectsResponse -typealias ManageChannelMembersResponse = PagedObjectsResponse +typealias ManageChannelMembersResponse = PagedObjectsResponse -typealias ManageMembershipsResponse = PagedObjectsResponse +typealias ManageMembershipsResponse = PagedObjectsResponse -typealias Callback = (status: PubnubStatus, response: ResponseType) -> Unit +typealias Callback = (status: PubNub.PubnubStatus, response: ResponseType) -> Unit -typealias StatusCallback = (status: PubnubStatus) -> Unit +typealias StatusCallback = (status: PubNub.PubnubStatus) -> Unit external interface ObjectsResponse { var status: Number @@ -130,6 +125,8 @@ external interface RemoveMessageActionResult { var data: Any } +@JsModule("pubnub") +@JsNonModule open external class PubNub(config: Any /* UUID | UserId */) { open var channelGroups: ChannelGroups open var push: Push @@ -1650,13 +1647,3 @@ external interface ExponentialRetryPolicyConfiguration { var maximumDelay: Number var maximumRetry: Number } - -external interface JsMap - -fun entriesOf(jsObject: JsMap): List> = - (js("Object.entries") as (dynamic) -> Array>) - .invoke(jsObject) - .map { entry -> entry[0] as String to entry[1] } - -fun JsMap.toMap(): Map = - entriesOf(this).toMap() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt index ff4df2d54..53bb131f7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt @@ -363,7 +363,10 @@ actual interface PubNub { channels: List, channelGroups: List ) + actual fun unsubscribeAll() + actual fun setToken(token: String?) + actual fun destroy() } @@ -376,7 +379,7 @@ actual fun createEventListener( onObjects: (PubNub, PNObjectEventResult) -> Unit, onFile: (PubNub, PNFileEventResult) -> Unit ): EventListener { - val listener = object : PubNubJs.ListenerParameters { + return object : PubNubJs.ListenerParameters { override val message: (PubNubJs.MessageEvent) -> Unit = { messageEvent -> onMessage(pubnub, PNMessageResult( BasePubSubResult( @@ -386,7 +389,7 @@ actual fun createEventListener( messageEvent.userMetadata as? JsonElement, // TODO kmp messageEvent.publisher ), - messageEvent.message as JsonElement, // TODO kmp + messageEvent.message.unsafeCast(), // TODO kmp null //TODO kmp error )) } @@ -448,7 +451,6 @@ actual fun createEventListener( ) ) } } - return listener } actual fun createStatusListener( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 7dffe17d1..9b206ada8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -3,40 +3,56 @@ package com.pubnub.api import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages import com.pubnub.api.endpoints.FetchMessages +import com.pubnub.api.endpoints.FetchMessagesImpl import com.pubnub.api.endpoints.MessageCounts import com.pubnub.api.endpoints.Time import com.pubnub.api.endpoints.access.GrantToken import com.pubnub.api.endpoints.access.RevokeToken import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroupImpl import com.pubnub.api.endpoints.files.DeleteFile import com.pubnub.api.endpoints.files.GetFileUrl import com.pubnub.api.endpoints.files.ListFiles import com.pubnub.api.endpoints.files.PublishFileMessage import com.pubnub.api.endpoints.message_actions.AddMessageAction +import com.pubnub.api.endpoints.message_actions.AddMessageActionImpl +import com.pubnub.api.endpoints.message_actions.GetMessageActionImpl import com.pubnub.api.endpoints.message_actions.GetMessageActions import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.endpoints.message_actions.RemoveMessageActionImpl import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata import com.pubnub.api.endpoints.objects.member.GetChannelMembers +import com.pubnub.api.endpoints.objects.member.GetChannelMembersImpl import com.pubnub.api.endpoints.objects.member.ManageChannelMembers import com.pubnub.api.endpoints.objects.membership.GetMemberships import com.pubnub.api.endpoints.objects.membership.ManageMemberships import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadataImpl import com.pubnub.api.endpoints.presence.GetState import com.pubnub.api.endpoints.presence.HereNow +import com.pubnub.api.endpoints.presence.HereNowImpl import com.pubnub.api.endpoints.presence.SetState import com.pubnub.api.endpoints.presence.WhereNow +import com.pubnub.api.endpoints.presence.WhereNowImpl +import com.pubnub.api.endpoints.pubsub.FireImpl import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.PublishImpl import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.endpoints.pubsub.SignalImpl import com.pubnub.api.endpoints.push.AddChannelsToPush import com.pubnub.api.endpoints.push.ListPushProvisions import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice @@ -60,22 +76,24 @@ import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.v2.PNConfiguration -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.StatusListener import com.pubnub.kmp.Optional +import com.pubnub.kmp.toOptional import PubNub as PubNubJs class PubNubImpl(override val configuration: PNConfiguration) : PubNub { - override fun addListener(listener: EventListener) { - TODO("Not yet implemented") + + private val jsPubNub: PubNubJs = PubNubJs(configuration.toJs()) + + override fun addListener(listener: PubNubJs.ListenerParameters) { + jsPubNub.addListener(listener) } - override fun addListener(listener: StatusListener) { - TODO("Not yet implemented") + override fun addListener(listener: PubNubJs.StatusListenerParameters) { + jsPubNub.addListener(listener) } override fun removeListener(listener: Listener) { - TODO("Not yet implemented") + jsPubNub.removeListener(listener.asDynamic()) } override fun removeAllListeners() { @@ -91,24 +109,35 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { replicate: Boolean, ttl: Int? ): Publish { - TODO("Not yet implemented") + return PublishImpl(jsPubNub, createJsObject { + this.message = message + this.channel = channel + this.storeInHistory = shouldStore + this.meta = meta + this.sendByPost = usePost + this.ttl = ttl + }) } override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { - TODO("Not yet implemented") + return FireImpl(jsPubNub, createJsObject { + this.message = message + this.channel = channel + this.meta = meta + this.sendByPost = usePost + }) } override fun signal(channel: String, message: Any): Signal { - TODO("Not yet implemented") + return SignalImpl(jsPubNub, createJsObject { + this.message = message + this.channel = channel + }) } - override fun getSubscribedChannels(): List { - TODO("Not yet implemented") - } + override fun getSubscribedChannels(): List = jsPubNub.getSubscribedChannels().toList() - override fun getSubscribedChannelGroups(): List { - TODO("Not yet implemented") - } + override fun getSubscribedChannelGroups(): List = jsPubNub.getSubscribedChannelGroups().toList() override fun addPushNotificationsOnChannels( pushType: PNPushType, @@ -156,7 +185,18 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeMessageActions: Boolean, includeMessageType: Boolean ): FetchMessages { - TODO("Not yet implemented") + return FetchMessagesImpl(jsPubNub, createJsObject { + this.channels = channels.toTypedArray() + this.start = page.start + this.end = page.end + this.count = page.limit + this.includeUUID = includeUUID + this.includeMeta = includeMeta + this.withMessageActions = includeMessageActions + this.includeMessageActions = includeMessageActions + this.includeMessageType = includeMessageType + this.stringifiedTimeToken = true + }) } override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { @@ -173,11 +213,18 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeState: Boolean, includeUUIDs: Boolean ): HereNow { - TODO("Not yet implemented") + return HereNowImpl(jsPubNub, createJsObject { + this.channels = channels.toTypedArray() + this.channelGroups = channelGroups.toTypedArray() + this.includeState = includeState + this.includeUUIDs = includeUUIDs + }) } override fun whereNow(uuid: String): WhereNow { - TODO("Not yet implemented") + return WhereNowImpl(jsPubNub, createJsObject { + this.uuid = uuid + }) } override fun setPresenceState( @@ -198,7 +245,14 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun addMessageAction(channel: String, messageAction: PNMessageAction): AddMessageAction { - TODO("Not yet implemented") + return AddMessageActionImpl(jsPubNub, createJsObject { + this.channel = channel + this.messageTimetoken = messageAction.messageTimetoken.toString() + this.action = createJsObject { + this.type = messageAction.type + this.value = messageAction.value + } + }) } override fun removeMessageAction( @@ -206,30 +260,47 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { messageTimetoken: Long, actionTimetoken: Long ): RemoveMessageAction { - TODO("Not yet implemented") + return RemoveMessageActionImpl(jsPubNub, createJsObject { + this.channel = channel + this.messageTimetoken = messageTimetoken.toString() + this.actionTimetoken = actionTimetoken.toString() + }) } override fun getMessageActions(channel: String, page: PNBoundedPage): GetMessageActions { - TODO("Not yet implemented") + return GetMessageActionImpl(jsPubNub, createJsObject { + this.channel = channel + this.start = page.start?.toString() + this.end = page.end?.toString() + this.limit = page.limit + }) } override fun addChannelsToChannelGroup(channels: List, channelGroup: String): AddChannelChannelGroup { - TODO("Not yet implemented") + return AddChannelChannelGroupImpl(jsPubNub, createJsObject { + this.channels = channels.toTypedArray() + this.channelGroup = channelGroup + }) } override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { - TODO("Not yet implemented") + return AllChannelsChannelGroupImpl(jsPubNub, createJsObject { + this.channelGroup = channelGroup + }) } override fun removeChannelsFromChannelGroup( channels: List, channelGroup: String ): RemoveChannelChannelGroup { - TODO("Not yet implemented") + return RemoveChannelChannelGroupImpl(jsPubNub, createJsObject { + this.channels = channels.toTypedArray() + this.channelGroup = channelGroup + }) } override fun listAllChannelGroups(): ListAllChannelGroup { - TODO("Not yet implemented") + return ListAllChannelGroupImpl(jsPubNub) } override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { @@ -317,16 +388,35 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { externalId: String?, profileUrl: String?, email: String?, - custom: CustomObject?, + custom: CustomObjectImpl?, includeCustom: Boolean, type: String?, status: String? ): SetUUIDMetadata { - TODO("Not yet implemented") + + val params = createJsObject { + data = UUIDMetadata( + name.toOptional(), + externalId.toOptional(), + profileUrl.toOptional(), + email.toOptional(), + status.toOptional(), + type.toOptional(), + custom.toOptional() + ) + this.uuid = uuid + + include = object : PubNubJs.`T$30` { + override var customFields: Boolean? = includeCustom + } + } + return SetUUIDMetadataImpl(jsPubNub, params) } override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { - TODO("Not yet implemented") + return RemoveUUIDMetadataImpl(jsPubNub, createJsObject { + this.uuid = uuid + }) } override fun getMemberships( @@ -395,7 +485,27 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel? ): GetChannelMembers { - TODO("Not yet implemented") + return GetChannelMembersImpl(jsPubNub, createJsObject { + this.channel = channel + this.limit = limit + this.page = page?.let { pageNotNull -> + createJsObject { + if (pageNotNull is PNPage.PNNext) { + this.next = pageNotNull.pageHash + } else { + this.prev = pageNotNull.pageHash + } + } + } + this.filter = filter + this.include = createJsObject { + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.UUIDFields = true + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.customUUIDFields = true + this.customFields = includeCustom + this.totalCount = includeCount + } + this.sort = sort.associateBy(keySelector = { pnSortKey -> pnSortKey.key.fieldName }, valueTransform = { pnSortKey -> pnSortKey.dir }) + }) } override fun setChannelMembers( @@ -471,16 +581,33 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { withPresence: Boolean, withTimetoken: Long ) { - TODO("Not yet implemented") + jsPubNub.subscribe(createJsObject { + this.channels = channels.toTypedArray() + this.channelGroups = channelGroups.toTypedArray() + this.withPresence = withPresence + this.timetoken = withTimetoken + }) } override fun unsubscribe(channels: List, channelGroups: List) { - TODO("Not yet implemented") + jsPubNub.unsubscribe(createJsObject { + this.channels = channels.toTypedArray() + this.channelGroups = channelGroups.toTypedArray() + }) + } + + override fun unsubscribeAll() { + jsPubNub.unsubscribeAll() } override fun setToken(token: String?) { - TODO("Not yet implemented") + jsPubNub.setToken(token) } + + override fun destroy() { + + } + } fun UUIDMetadata( @@ -512,14 +639,13 @@ fun Map.toJsObject(): PubNubJs.CustomObject { return custom } -fun createJsObject(configure: T.() -> Unit = {}): T = js("({})") as T +fun createJsObject(configure: T.() -> Unit = {}): T = (js("({})") as T).apply(configure) fun PNConfiguration.toJs(): PubNubJs.PNConfiguration { val config: PubNubJs.PNConfiguration = createJsObject() config.userId = userId.value config.subscribeKey = subscribeKey config.publishKey = publishKey - config.cipherKey // config.authKeys: String? // config.logVerbosity: Boolean? // config.ssl: Boolean? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt new file mode 100644 index 000000000..c80fc94cc --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt @@ -0,0 +1,34 @@ +package com.pubnub.api.endpoints + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.JsonElement +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.history.HistoryMessageType +import com.pubnub.api.models.consumer.history.PNFetchMessageItem +import com.pubnub.api.models.consumer.history.PNFetchMessagesResult +import com.pubnub.kmp.toMap + +class FetchMessagesImpl(pubnub: PubNub, params: PubNub.FetchMessagesParameters) : FetchMessages, + EndpointImpl(promiseFactory = { pubnub.fetchMessages(params) }, + responseMapping = { response -> + PNFetchMessagesResult(response.channels.toMap().mapValues { + it.value.map { item -> + PNFetchMessageItem( + item.uuid, + item.message, + item.meta as JsonElement, + item.timetoken.toString().toLong(), + item.actions?.toMap()?.mapValues { entry: Map.Entry -> + entry.value.toMap().mapValues { entry2: Map.Entry> -> + entry2.value.map { action -> + PNFetchMessageItem.Action(action.uuid, action.actionTimetoken.toString()) + } + } + }, + HistoryMessageType.of(item.messageType?.toString()?.toInt()), + null, //TODO item.error + ) + } + }, response.more?.let { PNBoundedPage(it.start.toLong(), null, it.max.toInt()) }) + }) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroupImpl.kt new file mode 100644 index 000000000..34a72c9f2 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroupImpl.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.endpoints.channel_groups + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult + +class AddChannelChannelGroupImpl(pubnub: PubNub, params: PubNub.AddChannelParameters) : AddChannelChannelGroup, EndpointImpl( + promiseFactory = { pubnub.channelGroups.addChannels(params) }, + responseMapping = { + PNChannelGroupsAddChannelResult() + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt new file mode 100644 index 000000000..8d8f292c9 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt @@ -0,0 +1,14 @@ +package com.pubnub.api.endpoints.channel_groups + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult + +class AllChannelsChannelGroupImpl(pubnub: PubNub, params: PubNub.ListChannelsParameters) : AllChannelsChannelGroup, EndpointImpl( + promiseFactory = { pubnub.channelGroups.listChannels(params) }, + responseMapping = { + PNChannelGroupsAllChannelsResult( + it.channels.toList() + ) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroupImpl.kt new file mode 100644 index 000000000..e3221b0e1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroupImpl.kt @@ -0,0 +1,15 @@ +package com.pubnub.api.endpoints.channel_groups + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult + +class ListAllChannelGroupImpl(pubnub: PubNub) : ListAllChannelGroup, + EndpointImpl( + promiseFactory = { pubnub.channelGroups.listGroups() }, + responseMapping = { + PNChannelGroupsListAllResult( + it.groups.toList() + ) + } + ) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt new file mode 100644 index 000000000..96aa269ac --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt @@ -0,0 +1,13 @@ +package com.pubnub.api.endpoints.channel_groups + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult + +class RemoveChannelChannelGroupImpl(pubnub: PubNub, params: PubNub.RemoveChannelParameters) : RemoveChannelChannelGroup, + EndpointImpl( + promiseFactory = { pubnub.channelGroups.removeChannels(params) }, + responseMapping = { + PNChannelGroupsRemoveChannelResult() + } + ) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt new file mode 100644 index 000000000..71331d746 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt @@ -0,0 +1,22 @@ +package com.pubnub.api.endpoints.message_actions + +import AddMessageActionResult +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult +import com.pubnub.api.models.consumer.message_actions.PNMessageAction + +class AddMessageActionImpl(pubnub: PubNub, params: PubNub.AddMessageActionParameters) : AddMessageAction, EndpointImpl( + promiseFactory = { pubnub.addMessageAction(params) }, + responseMapping = { + PNAddMessageActionResult( + PNMessageAction( + it.data.type, + it.data.value, + it.data.messageTimetoken.toLong() + ).apply { + actionTimetoken = it.data.actionTimetoken.toLong() + } + ) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt new file mode 100644 index 000000000..dd7589e17 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt @@ -0,0 +1,27 @@ +package com.pubnub.api.endpoints.message_actions + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult +import com.pubnub.api.models.consumer.message_actions.PNMessageAction + +class GetMessageActionImpl(pubnub: PubNub, params: PubNub.GetMessageActionsParameters) : GetMessageActions, EndpointImpl( + promiseFactory = { pubnub.getMessageActions(params) }, + responseMapping = { + PNGetMessageActionsResult( + it.data.map { + PNMessageAction( + it.type, + it.value, + it.messageTimetoken.toLong() + ).apply { + actionTimetoken = it.actionTimetoken.toLong() + } + }, + it.start?.let { startNotNull -> + PNBoundedPage(startNotNull.toLong(), it.end?.toLong(), null) //TODO kmp does js not return limit? + } + ) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageActionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageActionImpl.kt new file mode 100644 index 000000000..b2c212744 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageActionImpl.kt @@ -0,0 +1,13 @@ +package com.pubnub.api.endpoints.message_actions + +import PubNub +import RemoveMessageActionResult +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult + +class RemoveMessageActionImpl(pubnub: PubNub, params: PubNub.RemoveMessageActionParameters) : RemoveMessageAction, EndpointImpl( + promiseFactory = { pubnub.removeMessageAction(params) }, + responseMapping = { + PNRemoveMessageActionResult() + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt new file mode 100644 index 000000000..83c78145e --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt @@ -0,0 +1,42 @@ +package com.pubnub.api.endpoints.objects.member + +import ManageChannelMembersResponse +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.member.PNMember +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.kmp.toMap + +class GetChannelMembersImpl(pubnub: PubNub, params: PubNub.GetChannelMembersParameters) : GetChannelMembers, EndpointImpl( + promiseFactory = { pubnub.objects.getChannelMembers(params) }, + responseMapping = { + PNMemberArrayResult( + it.status.toInt(), + it.data.map { member -> + PNMember( + PNUUIDMetadata( + member.uuid.id, + member.uuid.name, + member.uuid.externalId, + member.uuid.profileUrl, + member.uuid.email, + member.uuid.custom?.toMap(), + member.uuid.updated, + member.uuid.eTag, + member.uuid.type, + member.uuid.status + ), + member.custom, + member.updated, + member.eTag, + member.status + ) + }, + it.totalCount?.toInt(), + it.next?.let { next -> PNPage.PNNext(next) }, + it.prev?.let { prev -> PNPage.PNPrev(prev) }, + ) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt new file mode 100644 index 000000000..09bdb69a1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt @@ -0,0 +1,18 @@ +package com.pubnub.api.endpoints.objects.uuid + +import PubNub +import SetUUIDMetadataResponse +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.kmp.toMap + +class SetUUIDMetadataImpl(pubnub: PubNub, params: PubNub.SetUUIDMetadataParameters) : SetUUIDMetadata, + EndpointImpl(promiseFactory = { pubnub.objects.setUUIDMetadata(params) }, + responseMapping = { + PNUUIDMetadataResult(it.status.toInt(), with(it.data) { + PNUUIDMetadata( + id, name, externalId, profileUrl, email, custom?.toMap(), updated, eTag, type, status + ) + }) + }) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt new file mode 100644 index 000000000..4d47edb02 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt @@ -0,0 +1,32 @@ +package com.pubnub.api.endpoints.presence + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.JsonElement +import com.pubnub.api.models.consumer.presence.PNHereNowChannelData +import com.pubnub.api.models.consumer.presence.PNHereNowOccupantData +import com.pubnub.api.models.consumer.presence.PNHereNowResult +import com.pubnub.kmp.toMap + +class HereNowImpl(pubnub: PubNub, params: PubNub.HereNowParameters) : HereNow, EndpointImpl( + promiseFactory = { pubnub.hereNow(params) }, + responseMapping = { hereNowResponse -> + PNHereNowResult( + hereNowResponse.totalChannels.toInt(), + hereNowResponse.totalOccupancy.toInt(), + hereNowResponse.channels.toMap().mapValues { + val data = it.value + PNHereNowChannelData( + data.name, + data.occupancy.toInt(), + data.occupants.map { occupant -> + PNHereNowOccupantData( + occupant.uuid, + occupant.state as JsonElement // TODO kmp + ) + } + ) + }.toMutableMap() + ) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNowImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNowImpl.kt new file mode 100644 index 000000000..7cb36d77e --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNowImpl.kt @@ -0,0 +1,14 @@ +package com.pubnub.api.endpoints.presence + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.presence.PNWhereNowResult + +class WhereNowImpl(pubnub: PubNub, params: PubNub.WhereNowParameters) : WhereNow, EndpointImpl( + promiseFactory = { pubnub.whereNow(params) }, + responseMapping = { whereNowResponse -> + PNWhereNowResult( + whereNowResponse.channels.toList() + ) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/FireImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/FireImpl.kt new file mode 100644 index 000000000..65591fd60 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/FireImpl.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.endpoints.pubsub + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.PNPublishResult + +class FireImpl(pubnub: PubNub, params: PubNub.FireParameters) : Publish, EndpointImpl( + promiseFactory = { pubnub.fire(params) }, + responseMapping = { + PNPublishResult(it.timetoken.toLong()) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/PublishImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/PublishImpl.kt new file mode 100644 index 000000000..82733b2dd --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/PublishImpl.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.endpoints.pubsub + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.PNPublishResult + +class PublishImpl(pubnub: PubNub, params: PubNub.PublishParameters) : Publish, EndpointImpl( + promiseFactory = { pubnub.publish(params) }, + responseMapping = { + PNPublishResult(it.timetoken.toLong()) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/SignalImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/SignalImpl.kt new file mode 100644 index 000000000..1c2a665cc --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/SignalImpl.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.endpoints.pubsub + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.PNPublishResult + +class SignalImpl(pubnub: PubNub, params: PubNub.SignalParameters) : Signal, EndpointImpl( + promiseFactory = { pubnub.signal(params) }, + responseMapping = { + PNPublishResult(it.timetoken.toLong()) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt index 668a06247..569331ff0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt @@ -1,9 +1,6 @@ package com.pubnub.api.v2 import com.pubnub.api.UserId -import com.pubnub.api.enums.PNHeartbeatNotificationOptions -import com.pubnub.api.enums.PNLogVerbosity -import com.pubnub.api.retry.RetryConfiguration actual interface PNConfiguration { actual val userId: UserId @@ -16,7 +13,8 @@ actual interface PNConfiguration { actual fun createPNConfiguration( userId: UserId, - subscribeKey: String + subscribeKey: String, + publishKey: String ): PNConfiguration { return object : PNConfiguration { override val userId: UserId @@ -24,7 +22,7 @@ actual fun createPNConfiguration( override val subscribeKey: String get() = subscribeKey override val publishKey: String - get() = "" + get() = publishKey override val secretKey: String get() = TODO("Not yet implemented") override val authKey: String diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt new file mode 100644 index 000000000..e851b59d5 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt @@ -0,0 +1,11 @@ +package com.pubnub.kmp + +external interface JsMap + +fun entriesOf(jsObject: JsMap): List> = + (js("Object.entries") as (dynamic) -> Array>) + .invoke(jsObject) + .map { entry -> entry[0] as String to entry[1] } + +fun JsMap.toMap(): Map = + entriesOf(this).toMap() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt index 5af0c54ae..120a2d100 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt @@ -5,9 +5,12 @@ import com.pubnub.api.crypto.CryptoModule actual fun createPNConfiguration( userId: UserId, - subscribeKey: String + subscribeKey: String, + publishKey: String ): PNConfiguration { - return PNConfiguration.builder(userId, subscribeKey).build() + return PNConfiguration.builder(userId, subscribeKey) { + this.publishKey = publishKey + }.build() } actual typealias CryptoModule = CryptoModule \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts index 1c9cf62d1..7b7ae92fe 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -1,13 +1,23 @@ +import org.jetbrains.dokka.DokkaDefaults.moduleName +import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType + plugins { alias(libs.plugins.benmanes.versions) id("pubnub.shared") kotlin("multiplatform") + kotlin("native.cocoapods") } kotlin { jvmToolchain(8) js { browser { + testTask { + useMocha { + timeout = "10s" + } + } + } binaries.executable() } @@ -22,6 +32,12 @@ kotlin { } } + listOf( + iosArm64(), +// iosX64(), + iosSimulatorArm64(), + ) + sourceSets { val commonMain by getting { dependencies { @@ -31,11 +47,55 @@ kotlin { } } - val jvmMain by getting { + val commonTest by getting { dependencies { - implementation(project(":pubnub-core:pubnub-core-impl")) + implementation(kotlin("test")) + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1") + } + } + + val jvmTest by getting { + dependencies { + implementation(project(":pubnub-kotlin:pubnub-kotlin-impl")) implementation(libs.slf4j) } } } + + cocoapods { + ios.deploymentTarget = "14" + + // Required properties + // Specify the required Pod version here. Otherwise, the Gradle project version is used. + version = "1.0" + summary = "Some description for a Kotlin/Native module" + homepage = "Link to a Kotlin/Native module homepage" + + // Optional properties + // Configure the Pod name here instead of changing the Gradle project name + name = "PubNubKMPTest" + + // Maps custom Xcode configuration to NativeBuildType + xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG + xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE + + framework { + // Required properties + // Framework name configuration. Use this property instead of deprecated 'frameworkName' + baseName = "PubNubKMPTest" + + // Optional properties + // Specify the framework linking type. It's dynamic by default. + isStatic = true + } + + pod("PubNubSwift") { + source = git("https://github.com/pubnub/swift") { + branch = "feat/kmp" + } + + moduleName = "PubNub" + extraOpts += listOf("-compiler-option", "-fmodules") + } + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/createEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/createEndpoint.kt deleted file mode 100644 index 8402c7a2a..000000000 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/createEndpoint.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.test - -import com.pubnub.api.Endpoint - -expect fun createEndpoint(action: () -> T): Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt new file mode 100644 index 000000000..7f5f59dfa --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt @@ -0,0 +1,47 @@ +package com.pubnub.api + +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch +import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.withContext +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue +import kotlin.time.Duration.Companion.seconds + +class PublishTest : BaseIntegrationTest() { + private val channel = "myChannel" + + @Test + fun can_publish_message() = runTest { + val result = pubnub.publish(channel, "some message").await() + assertTrue { result.timetoken > 0 } + } + + @Test + fun can_receive_message() = runTest(timeout = 10.seconds) { + val queue = Channel() + pubnub.addListener(createEventListener(pubnub, onMessage = {pubNub, pnMessageResult -> + backgroundScope.launch { + queue.send(pnMessageResult) + } + })) + pubnub.subscribeWithDelay(channel) + + pubnub.publish(channel, "some message").await() + val result = queue.receive() + assertEquals("some message", result.message.asString()) + } +} + +private suspend fun PubNub.subscribeWithDelay(channel: String) { + subscribe(listOf(channel)) + withContext(Dispatchers.Default) { + delay(1.seconds) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt new file mode 100644 index 000000000..5d29e4ff9 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt @@ -0,0 +1,39 @@ +package com.pubnub.test + +import com.pubnub.api.Endpoint +import com.pubnub.api.PubNub +import com.pubnub.api.UserId +import com.pubnub.api.createPubNub +import com.pubnub.api.v2.createPNConfiguration +import kotlinx.coroutines.suspendCancellableCoroutine +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException +import kotlin.test.AfterTest +import kotlin.test.BeforeTest + +abstract class BaseIntegrationTest { + + lateinit var pubnub: PubNub + + @BeforeTest + fun before() { + pubnub = createPubNub(createPNConfiguration(UserId("demo_user"), "demo", "demo")) + } + + @AfterTest + fun after() { + pubnub.unsubscribeAll() + pubnub.destroy() + } +} + + +suspend fun Endpoint.await() = suspendCancellableCoroutine { cont -> + async { result -> + result.onSuccess { + cont.resume(it) + }.onFailure { + cont.resumeWithException(it) + } + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt deleted file mode 100644 index 8ce17ea3f..000000000 --- a/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.pubnub.test - -import com.pubnub.api.Endpoint - -actual fun createEndpoint(action: () -> T): Endpoint { - TODO("Not yet implemented") -} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt deleted file mode 100644 index c3ecc3cdc..000000000 --- a/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.pubnub.test - -import com.pubnub.api.Endpoint -import com.pubnub.api.PubNubException -import com.pubnub.api.enums.PNOperationType -import com.pubnub.api.v2.PNConfiguration -import com.pubnub.api.v2.PNConfigurationOverride -import com.pubnub.api.v2.callbacks.Result -import java.util.function.Consumer - -actual fun createEndpoint(action: () -> T): Endpoint { - return object : Endpoint { - override fun overrideConfiguration(action: PNConfigurationOverride.Builder.() -> Unit): Endpoint { - TODO("Not yet implemented") - } - - override fun overrideConfiguration(configuration: PNConfiguration): Endpoint { - TODO("Not yet implemented") - } - - override fun operationType(): PNOperationType { - TODO("Not yet implemented") - } - - override fun sync(): T { - TODO("Not yet implemented") - } - - override fun retry() { - TODO("Not yet implemented") - } - - override fun silentCancel() { - TODO("Not yet implemented") - } - - override fun async(callback: Consumer>) { - try { - callback.accept(Result.success(action())) - } catch (e: PubNubException) { - callback.accept(Result.failure(e)) - } - } - } -} \ No newline at end of file From 98553875b7712ad8ad0f457bb55bab628c994a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 21 May 2024 14:08:01 +0000 Subject: [PATCH 04/62] Continue adding JS implementations for KMP (#215) * Add JS wrappers for some endpoints * First tests for common code * Add integrationTest gradle task * [JS] Fix JsonElement casts * We can run iOS tests now. * Configurable iOS simulator through gradle.properties * Make listeners work in JS and update PublishTest * Only run simulator tasks on macOs hosts * Add getState, deleteChannelGroup and grantToken for JS KMP --- build-logic/gradle-plugins/build.gradle.kts | 4 + .../gradle/PubNubIntegrationTestPlugin.kt | 18 ++- .../gradle/PubNubIosSimulatorTestPlugin.kt | 48 ++++++ gradle.properties | 2 + gradle/libs.versions.toml | 4 + .../com/pubnub/api/PubNubException.ios.kt | 16 +- .../kotlin/com/pubnub/api/JsonElement.js.kt | 6 +- .../consumer/objects/member/PNMember.kt | 2 +- .../objects/membership/PNChannelMembership.kt | 2 +- .../pubnub-kotlin-api/build.gradle.kts | 6 - .../kotlin/com/pubnub/api/PubNub.kt | 50 ++----- .../consumer/objects/member/PNMember.kt | 2 +- .../objects/membership/PNChannelMembership.kt | 5 +- .../pubnub/api/v2/callbacks/EventListener.kt | 4 +- .../pubnub/api/v2/callbacks/StatusListener.kt | 3 +- .../kotlin/com/pubnub/kmp/abstractions.kt | 3 + .../kotlin/com/pubnub/kmp/factories.kt | 31 ++++ .../kotlin/com/pubnub/api/PubNub.ios.kt | 47 +----- .../kotlin/com/pubnub/api/PubNubImpl.kt | 18 +-- .../api/endpoints/pubsub/Publish.ios.kt | 4 +- .../pubnub/api/endpoints/pubsub/Signal.ios.kt | 2 +- .../api/v2/callbacks/EventListener.ios.kt | 4 +- .../api/v2/callbacks/StatusListener.ios.kt | 4 +- .../kotlin/com/pubnub/kmp/abstractions.ios.kt | 3 + .../kotlin/com/pubnub/kmp/factories.ios.kt | 41 +++++ .../src/jsMain/kotlin/Pubnub.d.kt | 22 +-- .../jsMain/kotlin/com/pubnub/api/PubNub.js.kt | 135 +---------------- .../kotlin/com/pubnub/api/PubNubImpl.kt | 89 ++++++++--- .../pubnub/api/endpoints/FetchMessagesImpl.kt | 3 +- .../api/endpoints/access/GrantToken.js.kt | 3 +- .../api/endpoints/access/GrantTokenImpl.kt | 14 ++ .../channel_groups/DeleteChannelGroupImpl.kt | 13 ++ .../objects/member/GetChannelMembersImpl.kt | 2 +- .../api/endpoints/presence/GetStateImpl.kt | 20 +++ .../api/endpoints/presence/HereNowImpl.kt | 3 +- .../api/endpoints/presence/SetState.js.kt | 3 +- .../api/endpoints/presence/SetStateImpl.kt | 15 ++ .../api/v2/callbacks/EventListener.js.kt | 4 +- .../api/v2/callbacks/StatusListener.js.kt | 3 +- .../src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt | 8 + .../kotlin/com/pubnub/kmp/abstractions.js.kt | 5 + .../kotlin/com/pubnub/kmp/factories.js.kt | 140 ++++++++++++++++++ .../jvmMain/kotlin/com/pubnub/api/PubNub.kt | 28 +++- .../pubnub/api/v2/callbacks/EventListener.kt | 3 +- .../pubnub/api/v2/callbacks/StatusListener.kt | 3 +- .../kotlin/com/pubnub/kmp/abstractions.jvm.kt | 3 + .../PubNub.jvm.kt => kmp/factories.jvm.kt} | 13 +- .../kotlin/com/pubnub/internal/PubNubImpl.kt | 15 ++ .../pubnub-kotlin-test/build.gradle.kts | 19 ++- .../kotlin/com/pubnub/api/PublishTest.kt | 43 ++++-- .../com/pubnub/test/BaseIntegrationTest.kt | 5 +- .../src/iosTest/kotlin/testlauncher.kt | 18 +++ 52 files changed, 627 insertions(+), 334 deletions(-) create mode 100644 build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetStateImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt rename pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/{api/PubNub.jvm.kt => kmp/factories.jvm.kt} (97%) create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/iosTest/kotlin/testlauncher.kt diff --git a/build-logic/gradle-plugins/build.gradle.kts b/build-logic/gradle-plugins/build.gradle.kts index 4c427abce..3ffddb56d 100644 --- a/build-logic/gradle-plugins/build.gradle.kts +++ b/build-logic/gradle-plugins/build.gradle.kts @@ -42,5 +42,9 @@ gradlePlugin { id = "pubnub.kotlin-library" implementationClass = "com.pubnub.gradle.PubNubKotlinLibraryPlugin" } + register("pubnubIosSimulatorTest") { + id = "pubnub.ios-simulator-test" + implementationClass = "com.pubnub.gradle.PubNubIosSimulatorTestPlugin" + } } } \ No newline at end of file diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIntegrationTestPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIntegrationTestPlugin.kt index fa1e3b885..1987ebdf6 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIntegrationTestPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIntegrationTestPlugin.kt @@ -4,19 +4,35 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.JavaLibraryPlugin import org.gradle.api.tasks.SourceSetContainer +import org.gradle.api.tasks.testing.Test import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.register class PubNubIntegrationTestPlugin : Plugin { override fun apply(target: Project) { with(target) { apply() + val integrationTestTask = tasks.register("integrationTest") { + description = "Runs integration tests." + group = "verification" + + useJUnitPlatform() + testLogging { + it.events("passed") + } + } + configure { - create("integrationTest") { + val integrationTestSourceSet = create("integrationTest") { it.compileClasspath += getByName("main").output it.runtimeClasspath += getByName("main").output } + integrationTestTask.configure { + it.testClassesDirs = integrationTestSourceSet.output.classesDirs + it.classpath = integrationTestSourceSet.runtimeClasspath + } } configurations.getByName("integrationTestImplementation") { diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt new file mode 100644 index 000000000..2c69993a8 --- /dev/null +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt @@ -0,0 +1,48 @@ +package com.pubnub.gradle + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.tasks.Exec +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.register +import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper +import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest +import java.io.ByteArrayOutputStream + +class PubNubIosSimulatorTestPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + apply() + + val deviceName = project.findProperty("IOS_SIMULATOR_ID") as? String ?: "iPhone 15 Pro" + val isMacOs = providers.systemProperty("os.name").map { it.contains("mac", ignoreCase = true) } + + val bootTask = tasks.register("bootIOSSimulator") { + onlyIf { isMacOs.get() } + isIgnoreExitValue = true + commandLine("xcrun", "simctl", "boot", deviceName) + doLast { + val result = executionResult.get() + if (result.exitValue != 148 && result.exitValue != 149) { // ignoring device already booted errors + result.assertNormalExitValue() + } + } + } + + val shutdownTask = tasks.register("shutdownIOSSimulator") { + onlyIf { isMacOs.get() } + commandLine("xcrun", "simctl", "shutdown", deviceName) + dependsOn(tasks.withType()) + } + + tasks.withType().configureEach { + it.onlyIf { isMacOs.get() } + it.standalone.set(false) + it.device.set(deviceName) + it.dependsOn(bootTask) + it.finalizedBy(shutdownTask) + } + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index b5ae4e47f..24b0bf128 100644 --- a/gradle.properties +++ b/gradle.properties @@ -38,3 +38,5 @@ POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/pubnub/kotlin POM_DEVELOPER_ID=PubNub POM_DEVELOPER_NAME=PubNub POM_DEVELOPER_URL=support@pubnub.com + +IOS_SIMULATOR_ID=iPhone 15 Pro diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b1b5fbff6..4f2244181 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,6 +9,8 @@ kotlin = "2.0.0-RC3" vanniktech = "0.22.0" ktlint = "12.1.0" dokka = "1.9.20" +kotlinx_datetime = "0.6.0-RC.2" +kotlinx_coroutines = "1.8.1" [libraries] retrofit2 = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit2" } @@ -37,6 +39,8 @@ mockk = { module = "io.mockk:mockk", version = "1.11.0" } owner = { module = "org.aeonbits.owner:owner", version = "1.0.12" } mockito = { module = "org.mockito:mockito-core", version = "4.8.1" } hamcrest = { module = "org.hamcrest:hamcrest-all", version = "1.3" } +datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx_datetime"} +coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "kotlinx_coroutines"} # plugins for included build kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt index 6c24c4f11..117e84624 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt @@ -9,19 +9,17 @@ package com.pubnub.api * @property statusCode HTTP status code. * @property affectedCall A reference to the affected call. Useful for calling [retry][Endpoint.retry]. */ -actual class PubNubException() : Exception() { +actual class PubNubException actual constructor(errorMessage: String?): Exception(errorMessage) { - actual constructor(pubnubError: PubNubError): this() { - TODO("Not yet implemented") - } - - actual constructor(errorMessage: String?) : this() { - TODO("Not yet implemented") - } + actual constructor(pubnubError: PubNubError) : this(pubnubError.message) actual companion object { actual fun from(e: Throwable): PubNubException { - TODO("Not yet implemented") + return if (e is PubNubException) { + e + } else { + PubNubException(e.message) + } } } } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt index fb08af7ff..0af1950d8 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt @@ -2,8 +2,10 @@ package com.pubnub.api -actual abstract class JsonElement +actual abstract class JsonElement(val value: Any?) + +class JsonElementImpl(value: Any?) : JsonElement(value) actual fun JsonElement.asString(): String { - return this.toString() // todo ? + return value.toString() // todo kmp } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt index d187ea95c..a6c889284 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt @@ -4,7 +4,7 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata data class PNMember( val uuid: PNUUIDMetadata?, - val custom: Any? = null, + val custom: Map? = null, val updated: String, val eTag: String, val status: String?, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt index 583155159..8178158fb 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt @@ -4,7 +4,7 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata data class PNChannelMembership( val channel: PNChannelMetadata?, - val custom: Any?, + val custom: Map?, val updated: String, val eTag: String, val status: String?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index 13f88526f..5f1161853 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -90,12 +90,6 @@ kotlin { } } - val commonTest by getting { - dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0-RC.2") - } - } - val jvmMain by getting { dependencies { implementation(project(":pubnub-core:pubnub-core-impl")) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt index 0149709bf..b413e08ee 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt @@ -44,7 +44,6 @@ import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant @@ -60,32 +59,10 @@ import com.pubnub.api.models.consumer.objects.member.MemberInput import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -import com.pubnub.api.models.consumer.pubsub.PNSignalResult -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener - -expect fun createPubNub(config: PNConfiguration): PubNub - -expect fun createEventListener( - pubnub: PubNub, - onMessage: (PubNub, PNMessageResult) -> Unit = { _, _ -> }, - onPresence: (PubNub, PNPresenceEventResult) -> Unit = { _, _ -> }, - onSignal: (PubNub, PNSignalResult) -> Unit = { _, _ -> }, - onMessageAction: (PubNub, PNMessageActionResult) -> Unit = { _, _ -> }, - onObjects: (PubNub, PNObjectEventResult) -> Unit = { _, _ -> }, - onFile: (PubNub, PNFileEventResult) -> Unit = { _, _ -> }, -): EventListener - -expect fun createStatusListener( - pubnub: PubNub, - onStatus: (PubNub, PNStatus) -> Unit = { _, _ -> }, -): StatusListener +import com.pubnub.kmp.CustomObject expect interface PubNub { val configuration: PNConfiguration @@ -176,11 +153,20 @@ expect interface PubNub { ): HereNow fun whereNow(uuid: String = configuration.userId.value): WhereNow + + +// TODO bring back when/if all SDKs accept a `uuid` parameter +// fun setPresenceState( +// channels: List = listOf(), +// channelGroups: List = listOf(), +// state: Any, +// uuid: String = configuration.userId.value, +// ): SetState + fun setPresenceState( channels: List = listOf(), channelGroups: List = listOf(), state: Any, - uuid: String = configuration.userId.value, ): SetState fun getPresenceState( @@ -227,21 +213,13 @@ expect interface PubNub { fun grantToken( ttl: Int, - meta: Any? = null, + meta: CustomObject? = null, authorizedUUID: String? = null, channels: List = emptyList(), channelGroups: List = emptyList(), uuids: List = emptyList(), ): GrantToken - fun grantToken( - ttl: Int, - meta: Any? = null, - authorizedUserId: UserId? = null, - spacesPermissions: List = emptyList(), - usersPermissions: List = emptyList(), - ): GrantToken - fun revokeToken(token: String): RevokeToken fun time(): Time fun getAllChannelMetadata( @@ -445,7 +423,3 @@ expect interface PubNub { fun destroy() } - -expect class CustomObject - -expect fun createCustomObject(map: Map): CustomObject diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt index 213e2a629..d2c5bfe64 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt @@ -4,7 +4,7 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata data class PNMember( val uuid: PNUUIDMetadata?, - val custom: Any? = null, + val custom: Map? = null, val updated: String, val eTag: String, val status: String?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt index f52a83922..5eb450e8b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt @@ -1,17 +1,18 @@ package com.pubnub.api.models.consumer.objects.membership +import com.pubnub.kmp.CustomObject import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata data class PNChannelMembership( val channel: PNChannelMetadata?, - val custom: Any?, + val custom: Map?, val updated: String, val eTag: String, val status: String?, ) { data class Partial( val channelId: String, - override val custom: Any? = null, + override val custom: CustomObject? = null, override val status: String? = null, ) : ChannelMembershipInput { override val channel: String = channelId diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt index 514a82487..2d61024fa 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt @@ -1,7 +1,9 @@ package com.pubnub.api.v2.callbacks +import com.pubnub.api.callbacks.Listener + /** * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -expect interface EventListener \ No newline at end of file +expect interface EventListener : Listener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt index e8294d9d9..03c3c98a1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt @@ -1,10 +1,11 @@ package com.pubnub.api.v2.callbacks import com.pubnub.api.PubNub +import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.PNStatus /** * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for * PubNub connection status changes. */ -expect interface StatusListener \ No newline at end of file +expect interface StatusListener : Listener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt new file mode 100644 index 000000000..a9e844b1b --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt @@ -0,0 +1,3 @@ +package com.pubnub.kmp + +expect class CustomObject \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt new file mode 100644 index 000000000..0642ffe31 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt @@ -0,0 +1,31 @@ +package com.pubnub.kmp + +import com.pubnub.api.PubNub +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener + +expect fun createPubNub(config: PNConfiguration): PubNub +expect fun createEventListener( + pubnub: PubNub, + onMessage: (PubNub, PNMessageResult) -> Unit = { _, _ -> }, + onPresence: (PubNub, PNPresenceEventResult) -> Unit = { _, _ -> }, + onSignal: (PubNub, PNSignalResult) -> Unit = { _, _ -> }, + onMessageAction: (PubNub, PNMessageActionResult) -> Unit = { _, _ -> }, + onObjects: (PubNub, PNObjectEventResult) -> Unit = { _, _ -> }, + onFile: (PubNub, PNFileEventResult) -> Unit = { _, _ -> }, +): EventListener + +expect fun createStatusListener( + pubnub: PubNub, + onStatus: (PubNub, PNStatus) -> Unit = { _, _ -> }, +): StatusListener + +expect fun createCustomObject(map: Map): CustomObject \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt index f25efdce5..5bcdb6eeb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt @@ -44,7 +44,6 @@ import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant @@ -60,15 +59,10 @@ import com.pubnub.api.models.consumer.objects.member.MemberInput import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -import com.pubnub.api.models.consumer.pubsub.PNSignalResult -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.kmp.CustomObject actual interface PubNub { actual val configuration: PNConfiguration @@ -159,7 +153,6 @@ actual interface PubNub { channels: List, channelGroups: List, state: Any, - uuid: String ): SetState actual fun getPresenceState( @@ -205,21 +198,13 @@ actual interface PubNub { actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup actual fun grantToken( ttl: Int, - meta: Any?, + meta: CustomObject?, authorizedUUID: String?, channels: List, channelGroups: List, uuids: List ): GrantToken - actual fun grantToken( - ttl: Int, - meta: Any?, - authorizedUserId: UserId?, - spacesPermissions: List, - usersPermissions: List - ): GrantToken - actual fun revokeToken(token: String): RevokeToken actual fun time(): Time actual fun getAllChannelMetadata( @@ -416,31 +401,3 @@ actual interface PubNub { } -actual fun createStatusListener( - pubnub: PubNub, - onStatus: (PubNub, PNStatus) -> Unit -): StatusListener { - TODO("Not yet implemented") -} - -actual fun createEventListener( - pubnub: PubNub, - onMessage: (PubNub, PNMessageResult) -> Unit, - onPresence: (PubNub, PNPresenceEventResult) -> Unit, - onSignal: (PubNub, PNSignalResult) -> Unit, - onMessageAction: (PubNub, PNMessageActionResult) -> Unit, - onObjects: (PubNub, PNObjectEventResult) -> Unit, - onFile: (PubNub, PNFileEventResult) -> Unit -): EventListener { - TODO("Not yet implemented") -} - -actual class CustomObject - -actual fun createCustomObject(map: Map): CustomObject { - TODO("Not yet implemented") -} - -actual fun createPubNub(config: PNConfiguration): PubNub { - return PubNubImpl(config) -} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 4fdf024ab..0b89cc359 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -65,6 +65,7 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.kmp.CustomObject import kotlinx.cinterop.ExperimentalForeignApi class PubNubImpl(override val configuration: PNConfiguration) : PubNub { @@ -222,7 +223,6 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { channels: List, channelGroups: List, state: Any, - uuid: String ): SetState { TODO("Not yet implemented") } @@ -276,7 +276,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { override fun grantToken( ttl: Int, - meta: Any?, + meta: CustomObject?, authorizedUUID: String?, channels: List, channelGroups: List, @@ -285,16 +285,6 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { TODO("Not yet implemented") } - override fun grantToken( - ttl: Int, - meta: Any?, - authorizedUserId: UserId?, - spacesPermissions: List, - usersPermissions: List - ): GrantToken { - TODO("Not yet implemented") - } - override fun revokeToken(token: String): RevokeToken { TODO("Not yet implemented") } @@ -521,10 +511,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun destroy() { - TODO("Not yet implemented") +// TODO("Not yet implemented") } override fun unsubscribeAll() { - TODO("Not yet implemented") +// TODO("Not yet implemented") } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt index 023511258..648280233 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt @@ -10,6 +10,8 @@ import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSNumber +import platform.posix.uint64_t +import platform.zlib.uLong /** * @see [PubNub.publish] @@ -32,7 +34,7 @@ open class PublishImpl( meta = meta, shouldStore = if (shouldStore != null) NSNumber(bool = shouldStore) else null, ttl = if (ttl != null) NSNumber(int = ttl) else null, - onResponse = callback.onSuccessHandler { PNPublishResult(it.toLong()) }, + onSuccess = callback.onSuccessHandler { PNPublishResult(it.toLong()) }, onFailure = callback.onFailureHandler() ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt index 3282f54fa..a977c3823 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt @@ -24,7 +24,7 @@ open class SignalImpl( pubnub.signalWithChannel( channel = channel, message = message, - onResponse = callback.onSuccessHandler { PNPublishResult(it.toLong()) }, + onSuccess = callback.onSuccessHandler { PNPublishResult(it.toLong()) }, onFailure = callback.onFailureHandler() ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt index 86277e0fd..e887dd21f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -1,7 +1,9 @@ package com.pubnub.api.v2.callbacks +import com.pubnub.api.callbacks.Listener + /** * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -actual interface EventListener \ No newline at end of file +actual interface EventListener : Listener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt index 7415353a5..feb40c8cc 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt @@ -1,7 +1,9 @@ package com.pubnub.api.v2.callbacks +import com.pubnub.api.callbacks.Listener + /** * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for * PubNub connection status changes. */ -actual interface StatusListener \ No newline at end of file +actual interface StatusListener : Listener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt new file mode 100644 index 000000000..ba8b9b040 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt @@ -0,0 +1,3 @@ +package com.pubnub.kmp + +actual class CustomObject \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt new file mode 100644 index 000000000..fb39ea2f8 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -0,0 +1,41 @@ +package com.pubnub.kmp + +import com.pubnub.api.PubNub +import com.pubnub.api.PubNubImpl +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener + +actual fun createPubNub(config: PNConfiguration): PubNub { + return PubNubImpl(config) +} + +actual fun createEventListener( + pubnub: PubNub, + onMessage: (PubNub, PNMessageResult) -> Unit, + onPresence: (PubNub, PNPresenceEventResult) -> Unit, + onSignal: (PubNub, PNSignalResult) -> Unit, + onMessageAction: (PubNub, PNMessageActionResult) -> Unit, + onObjects: (PubNub, PNObjectEventResult) -> Unit, + onFile: (PubNub, PNFileEventResult) -> Unit +): EventListener { + TODO("Not yet implemented") +} + +actual fun createStatusListener( + pubnub: PubNub, + onStatus: (PubNub, PNStatus) -> Unit +): StatusListener { + TODO("Not yet implemented") +} + +actual fun createCustomObject(map: Map): CustomObject { + TODO("Not yet implemented") +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt index bf52262b0..15262a9b9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt @@ -156,7 +156,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { open fun reconnect() open fun addListener(params: ListenerParameters) open fun addListener(params: StatusListenerParameters) - open fun removeListener(params: ListenerParameters) + open fun removeListener(params: Any) open fun getSubscribedChannels(): Array open fun getSubscribedChannelGroups(): Array open fun hereNow(params: HereNowParameters, callback: Callback) @@ -848,22 +848,14 @@ open external class PubNub(config: Any /* UUID | UserId */) { set(value) = definedExternally } - interface `T$26` { - @nativeGetter - operator fun get(key: String): GrantTokenPermissions? - - @nativeSetter - operator fun set(key: String, value: GrantTokenPermissions) - } - - interface `T$27` { - var channels: `T$26`? + interface PatternsOrResources { + var channels: JsMap? get() = definedExternally set(value) = definedExternally - var groups: `T$26`? + var groups: JsMap? get() = definedExternally set(value) = definedExternally - var uuids: `T$26`? + var uuids: JsMap? get() = definedExternally set(value) = definedExternally } @@ -873,10 +865,10 @@ open external class PubNub(config: Any /* UUID | UserId */) { var authorized_uuid: String? get() = definedExternally set(value) = definedExternally - var resources: `T$27`? + var resources: PatternsOrResources? get() = definedExternally set(value) = definedExternally - var patterns: `T$27`? + var patterns: PatternsOrResources? get() = definedExternally set(value) = definedExternally var meta: Json? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt index 53bb131f7..7fe3fad03 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt @@ -44,13 +44,11 @@ import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant -import com.pubnub.api.models.consumer.files.PNDownloadableFile import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNMemberKey @@ -61,21 +59,10 @@ import com.pubnub.api.models.consumer.objects.member.MemberInput import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.api.models.consumer.pubsub.BasePubSubResult -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -import com.pubnub.api.models.consumer.pubsub.PNSignalResult -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener -import PubNub as PubNubJs - -actual fun createPubNub(config: PNConfiguration): PubNub { - return PubNubImpl(config) -} +import com.pubnub.kmp.CustomObject actual interface PubNub { @@ -140,7 +127,7 @@ actual interface PubNub { actual fun whereNow(uuid: String): WhereNow actual fun setPresenceState( - channels: List, channelGroups: List, state: Any, uuid: String + channels: List, channelGroups: List, state: Any ): SetState actual fun getPresenceState( @@ -176,21 +163,13 @@ actual interface PubNub { actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup actual fun grantToken( ttl: Int, - meta: Any?, + meta: CustomObject?, authorizedUUID: String?, channels: List, channelGroups: List, uuids: List ): GrantToken - actual fun grantToken( - ttl: Int, - meta: Any?, - authorizedUserId: UserId?, - spacesPermissions: List, - usersPermissions: List - ): GrantToken - actual fun revokeToken(token: String): RevokeToken actual fun time(): Time actual fun getAllChannelMetadata( @@ -369,111 +348,3 @@ actual interface PubNub { actual fun destroy() } - -actual fun createEventListener( - pubnub: PubNub, - onMessage: (PubNub, PNMessageResult) -> Unit, - onPresence: (PubNub, PNPresenceEventResult) -> Unit, - onSignal: (PubNub, PNSignalResult) -> Unit, - onMessageAction: (PubNub, PNMessageActionResult) -> Unit, - onObjects: (PubNub, PNObjectEventResult) -> Unit, - onFile: (PubNub, PNFileEventResult) -> Unit -): EventListener { - return object : PubNubJs.ListenerParameters { - override val message: (PubNubJs.MessageEvent) -> Unit = { messageEvent -> - onMessage(pubnub, PNMessageResult( - BasePubSubResult( - messageEvent.channel, - messageEvent.subscription, - messageEvent.timetoken.toLong(), - messageEvent.userMetadata as? JsonElement, // TODO kmp - messageEvent.publisher - ), - messageEvent.message.unsafeCast(), // TODO kmp - null //TODO kmp error - )) - } - override val presence: ((presenceEvent: PubNubJs.PresenceEvent) -> Unit) = { presenceEvent -> - onPresence(pubnub, PNPresenceEventResult( - presenceEvent.action, - presenceEvent.uuid, - presenceEvent.timestamp.toLong(), - presenceEvent.occupancy.toInt(), - presenceEvent.state.asDynamic(), //TODO kmp - presenceEvent.channel, - presenceEvent.subscription, - presenceEvent.timetoken.toLong(), - )) - - } - override val signal: ((signalEvent: PubNubJs.SignalEvent) -> Unit) = { signalEvent -> - onSignal(pubnub, PNSignalResult( - BasePubSubResult( - signalEvent.channel, - signalEvent.subscription, - signalEvent.timetoken.toLong(), - null, - signalEvent.publisher - ), - signalEvent.message as JsonElement, // TODO kmp - )) - } - - override val messageAction: ((messageActionEvent: PubNubJs.MessageActionEvent) -> Unit) = { messageActionEvent -> - onMessageAction(pubnub, PNMessageActionResult( - BasePubSubResult( - messageActionEvent.channel, - messageActionEvent.subscription, - messageActionEvent.timetoken.toLong(), - null, - messageActionEvent.publisher - ), - messageActionEvent.event, - PNMessageAction( - messageActionEvent.data.type, - messageActionEvent.data.value, - messageActionEvent.data.messageTimetoken.toLong() - ).apply { - actionTimetoken = messageActionEvent.data.messageTimetoken.toLong() - } - )) - } - override val file: ((fileEvent: PubNubJs.FileEvent) -> Unit) = { fileEvent -> - onFile(pubnub, PNFileEventResult( - fileEvent.channel, - fileEvent.timetoken.toLong(), - fileEvent.publisher, - fileEvent.message, - PNDownloadableFile(fileEvent.file.id, fileEvent.file.name, fileEvent.file.url), - fileEvent.message as JsonElement, //TODO kmp - fileEvent.subscription, - null // TODO kmp error - ) ) - } - } -} - -actual fun createStatusListener( - pubnub: PubNub, - onStatus: (PubNub, PNStatus) -> Unit -): StatusListener { - return object : PubNubJs.StatusListenerParameters { - override val status: ((statusEvent: PubNubJs.StatusEvent) -> Unit) = { statusEvent -> - onStatus(pubnub, PNStatus( - enumValueOf(statusEvent.category), //TODO parse category - null, - statusEvent.currentTimetoken.toString().toLong(), - statusEvent.affectedChannels.toList(), - statusEvent.affectedChannelGroups.toList() - )) - } - } -} - -class CustomObjectImpl(map: Map = emptyMap()) : Map by map - -actual typealias CustomObject = CustomObjectImpl - -actual fun createCustomObject(map: Map): CustomObject { - return CustomObjectImpl(map) -} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 9b206ada8..1489be5ee 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -7,12 +7,14 @@ import com.pubnub.api.endpoints.FetchMessagesImpl import com.pubnub.api.endpoints.MessageCounts import com.pubnub.api.endpoints.Time import com.pubnub.api.endpoints.access.GrantToken +import com.pubnub.api.endpoints.access.GrantTokenImpl import com.pubnub.api.endpoints.access.RevokeToken import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup @@ -23,8 +25,8 @@ import com.pubnub.api.endpoints.files.ListFiles import com.pubnub.api.endpoints.files.PublishFileMessage import com.pubnub.api.endpoints.message_actions.AddMessageAction import com.pubnub.api.endpoints.message_actions.AddMessageActionImpl -import com.pubnub.api.endpoints.message_actions.GetMessageActionImpl import com.pubnub.api.endpoints.message_actions.GetMessageActions +import com.pubnub.api.endpoints.message_actions.GetMessageActionImpl import com.pubnub.api.endpoints.message_actions.RemoveMessageAction import com.pubnub.api.endpoints.message_actions.RemoveMessageActionImpl import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata @@ -43,9 +45,11 @@ import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadataImpl import com.pubnub.api.endpoints.presence.GetState +import com.pubnub.api.endpoints.presence.GetStateImpl import com.pubnub.api.endpoints.presence.HereNow import com.pubnub.api.endpoints.presence.HereNowImpl import com.pubnub.api.endpoints.presence.SetState +import com.pubnub.api.endpoints.presence.SetStateImpl import com.pubnub.api.endpoints.presence.WhereNow import com.pubnub.api.endpoints.presence.WhereNowImpl import com.pubnub.api.endpoints.pubsub.FireImpl @@ -64,6 +68,10 @@ import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNAbstractGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNPatternGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNResourceGrant import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.api.models.consumer.objects.PNKey @@ -76,24 +84,30 @@ import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.CustomObjectImpl import com.pubnub.kmp.Optional +import com.pubnub.kmp.toJsMap import com.pubnub.kmp.toOptional +import kotlin.js.json import PubNub as PubNubJs class PubNubImpl(override val configuration: PNConfiguration) : PubNub { private val jsPubNub: PubNubJs = PubNubJs(configuration.toJs()) - override fun addListener(listener: PubNubJs.ListenerParameters) { - jsPubNub.addListener(listener) + override fun addListener(listener: EventListener) { + jsPubNub.addListener(listener.asDynamic().unsafeCast()) // todo figure out a better way (similar to DelegatingEventListener in JVM) } - override fun addListener(listener: PubNubJs.StatusListenerParameters) { - jsPubNub.addListener(listener) + override fun addListener(listener: StatusListener) { + jsPubNub.addListener(listener.asDynamic().unsafeCast()) // todo figure out a better way (similar to DelegatingEventListener in JVM) } override fun removeListener(listener: Listener) { - jsPubNub.removeListener(listener.asDynamic()) + jsPubNub.removeListener(listener) } override fun removeAllListeners() { @@ -109,7 +123,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { replicate: Boolean, ttl: Int? ): Publish { - return PublishImpl(jsPubNub, createJsObject { + return PublishImpl(jsPubNub, createJsObject { this.message = message this.channel = channel this.storeInHistory = shouldStore @@ -231,13 +245,20 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { channels: List, channelGroups: List, state: Any, - uuid: String ): SetState { - TODO("Not yet implemented") + return SetStateImpl(jsPubNub, createJsObject { + this.state = state + this.channels = channels.toTypedArray() + this.channelGroups = channelGroups.toTypedArray() + }) } override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { - TODO("Not yet implemented") + return GetStateImpl(jsPubNub, createJsObject { + this.channels = channels.toTypedArray() + this.channelGroups = channelGroups.toTypedArray() + this.uuid = uuid + }) } override fun presence(channels: List, channelGroups: List, connected: Boolean) { @@ -304,28 +325,36 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { - TODO("Not yet implemented") + return DeleteChannelGroupImpl(jsPubNub, createJsObject { + this.channelGroup = channelGroup + }) } override fun grantToken( ttl: Int, - meta: Any?, + meta: CustomObject?, authorizedUUID: String?, channels: List, channelGroups: List, uuids: List ): GrantToken { - TODO("Not yet implemented") - } - - override fun grantToken( - ttl: Int, - meta: Any?, - authorizedUserId: UserId?, - spacesPermissions: List, - usersPermissions: List - ): GrantToken { - TODO("Not yet implemented") + return GrantTokenImpl(jsPubNub, createJsObject { + this.meta = meta?.let { metaNotNull -> + json(*metaNotNull.entries.map { Pair(it.key, it.value) }.toTypedArray()) + } + this.ttl = ttl + this.authorized_uuid = authorizedUUID + this.resources = createJsObject { + this.channels = getGrantTokenPermissions(channels) + this.groups = getGrantTokenPermissions(channelGroups) + this.uuids = getGrantTokenPermissions(uuids) + } + this.patterns = createJsObject { + this.channels = getGrantTokenPermissions(channels) + this.groups = getGrantTokenPermissions(channelGroups) + this.uuids = getGrantTokenPermissions(uuids) + } + }) } override fun revokeToken(token: String): RevokeToken { @@ -670,3 +699,17 @@ fun PNConfiguration.toJs(): PubNubJs.PNConfiguration { return config } + +private inline fun getGrantTokenPermissions(grants: List) = + grants.filterIsInstance().associate { + it.id to createJsObject { + this.get = it.get + this.join = it.join + this.delete = it.delete + this.update = it.update + this.write = it.write + this.manage = it.manage + this.read = it.read + //todo what about create? any other? + } + }.toJsMap() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt index c80fc94cc..6f2f51ab8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt @@ -3,6 +3,7 @@ package com.pubnub.api.endpoints import PubNub import com.pubnub.api.EndpointImpl import com.pubnub.api.JsonElement +import com.pubnub.api.JsonElementImpl import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.HistoryMessageType import com.pubnub.api.models.consumer.history.PNFetchMessageItem @@ -17,7 +18,7 @@ class FetchMessagesImpl(pubnub: PubNub, params: PubNub.FetchMessagesParameters) PNFetchMessageItem( item.uuid, item.message, - item.meta as JsonElement, + JsonElementImpl(item.meta), item.timetoken.toString().toLong(), item.actions?.toMap()?.mapValues { entry: Map.Entry -> entry.value.toMap().mapValues { entry2: Map.Entry> -> diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt index 0f81aa098..a6e9676e3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt @@ -3,5 +3,4 @@ package com.pubnub.api.endpoints.access import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult -actual interface GrantToken : Endpoint { -} \ No newline at end of file +actual interface GrantToken : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt new file mode 100644 index 000000000..1ee89e2e3 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt @@ -0,0 +1,14 @@ +package com.pubnub.api.endpoints.access + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult + +class GrantTokenImpl(pubnub: PubNub, params: PubNub.GrantTokenParameters) : GrantToken, EndpointImpl( + promiseFactory = { pubnub.grantToken(params) }, + responseMapping = { + PNGrantTokenResult(it) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt new file mode 100644 index 000000000..225d07f29 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt @@ -0,0 +1,13 @@ +package com.pubnub.api.endpoints.channel_groups + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult + +class DeleteChannelGroupImpl(pubnub: PubNub, params: PubNub.DeleteGroupParameters) : DeleteChannelGroup, EndpointImpl( + promiseFactory = { pubnub.channelGroups.deleteGroup(params) }, + responseMapping = { + PNChannelGroupsDeleteGroupResult() + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt index 83c78145e..e7e968480 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt @@ -28,7 +28,7 @@ class GetChannelMembersImpl(pubnub: PubNub, params: PubNub.GetChannelMembersPara member.uuid.type, member.uuid.status ), - member.custom, + member.custom?.toMap(), member.updated, member.eTag, member.status diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt new file mode 100644 index 000000000..515b6c47b --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt @@ -0,0 +1,20 @@ +package com.pubnub.api.endpoints.presence + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.JsonElementImpl +import com.pubnub.api.models.consumer.presence.PNGetStateResult +import com.pubnub.api.models.consumer.presence.PNSetStateResult +import com.pubnub.kmp.JsMap +import com.pubnub.kmp.toMap + +class GetStateImpl(pubnub: PubNub, params: PubNub.GetStateParameters) : GetState, EndpointImpl( + promiseFactory = { pubnub.getState(params) }, + responseMapping = { response -> + PNGetStateResult( + response.channels.unsafeCast>().toMap().mapValues { + JsonElementImpl(it.value) + } + ) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt index 4d47edb02..3dd440567 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt @@ -3,6 +3,7 @@ package com.pubnub.api.endpoints.presence import PubNub import com.pubnub.api.EndpointImpl import com.pubnub.api.JsonElement +import com.pubnub.api.JsonElementImpl import com.pubnub.api.models.consumer.presence.PNHereNowChannelData import com.pubnub.api.models.consumer.presence.PNHereNowOccupantData import com.pubnub.api.models.consumer.presence.PNHereNowResult @@ -22,7 +23,7 @@ class HereNowImpl(pubnub: PubNub, params: PubNub.HereNowParameters) : HereNow, E data.occupants.map { occupant -> PNHereNowOccupantData( occupant.uuid, - occupant.state as JsonElement // TODO kmp + JsonElementImpl(occupant.state), ) } ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt index 9325e0785..3d5552313 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.presence.PNSetStateResult /** * @see [PubNub.setPresenceState] */ -actual interface SetState : Endpoint { -} \ No newline at end of file +actual interface SetState : Endpoint \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetStateImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetStateImpl.kt new file mode 100644 index 000000000..ca009ab01 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetStateImpl.kt @@ -0,0 +1,15 @@ +package com.pubnub.api.endpoints.presence + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.JsonElementImpl +import com.pubnub.api.models.consumer.presence.PNSetStateResult + +class SetStateImpl(pubnub: PubNub, params: PubNub.SetStateParameters) : SetState, EndpointImpl( + promiseFactory = { pubnub.setState(params) }, + responseMapping = { response -> + PNSetStateResult( + JsonElementImpl(response.state) + ) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt index d9f833448..89cd32a10 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt @@ -1,8 +1,10 @@ package com.pubnub.api.v2.callbacks +import com.pubnub.api.callbacks.Listener + /** * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ //actual interface EventListener -actual typealias EventListener = PubNub.ListenerParameters \ No newline at end of file +actual interface EventListener : Listener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt index 1802b3a90..32372f854 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt @@ -1,6 +1,7 @@ package com.pubnub.api.v2.callbacks import com.pubnub.api.PubNub +import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.PNStatus import PubNub as PubNubJs @@ -9,4 +10,4 @@ import PubNub as PubNubJs * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for * PubNub connection status changes. */ -actual typealias StatusListener = PubNubJs.StatusListenerParameters \ No newline at end of file +actual interface StatusListener : Listener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt index e851b59d5..b55406cf4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt @@ -1,5 +1,7 @@ package com.pubnub.kmp +import com.pubnub.api.createJsObject + external interface JsMap fun entriesOf(jsObject: JsMap): List> = @@ -9,3 +11,9 @@ fun entriesOf(jsObject: JsMap): List> = fun JsMap.toMap(): Map = entriesOf(this).toMap() + +fun Map.toJsMap(): JsMap = createJsObject { + entries.forEach { + this[it.key] = it.value + } +}.unsafeCast>() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt new file mode 100644 index 000000000..8a4a78b7d --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt @@ -0,0 +1,5 @@ +package com.pubnub.kmp + +actual typealias CustomObject = CustomObjectImpl + +class CustomObjectImpl(map: Map = emptyMap()) : Map by map \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt new file mode 100644 index 000000000..15a29c843 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt @@ -0,0 +1,140 @@ +package com.pubnub.kmp + +import com.pubnub.api.JsonElementImpl +import com.pubnub.api.PubNub +import com.pubnub.api.PubNubImpl +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.files.PNDownloadableFile +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.pubsub.BasePubSubResult +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener +import PubNub as PubNubJs + +actual fun createPubNub(config: PNConfiguration): PubNub { + return PubNubImpl(config) +} + +actual fun createEventListener( + pubnub: PubNub, + onMessage: (PubNub, PNMessageResult) -> Unit, + onPresence: (PubNub, PNPresenceEventResult) -> Unit, + onSignal: (PubNub, PNSignalResult) -> Unit, + onMessageAction: (PubNub, PNMessageActionResult) -> Unit, + onObjects: (PubNub, PNObjectEventResult) -> Unit, + onFile: (PubNub, PNFileEventResult) -> Unit +): EventListener { + val listener = object : PubNubJs.ListenerParameters { + override val message: (PubNubJs.MessageEvent) -> Unit = { messageEvent -> + onMessage( + pubnub, PNMessageResult( + BasePubSubResult( + messageEvent.channel, + messageEvent.subscription, + messageEvent.timetoken.toLong(), + JsonElementImpl(messageEvent.userMetadata), + messageEvent.publisher + ), + JsonElementImpl(messageEvent.message), + null //TODO kmp error + ) + ) + } + override val presence: ((presenceEvent: PubNubJs.PresenceEvent) -> Unit) = { presenceEvent -> + onPresence( + pubnub, PNPresenceEventResult( + presenceEvent.action, + presenceEvent.uuid, + presenceEvent.timestamp.toLong(), + presenceEvent.occupancy.toInt(), + JsonElementImpl(presenceEvent.state), + presenceEvent.channel, + presenceEvent.subscription, + presenceEvent.timetoken.toLong(), + ) + ) + + } + override val signal: ((signalEvent: PubNubJs.SignalEvent) -> Unit) = { signalEvent -> + onSignal( + pubnub, PNSignalResult( + BasePubSubResult( + signalEvent.channel, + signalEvent.subscription, + signalEvent.timetoken.toLong(), + null, + signalEvent.publisher + ), + JsonElementImpl(signalEvent.message), + ) + ) + } + + override val messageAction: ((messageActionEvent: PubNubJs.MessageActionEvent) -> Unit) = + { messageActionEvent -> + onMessageAction(pubnub, PNMessageActionResult( + BasePubSubResult( + messageActionEvent.channel, + messageActionEvent.subscription, + messageActionEvent.timetoken.toLong(), + null, + messageActionEvent.publisher + ), + messageActionEvent.event, + PNMessageAction( + messageActionEvent.data.type, + messageActionEvent.data.value, + messageActionEvent.data.messageTimetoken.toLong() + ).apply { + actionTimetoken = messageActionEvent.data.messageTimetoken.toLong() + } + )) + } + override val file: ((fileEvent: PubNubJs.FileEvent) -> Unit) = { fileEvent -> + onFile( + pubnub, PNFileEventResult( + fileEvent.channel, + fileEvent.timetoken.toLong(), + fileEvent.publisher, + fileEvent.message, + PNDownloadableFile(fileEvent.file.id, fileEvent.file.name, fileEvent.file.url), + JsonElementImpl(fileEvent.message), + fileEvent.subscription, + null // TODO kmp error + ) + ) + } + } + return listener.asDynamic() +} + +actual fun createStatusListener( + pubnub: PubNub, + onStatus: (PubNub, PNStatus) -> Unit +): StatusListener { + val listener = object : PubNubJs.StatusListenerParameters { + override val status: ((statusEvent: PubNubJs.StatusEvent) -> Unit) = { statusEvent -> + onStatus( + pubnub, PNStatus( + enumValueOf(statusEvent.category), //TODO parse category + null, + statusEvent.currentTimetoken.toString().toLong(), + statusEvent.affectedChannels.toList(), + statusEvent.affectedChannelGroups.toList() + ) + ) + } + } + return listener.asDynamic() +} + +actual fun createCustomObject(map: Map): CustomObject { + return CustomObjectImpl(map) +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index f71ded501..888728ca8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -562,11 +562,35 @@ actual interface PubNub : * @param uuid UUID of the user to set the state for. Defaults to the UUID of the client. * @see [PNConfiguration.uuid] */ + fun setPresenceState( + channels: List = listOf(), + channelGroups: List = listOf(), + state: Any, + uuid: String = configuration.userId.value, + ): SetState + + /** + * Set state information specific to a subscriber UUID. + * + * State information is supplied as a JSON object of key/value pairs. + * + * If [PNConfiguration.maintainPresenceState] is `true`, and the `uuid` matches [PNConfiguration.uuid], the state + * for channels will be saved in the PubNub client and resent with every heartbeat and initial subscribe request. + * In that case, it's not recommended to mix setting state through channels *and* channel groups, as state set + * through the channel group will be overwritten after the next heartbeat or subscribe reconnection (e.g. after loss + * of network). + * + * @param channels Channels to set the state to. + * @param channelGroups Channel groups to set the state to. + * @param state The actual state object to set. + * NOTE: Presence state must be expressed as a JsonObject. + * When calling [PubNub.setPresenceState], be sure to supply an initialized JsonObject + * or POJO which can be serialized to a JsonObject. + */ actual fun setPresenceState( channels: List, channelGroups: List, state: Any, - uuid: String, ): SetState /** @@ -818,7 +842,7 @@ actual interface PubNub : * @param spacesPermissions List of all space grants * @param usersPermissions List of all userId grants */ - actual fun grantToken( + fun grantToken( ttl: Int, meta: Any?, authorizedUserId: UserId?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt index f16513c2b..ef5cd4a5d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt @@ -1,6 +1,7 @@ package com.pubnub.api.v2.callbacks import com.pubnub.api.PubNub +import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult @@ -12,7 +13,7 @@ import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -actual interface EventListener : BaseEventListener { +actual interface EventListener : BaseEventListener, Listener { /** * Receive messages at subscribed channels. * diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt index f134453d5..03733307d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt @@ -1,13 +1,14 @@ package com.pubnub.api.v2.callbacks import com.pubnub.api.PubNub +import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.PNStatus /** * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for * PubNub connection status changes. */ -actual interface StatusListener : BaseStatusListener { +actual interface StatusListener : BaseStatusListener, Listener { /** * Receive status updates from the PubNub client, such as: * * [PNStatusCategory.PNConnectedCategory], diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt new file mode 100644 index 000000000..5fb9d86f8 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt @@ -0,0 +1,3 @@ +package com.pubnub.kmp + +actual typealias CustomObject = Any \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt similarity index 97% rename from pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.jvm.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt index cc0be70aa..8765015ed 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt @@ -1,5 +1,6 @@ -package com.pubnub.api +package com.pubnub.kmp +import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult @@ -51,12 +52,6 @@ actual fun createEventListener( } } -actual typealias CustomObject = Any - -actual fun createCustomObject(map: Map): CustomObject { - return map -} - actual fun createStatusListener( pubnub: PubNub, onStatus: (PubNub, PNStatus) -> Unit @@ -66,4 +61,8 @@ actual fun createStatusListener( onStatus(pubnub, status) } } +} + +actual fun createCustomObject(map: Map): CustomObject { + return map } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt index 1b7314018..2e3aeb23f 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt @@ -519,6 +519,21 @@ class PubNubImpl( ) } + override fun setPresenceState( + channels: List, + channelGroups: List, + state: Any + ): SetState { + return com.pubnub.internal.endpoints.presence.SetStateImpl( + pubNubCore.setPresenceState( + channels, + channelGroups, + state, + configuration.userId.value, + ), + ) + } + override fun getPresenceState( channels: List, channelGroups: List, diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts index 7b7ae92fe..1e1a3af46 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -1,9 +1,12 @@ import org.jetbrains.dokka.DokkaDefaults.moduleName +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType +import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable plugins { alias(libs.plugins.benmanes.versions) id("pubnub.shared") + id("pubnub.ios-simulator-test") kotlin("multiplatform") kotlin("native.cocoapods") } @@ -43,7 +46,7 @@ kotlin { dependencies { api(project(":pubnub-kotlin:pubnub-kotlin-api")) api(project(":pubnub-core:pubnub-core-api")) - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0-RC.2") + implementation(libs.datetime) } } @@ -51,13 +54,13 @@ kotlin { dependencies { implementation(kotlin("test")) implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1") + implementation(libs.coroutines.test) } } val jvmTest by getting { dependencies { implementation(project(":pubnub-kotlin:pubnub-kotlin-impl")) - implementation(libs.slf4j) } } } @@ -87,6 +90,10 @@ kotlin { // Optional properties // Specify the framework linking type. It's dynamic by default. isStatic = true + + export(":pubnub-kotlin:pubnub-kotlin-api") + export(":pubnub-core:pubnub-core-api") + transitiveExport = true } pod("PubNubSwift") { @@ -98,4 +105,12 @@ kotlin { extraOpts += listOf("-compiler-option", "-fmodules") } } + + targets.withType { + if (konanTarget.family.isAppleFamily) { + binaries.withType { + freeCompilerArgs += listOf("-e", "testlauncher.mainBackground") + } + } + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt index 7f5f59dfa..4161a5ae3 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt @@ -1,14 +1,18 @@ package com.pubnub.api +import com.pubnub.api.enums.PNStatusCategory import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.kmp.createEventListener +import com.pubnub.kmp.createStatusListener import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.delay import kotlinx.coroutines.launch +import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.test.runTest -import kotlinx.coroutines.withContext +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -18,20 +22,23 @@ class PublishTest : BaseIntegrationTest() { private val channel = "myChannel" @Test - fun can_publish_message() = runTest { - val result = pubnub.publish(channel, "some message").await() - assertTrue { result.timetoken > 0 } - } + fun can_publish_message() = + runTest(timeout = 10.seconds) { + val result = pubnub.publish(channel, "some message").await() + // never getting to here + assertTrue { result.timetoken > 0 } + } @Test + @Ignore fun can_receive_message() = runTest(timeout = 10.seconds) { val queue = Channel() - pubnub.addListener(createEventListener(pubnub, onMessage = {pubNub, pnMessageResult -> + pubnub.addListener(createEventListener(pubnub, onMessage = { pubNub, pnMessageResult -> backgroundScope.launch { queue.send(pnMessageResult) } })) - pubnub.subscribeWithDelay(channel) + pubnub.subscribeAndWait(pubnub, channel) pubnub.publish(channel, "some message").await() val result = queue.receive() @@ -39,9 +46,19 @@ class PublishTest : BaseIntegrationTest() { } } -private suspend fun PubNub.subscribeWithDelay(channel: String) { - subscribe(listOf(channel)) - withContext(Dispatchers.Default) { - delay(1.seconds) +private suspend fun PubNub.subscribeAndWait(pubNub: PubNub, channel: String) = suspendCancellableCoroutine { cont -> + val statusListener = createStatusListener(pubNub) { pubNub, pnStatus -> + if (pnStatus.category == PNStatusCategory.PNConnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged + && pnStatus.affectedChannels.contains(channel)) { + cont.resume(Unit) + } + if (pnStatus.category == PNStatusCategory.PNUnexpectedDisconnectCategory || pnStatus.category == PNStatusCategory.PNConnectionError) { + cont.resumeWithException(pnStatus.exception ?: RuntimeException(pnStatus.category.toString())) + } } + pubNub.addListener(statusListener) + cont.invokeOnCancellation { + pubNub.removeListener(statusListener) + } + subscribe(listOf(channel)) } diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt index 5d29e4ff9..840f783cf 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt @@ -3,7 +3,7 @@ package com.pubnub.test import com.pubnub.api.Endpoint import com.pubnub.api.PubNub import com.pubnub.api.UserId -import com.pubnub.api.createPubNub +import com.pubnub.kmp.createPubNub import com.pubnub.api.v2.createPNConfiguration import kotlinx.coroutines.suspendCancellableCoroutine import kotlin.coroutines.resume @@ -27,8 +27,7 @@ abstract class BaseIntegrationTest { } } - -suspend fun Endpoint.await() = suspendCancellableCoroutine { cont -> +suspend fun Endpoint.await() = suspendCancellableCoroutine { cont -> async { result -> result.onSuccess { cont.resume(it) diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/iosTest/kotlin/testlauncher.kt b/pubnub-kotlin/pubnub-kotlin-test/src/iosTest/kotlin/testlauncher.kt new file mode 100644 index 000000000..2812f05a2 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/iosTest/kotlin/testlauncher.kt @@ -0,0 +1,18 @@ +package testlauncher + +import platform.CoreFoundation.* +import kotlin.experimental.ExperimentalNativeApi +import kotlin.native.concurrent.* +import kotlin.native.internal.test.* +import kotlin.system.* + +@OptIn(ExperimentalNativeApi::class) +fun mainBackground(args: Array) { + val worker = Worker.start(name = "main-background") + worker.execute(TransferMode.SAFE, { args.freeze() }) { + val result = testLauncherEntryPoint(it) + exitProcess(result) + } + CFRunLoopRun() + error("CFRunLoopRun should never return") +} \ No newline at end of file From d5071b1b31b29cb615d5a36068d80c5c894980ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Wed, 22 May 2024 11:45:54 +0200 Subject: [PATCH 05/62] Add mapCatching to Result --- .../kotlin/com/pubnub/api/v2/callbacks/Result.kt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt index 0a2e3cf8e..0d9d86eb9 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt @@ -230,4 +230,19 @@ public inline fun Result.map(transform: (value: T) -> R): Result { isSuccess -> Result.success(transform(value as T)) else -> Result(value) } +} + +public inline fun Result.mapCatching(transform: (value: T) -> R): Result { + return when { + isSuccess -> runCatching { transform(value as T) } + else -> Result(value) + } +} + +public inline fun T.runCatching(block: T.() -> R): Result { + return try { + Result.success(block()) + } catch (e: Throwable) { + Result.failure(e) + } } \ No newline at end of file From 9bff71854491337d9eb160d4943aade63050d77c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Wed, 22 May 2024 09:58:49 +0000 Subject: [PATCH 06/62] Kotlin 2.0, keys in tests, more JS endpoints (#217) * [JS] Time and UUIDMetadata endpoints * Bump Kotlin version to 2.0.0 stable * Add buildKonfig for loading API keys in tests * Don't fail on missing test.properties --- gradle/libs.versions.toml | 2 +- .../src/jsMain/kotlin/Pubnub.d.kt | 14 +++--- .../kotlin/com/pubnub/api/PubNubImpl.kt | 45 ++++++++++++++----- .../com/pubnub/api/endpoints/TimeImpl.kt | 10 +++++ .../api/endpoints/access/RevokeTokenImpl.kt | 9 ++++ .../objects/uuid/GetAllUUIDMetadataImpl.kt | 26 +++++++++++ .../objects/uuid/GetUUIDMetadata.js.kt | 3 +- .../objects/uuid/GetUUIDMetadataImpl.kt | 22 +++++++++ .../objects/uuid/RemoveUUIDMetadata.js.kt | 12 ----- .../objects/uuid/RemoveUUIDMetadataImpl.kt | 12 +++++ .../objects/uuid/SetUUIDMetadataImpl.kt | 10 ++--- .../pubnub-kotlin-test/build.gradle.kts | 29 ++++++++++++ .../com/pubnub/test/BaseIntegrationTest.kt | 2 +- 13 files changed, 156 insertions(+), 40 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/TimeImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeTokenImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4f2244181..544906fe3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ logback = "1.2.11" okhttp = "4.12.0" retrofit2 = "2.9.0" nexus = "2.0.0-rc-2" -kotlin = "2.0.0-RC3" +kotlin = "2.0.0" vanniktech = "0.22.0" ktlint = "12.1.0" dokka = "1.9.20" diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt index 15262a9b9..ceb195573 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt @@ -1122,7 +1122,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface UUIDMetadata : ObjectParam, UUIDMetadataFieldsNullable, Partial interface UUIDMetadataObject : v2ObjectData, UUIDMetadataFieldsNullable - interface `T$30` { + interface UuidIncludeCustom { var customFields: Boolean? get() = definedExternally set(value) = definedExternally @@ -1133,7 +1133,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { get() = definedExternally set(value) = definedExternally var data: UUIDMetadata - var include: `T$30`? + var include: UuidIncludeCustom? get() = definedExternally set(value) = definedExternally } @@ -1144,7 +1144,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { set(value) = definedExternally } - interface `T$31` { + interface UuidIncludeOptions { var totalCount: Boolean? get() = definedExternally set(value) = definedExternally @@ -1163,13 +1163,13 @@ open external class PubNub(config: Any /* UUID | UserId */) { } interface GetAllMetadataParameters { - var include: `T$31`? + var include: UuidIncludeOptions? get() = definedExternally set(value) = definedExternally var filter: String? get() = definedExternally set(value) = definedExternally - var sort: Any? + var sort: Map? get() = definedExternally set(value) = definedExternally var limit: Number? @@ -1184,7 +1184,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { var uuid: String? get() = definedExternally set(value) = definedExternally - var include: `T$30`? + var include: UuidIncludeCustom? get() = definedExternally set(value) = definedExternally } @@ -1208,7 +1208,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface SetChannelMetadataParameters { var channel: String var data: ChannelMetadata - var include: `T$30`? + var include: UuidIncludeCustom? get() = definedExternally set(value) = definedExternally } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 1489be5ee..e786b37be 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -6,9 +6,11 @@ import com.pubnub.api.endpoints.FetchMessages import com.pubnub.api.endpoints.FetchMessagesImpl import com.pubnub.api.endpoints.MessageCounts import com.pubnub.api.endpoints.Time +import com.pubnub.api.endpoints.TimeImpl import com.pubnub.api.endpoints.access.GrantToken import com.pubnub.api.endpoints.access.GrantTokenImpl import com.pubnub.api.endpoints.access.RevokeToken +import com.pubnub.api.endpoints.access.RevokeTokenImpl import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup @@ -39,7 +41,9 @@ import com.pubnub.api.endpoints.objects.member.ManageChannelMembers import com.pubnub.api.endpoints.objects.membership.GetMemberships import com.pubnub.api.endpoints.objects.membership.ManageMemberships import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata @@ -358,11 +362,11 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun revokeToken(token: String): RevokeToken { - TODO("Not yet implemented") + return RevokeTokenImpl(jsPubNub, token) } override fun time(): Time { - TODO("Not yet implemented") + return TimeImpl(jsPubNub) } override fun getAllChannelMetadata( @@ -404,11 +408,34 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCount: Boolean, includeCustom: Boolean ): GetAllUUIDMetadata { - TODO("Not yet implemented") + return GetAllUUIDMetadataImpl(jsPubNub, createJsObject { + this.limit = limit + this.page = page?.let { pageNotNull -> + createJsObject { + if (pageNotNull is PNPage.PNNext) { + this.next = pageNotNull.pageHash + } else { + this.prev = pageNotNull.pageHash + } + } + } + this.filter = filter + this.include = createJsObject { + this.customFields = includeCustom + this.totalCount = includeCount + } + this.sort = sort.associateBy(keySelector = { pnSortKey -> pnSortKey.key.fieldName }, valueTransform = { pnSortKey -> pnSortKey.dir }) + + }) } override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { - TODO("Not yet implemented") + return GetUUIDMetadataImpl(jsPubNub, createJsObject { + this.uuid = uuid + this.include = createJsObject { + this.customFields = customFields + } + }) } override fun setUUIDMetadata( @@ -422,8 +449,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { type: String?, status: String? ): SetUUIDMetadata { - - val params = createJsObject { + return SetUUIDMetadataImpl(jsPubNub, createJsObject { data = UUIDMetadata( name.toOptional(), externalId.toOptional(), @@ -435,11 +461,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ) this.uuid = uuid - include = object : PubNubJs.`T$30` { - override var customFields: Boolean? = includeCustom + include = createJsObject { + this.customFields = includeCustom } - } - return SetUUIDMetadataImpl(jsPubNub, params) + }) } override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/TimeImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/TimeImpl.kt new file mode 100644 index 000000000..f86f01642 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/TimeImpl.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.PNTimeResult + +class TimeImpl(pubnub: PubNub) : Time, EndpointImpl( + promiseFactory = { pubnub.time() }, + responseMapping = { PNTimeResult(it.timetoken.toLong()) } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeTokenImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeTokenImpl.kt new file mode 100644 index 000000000..d9ed2cf2e --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeTokenImpl.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.access + +import PubNub +import com.pubnub.api.EndpointImpl + +class RevokeTokenImpl(pubnub: PubNub, params: String) : RevokeToken, EndpointImpl( + promiseFactory = { pubnub.revokeToken(params) }, + responseMapping = { } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt new file mode 100644 index 000000000..d99ebd654 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt @@ -0,0 +1,26 @@ +package com.pubnub.api.endpoints.objects.uuid + +import GetAllUUIDMetadataResponse +import GetUUIDMetadataResponse +import ObjectsResponse +import PubNub +import SetUUIDMetadataResponse +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.kmp.toMap + +class GetAllUUIDMetadataImpl(pubnub: PubNub, params: PubNub.GetAllMetadataParameters) : GetAllUUIDMetadata, + EndpointImpl(promiseFactory = { pubnub.objects.getAllUUIDMetadata(params) }, + responseMapping = {pagedObjectsResponse: GetAllUUIDMetadataResponse -> + PNUUIDMetadataArrayResult( + pagedObjectsResponse.status.toInt(), + pagedObjectsResponse.data.map(PubNub.UUIDMetadataObject::toPNUUIDMetadata), + pagedObjectsResponse.totalCount?.toInt(), + pagedObjectsResponse.next?.let { PNPage.PNNext(it) }, + pagedObjectsResponse.prev?.let { PNPage.PNPrev(it) }, + ) + } + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt index dd2440021..e6ac8e468 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult /** * @see [PubNub.getUUIDMetadata] */ -actual interface GetUUIDMetadata : Endpoint { -} \ No newline at end of file +actual interface GetUUIDMetadata : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt new file mode 100644 index 000000000..239db7652 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt @@ -0,0 +1,22 @@ +package com.pubnub.api.endpoints.objects.uuid + +import GetUUIDMetadataResponse +import ObjectsResponse +import PubNub +import SetUUIDMetadataResponse +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.kmp.toMap + +class GetUUIDMetadataImpl(pubnub: PubNub, params: PubNub.GetUUIDMetadataParameters) : GetUUIDMetadata, + EndpointImpl(promiseFactory = { pubnub.objects.getUUIDMetadata(params) }, + responseMapping = GetUUIDMetadataResponse::toPNUUIDMetadataResult + ) + + +fun ObjectsResponse.toPNUUIDMetadataResult() = PNUUIDMetadataResult(status.toInt(), data.toPNUUIDMetadata()) + +fun PubNub.UUIDMetadataObject.toPNUUIDMetadata() = PNUUIDMetadata( + id, name, externalId, profileUrl, email, custom?.toMap(), updated, eTag, type, status +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt index c0e273261..34574a844 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt @@ -1,18 +1,6 @@ package com.pubnub.api.endpoints.objects.uuid -import PubNub -import RemoveUUIDMetadataResponse -import SetUUIDMetadataResponse import com.pubnub.api.Endpoint -import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult actual interface RemoveUUIDMetadata : Endpoint - -class RemoveUUIDMetadataImpl(pubnub: PubNub, params: PubNub.RemoveUUIDMetadataParameters) : RemoveUUIDMetadata, - EndpointImpl(promiseFactory = { pubnub.objects.removeUUIDMetadata(params) }, - responseMapping = { - PNRemoveMetadataResult(it.status.toInt()) - }) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt new file mode 100644 index 000000000..c9ca55ae7 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.endpoints.objects.uuid + +import PubNub +import RemoveUUIDMetadataResponse +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult + +class RemoveUUIDMetadataImpl(pubnub: PubNub, params: PubNub.RemoveUUIDMetadataParameters) : RemoveUUIDMetadata, + EndpointImpl(promiseFactory = { pubnub.objects.removeUUIDMetadata(params) }, + responseMapping = { + PNRemoveMetadataResult(it.status.toInt()) + }) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt index 09bdb69a1..6b758f5fc 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.objects.uuid +import GetUUIDMetadataResponse import PubNub import SetUUIDMetadataResponse import com.pubnub.api.EndpointImpl @@ -9,10 +10,5 @@ import com.pubnub.kmp.toMap class SetUUIDMetadataImpl(pubnub: PubNub, params: PubNub.SetUUIDMetadataParameters) : SetUUIDMetadata, EndpointImpl(promiseFactory = { pubnub.objects.setUUIDMetadata(params) }, - responseMapping = { - PNUUIDMetadataResult(it.status.toInt(), with(it.data) { - PNUUIDMetadata( - id, name, externalId, profileUrl, email, custom?.toMap(), updated, eTag, type, status - ) - }) - }) \ No newline at end of file + responseMapping = GetUUIDMetadataResponse::toPNUUIDMetadataResult + ) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts index 1e1a3af46..61d2817b5 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -1,7 +1,9 @@ +import com.codingfeline.buildkonfig.compiler.FieldSpec.Type import org.jetbrains.dokka.DokkaDefaults.moduleName import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable +import java.util.Properties plugins { alias(libs.plugins.benmanes.versions) @@ -9,6 +11,7 @@ plugins { id("pubnub.ios-simulator-test") kotlin("multiplatform") kotlin("native.cocoapods") + id("com.codingfeline.buildkonfig") version "0.15.1" } kotlin { @@ -113,4 +116,30 @@ kotlin { } } } + + buildkonfig { + packageName = "com.pubnub.test" + objectName = "Keys" + + defaultConfigs { + val testProps = Properties() + try { + rootProject.file("test.properties").inputStream().use { + testProps.load(it) + } + } catch (e: Exception) { + testProps.setProperty("pubKey", "demo") + testProps.setProperty("subKey", "demo") + testProps.setProperty("pamPubKey", "demo") + testProps.setProperty("pamSubKey", "demo") + testProps.setProperty("pamSecKey", "demo") + } + buildConfigField(Type.STRING, "pubKey", testProps.getProperty("pubKey")) + buildConfigField(Type.STRING, "subKey", testProps.getProperty("subKey")) + buildConfigField(Type.STRING, "pamPubKey", testProps.getProperty("pamPubKey")) + buildConfigField(Type.STRING, "pamSubKey", testProps.getProperty("pamSubKey")) + buildConfigField(Type.STRING, "pamSecKey", testProps.getProperty("pamSecKey")) + } + } + } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt index 840f783cf..84e0a2cd3 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt @@ -17,7 +17,7 @@ abstract class BaseIntegrationTest { @BeforeTest fun before() { - pubnub = createPubNub(createPNConfiguration(UserId("demo_user"), "demo", "demo")) + pubnub = createPubNub(createPNConfiguration(UserId("demo_user"), Keys.subKey, Keys.pubKey)) } @AfterTest From 47c28a518cb453c236dc0ca98a21bf2d7c1831a3 Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Wed, 22 May 2024 19:19:00 +0200 Subject: [PATCH 07/62] Added Swift wrappers for push notification methods (#216) --- .../kotlin/com/pubnub/api/PubNubImpl.kt | 26 +++++++++++++--- .../endpoints/push/AddChannelsToPush.ios.kt | 16 +++------- .../endpoints/push/ListPushProvisions.ios.kt | 30 +++++++++++++++++- .../RemoveAllPushChannelsForDevice.ios.kt | 29 ++++++++++++++++- .../push/RemoveChannelsFromPush.ios.kt | 31 ++++++++++++++++++- .../kotlin/com/pubnub/kmp/Converters.kt | 10 ++++++ 6 files changed, 124 insertions(+), 18 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 0b89cc359..4609e287e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -42,8 +42,11 @@ import com.pubnub.api.endpoints.pubsub.SignalImpl import com.pubnub.api.endpoints.push.AddChannelsToPush import com.pubnub.api.endpoints.push.AddChannelsToPushImpl import com.pubnub.api.endpoints.push.ListPushProvisions +import com.pubnub.api.endpoints.push.ListPushProvisionsImpl import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDeviceImpl import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.endpoints.push.RemoveChannelsFromPushImpl import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage @@ -114,6 +117,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ) } + @OptIn(ExperimentalForeignApi::class) // TODO: usePost parameter is not present in Swift SDK override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { @@ -142,9 +146,9 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { return pubNubObjC.subscribedChannelGroups() as List } + @OptIn(ExperimentalForeignApi::class) // TODO: Missing pushType (PushService like APNS, GCM, etc) parameter // TODO: Why do we need topic parameter here? - @OptIn(ExperimentalForeignApi::class) override fun addPushNotificationsOnChannels( pushType: PNPushType, channels: List, @@ -159,15 +163,19 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ) } + @OptIn(ExperimentalForeignApi::class) + // TODO: topic and environment parameters are not present in Swift SDK override fun auditPushChannelProvisions( pushType: PNPushType, deviceId: String, topic: String?, environment: PNPushEnvironment ): ListPushProvisions { - TODO("Not yet implemented") + return ListPushProvisionsImpl(pubnub = pubNubObjC, deviceId = deviceId, pushType = pushType) } + @OptIn(ExperimentalForeignApi::class) + // TODO: topic and environment parameters are not present in Swift SDK override fun removePushNotificationsFromChannels( pushType: PNPushType, channels: List, @@ -175,16 +183,26 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { topic: String?, environment: PNPushEnvironment ): RemoveChannelsFromPush { - TODO("Not yet implemented") + return RemoveChannelsFromPushImpl( + pubnub = pubNubObjC, + channels = channels, + deviceId = deviceId, + pushType = pushType + ) } + @OptIn(ExperimentalForeignApi::class) override fun removeAllPushNotificationsFromDeviceWithPushToken( pushType: PNPushType, deviceId: String, topic: String?, environment: PNPushEnvironment ): RemoveAllPushChannelsForDevice { - TODO("Not yet implemented") + return RemoveAllPushChannelsForDeviceImpl( + pubnub = pubNubObjC, + deviceId = deviceId, + pushType = pushType + ) } override fun fetchMessages( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt index f796d28cb..56ec94f35 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt @@ -8,11 +8,9 @@ import com.pubnub.api.onFailureHandler import com.pubnub.api.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.toNSData import kotlinx.cinterop.ExperimentalForeignApi -import platform.Foundation.NSString -import platform.Foundation.NSUTF8StringEncoding -import platform.Foundation.dataUsingEncoding - +import platform.Foundation.NSData /** * @see [PubNub.addPushNotificationsOnChannels] */ @@ -25,17 +23,13 @@ open class AddChannelsToPushImpl( private val deviceId: String ): AddChannelsToPush { override fun async(callback: Consumer>) { - val deviceIdData = (deviceId as NSString).dataUsingEncoding(NSUTF8StringEncoding) - - if (deviceIdData != null) { + deviceId.toNSData()?.let { data: NSData -> pubnub.addChannelsToPushNotificationsWithChannels( channels = channels, - deviceId = deviceIdData, + deviceId = data, onSuccess = callback.onSuccessHandler { PNPushAddChannelResult() }, onFailure = callback.onFailureHandler() ) - } else { - callback.accept(Result.failure(PubNubException(errorMessage = "Cannot decode $deviceId to NSData object"))) - } + } ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId"))) } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt index 63496da48..b29ac8662 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt @@ -1,9 +1,37 @@ package com.pubnub.api.endpoints.push +import cocoapods.PubNubSwift.PubNubObjC import com.pubnub.api.Endpoint +import com.pubnub.api.PubNubException +import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.toNSData +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSData /** * @see [PubNub.auditPushChannelProvisions] */ -actual interface ListPushProvisions : Endpoint \ No newline at end of file +actual interface ListPushProvisions : Endpoint + +@OptIn(ExperimentalForeignApi::class) +open class ListPushProvisionsImpl( + private val pubnub: PubNubObjC, + private val deviceId: String, + private val pushType: PNPushType +): ListPushProvisions { + override fun async(callback: Consumer>) { + deviceId.toNSData()?.let { data: NSData -> + pubnub.listPushChannelsWithDeviceId( + deviceId = data, + pushType = pushType.toParamString(), + onSuccess = callback.onSuccessHandler { PNPushListProvisionsResult(channels = it as List) }, + onFailure = callback.onFailureHandler() + ) + } ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId"))) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt index f88e4e04f..465d6a7b9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt @@ -1,9 +1,36 @@ package com.pubnub.api.endpoints.push +import cocoapods.PubNubSwift.PubNubObjC import com.pubnub.api.Endpoint +import com.pubnub.api.PubNubException +import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.toNSData +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSData /** * @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken] */ -actual interface RemoveAllPushChannelsForDevice : Endpoint \ No newline at end of file +actual interface RemoveAllPushChannelsForDevice : Endpoint + +@OptIn(ExperimentalForeignApi::class) +open class RemoveAllPushChannelsForDeviceImpl( + private val pubnub: PubNubObjC, + private val deviceId: String, + private val pushType: PNPushType +): RemoveAllPushChannelsForDevice { + override fun async(callback: Consumer>) { + deviceId.toNSData()?.let { data: NSData -> + pubnub.removeAllChannelsFromPushWithPushType( + pushType = pushType.toParamString(), + deviceId = data, + onSuccess = { callback.accept(Result.success(PNPushRemoveAllChannelsResult())) }, + onFailure = callback.onFailureHandler() + ) + } ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId"))) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt index e17227963..cb8d4ed42 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt @@ -1,9 +1,38 @@ package com.pubnub.api.endpoints.push +import cocoapods.PubNubSwift.PubNubObjC import com.pubnub.api.Endpoint +import com.pubnub.api.PubNubException +import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.toNSData +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSData /** * @see [PubNub.removePushNotificationsFromChannels] */ -actual interface RemoveChannelsFromPush : Endpoint \ No newline at end of file +actual interface RemoveChannelsFromPush : Endpoint +@OptIn(ExperimentalForeignApi::class) +open class RemoveChannelsFromPushImpl( + private val pubnub: PubNubObjC, + private val channels: List, + private val deviceId: String, + private val pushType: PNPushType +): RemoveChannelsFromPush { + override fun async(callback: Consumer>) { + deviceId.toNSData()?.let { data: NSData -> + pubnub.removeChannelsFromPushWithChannels( + channels = channels, + deviceId = data, + pushType = pushType.toParamString(), + onSuccess = callback.onSuccessHandler { PNPushRemoveChannelResult() }, + onFailure = callback.onFailureHandler() + ) + } ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId"))) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt new file mode 100644 index 000000000..89e79900a --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt @@ -0,0 +1,10 @@ +package com.pubnub.kmp + +import platform.Foundation.NSData +import platform.Foundation.NSString +import platform.Foundation.NSUTF8StringEncoding +import platform.Foundation.dataUsingEncoding + +fun String.toNSData(): NSData? { + return (this as NSString).dataUsingEncoding(NSUTF8StringEncoding) +} \ No newline at end of file From f63464fc4edf8e5c2be005dc3456573e5b9ac374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Fri, 24 May 2024 06:33:49 +0000 Subject: [PATCH 08/62] UUID & channel metadata (#218) * Tests for UUID metadata + setChannelMetadata test and impl * Channel metadata get & remove, tests & impl * Fix sort parameter --- .../kotlin/com/pubnub/api/JsonElement.kt | 2 +- .../kotlin/com/pubnub/api/JsonElement.ios.kt | 4 + .../kotlin/com/pubnub/api/JsonElement.js.kt | 7 + .../src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt | 5 +- .../kotlin/com/pubnub/api/JsonElement.jvm.kt | 4 + .../kotlin/com/pubnub/api/PubNub.kt | 4 +- .../kotlin/com/pubnub/api/PubNub.ios.kt | 4 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 4 +- .../src/jsMain/kotlin/Pubnub.d.kt | 35 +-- .../kotlin/com/pubnub/api/EndpointImpl.kt | 2 +- .../jsMain/kotlin/com/pubnub/api/PubNub.js.kt | 4 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 67 +++-- .../pubnub/api/endpoints/FetchMessagesImpl.kt | 1 - .../pubnub/api/endpoints/MessageCounts.js.kt | 1 + .../com/pubnub/api/endpoints/Time.js.kt | 1 + .../api/endpoints/access/GrantTokenImpl.kt | 2 - .../channel_groups/DeleteChannelGroup.js.kt | 1 + .../channel_groups/DeleteChannelGroupImpl.kt | 1 - .../api/endpoints/files/DeleteFile.js.kt | 1 + .../api/endpoints/files/GetFileUrl.js.kt | 1 + .../api/endpoints/files/ListFiles.js.kt | 1 + .../endpoints/files/PublishFileMessage.js.kt | 1 + .../channel/GetAllChannelMetadata.js.kt | 1 + .../objects/channel/GetChannelMetadata.js.kt | 1 + .../objects/channel/GetChannelMetadataImpl.kt | 12 + .../channel/RemoveChannelMetadataImpl.kt | 12 + .../objects/channel/SetChannelMetadata.js.kt | 1 + .../objects/channel/SetChannelMetadataImpl.kt | 31 +++ .../objects/member/ManageChannelMembers.js.kt | 4 - .../objects/membership/GetMemberships.js.kt | 1 + .../membership/ManageMemberships.js.kt | 1 + .../objects/uuid/GetAllUUIDMetadata.js.kt | 1 + .../objects/uuid/GetAllUUIDMetadataImpl.kt | 8 +- .../objects/uuid/GetUUIDMetadata.js.kt | 1 + .../objects/uuid/GetUUIDMetadataImpl.kt | 3 +- .../objects/uuid/SetUUIDMetadataImpl.kt | 2 - .../api/endpoints/presence/GetState.js.kt | 1 + .../api/endpoints/presence/GetStateImpl.kt | 1 - .../api/endpoints/presence/HereNowImpl.kt | 1 - .../api/endpoints/presence/SetState.js.kt | 1 + .../endpoints/push/AddChannelsToPush.js.kt | 1 + .../endpoints/push/ListPushProvisions.js.kt | 1 + .../push/RemoveAllPushChannelsForDevice.js.kt | 1 + .../push/RemoveChannelsFromPush.js.kt | 1 + .../api/v2/callbacks/StatusListener.js.kt | 4 - .../kotlin/com/pubnub/kmp/factories.js.kt | 51 ++++ .../jvmMain/kotlin/com/pubnub/api/PubNub.kt | 11 +- .../kotlin/com/pubnub/internal/PubNubImpl.kt | 3 +- .../pubnub-kotlin-test/build.gradle.kts | 6 +- .../com/pubnub/api/ChannelMetadataTest.kt | 129 ++++++++++ .../kotlin/com/pubnub/api/PublishTest.kt | 61 ++--- .../kotlin/com/pubnub/api/UserMetadataTest.kt | 230 ++++++++++++++++++ .../com/pubnub/test/BaseIntegrationTest.kt | 196 ++++++++++++++- 53 files changed, 802 insertions(+), 129 deletions(-) rename {pubnub-kotlin/pubnub-kotlin-api => pubnub-core/pubnub-core-api}/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt (83%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadataImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt index 2579a8193..f255615af 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt @@ -5,5 +5,5 @@ expect abstract class JsonElement expect fun JsonElement.asString(): String //expect fun JsonElement.asNumber(): Number -//expect fun JsonElement.asMap(): Map +expect fun JsonElement.asMap(): Map //expect fun JsonElement.asList(): List diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt index bf910f2b9..7d18a278f 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt @@ -4,4 +4,8 @@ actual abstract class JsonElement actual fun JsonElement.asString(): String { return TODO() +} + +actual fun JsonElement.asMap(): Map { + TODO("Not yet implemented") } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt index 0af1950d8..c619cf17b 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt @@ -2,10 +2,17 @@ package com.pubnub.api +import com.pubnub.kmp.JsMap +import com.pubnub.kmp.toMap + actual abstract class JsonElement(val value: Any?) class JsonElementImpl(value: Any?) : JsonElement(value) actual fun JsonElement.asString(): String { return value.toString() // todo kmp +} + +actual fun JsonElement.asMap(): Map { + return value.unsafeCast>().toMap().mapValues { JsonElementImpl(it.value) } // todo kmp } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt similarity index 83% rename from pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt rename to pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt index b55406cf4..957a1fea9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt @@ -1,7 +1,5 @@ package com.pubnub.kmp -import com.pubnub.api.createJsObject - external interface JsMap fun entriesOf(jsObject: JsMap): List> = @@ -17,3 +15,6 @@ fun Map.toJsMap(): JsMap = createJsObject { this[it.key] = it.value } }.unsafeCast>() + + +fun createJsObject(configure: T.() -> Unit = {}): T = (js("({})") as T).apply(configure) diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt index 4dc18ea4b..15829c9db 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt @@ -4,4 +4,8 @@ actual typealias JsonElement = com.google.gson.JsonElement actual fun JsonElement.asString(): String { return this.asString +} + +actual fun JsonElement.asMap(): Map { + return this.asJsonObject.asMap() } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt index b413e08ee..296d4f653 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt @@ -44,8 +44,6 @@ import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions -import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant @@ -240,7 +238,7 @@ expect interface PubNub { channel: String, name: String? = null, description: String? = null, - custom: Any? = null, + custom: CustomObject? = null, includeCustom: Boolean = false, type: String? = null, status: String? = null, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt index 5bcdb6eeb..ffad22939 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt @@ -44,8 +44,6 @@ import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions -import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant @@ -225,7 +223,7 @@ actual interface PubNub { channel: String, name: String?, description: String?, - custom: Any?, + custom: CustomObject?, includeCustom: Boolean, type: String?, status: String? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 4609e287e..ee6c9fbe6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -50,8 +50,6 @@ import com.pubnub.api.endpoints.push.RemoveChannelsFromPushImpl import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions -import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant @@ -330,7 +328,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { channel: String, name: String?, description: String?, - custom: Any?, + custom: CustomObject?, includeCustom: Boolean, type: String?, status: String? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt index ceb195573..dc1ef86a9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt @@ -348,6 +348,8 @@ open external class PubNub(config: Any /* UUID | UserId */) { } interface `T$6` { + var source: String + var version: String var event: String /* "set" | "delete" */ var type: String /* "uuid" | "channel" | "membership" */ var data: Any? @@ -697,34 +699,13 @@ open external class PubNub(config: Any /* UUID | UserId */) { var channels: Array } - interface ObjectsListener { - @nativeInvoke - operator fun invoke(objectsEvent: SetUUIDMetadataEvent) - - @nativeInvoke - operator fun invoke(objectsEvent: RemoveUUIDMetadataEvent) - - @nativeInvoke - operator fun invoke(objectsEvent: SetChannelMetadataEvent) - - @nativeInvoke - operator fun invoke(objectsEvent: RemoveChannelMetadataEvent) - - @nativeInvoke - operator fun invoke(objectsEvent: SetMembershipEvent) - - @nativeInvoke - operator fun invoke(objectsEvent: RemoveMembershipEvent) - } - interface ListenerParameters { val message: ((messageEvent: MessageEvent) -> Unit)? val presence: ((presenceEvent: PresenceEvent) -> Unit)? val signal: ((signalEvent: SignalEvent) -> Unit)? val messageAction: ((messageActionEvent: MessageActionEvent) -> Unit)? val file: ((fileEvent: FileEvent) -> Unit)? - val objects: ObjectsListener? - get() = definedExternally + val objects: ((objectEvent: BaseObjectsEvent) -> Unit)? } interface StatusListenerParameters { @@ -1169,7 +1150,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { var filter: String? get() = definedExternally set(value) = definedExternally - var sort: Map? + var sort: JsMap? get() = definedExternally set(value) = definedExternally var limit: Number? @@ -1203,7 +1184,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { var type: String? } - interface ChannelMetadata : ObjectParam, ChannelMetadataFieldsPartial + interface ChannelMetadata : ObjectParam, ChannelMetadataFieldsNullable interface ChannelMetadataObject : v2ObjectData, ChannelMetadataFieldsNullable interface SetChannelMetadataParameters { var channel: String @@ -1217,13 +1198,13 @@ open external class PubNub(config: Any /* UUID | UserId */) { var channel: String } - interface `T$33` { + interface IncludeCustomFields { var customFields: Boolean } interface GetChannelMetadataParameters { var channel: String - var include: `T$33`? + var include: IncludeCustomFields? get() = definedExternally set(value) = definedExternally } @@ -1281,7 +1262,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { var filter: String? get() = definedExternally set(value) = definedExternally - var sort: Map? + var sort: JsMap? get() = definedExternally set(value) = definedExternally var limit: Number? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt index f02106346..975bdafde 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt @@ -1,8 +1,8 @@ package com.pubnub.api import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result import kotlin.js.Promise -import com.pubnub.api.v2.callbacks.Result as Result open class EndpointImpl(private val promiseFactory: () -> Promise, private val responseMapping: (T) -> U): Endpoint { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt index 7fe3fad03..1b8c7cbc3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt @@ -44,8 +44,6 @@ import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions -import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant @@ -189,7 +187,7 @@ actual interface PubNub { channel: String, name: String?, description: String?, - custom: Any?, + custom: CustomObject?, includeCustom: Boolean, type: String?, status: String? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index e786b37be..59feda32e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -27,14 +27,17 @@ import com.pubnub.api.endpoints.files.ListFiles import com.pubnub.api.endpoints.files.PublishFileMessage import com.pubnub.api.endpoints.message_actions.AddMessageAction import com.pubnub.api.endpoints.message_actions.AddMessageActionImpl -import com.pubnub.api.endpoints.message_actions.GetMessageActions import com.pubnub.api.endpoints.message_actions.GetMessageActionImpl +import com.pubnub.api.endpoints.message_actions.GetMessageActions import com.pubnub.api.endpoints.message_actions.RemoveMessageAction import com.pubnub.api.endpoints.message_actions.RemoveMessageActionImpl import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadataImpl import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadataImpl import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadataImpl import com.pubnub.api.endpoints.objects.member.GetChannelMembers import com.pubnub.api.endpoints.objects.member.GetChannelMembersImpl import com.pubnub.api.endpoints.objects.member.ManageChannelMembers @@ -68,8 +71,6 @@ import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions -import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant import com.pubnub.api.models.consumer.access_manager.v3.PNAbstractGrant @@ -93,6 +94,7 @@ import com.pubnub.api.v2.callbacks.StatusListener import com.pubnub.kmp.CustomObject import com.pubnub.kmp.CustomObjectImpl import com.pubnub.kmp.Optional +import com.pubnub.kmp.createJsObject import com.pubnub.kmp.toJsMap import com.pubnub.kmp.toOptional import kotlin.js.json @@ -131,7 +133,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { this.message = message this.channel = channel this.storeInHistory = shouldStore - this.meta = meta + this.meta = if (meta is CustomObjectImpl) { meta.toJsObject() } else meta this.sendByPost = usePost this.ttl = ttl }) @@ -381,23 +383,43 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { - TODO("Not yet implemented") + return GetChannelMetadataImpl(jsPubNub, createJsObject { + this.channel = channel + this.include = createJsObject { + this.customFields = includeCustom + } + }) } override fun setChannelMetadata( channel: String, name: String?, description: String?, - custom: Any?, + custom: CustomObject?, includeCustom: Boolean, type: String?, status: String? ): SetChannelMetadata { - TODO("Not yet implemented") + return SetChannelMetadataImpl(jsPubNub, createJsObject { + this.channel = channel + this.data = ChannelMetadata( + name.toOptional(), + description.toOptional(), + status.toOptional(), + type.toOptional(), + custom.toOptional() + ) + + this.include = createJsObject { + this.customFields = includeCustom + } + }) } override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { - TODO("Not yet implemented") + return RemoveChannelMetadataImpl(jsPubNub, createJsObject { + this.channel = channel + }) } override fun getAllUUIDMetadata( @@ -424,8 +446,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { this.customFields = includeCustom this.totalCount = includeCount } - this.sort = sort.associateBy(keySelector = { pnSortKey -> pnSortKey.key.fieldName }, valueTransform = { pnSortKey -> pnSortKey.dir }) - + this.sort = sort.associateBy(keySelector = { pnSortKey -> pnSortKey.key.fieldName }, valueTransform = { pnSortKey -> pnSortKey.dir }).toJsMap() }) } @@ -444,7 +465,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { externalId: String?, profileUrl: String?, email: String?, - custom: CustomObjectImpl?, + custom: CustomObject?, includeCustom: Boolean, type: String?, status: String? @@ -558,7 +579,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { this.customFields = includeCustom this.totalCount = includeCount } - this.sort = sort.associateBy(keySelector = { pnSortKey -> pnSortKey.key.fieldName }, valueTransform = { pnSortKey -> pnSortKey.dir }) + this.sort = sort.associateBy(keySelector = { pnSortKey -> pnSortKey.key.fieldName }, valueTransform = { pnSortKey -> pnSortKey.dir }).toJsMap() }) } @@ -684,6 +705,26 @@ fun UUIDMetadata( return result } +fun ChannelMetadata( + name: Optional, + description: Optional, + status: Optional, + type: Optional, + custom: Optional?> +): PubNubJs.ChannelMetadata { + val result: PubNubJs.ChannelMetadata = createJsObject() + name.onValue { result.name = it } + description.onValue { result.description = it } + status.onValue { result.status = it } + type.onValue { result.type = it } + custom.onValue { result.custom = it?.toJsObject() } + return result +} + + + + + fun Map.toJsObject(): PubNubJs.CustomObject { val custom = createJsObject { } entries.forEach { @@ -693,8 +734,6 @@ fun Map.toJsObject(): PubNubJs.CustomObject { return custom } -fun createJsObject(configure: T.() -> Unit = {}): T = (js("({})") as T).apply(configure) - fun PNConfiguration.toJs(): PubNubJs.PNConfiguration { val config: PubNubJs.PNConfiguration = createJsObject() config.userId = userId.value diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt index 6f2f51ab8..c48c3f8e4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt @@ -2,7 +2,6 @@ package com.pubnub.api.endpoints import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.JsonElement import com.pubnub.api.JsonElementImpl import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.HistoryMessageType diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt index c6e9ea3a5..e2ae91b26 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.history.PNMessageCountResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt index 89eb3e7e4..297940ec9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.PNTimeResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt index 1ee89e2e3..9df06ce48 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt @@ -3,8 +3,6 @@ package com.pubnub.api.endpoints.access import PubNub import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult class GrantTokenImpl(pubnub: PubNub, params: PubNub.GrantTokenParameters) : GrantToken, EndpointImpl( promiseFactory = { pubnub.grantToken(params) }, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt index a480015a4..9d871d3d5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.channel_groups +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt index 225d07f29..2257f9aca 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt @@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.channel_groups import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult class DeleteChannelGroupImpl(pubnub: PubNub, params: PubNub.DeleteGroupParameters) : DeleteChannelGroup, EndpointImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt index df58b5133..e44e32bbc 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.files +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.files.PNDeleteFileResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt index b15d6b85d..854691183 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.files +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.files.PNFileUrlResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt index d6afdd889..8008d03fa 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.files +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.files.PNListFilesResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt index eeed730c4..4b6ffa4ec 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.files +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt index 51a8b8d90..39bebe9d4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.objects.channel +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt index 26a269e4a..82a462b25 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.objects.channel +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt new file mode 100644 index 000000000..aacedc4d4 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.endpoints.objects.channel + +import GetChannelMetadataResponse +import PubNub +import SetChannelMetadataResponse +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult + +class GetChannelMetadataImpl(pubnub: PubNub, params: PubNub.GetChannelMetadataParameters) : GetChannelMetadata, + EndpointImpl(promiseFactory = { pubnub.objects.getChannelMetadata(params) }, + responseMapping = SetChannelMetadataResponse::toChannelMetadataResult + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadataImpl.kt new file mode 100644 index 000000000..2ca403544 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadataImpl.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.endpoints.objects.channel + +import PubNub +import RemoveChannelMetadataResponse +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult + +class RemoveChannelMetadataImpl(pubnub: PubNub, params: PubNub.RemoveChannelMetadataParameters) : RemoveChannelMetadata, + EndpointImpl(promiseFactory = { pubnub.objects.removeChannelMetadata(params) }, + responseMapping = { + PNRemoveMetadataResult(it.status.toInt()) + }) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt index 1ab95a261..f37c3a6ca 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.objects.channel +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt new file mode 100644 index 000000000..f2d8f350b --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt @@ -0,0 +1,31 @@ +package com.pubnub.api.endpoints.objects.channel + +import PubNub +import SetChannelMetadataResponse +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult +import com.pubnub.kmp.toMap + +class SetChannelMetadataImpl(pubnub: PubNub, params: PubNub.SetChannelMetadataParameters) : SetChannelMetadata, + EndpointImpl(promiseFactory = { pubnub.objects.setChannelMetadata(params) }, + responseMapping = SetChannelMetadataResponse::toChannelMetadataResult + ) + +internal fun SetChannelMetadataResponse.toChannelMetadataResult(): PNChannelMetadataResult { + return PNChannelMetadataResult(status.toInt(), + data.toChannelMetadata()) +} + +internal fun PubNub.ChannelMetadataObject.toChannelMetadata(): PNChannelMetadata { + return PNChannelMetadata( + id, + name, + description, + custom?.toMap(), + updated, + eTag, + type, + status + ) +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt index 29cc33420..642b078a2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt @@ -1,11 +1,7 @@ package com.pubnub.api.endpoints.objects.member import PubNub -import RemoveMessageActionResult import com.pubnub.api.Endpoint -import com.pubnub.api.EndpointImpl -import com.pubnub.api.endpoints.message_actions.RemoveMessageAction -import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt index 8cec56fd6..82a9ef1de 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.objects.membership +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt index a7af4557b..e00979f1a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.objects.membership +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt index 67faf7dd0..518b97e6f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.objects.uuid +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt index d99ebd654..3edbb17bd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt @@ -1,20 +1,14 @@ package com.pubnub.api.endpoints.objects.uuid import GetAllUUIDMetadataResponse -import GetUUIDMetadataResponse -import ObjectsResponse import PubNub -import SetUUIDMetadataResponse import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -import com.pubnub.kmp.toMap class GetAllUUIDMetadataImpl(pubnub: PubNub, params: PubNub.GetAllMetadataParameters) : GetAllUUIDMetadata, EndpointImpl(promiseFactory = { pubnub.objects.getAllUUIDMetadata(params) }, - responseMapping = {pagedObjectsResponse: GetAllUUIDMetadataResponse -> + responseMapping = { pagedObjectsResponse: GetAllUUIDMetadataResponse -> PNUUIDMetadataArrayResult( pagedObjectsResponse.status.toInt(), pagedObjectsResponse.data.map(PubNub.UUIDMetadataObject::toPNUUIDMetadata), diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt index e6ac8e468..be3d30708 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.objects.uuid +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt index 239db7652..1ff284acb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt @@ -3,7 +3,6 @@ package com.pubnub.api.endpoints.objects.uuid import GetUUIDMetadataResponse import ObjectsResponse import PubNub -import SetUUIDMetadataResponse import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult @@ -17,6 +16,6 @@ class GetUUIDMetadataImpl(pubnub: PubNub, params: PubNub.GetUUIDMetadataParamete fun ObjectsResponse.toPNUUIDMetadataResult() = PNUUIDMetadataResult(status.toInt(), data.toPNUUIDMetadata()) -fun PubNub.UUIDMetadataObject.toPNUUIDMetadata() = PNUUIDMetadata( +internal fun PubNub.UUIDMetadataObject.toPNUUIDMetadata() = PNUUIDMetadata( id, name, externalId, profileUrl, email, custom?.toMap(), updated, eTag, type, status ) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt index 6b758f5fc..aa5ca3c0b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt @@ -4,9 +4,7 @@ import GetUUIDMetadataResponse import PubNub import SetUUIDMetadataResponse import com.pubnub.api.EndpointImpl -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -import com.pubnub.kmp.toMap class SetUUIDMetadataImpl(pubnub: PubNub, params: PubNub.SetUUIDMetadataParameters) : SetUUIDMetadata, EndpointImpl(promiseFactory = { pubnub.objects.setUUIDMetadata(params) }, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt index db440e6c6..6621c6bb9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.presence +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.presence.PNGetStateResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt index 515b6c47b..696491f05 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt @@ -4,7 +4,6 @@ import PubNub import com.pubnub.api.EndpointImpl import com.pubnub.api.JsonElementImpl import com.pubnub.api.models.consumer.presence.PNGetStateResult -import com.pubnub.api.models.consumer.presence.PNSetStateResult import com.pubnub.kmp.JsMap import com.pubnub.kmp.toMap diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt index 3dd440567..8e700700e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt @@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.presence import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.JsonElement import com.pubnub.api.JsonElementImpl import com.pubnub.api.models.consumer.presence.PNHereNowChannelData import com.pubnub.api.models.consumer.presence.PNHereNowOccupantData diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt index 3d5552313..7e8624c55 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.presence +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.presence.PNSetStateResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt index 12aef0b7d..3eb2988bd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.push +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.push.PNPushAddChannelResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt index 63496da48..fc0c8cdad 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.push +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt index f88e4e04f..1d7642bdd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.push +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt index e17227963..91c47e4b1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.push +import PubNub import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt index 32372f854..feb40c8cc 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt @@ -1,10 +1,6 @@ package com.pubnub.api.v2.callbacks -import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener -import com.pubnub.api.models.consumer.PNStatus - -import PubNub as PubNubJs /** * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt index 15a29c843..d43dc2315 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt @@ -3,6 +3,8 @@ package com.pubnub.kmp import com.pubnub.api.JsonElementImpl import com.pubnub.api.PubNub import com.pubnub.api.PubNubImpl +import com.pubnub.api.endpoints.objects.channel.toChannelMetadata +import com.pubnub.api.endpoints.objects.uuid.toPNUUIDMetadata import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.files.PNDownloadableFile import com.pubnub.api.models.consumer.message_actions.PNMessageAction @@ -12,7 +14,11 @@ import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener @@ -111,6 +117,51 @@ actual fun createEventListener( ) ) } + override val objects = { event: PubNubJs.BaseObjectsEvent -> + val eventAndType = event.message.event to event.message.type + onObjects(pubnub, PNObjectEventResult( + BasePubSubResult( + event.channel, + event.subscription, + event.timetoken.toLong(), + null, + event.publisher + ), + when(eventAndType) { + "set" to "channel" -> PNSetChannelMetadataEventMessage( + event.message.source, + event.message.version, + event.message.event, + event.message.type, + event.message.data.unsafeCast().toChannelMetadata() + ) + "set" to "uuid" -> PNSetUUIDMetadataEventMessage( + event.message.source, + event.message.version, + event.message.event, + event.message.type, + event.message.data.unsafeCast().toPNUUIDMetadata() + ) +// "set" to "membership" -> {} + "delete" to "channel" -> PNDeleteChannelMetadataEventMessage( + event.message.source, + event.message.version, + event.message.event, + event.message.type, + event.message.data.asDynamic().id + ) + "delete" to "uuid" -> PNDeleteUUIDMetadataEventMessage( + event.message.source, + event.message.version, + event.message.event, + event.message.type, + event.message.data.asDynamic().id + ) +// "delete" to "membership" -> {} + else -> throw IllegalStateException("Bad object event") + } + )) + } } return listener.asDynamic() } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index 888728ca8..bc40f4536 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -74,6 +74,7 @@ import com.pubnub.api.v2.entities.UserMetadata import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.internal.BasePubNubImpl +import com.pubnub.kmp.CustomObject import java.io.InputStream actual interface PubNub : @@ -844,10 +845,10 @@ actual interface PubNub : */ fun grantToken( ttl: Int, - meta: Any?, - authorizedUserId: UserId?, - spacesPermissions: List, - usersPermissions: List, + meta: Any? = null, + authorizedUserId: UserId? = null, + spacesPermissions: List = emptyList(), + usersPermissions: List = emptyList(), ): GrantToken /** @@ -913,7 +914,7 @@ actual interface PubNub : channel: String, name: String?, description: String?, - custom: Any?, + custom: CustomObject?, includeCustom: Boolean, type: String?, status: String?, diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt index 2e3aeb23f..f8eea5267 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt @@ -111,6 +111,7 @@ import com.pubnub.internal.v2.entities.UserMetadataImpl import com.pubnub.internal.v2.subscription.EmitterHelper import com.pubnub.internal.v2.subscription.SubscriptionImpl import com.pubnub.internal.v2.subscription.SubscriptionSetImpl +import com.pubnub.kmp.CustomObject import java.io.InputStream private const val PNSDK_PUBNUB_KOTLIN = "PubNub-Kotlin" @@ -759,7 +760,7 @@ class PubNubImpl( channel: String, name: String?, description: String?, - custom: Any?, + custom: CustomObject?, includeCustom: Boolean, type: String?, status: String?, diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts index 61d2817b5..2f57ae4d1 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -4,6 +4,8 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable import java.util.Properties +import kotlin.time.Duration.Companion.seconds +import kotlin.time.toJavaDuration plugins { alias(libs.plugins.benmanes.versions) @@ -20,10 +22,9 @@ kotlin { browser { testTask { useMocha { - timeout = "10s" + timeout = "30s" } } - } binaries.executable() } @@ -128,6 +129,7 @@ kotlin { testProps.load(it) } } catch (e: Exception) { + println("No test.properties found in root project. Using 'demo' for all keys.") testProps.setProperty("pubKey", "demo") testProps.setProperty("subKey", "demo") testProps.setProperty("pamPubKey", "demo") diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt new file mode 100644 index 000000000..223d63c47 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt @@ -0,0 +1,129 @@ +package com.pubnub.api + +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage +import com.pubnub.kmp.createCustomObject +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import com.pubnub.test.randomString +import com.pubnub.test.test +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.time.Duration.Companion.seconds + +class ChannelMetadataTest : BaseIntegrationTest() { + private val channel = "myChannel" + randomString() + private val name = randomString() + private val description = randomString() + private val status = randomString() + private val customData = mapOf("aa" to randomString()) + private val custom = createCustomObject(customData) + private val includeCustom = true + private val type = randomString() + + @Test + fun can_set_metadata() = runTest(timeout = 10.seconds) { + // when + val result = pubnub.setChannelMetadata( + channel, + name = name, + status = status, + custom = custom, + includeCustom = includeCustom, + type = type, + description = description + ).await() + + // then + val pnuuidMetadata = result.data + requireNotNull(pnuuidMetadata) + assertEquals(channel, pnuuidMetadata.id) + assertEquals(name, pnuuidMetadata.name) + assertEquals(status, pnuuidMetadata.status) + assertEquals(customData, pnuuidMetadata.custom) + assertEquals(type, pnuuidMetadata.type) + assertEquals(description, pnuuidMetadata.description) + } + + @Test + fun can_receive_set_metadata_event() = runTest(timeout = 10.seconds) { + pubnub.test(backgroundScope) { + // given + pubnub.awaitSubscribe(listOf(channel)) + + // when + pubnub.setChannelMetadata( + channel, + name = name, + status = status, + custom = custom, + includeCustom = includeCustom, + type = type, + description = description + ).await() + + // then + val result = nextEvent() + val message = result.extractedMessage + message as PNSetChannelMetadataEventMessage + assertEquals(channel, message.data.id) + assertEquals(name, message.data.name) + assertEquals(description, message.data.description) + assertEquals(status, message.data.status) + assertEquals(customData, message.data.custom) + assertEquals(type, message.data.type) + } + } + + @Test + fun can_delete_metadata() = runTest(timeout = 10.seconds) { + // given + pubnub.setChannelMetadata( + channel, + name = name, + status = status, + custom = custom, + includeCustom = includeCustom, + type = type, + description = description + ).await() + + // when + pubnub.removeChannelMetadata(channel).await() + + // then + assertFailsWith { + pubnub.getChannelMetadata(channel).await() + } + } + + @Test + fun can_receive_delete_metadata_event() = runTest(timeout = 10.seconds) { + pubnub.test(backgroundScope) { + pubnub.setChannelMetadata( + channel, + name = name, + status = status, + custom = custom, + includeCustom = includeCustom, + type = type, + description = description + ).await() + pubnub.awaitSubscribe(listOf(channel)) + + // when + pubnub.removeChannelMetadata(channel).await() + + // then + val result = nextEvent() + val message = result.extractedMessage + message as PNDeleteChannelMetadataEventMessage + assertEquals(channel, message.channel) + } + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt index 4161a5ae3..b07cae35e 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt @@ -1,17 +1,10 @@ package com.pubnub.api -import com.pubnub.api.enums.PNStatusCategory -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.kmp.createEventListener -import com.pubnub.kmp.createStatusListener +import com.pubnub.kmp.createCustomObject import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await -import kotlinx.coroutines.channels.Channel -import kotlinx.coroutines.launch -import kotlinx.coroutines.suspendCancellableCoroutine +import com.pubnub.test.test import kotlinx.coroutines.test.runTest -import kotlin.coroutines.resume -import kotlin.coroutines.resumeWithException import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals @@ -25,40 +18,34 @@ class PublishTest : BaseIntegrationTest() { fun can_publish_message() = runTest(timeout = 10.seconds) { val result = pubnub.publish(channel, "some message").await() - // never getting to here assertTrue { result.timetoken > 0 } } @Test - @Ignore - fun can_receive_message() = runTest(timeout = 10.seconds) { - val queue = Channel() - pubnub.addListener(createEventListener(pubnub, onMessage = { pubNub, pnMessageResult -> - backgroundScope.launch { - queue.send(pnMessageResult) - } - })) - pubnub.subscribeAndWait(pubnub, channel) - - pubnub.publish(channel, "some message").await() - val result = queue.receive() - assertEquals("some message", result.message.asString()) + fun can_receive_message_with_object_metadata() = runTest(timeout = 10.seconds) { + pubnub.test(backgroundScope) { + pubnub.awaitSubscribe(listOf(channel)) + pubnub.publish(channel, "some message", createCustomObject(mapOf("aa" to "bb"))).await() + val result = nextMessage() + assertEquals("some message", result.message.asString()) + assertEquals(mapOf("aa" to "bb"), result.userMetadata?.asMap()?.mapValues { it.value.asString() }) + } } -} -private suspend fun PubNub.subscribeAndWait(pubNub: PubNub, channel: String) = suspendCancellableCoroutine { cont -> - val statusListener = createStatusListener(pubNub) { pubNub, pnStatus -> - if (pnStatus.category == PNStatusCategory.PNConnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged - && pnStatus.affectedChannels.contains(channel)) { - cont.resume(Unit) - } - if (pnStatus.category == PNStatusCategory.PNUnexpectedDisconnectCategory || pnStatus.category == PNStatusCategory.PNConnectionError) { - cont.resumeWithException(pnStatus.exception ?: RuntimeException(pnStatus.category.toString())) + @Test + @Ignore + fun can_receive_message_with_primitive_metadata() = runTest(timeout = 10.seconds) { + pubnub.test(backgroundScope) { + pubnub.awaitSubscribe(listOf(channel)) + pubnub.publish(channel, "some message", "some meta").await() + val result = nextMessage() + assertEquals("some message", result.message.asString()) + assertEquals("some meta", result.userMetadata?.asString()) + + pubnub.publish(channel, "some message", 123).await() + val result2 = nextMessage() + assertEquals("some message", result2.message.asString()) + assertEquals("123", result2.userMetadata?.asString()) } } - pubNub.addListener(statusListener) - cont.invokeOnCancellation { - pubNub.removeListener(statusListener) - } - subscribe(listOf(channel)) } diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt new file mode 100644 index 000000000..65533e088 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt @@ -0,0 +1,230 @@ +package com.pubnub.api + +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage +import com.pubnub.kmp.createCustomObject +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import com.pubnub.test.randomString +import com.pubnub.test.test +import kotlinx.coroutines.test.runTest +import kotlin.test.Ignore +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertNotNull +import kotlin.test.assertTrue +import kotlin.time.Duration.Companion.seconds + +class UserMetadataTest : BaseIntegrationTest() { + private val uuid = "myUser" + randomString() + private val name = randomString() + private val externalId = randomString() + private val profileUrl = randomString() + private val email = randomString() + private val status = randomString() + private val customData = mapOf("aa" to randomString()) + private val custom = createCustomObject(customData) + private val includeCustom = true + private val type = randomString() + + @Test + fun can_set_metadata() = runTest(timeout = 10.seconds) { + // when + val result = pubnub.setUUIDMetadata( + uuid, + name = name, + externalId = externalId, + profileUrl = profileUrl, + email = email, + status = status, + custom = custom, + includeCustom = includeCustom, + type = type + ).await() + + // then + val pnuuidMetadata = result.data + requireNotNull(pnuuidMetadata) + assertEquals(uuid, pnuuidMetadata.id) + assertEquals(name, pnuuidMetadata.name) + assertEquals(externalId, pnuuidMetadata.externalId) + assertEquals(profileUrl, pnuuidMetadata.profileUrl) + assertEquals(email, pnuuidMetadata.email) + assertEquals(status, pnuuidMetadata.status) + assertEquals(customData, pnuuidMetadata.custom) + assertEquals(type, pnuuidMetadata.type) + } + + @Test + fun can_receive_set_metadata_event() = runTest(timeout = 10.seconds) { + pubnub.test(backgroundScope) { + // given + pubnub.awaitSubscribe(listOf(uuid)) + + // when + pubnub.setUUIDMetadata( + uuid, + name = name, + externalId = externalId, + profileUrl = profileUrl, + email = email, + status = status, + custom = custom, + includeCustom = includeCustom, + type = type + ).await() + + // then + val result = nextEvent() + val message = result.extractedMessage + message as PNSetUUIDMetadataEventMessage + assertEquals(uuid, message.data.id) + assertEquals(name, message.data.name) + assertEquals(externalId, message.data.externalId) + assertEquals(profileUrl, message.data.profileUrl) + assertEquals(email, message.data.email) + assertEquals(status, message.data.status) + assertEquals(customData, message.data.custom) + assertEquals(type, message.data.type) + } + } + + @Test + fun can_delete_metadata() = runTest(timeout = 10.seconds) { + // given + pubnub.setUUIDMetadata( + uuid, + name = name, + externalId = externalId, + profileUrl = profileUrl, + email = email, + status = status, + custom = custom, + includeCustom = includeCustom, + type = type + ).await() + + // when + pubnub.removeUUIDMetadata(uuid).await() + + // then + assertFailsWith { + pubnub.getUUIDMetadata(uuid).await() + } + } + + @Test + fun can_receive_delete_metadata_event() = runTest(timeout = 10.seconds) { + pubnub.test(backgroundScope) { + // given + pubnub.setUUIDMetadata( + uuid, + name = name, + externalId = externalId, + profileUrl = profileUrl, + email = email, + status = status, + custom = custom, + includeCustom = includeCustom, + type = type + ).await() + pubnub.awaitSubscribe(listOf(uuid)) + + // when + pubnub.removeUUIDMetadata(uuid).await() + + // then + val result = nextEvent() + val message = result.extractedMessage + message as PNDeleteUUIDMetadataEventMessage + assertEquals(uuid, message.uuid) + } + } + + @Test + fun can_get_metadata() = runTest(timeout = 10.seconds) { + // given + pubnub.setUUIDMetadata( + uuid, + name = name, + externalId = externalId, + profileUrl = profileUrl, + email = email, + status = status, + custom = custom, + includeCustom = includeCustom, + type = type + ).await() + + //when + val result = pubnub.getUUIDMetadata(uuid, includeCustom = true).await() + + // then + val pnuuidMetadata = result.data + requireNotNull(pnuuidMetadata) + assertEquals(uuid, pnuuidMetadata.id) + assertEquals(name, pnuuidMetadata.name) + assertEquals(externalId, pnuuidMetadata.externalId) + assertEquals(profileUrl, pnuuidMetadata.profileUrl) + assertEquals(email, pnuuidMetadata.email) + assertEquals(status, pnuuidMetadata.status) + assertEquals(customData, pnuuidMetadata.custom) + assertEquals(type, pnuuidMetadata.type) + } + + @Test + @Ignore // very slow, use to test once + fun can_get_all_metadata_with_paging() = runTest(timeout = 30.seconds) { + // given + repeat(10) { + pubnub.setUUIDMetadata( + uuid + it, + name = name, + externalId = externalId, + profileUrl = profileUrl, + email = email, + status = status, + custom = custom, + includeCustom = includeCustom, + type = type + ).await() + } + + // when + val allUsers = mutableListOf() + var next: PNPage.PNNext? = null + while(true) { + val result: PNUUIDMetadataArrayResult = pubnub.getAllUUIDMetadata(limit = 4, page = next, includeCustom = true).await() + allUsers.addAll(result.data) + next = result.next + if (next == null || result.data.isEmpty()) { + break + } + } + + // clean up before asserting + repeat(10) { + pubnub.removeUUIDMetadata(uuid + it) + } + + // then + assertTrue { allUsers.size >= 10 } + repeat(10) { + val pnuuidMetadata = allUsers.firstOrNull { user -> user.id == uuid + it } + assertNotNull(pnuuidMetadata) + assertEquals(name, pnuuidMetadata.name) + assertEquals(externalId, pnuuidMetadata.externalId) + assertEquals(profileUrl, pnuuidMetadata.profileUrl) + assertEquals(email, pnuuidMetadata.email) + assertEquals(status, pnuuidMetadata.status) + assertEquals(customData, pnuuidMetadata.custom) + assertEquals(type, pnuuidMetadata.type) + } + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt index 84e0a2cd3..da4568cdd 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt @@ -3,13 +3,23 @@ package com.pubnub.test import com.pubnub.api.Endpoint import com.pubnub.api.PubNub import com.pubnub.api.UserId -import com.pubnub.kmp.createPubNub +import com.pubnub.api.enums.PNStatusCategory +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.pubsub.PNEvent +import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.v2.createPNConfiguration +import com.pubnub.kmp.createEventListener +import com.pubnub.kmp.createPubNub +import com.pubnub.kmp.createStatusListener +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.launch import kotlinx.coroutines.suspendCancellableCoroutine import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.test.AfterTest import kotlin.test.BeforeTest +import kotlin.test.assertTrue abstract class BaseIntegrationTest { @@ -35,4 +45,186 @@ suspend fun Endpoint.await() = suspendCancellableCoroutine { cont -> cont.resumeWithException(it) } } -} \ No newline at end of file +} + + +class PubNubTest( + private val pubNub: PubNub, + private val withPresenceOverride: Boolean, + backgroundScope: CoroutineScope +) { + private val messageQueue = Channel(10) + private val statusQueue = Channel(10) + + private val statusVerificationListener = createStatusListener(pubNub) { _, status -> + backgroundScope.launch { + statusQueue.send(status) + } + } + private val eventVerificationListener = createEventListener( + pubNub, + onMessage = { _, event -> + backgroundScope.launch { + messageQueue.send(event) + } + }, + onSignal = { _, event -> + backgroundScope.launch { + messageQueue.send(event) + } + }, + onFile = { _, event -> + backgroundScope.launch { + messageQueue.send(event) + } + }, + onPresence = { _, event -> + backgroundScope.launch { + messageQueue.send(event) + } + }, + onObjects = { _, event -> + backgroundScope.launch { + messageQueue.send(event) + } + }, + onMessageAction = { _, event -> + backgroundScope.launch { + messageQueue.send(event) + } + }, + ) + + + init { + pubNub.addListener(eventVerificationListener) + pubNub.addListener(statusVerificationListener) + } + + suspend fun PubNub.awaitSubscribe( + channels: Collection = setOf(), + channelGroups: Collection = setOf(), + withPresence: Boolean = false + ) = suspendCancellableCoroutine { cont -> + val statusListener = createStatusListener(pubNub) { _, pnStatus -> + if ((pnStatus.category == PNStatusCategory.PNConnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged) + && pnStatus.affectedChannels.containsAll(channels) && pnStatus.affectedChannelGroups.containsAll( + channelGroups + ) + ) { + cont.resume(Unit) + } + if (pnStatus.category == PNStatusCategory.PNUnexpectedDisconnectCategory || pnStatus.category == PNStatusCategory.PNConnectionError) { + cont.resumeWithException(pnStatus.exception ?: RuntimeException(pnStatus.category.toString())) + } + } + pubNub.addListener(statusListener) + cont.invokeOnCancellation { + pubNub.removeListener(statusListener) + } + subscribe(channels.toList(), channelGroups.toList(), withPresence) + } + +// fun subscribe( +// channels: Collection = emptyList(), +// channelGroups: Collection = emptyList(), +// withPresence: Boolean = false, +// ) { +// pubNub.subscribe(channels.toList(), channelGroups.toList(), withPresence = withPresence || withPresenceOverride) +// val status = statusQueue.take() +// Assert.assertTrue( +// status.category == PNStatusCategory.PNConnectedCategory || status.category == PNStatusCategory.PNSubscriptionChanged, +// ) +// if (status.category == PNStatusCategory.PNConnectedCategory) { +// Assert.assertTrue(status.affectedChannels.containsAll(channels)) +// Assert.assertTrue(status.affectedChannelGroups.containsAll(channelGroups)) +// } else if (status.category == PNStatusCategory.PNSubscriptionChanged) { +// Assert.assertTrue(status.affectedChannels.containsAll(channels)) +// Assert.assertTrue(status.affectedChannelGroups.containsAll(channelGroups)) +// } +// } + + suspend fun PubNub.awaitUnsubscribe( + channels: Collection = setOf(), + channelGroups: Collection = setOf(), + withPresence: Boolean = false + ) = suspendCancellableCoroutine { cont -> + val statusListener = createStatusListener(pubNub) { _, pnStatus -> + if (pnStatus.category == PNStatusCategory.PNDisconnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged + && pnStatus.affectedChannels.containsAll(channels) && pnStatus.affectedChannelGroups.containsAll( + channelGroups + ) + ) { + cont.resume(Unit) + } + if (pnStatus.category == PNStatusCategory.PNUnexpectedDisconnectCategory || pnStatus.category == PNStatusCategory.PNConnectionError) { + cont.resumeWithException(pnStatus.exception ?: RuntimeException(pnStatus.category.toString())) + } + } + pubNub.addListener(statusListener) + cont.invokeOnCancellation { + pubNub.removeListener(statusListener) + } + unsubscribe(channels.toList(), channelGroups.toList()) + } + +// fun unsubscribeAll() { +// pubNub.unsubscribeAll() +// val status = statusQueue.take() +// Assert.assertTrue(status.category == PNStatusCategory.PNDisconnectedCategory) +// } + + suspend fun nextStatus(): PNStatus = statusQueue.receive() + +// suspend fun nextStatus(timeout: Duration): PNStatus? { +// return try { +// FutureTask { +// statusQueue.take() +// }.get(timeout.inWholeMilliseconds, TimeUnit.MILLISECONDS) +// } catch (e: TimeoutException) { +// null +// } +// } + + @Suppress("UNCHECKED_CAST") + suspend fun nextEvent(): T { + return messageQueue.receive() as T + } + + suspend fun nextMessage() = nextEvent() + + suspend fun skip(n: Int = 1) { + for (i in 0 until n) { + nextEvent() + } + } + + fun close() { + pubNub.unsubscribeAll() + pubNub.destroy() + + val remainingMessages = buildList { + messageQueue.tryReceive().getOrNull()?.apply { add(this) } ?: return@buildList + } + assertTrue( + "There were ${remainingMessages.size} unverified events in the test: ${remainingMessages.joinToString(", ")}" + ) { remainingMessages.isEmpty() } + } +} + +suspend fun PubNub.test( + backgroundScope: CoroutineScope, + withPresence: Boolean = false, + action: suspend PubNubTest.() -> Unit, +) { + val pubNubTest = PubNubTest(this, withPresence, backgroundScope) + try { + with(pubNubTest) { + action() + } + } finally { + pubNubTest.close() + } +} + +fun randomString() = (0..6).map { "abcdefghijklmnopqrstuvw".random() }.joinToString("") \ No newline at end of file From 32e257760fe1db58d523a92c9ee1072dbebd3aff Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Tue, 28 May 2024 11:29:50 +0200 Subject: [PATCH 09/62] Added Swift wrappers for next endpoints (#221) --- .../kotlin/com/pubnub/api/Endpoint.ios.kt | 4 + .../kotlin/com/pubnub/api/PubNubImpl.kt | 59 +++-- .../api/endpoints/DeleteMessages.ios.kt | 28 ++- .../pubnub/api/endpoints/FetchMessages.ios.kt | 86 ++++++- .../pubnub/api/endpoints/MessageCounts.ios.kt | 25 +- .../com/pubnub/api/endpoints/Time.ios.kt | 22 +- .../api/endpoints/pubsub/Publish.ios.kt | 5 +- .../pubnub/api/endpoints/pubsub/Signal.ios.kt | 3 +- .../endpoints/push/AddChannelsToPush.ios.kt | 3 +- .../endpoints/push/ListPushProvisions.ios.kt | 3 +- .../RemoveAllPushChannelsForDevice.ios.kt | 7 +- .../push/RemoveChannelsFromPush.ios.kt | 3 +- .../api/v2/callbacks/EventListener.ios.kt | 12 +- .../kotlin/com/pubnub/kmp/factories.ios.kt | 230 +++++++++++++++++- 14 files changed, 456 insertions(+), 34 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt index 18f67a58b..b87350800 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt @@ -12,6 +12,10 @@ fun Consumer>.onSuccessHandler(mapper: (T) -> U) : (T) -> Unit { return fun(input: T) { accept(Result.success(mapper(input))) } } +fun Consumer>.onSuccessReturnValue(value: T) : () -> Unit { + return fun() { accept(Result.success(value)) } +} + fun Consumer>.onFailureHandler(mapper: (NSError?) -> Throwable = { error: NSError? -> PubNubException(errorMessage = error?.localizedDescription) } ): (NSError?) -> Unit { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index ee6c9fbe6..830d1ce39 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -1,10 +1,19 @@ package com.pubnub.api +import cocoapods.PubNubSwift.addEventListenerWithListener +import cocoapods.PubNubSwift.subscribeWithChannels +import cocoapods.PubNubSwift.subscribedChannelGroups +import cocoapods.PubNubSwift.subscribedChannels +import cocoapods.PubNubSwift.unsubscribeFrom import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages +import com.pubnub.api.endpoints.DeleteMessagesImpl import com.pubnub.api.endpoints.FetchMessages +import com.pubnub.api.endpoints.FetchMessagesImpl import com.pubnub.api.endpoints.MessageCounts +import com.pubnub.api.endpoints.MessageCountsImpl import com.pubnub.api.endpoints.Time +import com.pubnub.api.endpoints.TimeImpl import com.pubnub.api.endpoints.access.GrantToken import com.pubnub.api.endpoints.access.RevokeToken import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup @@ -69,9 +78,8 @@ import com.pubnub.api.v2.callbacks.StatusListener import com.pubnub.kmp.CustomObject import kotlinx.cinterop.ExperimentalForeignApi +@OptIn(ExperimentalForeignApi::class) class PubNubImpl(override val configuration: PNConfiguration) : PubNub { - - @OptIn(ExperimentalForeignApi::class) private val pubNubObjC = cocoapods.PubNubSwift.PubNubObjC( user = configuration.userId.value, subKey = configuration.subscribeKey, @@ -79,7 +87,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ) override fun addListener(listener: EventListener) { - TODO("Not yet implemented") + pubNubObjC.addEventListenerWithListener(listener = listener.underlying) } override fun addListener(listener: StatusListener) { @@ -94,7 +102,6 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { TODO("Not yet implemented") } - @OptIn(ExperimentalForeignApi::class) // TODO: replicate and usePost parameters are not present in Swift SDK override fun publish( channel: String, @@ -115,8 +122,6 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ) } - - @OptIn(ExperimentalForeignApi::class) // TODO: usePost parameter is not present in Swift SDK override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { return PublishImpl( @@ -129,22 +134,19 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ) } - @OptIn(ExperimentalForeignApi::class) override fun signal(channel: String, message: Any): Signal { return SignalImpl(pubnub = pubNubObjC, channel = channel, message = message) } - @OptIn(ExperimentalForeignApi::class) override fun getSubscribedChannels(): List { return pubNubObjC.subscribedChannels() as List } - @OptIn(ExperimentalForeignApi::class) override fun getSubscribedChannelGroups(): List { return pubNubObjC.subscribedChannelGroups() as List } - @OptIn(ExperimentalForeignApi::class) + // TODO: Missing pushType (PushService like APNS, GCM, etc) parameter // TODO: Why do we need topic parameter here? override fun addPushNotificationsOnChannels( @@ -161,7 +163,6 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ) } - @OptIn(ExperimentalForeignApi::class) // TODO: topic and environment parameters are not present in Swift SDK override fun auditPushChannelProvisions( pushType: PNPushType, @@ -172,7 +173,6 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { return ListPushProvisionsImpl(pubnub = pubNubObjC, deviceId = deviceId, pushType = pushType) } - @OptIn(ExperimentalForeignApi::class) // TODO: topic and environment parameters are not present in Swift SDK override fun removePushNotificationsFromChannels( pushType: PNPushType, @@ -189,7 +189,6 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ) } - @OptIn(ExperimentalForeignApi::class) override fun removeAllPushNotificationsFromDeviceWithPushToken( pushType: PNPushType, deviceId: String, @@ -211,15 +210,32 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeMessageActions: Boolean, includeMessageType: Boolean ): FetchMessages { - TODO("Not yet implemented") + return FetchMessagesImpl( + pubnub = pubNubObjC, + channels = channels, + page = page, + includeUUID = includeUUID, + includeMeta = includeMeta, + includeMessageActions = includeMessageActions, + includeMessageType = includeMessageType + ) } override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { - TODO("Not yet implemented") + return DeleteMessagesImpl( + pubnub = pubNubObjC, + channels = channels, + start = start, + end = end + ) } override fun messageCounts(channels: List, channelsTimetoken: List): MessageCounts { - TODO("Not yet implemented") + return MessageCountsImpl( + pubnub = pubNubObjC, + channels = channels, + channelsTimetoken = channelsTimetoken + ) } override fun hereNow( @@ -306,7 +322,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun time(): Time { - TODO("Not yet implemented") + return TimeImpl(pubnub = pubNubObjC) } override fun getAllChannelMetadata( @@ -515,11 +531,16 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { withPresence: Boolean, withTimetoken: Long ) { - TODO("Not yet implemented") + pubNubObjC.subscribeWithChannels( + channels = channels, + channelGroups = channelGroups, + withPresence = withPresence, + timetoken = withTimetoken.toULong() + ) } override fun unsubscribe(channels: List, channelGroups: List) { - TODO("Not yet implemented") + pubNubObjC.unsubscribeFrom(channels = channels, channelGroups = channelGroups) } override fun setToken(token: String?) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt index 780e50eaf..746c60c12 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt @@ -1,9 +1,35 @@ package com.pubnub.api.endpoints +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.deleteMessagesFrom import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessReturnValue +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [com.pubnub.api.PubNub.deleteMessages] */ -actual interface DeleteMessages : Endpoint \ No newline at end of file +actual interface DeleteMessages : Endpoint + +@OptIn(ExperimentalForeignApi::class) +class DeleteMessagesImpl ( + private val pubnub: PubNubObjC, + private val channels: List, + private val start: Long?, + private val end: Long? +): DeleteMessages { + override fun async(callback: Consumer>) { + pubnub.deleteMessagesFrom( + channels = channels, + start = start?.let { NSNumber(long = it) }, + end = end?.let { NSNumber(long = it) }, + onSuccess = callback.onSuccessReturnValue(PNDeleteMessagesResult()), + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt index 5b9e811c1..cad9fb4e5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt @@ -1,10 +1,94 @@ package com.pubnub.api.endpoints +import cocoapods.PubNubSwift.PubNubBoundedPageObjC +import cocoapods.PubNubSwift.PubNubMessageActionObjC +import cocoapods.PubNubSwift.PubNubMessageObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.fetchMessagesFrom import com.pubnub.api.Endpoint +import com.pubnub.api.JsonElement +import com.pubnub.api.PubNubError +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.history.HistoryMessageType +import com.pubnub.api.models.consumer.history.PNFetchMessageItem import com.pubnub.api.models.consumer.history.PNFetchMessagesResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [PubNub.fetchMessages] */ -actual interface FetchMessages : Endpoint { +actual interface FetchMessages : Endpoint {} + +@OptIn(ExperimentalForeignApi::class) +open class FetchMessagesImpl( + private val pubnub: PubNubObjC, + private val channels: List, + private val page: PNBoundedPage, + private val includeUUID: Boolean, + private val includeMeta: Boolean, + private val includeMessageActions: Boolean, + private val includeMessageType: Boolean +): FetchMessages { + override fun async(callback: Consumer>) { + pubnub.fetchMessagesFrom( + channels = channels, + includeUUID = includeUUID, + includeMeta = includeMeta, + includeMessageActions = includeMessageActions, + includeMessageType = includeMessageType, + page = PubNubBoundedPageObjC( + start = page.start?.let { NSNumber(long = it) }, + end = page.end?.let { NSNumber(long = it) }, + limit = page.limit?.let { NSNumber(int = it) } + ), + onSuccess = callback.onSuccessHandler { + PNFetchMessagesResult( + channels = mapMessages(rawValue = it?.messages()), + page = PNBoundedPage( + start = it?.page()?.start()?.longValue, + end = it?.page()?.end()?.longValue, + limit = it?.page()?.limit()?.intValue + ) + )}, + onFailure = callback.onFailureHandler() + ) + } + + private fun mapMessages(rawValue: Map?): Map> { + return (rawValue as? Map>)?.mapValues { entry -> + entry.value.map { + PNFetchMessageItem( + uuid = it.publisher(), + message = it.payload() as JsonElement, + meta = it.metadata() as? JsonElement, + timetoken = it.published().toLong(), + actions = mapMessageActions(rawValue = it.actions()), + messageType = HistoryMessageType.of(it.messageType().toInt()), + error = PubNubError.CRYPTO_ERROR + ) + } + } ?: emptyMap() + } + + private fun mapMessageActions(rawValue: List<*>): Map>> { + return (rawValue as? List)?.groupBy { messageAction -> + messageAction.actionType() + }?.mapValues { entry -> + entry.value.groupBy { groupedMessageAction -> + groupedMessageAction.actionValue() + }.mapValues { groupedEntry -> + groupedEntry.value.map { + PNFetchMessageItem.Action( + uuid = it.publisher(), + actionTimetoken = it.published()?.longValue.toString() + ) + } + } + } ?: emptyMap() + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt index c6e9ea3a5..698fc13a7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt @@ -1,9 +1,32 @@ package com.pubnub.api.endpoints +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.messageCountsFor import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.history.PNMessageCountResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.messageCounts] */ -actual interface MessageCounts : Endpoint \ No newline at end of file +actual interface MessageCounts : Endpoint + +@OptIn(ExperimentalForeignApi::class) +class MessageCountsImpl( + private val pubnub: PubNubObjC, + private val channels: List, + private val channelsTimetoken: List +): MessageCounts { + override fun async(callback: Consumer>) { + pubnub.messageCountsFor( + channels = channels, + channelsTimetokens = channelsTimetoken, + onSuccess = callback.onSuccessHandler { PNMessageCountResult(it?.channels() as Map) }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt index 89eb3e7e4..aa91fd7bc 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt @@ -1,9 +1,29 @@ package com.pubnub.api.endpoints +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.timeOnSuccess import com.pubnub.api.Endpoint +import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNTimeResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.time] */ -actual interface Time : Endpoint \ No newline at end of file +actual interface Time : Endpoint + +@OptIn(ExperimentalForeignApi::class) +class TimeImpl( + private val pubnub: PubNubObjC +): Time { + override fun async(callback: Consumer>) { + pubnub.timeOnSuccess( + onSuccess = callback.onSuccessHandler { PNTimeResult(it.toLong()) }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt index 648280233..a90033ff5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt @@ -1,6 +1,7 @@ package com.pubnub.api.endpoints.pubsub import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.publishWithChannel import com.pubnub.api.Endpoint import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNPublishResult @@ -10,8 +11,6 @@ import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSNumber -import platform.posix.uint64_t -import platform.zlib.uLong /** * @see [PubNub.publish] @@ -19,7 +18,7 @@ import platform.zlib.uLong actual interface Publish : Endpoint @OptIn(ExperimentalForeignApi::class) -open class PublishImpl( +class PublishImpl( private val pubnub: PubNubObjC, private val channel: String, private val message: Any, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt index a977c3823..0251f3719 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt @@ -1,6 +1,7 @@ package com.pubnub.api.endpoints.pubsub import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.signalWithChannel import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.PNPublishResult import com.pubnub.api.onFailureHandler @@ -15,7 +16,7 @@ import kotlinx.cinterop.ExperimentalForeignApi actual interface Signal : Endpoint @OptIn(ExperimentalForeignApi::class) -open class SignalImpl( +class SignalImpl( private val pubnub: PubNubObjC, private val channel: String, private val message: Any diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt index 56ec94f35..df416b57c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt @@ -1,6 +1,7 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.addChannelsToPushNotificationsWithChannels import com.pubnub.api.Endpoint import com.pubnub.api.PubNubException import com.pubnub.api.models.consumer.push.PNPushAddChannelResult @@ -17,7 +18,7 @@ import platform.Foundation.NSData actual interface AddChannelsToPush : Endpoint @OptIn(ExperimentalForeignApi::class) -open class AddChannelsToPushImpl( +class AddChannelsToPushImpl( private val pubnub: PubNubObjC, private val channels: List, private val deviceId: String diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt index b29ac8662..f391a6eed 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt @@ -1,6 +1,7 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.listPushChannelsWithDeviceId import com.pubnub.api.Endpoint import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushType @@ -19,7 +20,7 @@ import platform.Foundation.NSData actual interface ListPushProvisions : Endpoint @OptIn(ExperimentalForeignApi::class) -open class ListPushProvisionsImpl( +class ListPushProvisionsImpl( private val pubnub: PubNubObjC, private val deviceId: String, private val pushType: PNPushType diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt index 465d6a7b9..3d09f99c4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt @@ -1,11 +1,14 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.removeAllChannelsFromPushWithPushType import com.pubnub.api.Endpoint import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushType +import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessReturnValue import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.toNSData @@ -18,7 +21,7 @@ import platform.Foundation.NSData actual interface RemoveAllPushChannelsForDevice : Endpoint @OptIn(ExperimentalForeignApi::class) -open class RemoveAllPushChannelsForDeviceImpl( +class RemoveAllPushChannelsForDeviceImpl( private val pubnub: PubNubObjC, private val deviceId: String, private val pushType: PNPushType @@ -28,7 +31,7 @@ open class RemoveAllPushChannelsForDeviceImpl( pubnub.removeAllChannelsFromPushWithPushType( pushType = pushType.toParamString(), deviceId = data, - onSuccess = { callback.accept(Result.success(PNPushRemoveAllChannelsResult())) }, + onSuccess = callback.onSuccessReturnValue(PNPushRemoveAllChannelsResult()), onFailure = callback.onFailureHandler() ) } ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId"))) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt index cb8d4ed42..f4f14842c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt @@ -1,6 +1,7 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.removeChannelsFromPushWithChannels import com.pubnub.api.Endpoint import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushType @@ -18,7 +19,7 @@ import platform.Foundation.NSData */ actual interface RemoveChannelsFromPush : Endpoint @OptIn(ExperimentalForeignApi::class) -open class RemoveChannelsFromPushImpl( +class RemoveChannelsFromPushImpl( private val pubnub: PubNubObjC, private val channels: List, private val deviceId: String, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt index e887dd21f..700a9115f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -1,9 +1,19 @@ package com.pubnub.api.v2.callbacks +import cocoapods.PubNubSwift.EventListenerObjC import com.pubnub.api.callbacks.Listener +import kotlinx.cinterop.ExperimentalForeignApi /** * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -actual interface EventListener : Listener \ No newline at end of file + +@OptIn(ExperimentalForeignApi::class) +actual interface EventListener : Listener { + val underlying: EventListenerObjC +} +@OptIn(ExperimentalForeignApi::class) +class EventListenerImpl( + override val underlying: EventListenerObjC +): EventListener {} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index fb39ea2f8..0dbd32030 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -1,22 +1,54 @@ package com.pubnub.kmp +import cocoapods.PubNubSwift.EventListenerObjC +import cocoapods.PubNubSwift.PubNubDeleteChannelMetadataEventMessageObjC +import cocoapods.PubNubSwift.PubNubDeleteMembershipEventMessageObjC +import cocoapods.PubNubSwift.PubNubDeleteUUIDMetadataEventMessageObjC +import cocoapods.PubNubSwift.PubNubFileEventResultObjC +import cocoapods.PubNubSwift.PubNubMessageActionObjC +import cocoapods.PubNubSwift.PubNubMessageObjC +import cocoapods.PubNubSwift.PubNubObjectEventMessageObjC +import cocoapods.PubNubSwift.PubNubObjectEventResultObjC +import cocoapods.PubNubSwift.PubNubPresenceEventResultObjC +import cocoapods.PubNubSwift.PubNubSetChannelMetadataEventMessageObjC +import cocoapods.PubNubSwift.PubNubSetMembershipEventMessageObjC +import cocoapods.PubNubSwift.PubNubSetUUIDMetadataEventMessageObjC +import com.pubnub.api.JsonElement import com.pubnub.api.PubNub import com.pubnub.api.PubNubImpl +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.files.PNDownloadableFile +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.pubsub.BasePubSubResult import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEvent +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventMessage import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.EventListenerImpl import com.pubnub.api.v2.callbacks.StatusListener +import kotlinx.cinterop.ExperimentalForeignApi actual fun createPubNub(config: PNConfiguration): PubNub { return PubNubImpl(config) } +@OptIn(ExperimentalForeignApi::class) actual fun createEventListener( pubnub: PubNub, onMessage: (PubNub, PNMessageResult) -> Unit, @@ -26,7 +58,203 @@ actual fun createEventListener( onObjects: (PubNub, PNObjectEventResult) -> Unit, onFile: (PubNub, PNFileEventResult) -> Unit ): EventListener { - TODO("Not yet implemented") + return EventListenerImpl( + underlying = EventListenerObjC( + onMessage = { onMessage(pubnub, createMessageResult(it)) }, + onPresence = { presenceEvents -> createPresenceEventResults(presenceEvents).forEach { onPresence(pubnub, it) } }, + onSignal = { onSignal(pubnub, createSignalResult(it)) }, + onMessageAction = { onMessageAction(pubnub, createMessageActionResult(it)) }, + onAppContext = { if (createObjectEvent(it) != null) { createObjectEvent(it) } else {} }, + onFile = { onFile(pubnub, createFileEventResult(it)) } + ) + ) +} + +@OptIn(ExperimentalForeignApi::class) +private fun createMessageResult(from: PubNubMessageObjC?): PNMessageResult { + return PNMessageResult( + basePubSubResult = BasePubSubResult( + channel = from!!.channel(), + subscription = from.subscription(), + timetoken = from.published().toLong(), + userMetadata = from.metadata() as? JsonElement, + publisher = from.publisher() + ), + message = from.payload() as JsonElement, + error = null // TODO: Map error from Swift SDK to PubNubError in Kotlin SDK + ) +} + +@OptIn(ExperimentalForeignApi::class) +private fun createSignalResult(from: PubNubMessageObjC?): PNSignalResult { + return PNSignalResult( + basePubSubResult = BasePubSubResult( + channel = from!!.channel(), + subscription = from.subscription(), + timetoken = from.published().toLong(), + userMetadata = from.metadata() as? JsonElement, + publisher = from.publisher() + ), + message = from.payload() as JsonElement + ) +} + +@OptIn(ExperimentalForeignApi::class) +private fun createMessageActionResult(from: PubNubMessageActionObjC?): PNMessageActionResult { + return PNMessageActionResult( + result = BasePubSubResult( + channel = from!!.channel(), + subscription = from.subscription(), + timetoken = from.actionTimetoken().toLong(), + userMetadata = null, + publisher = from.publisher() + ), + event = from.event(), + data = PNMessageAction( + type = from.actionType(), + value = from.actionValue(), + messageTimetoken = from.messageTimetoken().toLong() + ) + ) +} + +@OptIn(ExperimentalForeignApi::class) +private fun createPresenceEventResults(from: List<*>?): List { + return (from as? List)?.let { + it.map { item: PubNubPresenceEventResultObjC -> + PNPresenceEventResult( + event = item.event(), + uuid = item.uuid(), + timestamp = item.timetoken()?.longValue, + occupancy = item.occupancy()?.intValue, + state = item.state() as JsonElement, + channel = item.channel() ?: "", + subscription = item.subscription(), + timetoken = item.timetoken()?.longValue, + join = item.join() as? List, + leave = item.leave() as? List, + timeout = item.timeout() as? List, + hereNowRefresh = item.refreshHereNow()?.boolValue, + userMetadata = item.userMetadata() + ) + } + } ?: emptyList() +} + +@OptIn(ExperimentalForeignApi::class) +private fun createFileEventResult(from: PubNubFileEventResultObjC?): PNFileEventResult { + return PNFileEventResult( + channel = from!!.channel(), + timetoken = from.timetoken()?.longValue, + publisher = from.publisher(), + message = from.message(), + jsonMessage = from.message() as JsonElement, + file = PNDownloadableFile( + id = from.file().id(), + name = from.file().name(), + url = from.file().url() + ) + ) +} + +@OptIn(ExperimentalForeignApi::class) +private fun createObjectEvent(from: PubNubObjectEventResultObjC?): PNObjectEventResult? { + return mapObjectMessage(from?.message())?.let { + PNObjectEventResult( + result = BasePubSubResult( + channel = from!!.channel(), + subscription = from.subscription(), + timetoken = from.timetoken()?.longValue, + userMetadata = from.userMetadata() as? JsonElement, + publisher = from.publisher(), + ), extractedMessage = it + ) + } +} + +@OptIn(ExperimentalForeignApi::class) +private fun mapObjectMessage(from: PubNubObjectEventMessageObjC?): PNObjectEventMessage? { + if (from is PubNubSetUUIDMetadataEventMessageObjC) { + return PNSetUUIDMetadataEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + data = PNUUIDMetadata( + id = from.data().id(), + name = from.data().name(), + externalId = from.data().externalId(), + profileUrl = from.data().profileUrl(), + email = from.data().email(), + custom = from.data().custom() as? Map, + updated = from.data().updated(), + eTag = from.data().eTag(), + type = from.data().type(), + status = from.data().status() + ) + ) + } else if (from is PubNubDeleteUUIDMetadataEventMessageObjC) { + return PNDeleteUUIDMetadataEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + uuid = from.uuid() + ) + } else if (from is PubNubSetChannelMetadataEventMessageObjC) { + return PNSetChannelMetadataEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + data = PNChannelMetadata( + id = from.data().id(), + name = from.data().name(), + description = from.data().descr(), + custom = from.data().custom() as? Map, + updated = from.data().updated(), + eTag = from.data().eTag(), + type = from.data().type(), + status = from.data().status() + ) + ) + } else if (from is PubNubDeleteChannelMetadataEventMessageObjC) { + return PNDeleteChannelMetadataEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + channel = from.channel() + ) + } else if (from is PubNubSetMembershipEventMessageObjC) { + return PNSetMembershipEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + data = PNSetMembershipEvent( + channel = from.data().channel(), + uuid = from.data().uuid(), + custom = from.data().custom(), + eTag = from.data().eTag(), + updated = from.data().updated(), + status = from.data().status() + ) + ) + } else if (from is PubNubDeleteMembershipEventMessageObjC) { + return PNDeleteMembershipEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + data = PNDeleteMembershipEvent( + channelId = from.data().channelId(), + uuid = from.data().uuid() + ) + ) + } else { + return null + } } actual fun createStatusListener( From 9bb68bbb7337eaf71e283628470d50b930b4a1c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 28 May 2024 11:28:54 +0000 Subject: [PATCH 10/62] JS cleanups and membership related endpoints (#220) * [JS] membership related methods * [JS] Cleanup PN JS bindings file * [JS] Deduplicate data converters * [JS] Fixing memberships events and adding tests (WIP) * Tests continued * [IOS] catch exception in mapper + formatting --- .../pubsub/objects/PNObjectEventResult.kt | 2 +- .../kotlin/com/pubnub/api/PubNub.kt | 48 +- .../consumer/objects/member/MemberInput.kt | 4 +- .../consumer/objects/member/PNMember.kt | 3 +- .../membership/ChannelMembershipInput.kt | 4 +- .../pubsub/objects/PNObjectEventResult.kt | 2 +- .../kotlin/com/pubnub/api/Endpoint.ios.kt | 8 +- .../kotlin/com/pubnub/api/PubNub.ios.kt | 48 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 56 +- .../kotlin/com/pubnub/kmp/factories.ios.kt | 2 +- .../src/jsMain/kotlin/Pubnub.d.kt | 633 ++++++------------ .../jsMain/kotlin/com/pubnub/api/PubNub.js.kt | 48 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 219 ++++-- .../pubnub/api/endpoints/FetchMessagesImpl.kt | 4 +- .../message_actions/AddMessageActionImpl.kt | 10 +- .../message_actions/GetMessageActionImpl.kt | 11 +- .../channel/GetAllChannelMetadataImpl.kt | 21 + .../objects/channel/GetChannelMetadataImpl.kt | 1 + .../objects/channel/SetChannelMetadataImpl.kt | 21 +- .../objects/member/GetChannelMembersImpl.kt | 37 +- .../member/RemoveChannelMembersImpl.kt | 13 + .../objects/member/SetChannelMembersImpl.kt | 17 + .../objects/membership/GetMembershipsImpl.kt | 12 + .../membership/RemoveMembershipsImpl.kt | 16 + .../objects/membership/SetMembershipsImpl.kt | 16 + .../objects/uuid/GetAllUUIDMetadataImpl.kt | 1 + .../objects/uuid/GetUUIDMetadataImpl.kt | 11 +- .../objects/uuid/SetUUIDMetadataImpl.kt | 1 + .../kotlin/com/pubnub/kmp/converters.js.kt | 96 +++ .../kotlin/com/pubnub/kmp/factories.js.kt | 44 +- .../jvmMain/kotlin/com/pubnub/api/PubNub.kt | 34 +- .../pubnub-kotlin-test/build.gradle.kts | 14 + .../kotlin/com.pubnub.test/FakePubNub.kt | 275 +++----- .../kotlin/com/pubnub/api/MembersTest.kt | 75 +++ .../kotlin/com/pubnub/api/MembershipsTest.kt | 116 ++++ 35 files changed, 1051 insertions(+), 872 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadataImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/RemoveChannelMembersImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/SetChannelMembersImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMembershipsImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/RemoveMembershipsImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/SetMembershipsImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/converters.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt index fa3a5a0e7..398c848fa 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt @@ -95,7 +95,7 @@ data class PNSetMembershipEvent( val channel: String, @JsonAdapter(UnwrapSingleField::class) val uuid: String, - val custom: Any?, + val custom: Map?, val eTag: String, val updated: String, val status: String?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt index 296d4f653..903a57248 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt @@ -307,18 +307,18 @@ expect interface PubNub { includeChannelDetails: PNChannelDetailsLevel? = null, ): ManageMemberships - fun manageMemberships( - channelsToSet: List, - channelsToRemove: List, - uuid: String? = null, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeChannelDetails: PNChannelDetailsLevel? = null, - ): ManageMemberships +// fun manageMemberships( +// channelsToSet: List, +// channelsToRemove: List, +// uuid: String? = null, +// limit: Int? = null, +// page: PNPage? = null, +// filter: String? = null, +// sort: Collection> = listOf(), +// includeCount: Boolean = false, +// includeCustom: Boolean = false, +// includeChannelDetails: PNChannelDetailsLevel? = null, +// ): ManageMemberships fun getChannelMembers( channel: String, @@ -355,18 +355,18 @@ expect interface PubNub { includeUUIDDetails: PNUUIDDetailsLevel? = null, ): ManageChannelMembers - fun manageChannelMembers( - channel: String, - uuidsToSet: Collection, - uuidsToRemove: Collection, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, - ): ManageChannelMembers +// fun manageChannelMembers( +// channel: String, +// uuidsToSet: Collection, +// uuidsToRemove: Collection, +// limit: Int? = null, +// page: PNPage? = null, +// filter: String? = null, +// sort: Collection> = listOf(), +// includeCount: Boolean = false, +// includeCustom: Boolean = false, +// includeUUIDDetails: PNUUIDDetailsLevel? = null, +// ): ManageChannelMembers // fun listFiles( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInput.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInput.kt index 685eb4dd2..f0a34ac2b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInput.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/MemberInput.kt @@ -1,7 +1,9 @@ package com.pubnub.api.models.consumer.objects.member +import com.pubnub.kmp.CustomObject + interface MemberInput { val uuid: String - val custom: Any? + val custom: CustomObject? val status: String? } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt index d2c5bfe64..cb4b20a58 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt @@ -1,6 +1,7 @@ package com.pubnub.api.models.consumer.objects.member import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.kmp.CustomObject data class PNMember( val uuid: PNUUIDMetadata?, @@ -11,7 +12,7 @@ data class PNMember( ) { data class Partial( val uuidId: String, - override val custom: Any? = null, + override val custom: CustomObject? = null, override val status: String? = null, ) : MemberInput { override val uuid: String = uuidId diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/ChannelMembershipInput.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/ChannelMembershipInput.kt index b24d925cd..d4b26ac96 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/ChannelMembershipInput.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/ChannelMembershipInput.kt @@ -1,7 +1,9 @@ package com.pubnub.api.models.consumer.objects.membership +import com.pubnub.kmp.CustomObject + interface ChannelMembershipInput { val channel: String - val custom: Any? + val custom: CustomObject? val status: String? } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt index 9c5dd4422..720f6ecf5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt @@ -68,7 +68,7 @@ data class PNDeleteUUIDMetadataEventMessage( data class PNSetMembershipEvent( val channel: String, val uuid: String, - val custom: Any?, + val custom: Map?, val eTag: String, val updated: String, val status: String?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt index b87350800..304ffe45b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt @@ -9,7 +9,13 @@ actual interface Endpoint { } fun Consumer>.onSuccessHandler(mapper: (T) -> U) : (T) -> Unit { - return fun(input: T) { accept(Result.success(mapper(input))) } + return fun(input: T) { accept( + try { + Result.success(mapper(input)) + } catch (e: Exception) { + Result.failure(e) + } + ) } } fun Consumer>.onSuccessReturnValue(value: T) : () -> Unit { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt index ffad22939..0e8080d50 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt @@ -292,18 +292,18 @@ actual interface PubNub { includeChannelDetails: PNChannelDetailsLevel? ): ManageMemberships - actual fun manageMemberships( - channelsToSet: List, - channelsToRemove: List, - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? - ): ManageMemberships +// actual fun manageMemberships( +// channelsToSet: List, +// channelsToRemove: List, +// uuid: String?, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeChannelDetails: PNChannelDetailsLevel? +// ): ManageMemberships actual fun getChannelMembers( channel: String, @@ -340,18 +340,18 @@ actual interface PubNub { includeUUIDDetails: PNUUIDDetailsLevel? ): ManageChannelMembers - actual fun manageChannelMembers( - channel: String, - uuidsToSet: Collection, - uuidsToRemove: Collection, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? - ): ManageChannelMembers +// actual fun manageChannelMembers( +// channel: String, +// uuidsToSet: Collection, +// uuidsToRemove: Collection, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeUUIDDetails: PNUUIDDetailsLevel? +// ): ManageChannelMembers actual fun listFiles( channel: String, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 830d1ce39..fd81f915f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -430,20 +430,20 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { TODO("Not yet implemented") } - override fun manageMemberships( - channelsToSet: List, - channelsToRemove: List, - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? - ): ManageMemberships { - TODO("Not yet implemented") - } +// override fun manageMemberships( +// channelsToSet: List, +// channelsToRemove: List, +// uuid: String?, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeChannelDetails: PNChannelDetailsLevel? +// ): ManageMemberships { +// TODO("Not yet implemented") +// } override fun getChannelMembers( channel: String, @@ -486,20 +486,20 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { TODO("Not yet implemented") } - override fun manageChannelMembers( - channel: String, - uuidsToSet: Collection, - uuidsToRemove: Collection, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? - ): ManageChannelMembers { - TODO("Not yet implemented") - } +// override fun manageChannelMembers( +// channel: String, +// uuidsToSet: Collection, +// uuidsToRemove: Collection, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeUUIDDetails: PNUUIDDetailsLevel? +// ): ManageChannelMembers { +// TODO("Not yet implemented") +// } override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { TODO("Not yet implemented") diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 0dbd32030..b4857e8a9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -235,7 +235,7 @@ private fun mapObjectMessage(from: PubNubObjectEventMessageObjC?): PNObjectEvent data = PNSetMembershipEvent( channel = from.data().channel(), uuid = from.data().uuid(), - custom = from.data().custom(), + custom = from.data().custom() as Map?, //TODO this will probably fail eTag = from.data().eTag(), updated = from.data().updated(), status = from.data().status() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt index dc1ef86a9..8a5a00499 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt @@ -1,8 +1,5 @@ @file:Suppress( - "INTERFACE_WITH_SUPERCLASS", - "OVERRIDING_FINAL_MEMBER", - "RETURN_TYPE_MISMATCH_ON_OVERRIDE", - "CONFLICTING_OVERLOADS" + "INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS" ) import PubNub.GetAllMetadataParameters @@ -29,8 +26,6 @@ import kotlin.js.Date import kotlin.js.Json import kotlin.js.Promise -typealias PubnubData = PubNub.MessageEvent - typealias SetUUIDMetadataResponse = ObjectsResponse typealias RemoveUUIDMetadataResponse = ObjectsResponse @@ -62,47 +57,40 @@ external interface ObjectsResponse { external interface PagedObjectsResponse : ObjectsResponse> { var prev: String? - get() = definedExternally - set(value) = definedExternally var next: String? - get() = definedExternally - set(value) = definedExternally var totalCount: Number? - get() = definedExternally - set(value) = definedExternally } external interface ObjectsFunctions { fun setUUIDMetadata(params: SetUUIDMetadataParameters, callback: Callback) fun setUUIDMetadata(params: SetUUIDMetadataParameters): Promise fun removeUUIDMetadata(callback: Callback) - fun removeUUIDMetadata(params: RemoveUUIDMetadataParameters = definedExternally): Promise + fun removeUUIDMetadata(params: RemoveUUIDMetadataParameters): Promise fun removeUUIDMetadata(): Promise fun removeUUIDMetadata(params: RemoveUUIDMetadataParameters, callback: Callback) fun getAllUUIDMetadata(callback: Callback) - fun getAllUUIDMetadata(params: GetAllMetadataParameters = definedExternally): Promise + fun getAllUUIDMetadata(params: GetAllMetadataParameters): Promise fun getAllUUIDMetadata(): Promise fun getAllUUIDMetadata(params: GetAllMetadataParameters, callback: Callback) fun getUUIDMetadata(callback: Callback) - fun getUUIDMetadata(params: GetUUIDMetadataParameters = definedExternally): Promise + fun getUUIDMetadata(params: GetUUIDMetadataParameters): Promise fun getUUIDMetadata(): Promise fun getUUIDMetadata(params: GetUUIDMetadataParameters, callback: Callback) fun setChannelMetadata(params: SetChannelMetadataParameters, callback: Callback) fun setChannelMetadata(params: SetChannelMetadataParameters): Promise fun removeChannelMetadata( - params: RemoveChannelMetadataParameters, - callback: Callback + params: RemoveChannelMetadataParameters, callback: Callback ) fun removeChannelMetadata(params: RemoveChannelMetadataParameters): Promise fun getAllChannelMetadata(callback: Callback) - fun getAllChannelMetadata(params: GetAllMetadataParameters = definedExternally): Promise + fun getAllChannelMetadata(params: GetAllMetadataParameters): Promise fun getAllChannelMetadata(): Promise fun getAllChannelMetadata(params: GetAllMetadataParameters, callback: Callback) fun getChannelMetadata(params: GetChannelMetadataParameters, callback: Callback) fun getChannelMetadata(params: GetChannelMetadataParameters): Promise fun getMemberships(callback: Callback) - fun getMemberships(params: GetMembershipsParametersv2 = definedExternally): Promise + fun getMemberships(params: GetMembershipsParametersv2): Promise fun getMemberships(): Promise fun getMemberships(params: GetMembershipsParametersv2, callback: Callback) fun setMemberships(params: SetMembershipsParameters, callback: Callback) @@ -195,23 +183,17 @@ open external class PubNub(config: Any /* UUID | UserId */) { open fun getMessageActions(params: GetMessageActionsParameters, callback: Callback) open fun getMessageActions(params: GetMessageActionsParameters): Promise open fun encrypt( - data: String, - customCipherKey: String = definedExternally, - options: CryptoParameters = definedExternally + data: String, customCipherKey: String = definedExternally, options: CryptoParameters = definedExternally ): String open fun decrypt( - data: String?, - customCipherKey: String = definedExternally, - options: CryptoParameters = definedExternally + data: String?, customCipherKey: String = definedExternally, options: CryptoParameters = definedExternally ): Any open fun decrypt(data: String?): Any open fun decrypt(data: String?, customCipherKey: String = definedExternally): Any open fun decrypt( - data: Any?, - customCipherKey: String = definedExternally, - options: CryptoParameters = definedExternally + data: Any?, customCipherKey: String = definedExternally, options: CryptoParameters = definedExternally ): Any open fun decrypt(data: Any?): Any @@ -220,20 +202,10 @@ open external class PubNub(config: Any /* UUID | UserId */) { open fun time(callback: Callback) interface KeepAliveSettings { var keepAliveMsecs: Number? - get() = definedExternally - set(value) = definedExternally var freeSocketKeepAliveTimeout: Number? - get() = definedExternally - set(value) = definedExternally var timeout: Number? - get() = definedExternally - set(value) = definedExternally var maxSockets: Number? - get() = definedExternally - set(value) = definedExternally var maxFreeSockets: Number? - get() = definedExternally - set(value) = definedExternally } interface PNConfiguration : Partial { @@ -271,13 +243,10 @@ open external class PubNub(config: Any /* UUID | UserId */) { var message: Any var publisher: String var error: String? - get() = definedExternally - set(value) = definedExternally var actualChannel: String var subscribedChannel: String var userMetadata: Any? - get() = definedExternally - set(value) = definedExternally + } interface StatusEvent { @@ -286,12 +255,8 @@ open external class PubNub(config: Any /* UUID | UserId */) { var affectedChannels: Array var subscribedChannels: Array var affectedChannelGroups: Array - var lastTimetoken: dynamic /* Number | String */ - get() = definedExternally - set(value) = definedExternally - var currentTimetoken: dynamic /* Number | String */ - get() = definedExternally - set(value) = definedExternally + var lastTimetoken: String + var currentTimetoken: String var statusCode: Number? } @@ -300,8 +265,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var channel: String var occupancy: Number var state: Any? - get() = definedExternally - set(value) = definedExternally var subscription: String var timestamp: Number var timetoken: String @@ -322,8 +285,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var channel: String var publisher: String var subscription: String? - get() = definedExternally - set(value) = definedExternally var timetoken: String var event: String var data: MessageAction @@ -343,8 +304,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var message: Any var file: `T$5` var userMetadata: Any? - get() = definedExternally - set(value) = definedExternally } interface `T$6` { @@ -360,9 +319,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { var message: `T$6` var subscription: String? var publisher: String? - get() = definedExternally - set(value) = definedExternally - var timetoken: Number + var timetoken: String } interface `T$7` { @@ -397,7 +354,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { } interface RemoveChannelMetadataEvent : BaseObjectsEvent - interface `T$12` { + interface SetMembershipObject { var channel: HasId var uuid: HasId var custom: CustomObject? @@ -408,11 +365,11 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface `T$13` { var event: String /* "set" */ var type: String /* "membership" */ - var data: `T$12` + var data: SetMembershipObject } interface SetMembershipEvent : BaseObjectsEvent - interface `T$14` { + interface DeleteMembershipObject { var channel: HasId var uuid: HasId } @@ -420,7 +377,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface `T$15` { var event: String /* "delete" */ var type: String /* "membership" */ - var data: `T$14` + var data: DeleteMembershipObject } interface RemoveMembershipEvent : BaseObjectsEvent @@ -428,17 +385,9 @@ open external class PubNub(config: Any /* UUID | UserId */) { var message: Any var channel: String var storeInHistory: Boolean? - get() = definedExternally - set(value) = definedExternally var sendByPost: Boolean? - get() = definedExternally - set(value) = definedExternally var meta: Any? - get() = definedExternally - set(value) = definedExternally var ttl: Number? - get() = definedExternally - set(value) = definedExternally } interface PublishResponse { @@ -458,42 +407,23 @@ open external class PubNub(config: Any /* UUID | UserId */) { var channel: String var count: Number var stringifiedTimeToken: Boolean? - get() = definedExternally - set(value) = definedExternally var includeTimetoken: Boolean? - get() = definedExternally - set(value) = definedExternally var reverse: Boolean? - get() = definedExternally - set(value) = definedExternally - var start: dynamic /* String? | Number? */ - get() = definedExternally - set(value) = definedExternally - var end: dynamic /* String? | Number? */ - get() = definedExternally - set(value) = definedExternally + var start: String? + var end: String? var includeMeta: Boolean? - get() = definedExternally - set(value) = definedExternally + } interface HistoryMessage { var entry: Any - var timetoken: dynamic /* String? | Number? */ - get() = definedExternally - set(value) = definedExternally + var timetoken: String? var meta: Any? - get() = definedExternally - set(value) = definedExternally } interface HistoryResponse { - var endTimeToken: dynamic /* String? | Number? */ - get() = definedExternally - set(value) = definedExternally - var startTimeToken: dynamic /* String? | Number? */ - get() = definedExternally - set(value) = definedExternally + var endTimeToken: String? + var startTimeToken: String? var messages: Array } @@ -501,8 +431,8 @@ open external class PubNub(config: Any /* UUID | UserId */) { var channels: Array var count: Number? var stringifiedTimeToken: Boolean? - var start: dynamic /* String? | Number? */ - var end: dynamic /* String? | Number? */ + var start: String? + var end: String? var withMessageActions: Boolean? var includeMessageType: Boolean? var includeUUID: Boolean? @@ -512,9 +442,8 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface Action { var uuid: String - var actionTimetoken: dynamic /* String | Number */ - get() = definedExternally - set(value) = definedExternally + var actionTimetoken: String + } interface ActionContentToAction : JsMap> @@ -523,8 +452,8 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface FetchMessageItem { var channel: String var message: JsonElement - var timetoken: dynamic /* String | Number */ - var messageType: dynamic /* String? | Number? */ + var timetoken: String + var messageType: String? var uuid: String var error: String? var meta: Json? @@ -542,37 +471,21 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface FetchMessagesResponse { var channels: ChannelsToFetchMessageItemsMap var more: Page? - get() = definedExternally - set(value) = definedExternally } interface DeleteMessagesParameters { var channel: String - var start: dynamic /* String? | Number? */ - get() = definedExternally - set(value) = definedExternally - var end: dynamic /* String? | Number? */ - get() = definedExternally - set(value) = definedExternally + var start: String? + var end: String? } interface MessageCountsParameters { var channels: Array var channelTimetokens: dynamic /* Array | Array */ - get() = definedExternally - set(value) = definedExternally - } - - interface `T$22` { - @nativeGetter - operator fun get(channel: String): Number? - - @nativeSetter - operator fun set(channel: String, value: Number) } interface MessageCountsResponse { - var channels: `T$22` + var channels: JsMap } interface Push { @@ -591,22 +504,18 @@ open external class PubNub(config: Any /* UUID | UserId */) { var device: String var pushGateway: String var environment: String? - get() = definedExternally - set(value) = definedExternally + var topic: String? - get() = definedExternally - set(value) = definedExternally + } interface PushDeviceParameters { var device: String var pushGateway: String var environment: String? - get() = definedExternally - set(value) = definedExternally + var topic: String? - get() = definedExternally - set(value) = definedExternally + } interface PushListChannelsResponse { @@ -616,48 +525,38 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface PubnubStatus { var error: Boolean var category: String? - get() = definedExternally - set(value) = definedExternally + var operation: String var statusCode: Number var errorData: Error? - get() = definedExternally - set(value) = definedExternally + } interface FireParameters { var message: Any var channel: String var sendByPost: Boolean? - get() = definedExternally - set(value) = definedExternally + var meta: Any? - get() = definedExternally - set(value) = definedExternally + } interface SubscribeParameters { var channels: Array? - get() = definedExternally - set(value) = definedExternally + var channelGroups: Array? - get() = definedExternally - set(value) = definedExternally + var withPresence: Boolean? - get() = definedExternally - set(value) = definedExternally + var timetoken: Number? - get() = definedExternally - set(value) = definedExternally + } interface UnsubscribeParameters { var channels: Array? - get() = definedExternally - set(value) = definedExternally + var channelGroups: Array? - get() = definedExternally - set(value) = definedExternally + } interface ChannelGroups { @@ -714,24 +613,19 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface HereNowParameters { var channels: Array? - get() = definedExternally - set(value) = definedExternally + var channelGroups: Array? - get() = definedExternally - set(value) = definedExternally + var includeUUIDs: Boolean? - get() = definedExternally - set(value) = definedExternally + var includeState: Boolean? - get() = definedExternally - set(value) = definedExternally + } interface HereNowOccupantData { var uuid: String var state: Any? - get() = definedExternally - set(value) = definedExternally + } interface HereNowChannelData { @@ -750,8 +644,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface WhereNowParameters { var uuid: String? - get() = definedExternally - set(value) = definedExternally + } interface WhereNowResponse { @@ -760,14 +653,11 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface SetStateParameters { var channels: Array? - get() = definedExternally - set(value) = definedExternally + var channelGroups: Array? - get() = definedExternally - set(value) = definedExternally + var state: Any? - get() = definedExternally - set(value) = definedExternally + } interface SetStateResponse { @@ -776,14 +666,11 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface GetStateParameters { var uuid: String? - get() = definedExternally - set(value) = definedExternally + var channels: Array? - get() = definedExternally - set(value) = definedExternally + var channelGroups: Array? - get() = definedExternally - set(value) = definedExternally + } interface GetStateResponse { @@ -792,69 +679,50 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface GrantParameters { var channels: Array? - get() = definedExternally - set(value) = definedExternally + var channelGroups: Array? - get() = definedExternally - set(value) = definedExternally + var uuids: Array? - get() = definedExternally - set(value) = definedExternally + var authKeys: Array? - get() = definedExternally - set(value) = definedExternally + var ttl: Number? - get() = definedExternally - set(value) = definedExternally + var read: Boolean? - get() = definedExternally - set(value) = definedExternally + var write: Boolean? - get() = definedExternally - set(value) = definedExternally + var manage: Boolean? - get() = definedExternally - set(value) = definedExternally + var delete: Boolean? - get() = definedExternally - set(value) = definedExternally + var get: Boolean? - get() = definedExternally - set(value) = definedExternally + var join: Boolean? - get() = definedExternally - set(value) = definedExternally + var update: Boolean? - get() = definedExternally - set(value) = definedExternally + } interface PatternsOrResources { var channels: JsMap? - get() = definedExternally - set(value) = definedExternally + var groups: JsMap? - get() = definedExternally - set(value) = definedExternally + var uuids: JsMap? - get() = definedExternally - set(value) = definedExternally + } interface GrantTokenParameters { var ttl: Number var authorized_uuid: String? - get() = definedExternally - set(value) = definedExternally + var resources: PatternsOrResources? - get() = definedExternally - set(value) = definedExternally + var patterns: PatternsOrResources? - get() = definedExternally - set(value) = definedExternally + var meta: Json? - get() = definedExternally - set(value) = definedExternally + } interface ParsedGrantToken : GrantTokenParameters { @@ -865,26 +733,19 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface GrantTokenPermissions { var read: Boolean? - get() = definedExternally - set(value) = definedExternally + var write: Boolean? - get() = definedExternally - set(value) = definedExternally + var manage: Boolean? - get() = definedExternally - set(value) = definedExternally + var delete: Boolean? - get() = definedExternally - set(value) = definedExternally + var get: Boolean? - get() = definedExternally - set(value) = definedExternally + var join: Boolean? - get() = definedExternally - set(value) = definedExternally + var update: Boolean? - get() = definedExternally - set(value) = definedExternally + } interface RevokeTokenResponse { @@ -920,80 +781,64 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface GetMessageActionsParameters { var channel: String var start: String? - get() = definedExternally - set(value) = definedExternally + var end: String? - get() = definedExternally - set(value) = definedExternally + var limit: Number? - get() = definedExternally - set(value) = definedExternally + } interface GetMessageActionsResponse { var data: Array var start: String? - get() = definedExternally - set(value) = definedExternally + var end: String? - get() = definedExternally - set(value) = definedExternally + } interface ListFilesParameters { var channel: String var limit: Number? - get() = definedExternally - set(value) = definedExternally + var next: String? - get() = definedExternally - set(value) = definedExternally + } interface SendFileParameters { var channel: String var file: dynamic /* StreamFileInput | BufferFileInput | UriFileInput */ - get() = definedExternally - set(value) = definedExternally + var message: Any? - get() = definedExternally - set(value) = definedExternally + var cipherKey: String? - get() = definedExternally - set(value) = definedExternally + var storeInHistory: Boolean? - get() = definedExternally - set(value) = definedExternally + var ttl: Number? - get() = definedExternally - set(value) = definedExternally + var meta: Any? - get() = definedExternally - set(value) = definedExternally + } interface StreamFileInput { var stream: Any var name: String var mimeType: String? - get() = definedExternally - set(value) = definedExternally + } interface BufferFileInput { var data: Any var name: String var mimeType: String? - get() = definedExternally - set(value) = definedExternally + } interface UriFileInput { var uri: String var name: String var mimeType: String? - get() = definedExternally - set(value) = definedExternally + } interface DownloadFileParameters { @@ -1001,8 +846,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { var id: String var name: String var cipherKey: String? - get() = definedExternally - set(value) = definedExternally + } interface FileInputParameters { @@ -1014,19 +858,15 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface PublishFileParameters { var channel: String var message: Any? - get() = definedExternally - set(value) = definedExternally + var fileId: String var fileName: String var storeInHistory: Boolean? - get() = definedExternally - set(value) = definedExternally + var ttl: Number? - get() = definedExternally - set(value) = definedExternally + var meta: Any? - get() = definedExternally - set(value) = definedExternally + } interface `T$29` { @@ -1073,8 +913,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { var eTag: String var updated: String var custom: CustomObject? - get() = definedExternally - set(value) = definedExternally + } interface v2ObjectData { @@ -1082,14 +921,12 @@ open external class PubNub(config: Any /* UUID | UserId */) { var eTag: String var updated: String var custom: CustomObject? - get() = definedExternally - set(value) = definedExternally + } interface ObjectParam { var custom: CustomObject? - get() = definedExternally - set(value) = definedExternally + } interface UUIDMetadataFieldsNullable { @@ -1105,69 +942,54 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface UUIDMetadataObject : v2ObjectData, UUIDMetadataFieldsNullable interface UuidIncludeCustom { var customFields: Boolean? - get() = definedExternally - set(value) = definedExternally + } interface SetUUIDMetadataParameters { var uuid: String? - get() = definedExternally - set(value) = definedExternally + var data: UUIDMetadata var include: UuidIncludeCustom? - get() = definedExternally - set(value) = definedExternally + } interface RemoveUUIDMetadataParameters { var uuid: String? - get() = definedExternally - set(value) = definedExternally + } - interface UuidIncludeOptions { + interface MetadataIncludeOptions { var totalCount: Boolean? - get() = definedExternally - set(value) = definedExternally + var customFields: Boolean? - get() = definedExternally - set(value) = definedExternally + } interface MetadataPage { var next: String? - get() = definedExternally - set(value) = definedExternally + var prev: String? - get() = definedExternally - set(value) = definedExternally + } interface GetAllMetadataParameters { - var include: UuidIncludeOptions? - get() = definedExternally - set(value) = definedExternally + var include: MetadataIncludeOptions? + var filter: String? - get() = definedExternally - set(value) = definedExternally + var sort: JsMap? - get() = definedExternally - set(value) = definedExternally + var limit: Number? - get() = definedExternally - set(value) = definedExternally + var page: MetadataPage? - get() = definedExternally - set(value) = definedExternally + } interface GetUUIDMetadataParameters { var uuid: String? - get() = definedExternally - set(value) = definedExternally + var include: UuidIncludeCustom? - get() = definedExternally - set(value) = definedExternally + } interface ChannelMetadataFieldsPartial { @@ -1190,8 +1012,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { var channel: String var data: ChannelMetadata var include: UuidIncludeCustom? - get() = definedExternally - set(value) = definedExternally + } interface RemoveChannelMetadataParameters { @@ -1205,114 +1026,85 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface GetChannelMetadataParameters { var channel: String var include: IncludeCustomFields? - get() = definedExternally - set(value) = definedExternally + } interface HasStatus { var status: String? - get() = definedExternally - set(value) = definedExternally + } interface UUIDMembershipObject : v2ObjectDataOmitId { var uuid: UUIDMetadataObject /* UUIDMetadataObject & HasStatus | HasId */ var status: String? - get() = definedExternally - set(value) = definedExternally + } interface ChannelMembershipObject : v2ObjectDataOmitId { - var channel: dynamic /* ChannelMetadataObject & HasStatus | HasId */ - get() = definedExternally - set(value) = definedExternally + var channel: ChannelMetadataObject? + var status: String? - get() = definedExternally - set(value) = definedExternally + } interface IncludeOptions { var totalCount: Boolean? - get() = definedExternally - set(value) = definedExternally + var customFields: Boolean? - get() = definedExternally - set(value) = definedExternally + var UUIDFields: Boolean? - get() = definedExternally - set(value) = definedExternally + var customUUIDFields: Boolean? - get() = definedExternally - set(value) = definedExternally + var statusField: Boolean? - get() = definedExternally - set(value) = definedExternally + var UUIDStatusField: Boolean? - get() = definedExternally - set(value) = definedExternally + var UUIDTypeField: Boolean? - get() = definedExternally - set(value) = definedExternally + } interface UUIDMembersParameters { var include: IncludeOptions? - get() = definedExternally - set(value) = definedExternally + var filter: String? - get() = definedExternally - set(value) = definedExternally + var sort: JsMap? - get() = definedExternally - set(value) = definedExternally + var limit: Number? - get() = definedExternally - set(value) = definedExternally + var page: MetadataPage? - get() = definedExternally - set(value) = definedExternally + } - interface `T$36` { + interface MembershipIncludeOptions { var totalCount: Boolean? - get() = definedExternally - set(value) = definedExternally + var customFields: Boolean? - get() = definedExternally - set(value) = definedExternally + var channelFields: Boolean? - get() = definedExternally - set(value) = definedExternally + var customChannelFields: Boolean? - get() = definedExternally - set(value) = definedExternally + var statusField: Boolean? - get() = definedExternally - set(value) = definedExternally + var channelStatusField: Boolean? - get() = definedExternally - set(value) = definedExternally + var channelTypeField: Boolean? - get() = definedExternally - set(value) = definedExternally + } interface ChannelMembersParameters { - var include: `T$36`? - get() = definedExternally - set(value) = definedExternally + var include: MembershipIncludeOptions? + var filter: String? - get() = definedExternally - set(value) = definedExternally + var sort: Any? - get() = definedExternally - set(value) = definedExternally + var limit: Number? - get() = definedExternally - set(value) = definedExternally + var page: MetadataPage? - get() = definedExternally - set(value) = definedExternally + } interface GetChannelMembersParameters : UUIDMembersParameters { @@ -1321,36 +1113,32 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface GetMembershipsParametersv2 : ChannelMembersParameters { var uuid: String? - get() = definedExternally - set(value) = definedExternally + } interface SetCustom { var id: String var custom: CustomObject? - get() = definedExternally - set(value) = definedExternally + var status: String? + } interface SetMembershipsParameters : ChannelMembersParameters { var uuid: String? - get() = definedExternally - set(value) = definedExternally - var channels: Array? - get() = definedExternally - set(value) = definedExternally + + var channels: Array? + } interface RemoveMembershipsParameters : ChannelMembersParameters { var uuid: String? - get() = definedExternally - set(value) = definedExternally + var channels: Array } interface SetChannelMembersParameters : UUIDMembersParameters { var channel: String - var uuids: Array + var uuids: Array } interface RemoveChannelMembersParameters : UUIDMembersParameters { @@ -1360,17 +1148,13 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface CryptoParameters { var encryptKey: Boolean? - get() = definedExternally - set(value) = definedExternally + var keyEncoding: String? - get() = definedExternally - set(value) = definedExternally + var keyLength: Number? - get() = definedExternally - set(value) = definedExternally + var mode: String? - get() = definedExternally - set(value) = definedExternally + } interface FetchTimeResponse { @@ -1379,74 +1163,58 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface APNS2Configuration { var collapseId: String? - get() = definedExternally - set(value) = definedExternally + var expirationDate: Date? - get() = definedExternally - set(value) = definedExternally + var targets: Array } interface APNS2Target { var topic: String var environment: String? /* "development" | "production" */ - get() = definedExternally - set(value) = definedExternally + var excludedDevices: Array? - get() = definedExternally - set(value) = definedExternally + } interface BaseNotificationPayload { var subtitle: String? - get() = definedExternally - set(value) = definedExternally + var payload: Any? var badge: Number? - get() = definedExternally - set(value) = definedExternally + var sound: String? - get() = definedExternally - set(value) = definedExternally + var title: String? - get() = definedExternally - set(value) = definedExternally + var body: String? - get() = definedExternally - set(value) = definedExternally + } interface APNSNotificationPayload : BaseNotificationPayload { var configurations: Array var apnsPushType: String? - get() = definedExternally - set(value) = definedExternally + var isSilent: Boolean } interface MPNSNotificationPayload : BaseNotificationPayload { var backContent: String? - get() = definedExternally - set(value) = definedExternally + var backTitle: String? - get() = definedExternally - set(value) = definedExternally + var count: Number? - get() = definedExternally - set(value) = definedExternally + var type: String? - get() = definedExternally - set(value) = definedExternally + } interface FCMNotificationPayload : BaseNotificationPayload { var isSilent: Boolean var icon: String? - get() = definedExternally - set(value) = definedExternally + var tag: String? - get() = definedExternally - set(value) = definedExternally + } interface `T$37` { @@ -1459,20 +1227,15 @@ open external class PubNub(config: Any /* UUID | UserId */) { var payload: `T$37` var debugging: Boolean var subtitle: String? - get() = definedExternally - set(value) = definedExternally + var badge: Number? - get() = definedExternally - set(value) = definedExternally + var sound: String? - get() = definedExternally - set(value) = definedExternally + var title: String? - get() = definedExternally - set(value) = definedExternally + var body: String? - get() = definedExternally - set(value) = definedExternally + var apns: APNSNotificationPayload var mpns: MPNSNotificationPayload var fcm: FCMNotificationPayload @@ -1499,8 +1262,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface PubNubFileType { var data: dynamic /* File | Blob */ - get() = definedExternally - set(value) = definedExternally + var name: String var mimeType: String fun create(config: Any): PubNubFileType @@ -1513,17 +1275,14 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface CryptorConfiguration { var cipherKey: String var useRandomIVs: Boolean? - get() = definedExternally - set(value) = definedExternally + } interface CryptoModuleConfiguration { var default: dynamic /* Cryptor | LegacyCryptor */ - get() = definedExternally - set(value) = definedExternally + var cryptors: Array */>? - get() = definedExternally - set(value) = definedExternally + } interface EncryptedDataType { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt index 1b8c7cbc3..a4a934018 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt @@ -255,18 +255,18 @@ actual interface PubNub { includeChannelDetails: PNChannelDetailsLevel? ): ManageMemberships - actual fun manageMemberships( - channelsToSet: List, - channelsToRemove: List, - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? - ): ManageMemberships +// actual fun manageMemberships( +// channelsToSet: List, +// channelsToRemove: List, +// uuid: String?, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeChannelDetails: PNChannelDetailsLevel? +// ): ManageMemberships actual fun getChannelMembers( channel: String, @@ -303,18 +303,18 @@ actual interface PubNub { includeUUIDDetails: PNUUIDDetailsLevel? ): ManageChannelMembers - actual fun manageChannelMembers( - channel: String, - uuidsToSet: Collection, - uuidsToRemove: Collection, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? - ): ManageChannelMembers +// actual fun manageChannelMembers( +// channel: String, +// uuidsToSet: Collection, +// uuidsToRemove: Collection, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeUUIDDetails: PNUUIDDetailsLevel? +// ): ManageChannelMembers actual fun listFiles( channel: String, limit: Int?, next: PNPage.PNNext? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 59feda32e..75de95799 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -32,6 +32,7 @@ import com.pubnub.api.endpoints.message_actions.GetMessageActions import com.pubnub.api.endpoints.message_actions.RemoveMessageAction import com.pubnub.api.endpoints.message_actions.RemoveMessageActionImpl import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadataImpl import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata import com.pubnub.api.endpoints.objects.channel.GetChannelMetadataImpl import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata @@ -41,8 +42,13 @@ import com.pubnub.api.endpoints.objects.channel.SetChannelMetadataImpl import com.pubnub.api.endpoints.objects.member.GetChannelMembers import com.pubnub.api.endpoints.objects.member.GetChannelMembersImpl import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +import com.pubnub.api.endpoints.objects.member.RemoveChannelMembersImpl +import com.pubnub.api.endpoints.objects.member.SetChannelMembersImpl import com.pubnub.api.endpoints.objects.membership.GetMemberships +import com.pubnub.api.endpoints.objects.membership.GetMembershipsImpl import com.pubnub.api.endpoints.objects.membership.ManageMemberships +import com.pubnub.api.endpoints.objects.membership.RemoveMembershipsImpl +import com.pubnub.api.endpoints.objects.membership.SetMembershipsImpl import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata @@ -84,6 +90,7 @@ import com.pubnub.api.models.consumer.objects.PNMemberKey import com.pubnub.api.models.consumer.objects.PNMembershipKey import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.SortField import com.pubnub.api.models.consumer.objects.member.MemberInput import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput @@ -207,8 +214,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ): FetchMessages { return FetchMessagesImpl(jsPubNub, createJsObject { this.channels = channels.toTypedArray() - this.start = page.start - this.end = page.end + this.start = page.start.toString() + this.end = page.end.toString() this.count = page.limit this.includeUUID = includeUUID this.includeMeta = includeMeta @@ -379,7 +386,16 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCount: Boolean, includeCustom: Boolean ): GetAllChannelMetadata { - TODO("Not yet implemented") + return GetAllChannelMetadataImpl(jsPubNub, createJsObject { + this.page = page.toMetadataPage() + this.filter = filter + this.limit = limit + this.sort = sort.toJsMap() + this.include = createJsObject { + this.customFields = includeCustom + this.totalCount = includeCount + } + }) } override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { @@ -432,21 +448,13 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ): GetAllUUIDMetadata { return GetAllUUIDMetadataImpl(jsPubNub, createJsObject { this.limit = limit - this.page = page?.let { pageNotNull -> - createJsObject { - if (pageNotNull is PNPage.PNNext) { - this.next = pageNotNull.pageHash - } else { - this.prev = pageNotNull.pageHash - } - } - } + this.page = page.toMetadataPage() this.filter = filter - this.include = createJsObject { + this.include = createJsObject { this.customFields = includeCustom this.totalCount = includeCount } - this.sort = sort.associateBy(keySelector = { pnSortKey -> pnSortKey.key.fieldName }, valueTransform = { pnSortKey -> pnSortKey.dir }).toJsMap() + this.sort = sort.toJsMap() }) } @@ -504,7 +512,21 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel? ): GetMemberships { - TODO("Not yet implemented") + return GetMembershipsImpl(jsPubNub, createJsObject { + this.sort = sort.toJsMap() + this.filter = filter + this.include = createJsObject { + this.customFields = includeCustom + this.totalCount = includeCount + if (includeChannelDetails != null) { + this.channelFields = true + this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM + } + this.channelTypeField = false + this.channelStatusField = true + //todo we don't have parameters for all fields here? + } + }) } override fun setMemberships( @@ -518,7 +540,29 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel? ): ManageMemberships { - TODO("Not yet implemented") + return SetMembershipsImpl(jsPubNub, createJsObject { + this.sort = sort.toJsMap() + this.page = page.toMetadataPage() + this.filter = filter + this.include = createJsObject { + this.customFields = includeCustom + this.totalCount = includeCount + if (includeChannelDetails != null) { + this.channelFields = true + this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM + } + this.channelTypeField = false + this.channelStatusField = true + //todo we don't have parameters for all fields here? + } + this.uuid = uuid + this.channels = channels.map { createJsObject { + this.id = it.channel + this.custom = it.custom?.toJsObject() + this.status = status //todo this doesn't seem to get to the server with JS, or cannot read it back + } }.toTypedArray() + this.limit = limit + }) } override fun removeMemberships( @@ -532,23 +576,42 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel? ): ManageMemberships { - TODO("Not yet implemented") + return RemoveMembershipsImpl(jsPubNub, createJsObject { + this.sort = sort.toJsMap() + this.page = page.toMetadataPage() + this.filter = filter + this.include = createJsObject { + this.customFields = includeCustom + this.totalCount = includeCount + if (includeChannelDetails != null) { + this.channelFields = true + this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM + } + this.channelTypeField = false + this.channelStatusField = true + //todo we don't have parameters for all fields here? + } + this.uuid = uuid + this.channels = channels.toTypedArray() + this.limit = limit + }) } - override fun manageMemberships( - channelsToSet: List, - channelsToRemove: List, - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? - ): ManageMemberships { - TODO("Not yet implemented") - } +// TODO doesn't exist in JS +// override fun manageMemberships( +// channelsToSet: List, +// channelsToRemove: List, +// uuid: String?, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeChannelDetails: PNChannelDetailsLevel? +// ): ManageMemberships { +// TODO("Not yet implemented") +// } override fun getChannelMembers( channel: String, @@ -563,23 +626,17 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { return GetChannelMembersImpl(jsPubNub, createJsObject { this.channel = channel this.limit = limit - this.page = page?.let { pageNotNull -> - createJsObject { - if (pageNotNull is PNPage.PNNext) { - this.next = pageNotNull.pageHash - } else { - this.prev = pageNotNull.pageHash - } - } - } + this.page = page.toMetadataPage() this.filter = filter this.include = createJsObject { if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.UUIDFields = true if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.customUUIDFields = true this.customFields = includeCustom this.totalCount = includeCount + this.UUIDTypeField = false + //todo we don't have parameters for all fields here } - this.sort = sort.associateBy(keySelector = { pnSortKey -> pnSortKey.key.fieldName }, valueTransform = { pnSortKey -> pnSortKey.dir }).toJsMap() + this.sort = sort.toJsMap() }) } @@ -594,7 +651,27 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel? ): ManageChannelMembers { - TODO("Not yet implemented") + return SetChannelMembersImpl(jsPubNub, createJsObject { + this.channel = channel + this.uuids = uuids.map { createJsObject { + this.id = it.uuid + this.custom = it.custom?.toJsObject() + this.status = status + } }.toTypedArray() + this.limit = limit + this.page = page.toMetadataPage() + this.filter = filter + this.sort = sort.toJsMap() + this.include = createJsObject { + this.totalCount = includeCount + this.customFields = includeCustom + this.statusField = true + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.UUIDFields = true + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.customUUIDFields = true +// this.UUIDStatusField = true + //todo we don't have parameters for all fields here + } + }) } override fun removeChannelMembers( @@ -608,23 +685,38 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel? ): ManageChannelMembers { - TODO("Not yet implemented") + return RemoveChannelMembersImpl(jsPubNub, createJsObject { + this.channel = channel + this.uuids = uuids.toTypedArray() + this.limit = limit + this.page = page.toMetadataPage() + this.filter = filter + this.sort = sort.toJsMap() + this.include = createJsObject { + this.totalCount = includeCount + this.customFields = includeCustom + this.statusField = true + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.UUIDFields = true + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.customUUIDFields = true + //todo we don't have parameters for all fields here + } + }) } - override fun manageChannelMembers( - channel: String, - uuidsToSet: Collection, - uuidsToRemove: Collection, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? - ): ManageChannelMembers { - TODO("Not yet implemented") - } +// override fun manageChannelMembers( +// channel: String, +// uuidsToSet: Collection, +// uuidsToRemove: Collection, +// limit: Int?, +// page: PNPage?, +// filter: String?, +// sort: Collection>, +// includeCount: Boolean, +// includeCustom: Boolean, +// includeUUIDDetails: PNUUIDDetailsLevel? +// ): ManageChannelMembers { +// TODO("Not yet implemented") +// } override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { TODO("Not yet implemented") @@ -777,3 +869,16 @@ private inline fun getGrantTokenPermissions(grants: //todo what about create? any other? } }.toJsMap() + +private fun Collection>.toJsMap() = associateBy(keySelector = { pnSortKey -> pnSortKey.key.fieldName }, valueTransform = { pnSortKey -> pnSortKey.dir }).toJsMap() + +private fun PNPage?.toMetadataPage(): PubNubJs.MetadataPage? = + this?.let { pageNotNull -> + createJsObject { + if (pageNotNull is PNPage.PNNext) { + this.next = pageNotNull.pageHash + } else { + this.prev = pageNotNull.pageHash + } + } + } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt index c48c3f8e4..eb296f42b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt @@ -22,11 +22,11 @@ class FetchMessagesImpl(pubnub: PubNub, params: PubNub.FetchMessagesParameters) item.actions?.toMap()?.mapValues { entry: Map.Entry -> entry.value.toMap().mapValues { entry2: Map.Entry> -> entry2.value.map { action -> - PNFetchMessageItem.Action(action.uuid, action.actionTimetoken.toString()) + PNFetchMessageItem.Action(action.uuid, action.actionTimetoken) } } }, - HistoryMessageType.of(item.messageType?.toString()?.toInt()), + HistoryMessageType.of(item.messageType?.toInt()), null, //TODO item.error ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt index 71331d746..faa1be288 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt @@ -4,19 +4,13 @@ import AddMessageActionResult import PubNub import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult -import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.kmp.toMessageAction class AddMessageActionImpl(pubnub: PubNub, params: PubNub.AddMessageActionParameters) : AddMessageAction, EndpointImpl( promiseFactory = { pubnub.addMessageAction(params) }, responseMapping = { PNAddMessageActionResult( - PNMessageAction( - it.data.type, - it.data.value, - it.data.messageTimetoken.toLong() - ).apply { - actionTimetoken = it.data.actionTimetoken.toLong() - } + it.data.toMessageAction() ) } ) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt index dd7589e17..1b81c3597 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt @@ -5,19 +5,14 @@ import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.kmp.toMessageAction class GetMessageActionImpl(pubnub: PubNub, params: PubNub.GetMessageActionsParameters) : GetMessageActions, EndpointImpl( promiseFactory = { pubnub.getMessageActions(params) }, responseMapping = { PNGetMessageActionsResult( - it.data.map { - PNMessageAction( - it.type, - it.value, - it.messageTimetoken.toLong() - ).apply { - actionTimetoken = it.actionTimetoken.toLong() - } + it.data.map { action -> + action.toMessageAction() }, it.start?.let { startNotNull -> PNBoundedPage(startNotNull.toLong(), it.end?.toLong(), null) //TODO kmp does js not return limit? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadataImpl.kt new file mode 100644 index 000000000..bdd2e45e2 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadataImpl.kt @@ -0,0 +1,21 @@ +package com.pubnub.api.endpoints.objects.channel + +import GetAllChannelMetadataResponse +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult +import com.pubnub.kmp.toChannelMetadata + +class GetAllChannelMetadataImpl(pubnub: PubNub, params: PubNub.GetAllMetadataParameters) : GetAllChannelMetadata, + EndpointImpl(promiseFactory = { pubnub.objects.getAllChannelMetadata(params) }, + responseMapping = { pagedObjectsResponse: GetAllChannelMetadataResponse -> + PNChannelMetadataArrayResult( + pagedObjectsResponse.status.toInt(), + pagedObjectsResponse.data.map(PubNub.ChannelMetadataObject::toChannelMetadata), + pagedObjectsResponse.totalCount?.toInt(), + pagedObjectsResponse.next?.let { PNPage.PNNext(it) }, + pagedObjectsResponse.prev?.let { PNPage.PNPrev(it) }, + ) + } + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt index aacedc4d4..1988fcfeb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt @@ -5,6 +5,7 @@ import PubNub import SetChannelMetadataResponse import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult +import com.pubnub.kmp.toChannelMetadataResult class GetChannelMetadataImpl(pubnub: PubNub, params: PubNub.GetChannelMetadataParameters) : GetChannelMetadata, EndpointImpl(promiseFactory = { pubnub.objects.getChannelMetadata(params) }, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt index f2d8f350b..f7716680a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt @@ -3,29 +3,10 @@ package com.pubnub.api.endpoints.objects.channel import PubNub import SetChannelMetadataResponse import com.pubnub.api.EndpointImpl -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult -import com.pubnub.kmp.toMap +import com.pubnub.kmp.toChannelMetadataResult class SetChannelMetadataImpl(pubnub: PubNub, params: PubNub.SetChannelMetadataParameters) : SetChannelMetadata, EndpointImpl(promiseFactory = { pubnub.objects.setChannelMetadata(params) }, responseMapping = SetChannelMetadataResponse::toChannelMetadataResult ) - -internal fun SetChannelMetadataResponse.toChannelMetadataResult(): PNChannelMetadataResult { - return PNChannelMetadataResult(status.toInt(), - data.toChannelMetadata()) -} - -internal fun PubNub.ChannelMetadataObject.toChannelMetadata(): PNChannelMetadata { - return PNChannelMetadata( - id, - name, - description, - custom?.toMap(), - updated, - eTag, - type, - status - ) -} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt index e7e968480..313fe7e52 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt @@ -4,39 +4,12 @@ import ManageChannelMembersResponse import PubNub import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.models.consumer.objects.member.PNMember import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -import com.pubnub.kmp.toMap +import com.pubnub.kmp.toPNMember +import com.pubnub.kmp.toPNMemberArrayResult class GetChannelMembersImpl(pubnub: PubNub, params: PubNub.GetChannelMembersParameters) : GetChannelMembers, EndpointImpl( promiseFactory = { pubnub.objects.getChannelMembers(params) }, - responseMapping = { - PNMemberArrayResult( - it.status.toInt(), - it.data.map { member -> - PNMember( - PNUUIDMetadata( - member.uuid.id, - member.uuid.name, - member.uuid.externalId, - member.uuid.profileUrl, - member.uuid.email, - member.uuid.custom?.toMap(), - member.uuid.updated, - member.uuid.eTag, - member.uuid.type, - member.uuid.status - ), - member.custom?.toMap(), - member.updated, - member.eTag, - member.status - ) - }, - it.totalCount?.toInt(), - it.next?.let { next -> PNPage.PNNext(next) }, - it.prev?.let { prev -> PNPage.PNPrev(prev) }, - ) - } -) \ No newline at end of file + responseMapping = ManageChannelMembersResponse::toPNMemberArrayResult +) + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/RemoveChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/RemoveChannelMembersImpl.kt new file mode 100644 index 000000000..194b225fe --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/RemoveChannelMembersImpl.kt @@ -0,0 +1,13 @@ +package com.pubnub.api.endpoints.objects.member + +import ManageChannelMembersResponse +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.kmp.toPNMemberArrayResult + +class RemoveChannelMembersImpl(pubnub: PubNub, params: PubNub.RemoveChannelMembersParameters) : ManageChannelMembers, EndpointImpl( + promiseFactory = { pubnub.objects.removeChannelMembers(params) }, + responseMapping = ManageChannelMembersResponse::toPNMemberArrayResult +) + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/SetChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/SetChannelMembersImpl.kt new file mode 100644 index 000000000..65bb59ea1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/SetChannelMembersImpl.kt @@ -0,0 +1,17 @@ +package com.pubnub.api.endpoints.objects.member + +import ManageChannelMembersResponse +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.member.PNMember +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.kmp.toMap +import com.pubnub.kmp.toPNMember +import com.pubnub.kmp.toPNMemberArrayResult + +class SetChannelMembersImpl(pubnub: PubNub, params: PubNub.SetChannelMembersParameters) : ManageChannelMembers, EndpointImpl( + promiseFactory = { pubnub.objects.setChannelMembers(params) }, + responseMapping = ManageChannelMembersResponse::toPNMemberArrayResult +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMembershipsImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMembershipsImpl.kt new file mode 100644 index 000000000..b6d7543f1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMembershipsImpl.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.endpoints.objects.membership + +import ManageMembershipsResponse +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult +import com.pubnub.kmp.toPNChannelMembershipArrayResult + +class GetMembershipsImpl(pubnub: PubNub, params: PubNub.GetMembershipsParametersv2) : GetMemberships, + EndpointImpl(promiseFactory = { pubnub.objects.getMemberships(params) }, + responseMapping = ManageMembershipsResponse::toPNChannelMembershipArrayResult + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/RemoveMembershipsImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/RemoveMembershipsImpl.kt new file mode 100644 index 000000000..970aaaf08 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/RemoveMembershipsImpl.kt @@ -0,0 +1,16 @@ +package com.pubnub.api.endpoints.objects.membership + +import ManageMembershipsResponse +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.kmp.toChannelMetadata +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult +import com.pubnub.kmp.toMap +import com.pubnub.kmp.toPNChannelMembershipArrayResult + +class RemoveMembershipsImpl(pubnub: PubNub, params: PubNub.RemoveMembershipsParameters) : ManageMemberships, + EndpointImpl(promiseFactory = { pubnub.objects.removeMemberships(params) }, + responseMapping = ManageMembershipsResponse::toPNChannelMembershipArrayResult + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/SetMembershipsImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/SetMembershipsImpl.kt new file mode 100644 index 000000000..00e42e85c --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/SetMembershipsImpl.kt @@ -0,0 +1,16 @@ +package com.pubnub.api.endpoints.objects.membership + +import ManageMembershipsResponse +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.kmp.toChannelMetadata +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult +import com.pubnub.kmp.toMap +import com.pubnub.kmp.toPNChannelMembershipArrayResult + +class SetMembershipsImpl(pubnub: PubNub, params: PubNub.SetMembershipsParameters) : ManageMemberships, + EndpointImpl(promiseFactory = { pubnub.objects.setMemberships(params) }, + responseMapping = ManageMembershipsResponse::toPNChannelMembershipArrayResult + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt index 3edbb17bd..64c5abb95 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt @@ -5,6 +5,7 @@ import PubNub import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult +import com.pubnub.kmp.toPNUUIDMetadata class GetAllUUIDMetadataImpl(pubnub: PubNub, params: PubNub.GetAllMetadataParameters) : GetAllUUIDMetadata, EndpointImpl(promiseFactory = { pubnub.objects.getAllUUIDMetadata(params) }, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt index 1ff284acb..3820e6c15 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt @@ -1,21 +1,12 @@ package com.pubnub.api.endpoints.objects.uuid import GetUUIDMetadataResponse -import ObjectsResponse import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -import com.pubnub.kmp.toMap +import com.pubnub.kmp.toPNUUIDMetadataResult class GetUUIDMetadataImpl(pubnub: PubNub, params: PubNub.GetUUIDMetadataParameters) : GetUUIDMetadata, EndpointImpl(promiseFactory = { pubnub.objects.getUUIDMetadata(params) }, responseMapping = GetUUIDMetadataResponse::toPNUUIDMetadataResult ) - - -fun ObjectsResponse.toPNUUIDMetadataResult() = PNUUIDMetadataResult(status.toInt(), data.toPNUUIDMetadata()) - -internal fun PubNub.UUIDMetadataObject.toPNUUIDMetadata() = PNUUIDMetadata( - id, name, externalId, profileUrl, email, custom?.toMap(), updated, eTag, type, status -) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt index aa5ca3c0b..4b7ea2950 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt @@ -5,6 +5,7 @@ import PubNub import SetUUIDMetadataResponse import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.kmp.toPNUUIDMetadataResult class SetUUIDMetadataImpl(pubnub: PubNub, params: PubNub.SetUUIDMetadataParameters) : SetUUIDMetadata, EndpointImpl(promiseFactory = { pubnub.objects.setUUIDMetadata(params) }, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/converters.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/converters.js.kt new file mode 100644 index 000000000..68d3b5645 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/converters.js.kt @@ -0,0 +1,96 @@ +package com.pubnub.kmp + +import ManageChannelMembersResponse +import ManageMembershipsResponse +import ObjectsResponse +import PubNub +import SetChannelMetadataResponse +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult +import com.pubnub.api.models.consumer.objects.member.PNMember +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult + +internal fun SetChannelMetadataResponse.toChannelMetadataResult(): PNChannelMetadataResult { + return PNChannelMetadataResult( + status.toInt(), + data.toChannelMetadata() + ) +} + +internal fun PubNub.ChannelMetadataObject.toChannelMetadata(): PNChannelMetadata { + return PNChannelMetadata( + id, + name, + description, + custom?.toMap(), + updated, + eTag, + type, + status + ) +} + +internal fun PubNub.UUIDMembershipObject.toPNMember() = PNMember( + PNUUIDMetadata( + uuid.id, + uuid.name, + uuid.externalId, + uuid.profileUrl, + uuid.email, + uuid.custom?.toMap(), + uuid.updated, + uuid.eTag, + uuid.type, + uuid.status + ), + custom?.toMap(), + updated, + eTag, + status +) + +internal fun ManageChannelMembersResponse.toPNMemberArrayResult() = PNMemberArrayResult( + status.toInt(), + data.map(PubNub.UUIDMembershipObject::toPNMember), + totalCount?.toInt(), + next?.let { next -> PNPage.PNNext(next) }, + prev?.let { prev -> PNPage.PNPrev(prev) }, +) + +internal fun ManageMembershipsResponse.toPNChannelMembershipArrayResult() = PNChannelMembershipArrayResult( + status.toInt(), + data.map { + PNChannelMembership( + it.channel?.toChannelMetadata(), + it.custom?.toMap(), + it.updated, + it.eTag, + it.status + ) + }, + totalCount?.toInt(), + next?.let { PNPage.PNNext(it) }, + prev?.let { PNPage.PNPrev(it) } +) + +internal fun ObjectsResponse.toPNUUIDMetadataResult() = + PNUUIDMetadataResult(status.toInt(), data.toPNUUIDMetadata()) +internal fun PubNub.UUIDMetadataObject.toPNUUIDMetadata() = PNUUIDMetadata( + id, name, externalId, profileUrl, email, custom?.toMap(), updated, eTag, type, status +) + +internal fun PubNub.MessageAction.toMessageAction() = + PNMessageAction( + type, + value, + messageTimetoken.toLong() + ).apply { + this.actionTimetoken = this@toMessageAction.actionTimetoken.toLong() + this.uuid = this@toMessageAction.uuid + } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt index d43dc2315..2d39662f1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt @@ -3,8 +3,6 @@ package com.pubnub.kmp import com.pubnub.api.JsonElementImpl import com.pubnub.api.PubNub import com.pubnub.api.PubNubImpl -import com.pubnub.api.endpoints.objects.channel.toChannelMetadata -import com.pubnub.api.endpoints.objects.uuid.toPNUUIDMetadata import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.files.PNDownloadableFile import com.pubnub.api.models.consumer.message_actions.PNMessageAction @@ -15,9 +13,13 @@ import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEvent +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage import com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener @@ -127,7 +129,7 @@ actual fun createEventListener( null, event.publisher ), - when(eventAndType) { + when (eventAndType) { "set" to "channel" -> PNSetChannelMetadataEventMessage( event.message.source, event.message.version, @@ -135,6 +137,7 @@ actual fun createEventListener( event.message.type, event.message.data.unsafeCast().toChannelMetadata() ) + "set" to "uuid" -> PNSetUUIDMetadataEventMessage( event.message.source, event.message.version, @@ -142,7 +145,24 @@ actual fun createEventListener( event.message.type, event.message.data.unsafeCast().toPNUUIDMetadata() ) -// "set" to "membership" -> {} + + "set" to "membership" -> event.message.data.unsafeCast().let { + PNSetMembershipEventMessage( + event.message.source, + event.message.version, + event.message.event, + event.message.type, + PNSetMembershipEvent( + it.channel.id, + it.uuid.id, + it.custom?.toMap(), + it.eTag, + it.updated, + null //todo missing + ) + ) + } + "delete" to "channel" -> PNDeleteChannelMetadataEventMessage( event.message.source, event.message.version, @@ -150,6 +170,7 @@ actual fun createEventListener( event.message.type, event.message.data.asDynamic().id ) + "delete" to "uuid" -> PNDeleteUUIDMetadataEventMessage( event.message.source, event.message.version, @@ -157,7 +178,20 @@ actual fun createEventListener( event.message.type, event.message.data.asDynamic().id ) -// "delete" to "membership" -> {} + + "delete" to "membership" -> PNDeleteMembershipEventMessage( + event.message.source, + event.message.version, + event.message.event, + event.message.type, + event.message.data.unsafeCast().let { + PNDeleteMembershipEvent( + it.channel.id, + it.uuid.id + ) + } + ) + else -> throw IllegalStateException("Bad object event") } )) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index bc40f4536..5541747a3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -1140,17 +1140,17 @@ actual interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - actual fun manageMemberships( + fun manageMemberships( channelsToSet: List, channelsToRemove: List, - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel?, + uuid: String? = null, + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + includeChannelDetails: PNChannelDetailsLevel? = null, ): ManageMemberships /** @@ -1348,17 +1348,17 @@ actual interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - actual fun manageChannelMembers( + fun manageChannelMembers( channel: String, uuidsToSet: Collection, uuidsToRemove: Collection, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel?, + limit: Int? = null, + page: PNPage? = null, + filter: String? = null, + sort: Collection> = listOf(), + includeCount: Boolean = false, + includeCustom: Boolean = false, + includeUUIDDetails: PNUUIDDetailsLevel? = null, ): ManageChannelMembers /** diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts index 2f57ae4d1..59e459861 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -1,5 +1,6 @@ import com.codingfeline.buildkonfig.compiler.FieldSpec.Type import org.jetbrains.dokka.DokkaDefaults.moduleName +import org.jetbrains.kotlin.builtins.StandardNames.FqNames.target import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable @@ -19,7 +20,19 @@ plugins { kotlin { jvmToolchain(8) js { +// compilations.all { +// compileTaskProvider.configure { +// kotlinOptions { +// target = "es2015" +// } +// } +// } + browser { +// dceTask { +// keep("com.pubnub.api", "com.pubnub.kmp") +// } + testTask { useMocha { timeout = "30s" @@ -50,6 +63,7 @@ kotlin { dependencies { api(project(":pubnub-kotlin:pubnub-kotlin-api")) api(project(":pubnub-core:pubnub-core-api")) + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") implementation(libs.datetime) } } diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt index df412f80e..a0e11213d 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt @@ -1,6 +1,7 @@ -//import com.pubnub.api.CustomObject +//package com.pubnub.test +// +//import com.pubnub.api.JsonElement //import com.pubnub.api.PubNub -//import com.pubnub.api.UserId //import com.pubnub.api.callbacks.Listener //import com.pubnub.api.endpoints.DeleteMessages //import com.pubnub.api.endpoints.FetchMessages @@ -45,8 +46,7 @@ //import com.pubnub.api.enums.PNPushEnvironment //import com.pubnub.api.enums.PNPushType //import com.pubnub.api.models.consumer.PNBoundedPage -//import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions -//import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions +//import com.pubnub.api.models.consumer.PNPublishResult //import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant //import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant //import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant @@ -56,90 +56,54 @@ //import com.pubnub.api.models.consumer.objects.PNMembershipKey //import com.pubnub.api.models.consumer.objects.PNPage //import com.pubnub.api.models.consumer.objects.PNSortKey +//import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata //import com.pubnub.api.models.consumer.objects.member.MemberInput //import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel //import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput //import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel //import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata //import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +//import com.pubnub.api.models.consumer.pubsub.BasePubSubResult +//import com.pubnub.api.models.consumer.pubsub.PNEvent +//import com.pubnub.api.models.consumer.pubsub.PNMessageResult //import com.pubnub.api.v2.PNConfiguration +//import com.pubnub.api.v2.callbacks.Consumer //import com.pubnub.api.v2.callbacks.EventListener +//import com.pubnub.api.v2.callbacks.Result //import com.pubnub.api.v2.callbacks.StatusListener -//import com.pubnub.test.createEndpoint +//import com.pubnub.kmp.CustomObject +//import kotlinx.coroutines.CoroutineScope +//import kotlinx.coroutines.SupervisorJob +//import kotlinx.coroutines.flow.MutableSharedFlow +//import kotlinx.coroutines.flow.mapNotNull +//import kotlinx.coroutines.launch //import kotlinx.datetime.Clock +//import kotlinx.datetime.Instant +//import kotlin.coroutines.EmptyCoroutineContext +//import kotlin.time.Duration.Companion.minutes +// // -////package com.pubnub.test -//// -////import com.pubnub.api.Endpoint -////import com.pubnub.api.JsonElement -////import com.pubnub.api.PubNub -////import com.pubnub.api.UserId -////import com.pubnub.api.callbacks.Listener -////import com.pubnub.api.endpoints.pubsub.Publish -////import com.pubnub.api.enums.PNPushEnvironment -////import com.pubnub.api.enums.PNPushType -////import com.pubnub.api.models.consumer.PNBoundedPage -////import com.pubnub.api.models.consumer.PNPublishResult -////import com.pubnub.api.models.consumer.PNTimeResult -////import com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult -////import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions -////import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions -////import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant -////import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant -////import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult -////import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant -////import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult -////import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult -////import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult -////import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult -////import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult -////import com.pubnub.api.models.consumer.files.PNDeleteFileResult -////import com.pubnub.api.models.consumer.files.PNFileUrlResult -////import com.pubnub.api.models.consumer.files.PNListFilesResult -////import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult -////import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult -////import com.pubnub.api.models.consumer.history.PNFetchMessagesResult -////import com.pubnub.api.models.consumer.history.PNMessageCountResult -////import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult -////import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult -////import com.pubnub.api.models.consumer.message_actions.PNMessageAction -////import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult -////import com.pubnub.api.models.consumer.objects.PNKey -////import com.pubnub.api.models.consumer.objects.PNMemberKey -////import com.pubnub.api.models.consumer.objects.PNMembershipKey -////import com.pubnub.api.models.consumer.objects.PNPage -////import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -////import com.pubnub.api.models.consumer.objects.PNSortKey -////import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult -////import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult -////import com.pubnub.api.models.consumer.objects.member.MemberInput -////import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult -////import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel -////import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput -////import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -////import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult -////import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -////import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult -////import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -////import com.pubnub.api.models.consumer.presence.PNGetStateResult -////import com.pubnub.api.models.consumer.presence.PNHereNowResult -////import com.pubnub.api.models.consumer.presence.PNSetStateResult -////import com.pubnub.api.models.consumer.presence.PNWhereNowResult -////import com.pubnub.api.models.consumer.pubsub.BasePubSubResult -////import com.pubnub.api.models.consumer.pubsub.PNMessageResult -////import com.pubnub.api.models.consumer.push.PNPushAddChannelResult -////import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult -////import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult -////import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult -////import com.pubnub.api.v2.PNConfiguration -////import com.pubnub.api.v2.callbacks.EventListener -////import com.pubnub.api.v2.callbacks.StatusListener -//// -////import kotlinx.datetime.Clock -//// -////expect fun createEndpoint(action: () -> T): Endpoint -//// //class FakePubNub(override val configuration: PNConfiguration) : PubNub { +// +// val scope = CoroutineScope(SupervisorJob()) +// +// fun Long.toEpochSeconds() = this / 10000000 +// fun generateTimetoken() = Clock.System.now().toEpochMilliseconds() * 10000 +// +// val events = MutableSharedFlow(100, 10) +// val subscriptionStream = events.mapNotNull { +// val tt = it.timetoken ?: return@mapNotNull null +// if (Clock.System.now() < Instant.fromEpochSeconds(tt.toEpochSeconds()) - 10.minutes) { +// it +// } else { +// null +// } +// } +// +// val messages: MutableList = mutableListOf() +// val userMetadata: MutableMap = mutableMapOf() +// val channelMetadata: MutableMap = mutableMapOf() +// // override fun addListener(listener: EventListener) { // TODO("Not yet implemented") // } @@ -165,7 +129,21 @@ // replicate: Boolean, // ttl: Int? // ): Publish { -// TODO("Not yet implemented") +// return object : Publish { +// override fun async(callback: Consumer>) { +// scope.launch { +// events.emit(PNMessageResult( +// BasePubSubResult( +// channel, +// null, +// generateTimetoken(), +// null, +// configuration.userId.value +// ), message, null +// )) +// } +// } +// } // } // // override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { @@ -254,15 +232,6 @@ // TODO("Not yet implemented") // } // -// override fun setPresenceState( -// channels: List, -// channelGroups: List, -// state: Any, -// uuid: String -// ): SetState { -// TODO("Not yet implemented") -// } -// // override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { // TODO("Not yet implemented") // } @@ -310,27 +279,6 @@ // TODO("Not yet implemented") // } // -// override fun grantToken( -// ttl: Int, -// meta: Any?, -// authorizedUUID: String?, -// channels: List, -// channelGroups: List, -// uuids: List -// ): GrantToken { -// TODO("Not yet implemented") -// } -// -// override fun grantToken( -// ttl: Int, -// meta: Any?, -// authorizedUserId: UserId?, -// spacesPermissions: List, -// usersPermissions: List -// ): GrantToken { -// TODO("Not yet implemented") -// } -// // override fun revokeToken(token: String): RevokeToken { // TODO("Not yet implemented") // } @@ -354,18 +302,6 @@ // TODO("Not yet implemented") // } // -// override fun setChannelMetadata( -// channel: String, -// name: String?, -// description: String?, -// custom: Any?, -// includeCustom: Boolean, -// type: String?, -// status: String? -// ): SetChannelMetadata { -// TODO("Not yet implemented") -// } -// // override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { // TODO("Not yet implemented") // } @@ -396,7 +332,6 @@ // type: String?, // status: String? // ): SetUUIDMetadata { -// return createEndpoint { // val actualUuid = uuid ?: configuration.userId.value // val result = userMetadata.compute(actualUuid) { a: String, b: PNUUIDMetadata? -> // PNUUIDMetadata( @@ -412,14 +347,18 @@ // status ?: b?.status // ) // } -// PNUUIDMetadataResult( -// 200, -// if (!includeCustom) { -// result?.copy(custom = null) -// } else { -// result -// } -// ) +// return object : SetUUIDMetadata { +// override fun async(callback: Consumer>) { +// callback.accept(Result.success(PNUUIDMetadataResult( +// 200, +// if (!includeCustom) { +// result?.copy(custom = null) +// } else { +// result +// } +// ) +// )) +// } // } // } // @@ -580,11 +519,44 @@ // TODO("Not yet implemented") // } // +// override fun setPresenceState(channels: List, channelGroups: List, state: Any): SetState { +// TODO("Not yet implemented") +// } +// +// override fun grantToken( +// ttl: Int, +// meta: CustomObject?, +// authorizedUUID: String?, +// channels: List, +// channelGroups: List, +// uuids: List +// ): GrantToken { +// TODO("Not yet implemented") +// } +// +// override fun setChannelMetadata( +// channel: String, +// name: String?, +// description: String?, +// custom: CustomObject?, +// includeCustom: Boolean, +// type: String?, +// status: String? +// ): SetChannelMetadata { +// TODO("Not yet implemented") +// } +// +// override fun unsubscribeAll() { +// TODO("Not yet implemented") +// } +// +// override fun destroy() { +// TODO("Not yet implemented") +// } +// //} //// -//// val messages: MutableList = mutableListOf() -//// val userMetadata: MutableMap = mutableMapOf() -//// val channelMetadata: MutableMap = mutableMapOf() +// //// //// /** //// * Remove a listener. @@ -936,43 +908,7 @@ //// } //// } //// -//// override fun setUUIDMetadata( -//// uuid: String?, -//// name: String?, -//// externalId: String?, -//// profileUrl: String?, -//// email: String?, -//// custom: Any?, -//// includeCustom: Boolean, -//// type: String?, -//// status: String? -//// ): Endpoint { -//// return createEndpoint { -//// val actualUuid = uuid ?: configuration.userId.value -//// val result = userMetadata.compute(actualUuid) { a: String, b: PNUUIDMetadata? -> -//// PNUUIDMetadata( -//// actualUuid, -//// name ?: b?.name, -//// externalId ?: b?.externalId, -//// profileUrl ?: b?.profileUrl, -//// email ?: b?.email, -//// custom ?: b?.custom, -//// Clock.System.now().toString(), -//// null, -//// type ?: b?.type, -//// status ?: b?.status -//// ) -//// } -//// PNUUIDMetadataResult( -//// 200, -//// if (!includeCustom) { -//// result?.copy(custom = null) -//// } else { -//// result -//// } -//// ) -//// } -//// } +//// //// //// override fun removeUUIDMetadata(uuid: String?): Endpoint { //// val actualUuid = uuid ?: configuration.userId.value @@ -1179,4 +1115,5 @@ // put(key, newValue) // return newValue // } -//} \ No newline at end of file +//} +// diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt new file mode 100644 index 000000000..846a51540 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt @@ -0,0 +1,75 @@ +package com.pubnub.api + +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.member.PNMember +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage +import com.pubnub.kmp.createCustomObject +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import com.pubnub.test.randomString +import com.pubnub.test.test +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertFalse +import kotlin.time.Duration.Companion.seconds + +class MembersTest : BaseIntegrationTest() { + private val channel = "myChannel" + randomString() + private val name = randomString() + private val description = randomString() + private val status = randomString() + private val customData = mapOf("aa" to randomString()) + private val custom = createCustomObject(customData) + private val includeCustom = true + private val type = randomString() + + @Test + fun can_set_members() = runTest(timeout = 10.seconds) { + // when + val result = pubnub.setChannelMembers( + channel, + listOf(PNMember.Partial(pubnub.configuration.userId.value, custom, status)), + includeCustom = includeCustom, + includeUUIDDetails = PNUUIDDetailsLevel.UUID_WITH_CUSTOM + ).await() + + // then + val pnChannelDetails = result.data.single { it.uuid?.id == pubnub.configuration.userId.value } + assertEquals(customData, pnChannelDetails.custom) + assertEquals(status, pnChannelDetails.status) + } + + @Test + fun can_delete_members() = runTest(timeout = 10.seconds) { + // given + pubnub.setChannelMembers( + channel, + listOf(PNMember.Partial(pubnub.configuration.userId.value, custom, status)) + ).await() + + // when + pubnub.removeChannelMembers(channel, listOf(pubnub.configuration.userId.value)).await() + + // then + var next: PNPage.PNNext? = null + while(true) { + val result = pubnub.getMemberships(pubnub.configuration.userId.value, page = next).await() + next = result.next + assertFalse { result.data.any { it.channel?.id == channel } } + if (next == null || result.data.isEmpty()) { + break + } + } + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt new file mode 100644 index 000000000..709eb996f --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt @@ -0,0 +1,116 @@ +package com.pubnub.api + +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage +import com.pubnub.kmp.createCustomObject +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import com.pubnub.test.randomString +import com.pubnub.test.test +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertFalse +import kotlin.time.Duration.Companion.seconds + +class MembershipsTest : BaseIntegrationTest() { + private val channel = "myChannel" + randomString() + private val name = randomString() + private val description = randomString() + private val status = randomString() + private val customData = mapOf("aa" to randomString()) + private val custom = createCustomObject(customData) + private val includeCustom = true + private val type = randomString() + + @Test + fun can_set_memberships() = runTest(timeout = 10.seconds) { + // when + val result = pubnub.setMemberships( + listOf(PNChannelMembership.Partial(channel, custom, status)), + includeCustom = includeCustom, + includeChannelDetails = PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM + ).await() + + // then + val pnChannelDetails = result.data.single { it.channel?.id == channel } + assertEquals(channel, pnChannelDetails.channel?.id) + assertEquals(customData, pnChannelDetails.custom) + } + + @Test + fun can_receive_set_membership_event() = runTest(timeout = 10.seconds) { + pubnub.test(backgroundScope) { + // given + pubnub.awaitSubscribe(listOf(channel)) + + // when + pubnub.setMemberships( + listOf(PNChannelMembership.Partial(channel, custom, status)), + includeCustom = includeCustom, + includeChannelDetails = PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM + ).await() + + // then + val result = nextEvent() + val message = result.extractedMessage + message as PNSetMembershipEventMessage + assertEquals(channel, message.data.channel) + assertEquals(pubnub.configuration.userId.value, message.data.uuid) + assertEquals(customData, message.data.custom) + } + } + + @Test + fun can_delete_membership() = runTest(timeout = 10.seconds) { + // given + pubnub.setMemberships( + listOf(PNChannelMembership.Partial(channel, custom, status)) + ).await() + + // when + pubnub.removeMemberships(listOf(channel)).await() + + // then + var next: PNPage.PNNext? = null + while(true) { + val result = pubnub.getChannelMembers(channel, page = next).await() + next = result.next + assertFalse { result.data.any { it.uuid?.id == pubnub.configuration.userId.value } } + if (next == null || result.data.isEmpty()) { + break + } + } + } + + @Test + fun can_receive_delete_membership_event() = runTest(timeout = 10.seconds) { + pubnub.test(backgroundScope) { + // given + pubnub.setMemberships( + listOf(PNChannelMembership.Partial(channel, custom, status)) + ).await() + + pubnub.awaitSubscribe(listOf(channel)) + + // when + pubnub.removeMemberships(listOf(channel)).await() + + // then + val result = nextEvent() + val message = result.extractedMessage + message as PNDeleteMembershipEventMessage + assertEquals(pubnub.configuration.userId.value, message.data.uuid) + assertEquals(channel, message.data.channelId) + } + } +} From c80d72c3920bf932c8c63b7647f61cbcfd8efd07 Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Tue, 4 Jun 2024 10:53:19 +0200 Subject: [PATCH 11/62] Wrapping next Swift endpoints (#224) --- .../kotlin/com/pubnub/api/Endpoint.ios.kt | 4 + .../kotlin/com/pubnub/api/PubNubImpl.kt | 85 ++++++++-- .../AddChannelChannelGroup.ios.kt | 23 +++ .../AllChannelsChannelGroup.ios.kt | 21 +++ .../channel_groups/DeleteChannelGroup.ios.kt | 23 ++- .../channel_groups/ListAllChannelGroup.ios.kt | 21 ++- .../RemoveChannelChannelGroup.ios.kt | 24 +++ .../message_actions/AddMessageAction.ios.kt | 33 ++++ .../message_actions/GetMessageActions.ios.kt | 40 +++++ .../RemoveMessageAction.ios.kt | 26 +++ .../channel/GetAllChannelMetadata.ios.kt | 71 +++++++- .../api/endpoints/presence/GetState.ios.kt | 26 +++ .../api/endpoints/presence/HereNow.ios.kt | 47 ++++++ .../api/endpoints/presence/WhereNow.ios.kt | 21 +++ .../kotlin/com/pubnub/kmp/factories.ios.kt | 153 +++++++++--------- 15 files changed, 523 insertions(+), 95 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt index 304ffe45b..aaba6b9a9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt @@ -22,6 +22,10 @@ fun Consumer>.onSuccessReturnValue(value: T) : () -> Unit { return fun() { accept(Result.success(value)) } } +fun Consumer>.onSuccessReturnValue(value: T) : () -> Unit { + return fun() { accept(Result.success(value)) } +} + fun Consumer>.onFailureHandler(mapper: (NSError?) -> Throwable = { error: NSError? -> PubNubException(errorMessage = error?.localizedDescription) } ): (NSError?) -> Unit { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index fd81f915f..db3966811 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -1,6 +1,7 @@ package com.pubnub.api import cocoapods.PubNubSwift.addEventListenerWithListener +import cocoapods.PubNubSwift.setWithToken import cocoapods.PubNubSwift.subscribeWithChannels import cocoapods.PubNubSwift.subscribedChannelGroups import cocoapods.PubNubSwift.subscribedChannels @@ -17,18 +18,27 @@ import com.pubnub.api.endpoints.TimeImpl import com.pubnub.api.endpoints.access.GrantToken import com.pubnub.api.endpoints.access.RevokeToken import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroupImpl import com.pubnub.api.endpoints.files.DeleteFile import com.pubnub.api.endpoints.files.GetFileUrl import com.pubnub.api.endpoints.files.ListFiles import com.pubnub.api.endpoints.files.PublishFileMessage import com.pubnub.api.endpoints.message_actions.AddMessageAction +import com.pubnub.api.endpoints.message_actions.AddMessageActionImpl import com.pubnub.api.endpoints.message_actions.GetMessageActions +import com.pubnub.api.endpoints.message_actions.GetMessageActionsImpl import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.endpoints.message_actions.RemoveMessageActionImpl import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadataImpl import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata @@ -41,9 +51,12 @@ import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata import com.pubnub.api.endpoints.presence.GetState +import com.pubnub.api.endpoints.presence.GetStateImpl import com.pubnub.api.endpoints.presence.HereNow +import com.pubnub.api.endpoints.presence.HereNowImpl import com.pubnub.api.endpoints.presence.SetState import com.pubnub.api.endpoints.presence.WhereNow +import com.pubnub.api.endpoints.presence.WhereNowImpl import com.pubnub.api.endpoints.pubsub.Publish import com.pubnub.api.endpoints.pubsub.PublishImpl import com.pubnub.api.endpoints.pubsub.Signal @@ -146,7 +159,6 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { return pubNubObjC.subscribedChannelGroups() as List } - // TODO: Missing pushType (PushService like APNS, GCM, etc) parameter // TODO: Why do we need topic parameter here? override fun addPushNotificationsOnChannels( @@ -244,11 +256,17 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeState: Boolean, includeUUIDs: Boolean ): HereNow { - TODO("Not yet implemented") + return HereNowImpl( + pubnub = pubNubObjC, + channels = channels, + channelGroups = channelGroups, + includeState = includeState, + includeUUIDs = includeUUIDs + ) } override fun whereNow(uuid: String): WhereNow { - TODO("Not yet implemented") + return WhereNowImpl(pubnub = pubNubObjC, uuid = uuid) } override fun setPresenceState( @@ -260,7 +278,12 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { - TODO("Not yet implemented") + return GetStateImpl( + pubnub = pubNubObjC, + channels = channels, + channelGroups = channelGroups, + uuid = uuid + ) } override fun presence(channels: List, channelGroups: List, connected: Boolean) { @@ -268,7 +291,13 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun addMessageAction(channel: String, messageAction: PNMessageAction): AddMessageAction { - TODO("Not yet implemented") + return AddMessageActionImpl( + pubnub = pubNubObjC, + channel = channel, + actionType = messageAction.type, + actionValue = messageAction.value, + messageTimetoken = messageAction.messageTimetoken + ) } override fun removeMessageAction( @@ -276,34 +305,51 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { messageTimetoken: Long, actionTimetoken: Long ): RemoveMessageAction { - TODO("Not yet implemented") + return RemoveMessageActionImpl( + pubnub = pubNubObjC, + channel = channel, + messageTimetoken = messageTimetoken, + actionTimetoken = actionTimetoken + ) } override fun getMessageActions(channel: String, page: PNBoundedPage): GetMessageActions { - TODO("Not yet implemented") + return GetMessageActionsImpl( + pubnub = pubNubObjC, + channel = channel, + page = page + ) } override fun addChannelsToChannelGroup(channels: List, channelGroup: String): AddChannelChannelGroup { - TODO("Not yet implemented") + return AddChannelChannelGroupImpl( + pubnub = pubNubObjC, + channels = channels, + channelGroup = channelGroup + ) } override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { - TODO("Not yet implemented") + return AllChannelsChannelGroupImpl(pubnub = pubNubObjC, channelGroup = channelGroup) } override fun removeChannelsFromChannelGroup( channels: List, channelGroup: String ): RemoveChannelChannelGroup { - TODO("Not yet implemented") + return RemoveChannelChannelGroupImpl( + pubnub = pubNubObjC, + channels = channels, + channelGroup = channelGroup + ) } override fun listAllChannelGroups(): ListAllChannelGroup { - TODO("Not yet implemented") + return ListAllChannelGroupImpl(pubnub = pubNubObjC) } override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { - TODO("Not yet implemented") + return DeleteChannelGroupImpl(pubnub = pubNubObjC, channelGroup = channelGroup) } override fun grantToken( @@ -333,7 +379,15 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCount: Boolean, includeCustom: Boolean ): GetAllChannelMetadata { - TODO("Not yet implemented") + return GetAllChannelMetadataImpl( + pubnub = pubNubObjC, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom + ) } override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { @@ -543,8 +597,11 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { pubNubObjC.unsubscribeFrom(channels = channels, channelGroups = channelGroups) } + // TODO: Why token is optional? What's the desired behavior for a null value? override fun setToken(token: String?) { - TODO("Not yet implemented") + token?.let { + pubNubObjC.setWithToken(token) + } } override fun destroy() { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt index 605ea25d5..cc741a364 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt @@ -1,10 +1,33 @@ package com.pubnub.api.endpoints.channel_groups +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.addChannelsTo import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.addChannelsToChannelGroup] */ actual interface AddChannelChannelGroup : Endpoint { +} + +@OptIn(ExperimentalForeignApi::class) +class AddChannelChannelGroupImpl( + private val pubnub: PubNubObjC, + private val channels: List, + private val channelGroup: String +): AddChannelChannelGroup { + override fun async(callback: Consumer>) { + pubnub.addChannelsTo( + channelGroup = channelGroup, + channels = channels, + onSuccess = callback.onSuccessHandler { PNChannelGroupsAddChannelResult() }, + onFailure = callback.onFailureHandler() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt index e92a2e4cb..94f5ed9e4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt @@ -1,10 +1,31 @@ package com.pubnub.api.endpoints.channel_groups +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.listChannelsFor import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.listChannelsForChannelGroup] */ actual interface AllChannelsChannelGroup : Endpoint { +} + +@OptIn(ExperimentalForeignApi::class) +class AllChannelsChannelGroupImpl( + private val pubnub: PubNubObjC, + private val channelGroup: String +): AllChannelsChannelGroup { + override fun async(callback: Consumer>) { + pubnub.listChannelsFor( + channelGroup = channelGroup, + onSuccess = callback.onSuccessHandler { PNChannelGroupsAllChannelsResult(channels = it as List) }, + onFailure = callback.onFailureHandler() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt index a480015a4..e19d81926 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt @@ -1,9 +1,30 @@ package com.pubnub.api.endpoints.channel_groups +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.deleteWithChannelGroup import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.deleteChannelGroup] */ -actual interface DeleteChannelGroup : Endpoint \ No newline at end of file +actual interface DeleteChannelGroup : Endpoint + +@OptIn(ExperimentalForeignApi::class) +class DeleteChannelGroupImpl( + private val pubnub: PubNubObjC, + private val channelGroup: String +): DeleteChannelGroup { + override fun async(callback: Consumer>) { + pubnub.deleteWithChannelGroup( + channelGroup = channelGroup, + onSuccess = callback.onSuccessHandler { PNChannelGroupsDeleteGroupResult() }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt index 64cc91e1e..038fca34a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt @@ -1,9 +1,28 @@ package com.pubnub.api.endpoints.channel_groups +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.listChannelGroupsOnSuccess import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.listAllChannelGroups] */ -actual interface ListAllChannelGroup : Endpoint \ No newline at end of file +actual interface ListAllChannelGroup : Endpoint + +@OptIn(ExperimentalForeignApi::class) +class ListAllChannelGroupImpl( + private val pubnub: PubNubObjC +): ListAllChannelGroup { + override fun async(callback: Consumer>) { + pubnub.listChannelGroupsOnSuccess( + onSuccess = callback.onSuccessHandler { PNChannelGroupsListAllResult(groups = it as List) }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt index 300aee3a9..f5fd5863e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt @@ -1,10 +1,34 @@ package com.pubnub.api.endpoints.channel_groups +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.removeWithChannels import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.onSuccessReturnValue +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.removeChannelsFromChannelGroup] */ actual interface RemoveChannelChannelGroup : Endpoint { +} + +@OptIn(ExperimentalForeignApi::class) +class RemoveChannelChannelGroupImpl( + private val pubnub: PubNubObjC, + private val channels: List, + private val channelGroup: String +): RemoveChannelChannelGroup { + override fun async(callback: Consumer>) { + pubnub.removeWithChannels( + channels = channels, + from = channelGroup, + onSuccess = callback.onSuccessHandler { PNChannelGroupsRemoveChannelResult() }, + onFailure = callback.onFailureHandler() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt index ec6a14aa2..077677bcd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt @@ -1,10 +1,43 @@ package com.pubnub.api.endpoints.message_actions +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.addMessageActionWithChannel import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.addMessageAction] */ actual interface AddMessageAction : Endpoint { +} + +@OptIn(ExperimentalForeignApi::class) +class AddMessageActionImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val actionType: String, + private val actionValue: String, + private val messageTimetoken: Long +): AddMessageAction { + override fun async(callback: Consumer>) { + pubnub.addMessageActionWithChannel( + channel = channel, + actionType = actionType, + actionValue = actionValue, + messageTimetoken = messageTimetoken.toULong(), + onSuccess = callback.onSuccessHandler { PNAddMessageActionResult( + action = PNMessageAction( + type = it?.type() ?: "", + value = it?.value() ?: "", + messageTimetoken = it?.messageTimetoken()?.toLong() ?: 0 + ) + )}, onFailure = callback.onFailureHandler() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt index 100ae5fe4..08036fe86 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt @@ -1,10 +1,50 @@ package com.pubnub.api.endpoints.message_actions +import cocoapods.PubNubSwift.PubNubBoundedPageObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.getMessageActionsFrom import com.pubnub.api.Endpoint +import com.pubnub.api.PubNub +import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [PubNub.getMessageActions] */ actual interface GetMessageActions : Endpoint { +} + +@OptIn(ExperimentalForeignApi::class) +class GetMessageActionsImpl( + private val channel: String, + private val pubnub: PubNubObjC, + private val page: PNBoundedPage +): GetMessageActions { + override fun async(callback: Consumer>) { + pubnub.getMessageActionsFrom( + channel = channel, + page = PubNubBoundedPageObjC( + start = page.start?.let { NSNumber(long = it) }, + end = page.end?.let { NSNumber(long = it) }, + limit = page.limit?.let { NSNumber(it) } + ), + onSuccess = callback.onSuccessHandler { + PNGetMessageActionsResult( + actions = emptyList(), + page = PNBoundedPage( + start = it?.next()?.start()?.longValue(), + end = it?.next()?.end()?.longValue(), + limit = it?.next()?.limit()?.intValue() + ) + ) + }, + onFailure = callback.onFailureHandler() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt index 71dfe0644..cc3390df8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt @@ -1,10 +1,36 @@ package com.pubnub.api.endpoints.message_actions +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.removeMessageActionWithChannel import com.pubnub.api.Endpoint +import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessReturnValue +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.removeMessageAction] */ actual interface RemoveMessageAction : Endpoint { +} + +@OptIn(ExperimentalForeignApi::class) +class RemoveMessageActionImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val messageTimetoken: Long, + private val actionTimetoken: Long +): RemoveMessageAction { + override fun async(callback: Consumer>) { + pubnub.removeMessageActionWithChannel( + channel = channel, + messageTimetoken = messageTimetoken.toULong(), + actionTimetoken = actionTimetoken.toULong(), + onSuccess = callback.onSuccessReturnValue(PNRemoveMessageActionResult()), + onFailure = callback.onFailureHandler() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt index 51a8b8d90..4d6f4dd49 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt @@ -1,10 +1,77 @@ package com.pubnub.api.endpoints.objects.channel +import cocoapods.PubNubSwift.PubNubChannelMetadataObjC +import cocoapods.PubNubSwift.PubNubGetChannelMetadataResultObjC +import cocoapods.PubNubSwift.PubNubHashedPageObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.PubNubSortPropertyObjC +import cocoapods.PubNubSwift.getAllChannelMetadataWithLimit import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [PubNub.getAllChannelMetadata] */ -actual interface GetAllChannelMetadata : - Endpoint \ No newline at end of file +actual interface GetAllChannelMetadata : Endpoint + +@OptIn(ExperimentalForeignApi::class) +class GetAllChannelMetadataImpl( + private val pubnub: PubNubObjC, + private val limit: Int?, + private val page: PNPage?, + private val filter: String?, + private val sort: Collection>, + private val includeCount: Boolean, + private val includeCustom: Boolean +): GetAllChannelMetadata { + override fun async(callback: Consumer>) { + pubnub.getAllChannelMetadataWithLimit( + limit = limit?.let { NSNumber(it) }, + page = PubNubHashedPageObjC( + start = if (page is PNPage.PNNext) { page.pageHash } else { null }, + end = if (page is PNPage.PNPrev) { page.pageHash } else { null }, + totalCount = null + ), + filter = filter, + sort = sort.map { + PubNubSortPropertyObjC( + key = it.key.fieldName, + direction = it.dir + ) + }, + includeCount = includeCount, + includeCustom = includeCustom, + onSuccess = callback.onSuccessHandler { + PNChannelMetadataArrayResult( + status = it?.status()?.toInt() ?: 0, + data = (it?.data() as List).map { metadata -> + PNChannelMetadata( + id = metadata.id(), + name = metadata.name(), + description = metadata.descr(), + custom = metadata.custom() as? Map, + updated = metadata.updated(), + eTag = metadata.eTag(), + type = metadata.type(), + status = metadata.status() + ) + }, + totalCount = it.totalCount()?.intValue ?: 0, + next = it.next()?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = it.next()?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt index db440e6c6..aa220b74d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt @@ -1,10 +1,36 @@ package com.pubnub.api.endpoints.presence +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.getPresenceStateWithChannels import com.pubnub.api.Endpoint +import com.pubnub.api.JsonElement import com.pubnub.api.models.consumer.presence.PNGetStateResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.getPresenceState] */ actual interface GetState : Endpoint { +} + +@OptIn(ExperimentalForeignApi::class) +class GetStateImpl( + private val pubnub: PubNubObjC, + private val channels: List, + private val channelGroups: List, + private val uuid: String +): GetState { + override fun async(callback: Consumer>) { + pubnub.getPresenceStateWithChannels( + channels = channels, + channelGroups = channelGroups, + uuid = uuid, + onSuccess = callback.onSuccessHandler { PNGetStateResult(stateByUUID = it as Map) }, + onFailure = callback.onFailureHandler() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt index ad2a76aae..034fa2eb2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt @@ -1,10 +1,57 @@ package com.pubnub.api.endpoints.presence +import cocoapods.PubNubSwift.PubNubHereNowChannelDataObjC +import cocoapods.PubNubSwift.PubNubHereNowOccupantDataObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.hereNowWithChannels import com.pubnub.api.Endpoint +import com.pubnub.api.JsonElement +import com.pubnub.api.models.consumer.presence.PNHereNowChannelData +import com.pubnub.api.models.consumer.presence.PNHereNowOccupantData import com.pubnub.api.models.consumer.presence.PNHereNowResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.hereNow] */ actual interface HereNow : Endpoint { +} + +@OptIn(ExperimentalForeignApi::class) +class HereNowImpl( + private val pubnub: PubNubObjC, + private val channels: List, + private val channelGroups: List, + private val includeState: Boolean, + private val includeUUIDs: Boolean +): HereNow { + override fun async(callback: Consumer>) { + pubnub.hereNowWithChannels( + channels = channels, + channelGroups = channelGroups, + includeState = includeState, + includeUUIDs = includeUUIDs, + onSuccess = callback.onSuccessHandler { PNHereNowResult( + totalChannels = it?.totalChannels()?.toInt() ?: 0, + totalOccupancy = it?.totalOccupancy()?.toInt() ?: 0, + channels = (it?.channels() as? Map)?.mapValues { entry -> + PNHereNowChannelData( + channelName = entry.value.channelName(), + occupancy = entry.value.occupancy().toInt(), + occupants = (entry.value.occupants() as? List)?.map { occupant -> + PNHereNowOccupantData( + uuid = occupant.uuid(), + state = occupant.state() as JsonElement + ) + } ?: emptyList() + ) + }?.toMutableMap() ?: emptyMap().toMutableMap() + )}, + onFailure = callback.onFailureHandler() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt index f20e29771..d83d02228 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt @@ -1,10 +1,31 @@ package com.pubnub.api.endpoints.presence +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.whereNowWithUuid import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.presence.PNWhereNowResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.whereNow] */ actual interface WhereNow : Endpoint { +} + +@OptIn(ExperimentalForeignApi::class) +class WhereNowImpl( + public val pubnub: PubNubObjC, + public val uuid: String +): WhereNow { + override fun async(callback: Consumer>) { + pubnub.whereNowWithUuid( + uuid = uuid, + onSuccess = callback.onSuccessHandler { PNWhereNowResult(it as? List ?: emptyList()) }, + onFailure = callback.onFailureHandler() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index b4857e8a9..0c8d7c007 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -16,7 +16,6 @@ import cocoapods.PubNubSwift.PubNubSetUUIDMetadataEventMessageObjC import com.pubnub.api.JsonElement import com.pubnub.api.PubNub import com.pubnub.api.PubNubImpl -import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.files.PNDownloadableFile import com.pubnub.api.models.consumer.message_actions.PNMessageAction @@ -174,86 +173,86 @@ private fun createObjectEvent(from: PubNubObjectEventResultObjC?): PNObjectEvent @OptIn(ExperimentalForeignApi::class) private fun mapObjectMessage(from: PubNubObjectEventMessageObjC?): PNObjectEventMessage? { - if (from is PubNubSetUUIDMetadataEventMessageObjC) { - return PNSetUUIDMetadataEventMessage( - source = from.source(), - version = from.version(), - event = from.event(), - type = from.type(), - data = PNUUIDMetadata( - id = from.data().id(), - name = from.data().name(), - externalId = from.data().externalId(), - profileUrl = from.data().profileUrl(), - email = from.data().email(), - custom = from.data().custom() as? Map, - updated = from.data().updated(), - eTag = from.data().eTag(), - type = from.data().type(), - status = from.data().status() + when (from) { + is PubNubSetUUIDMetadataEventMessageObjC -> + return PNSetUUIDMetadataEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + data = PNUUIDMetadata( + id = from.data().id(), + name = from.data().name(), + externalId = from.data().externalId(), + profileUrl = from.data().profileUrl(), + email = from.data().email(), + custom = from.data().custom() as? Map, + updated = from.data().updated(), + eTag = from.data().eTag(), + type = from.data().type(), + status = from.data().status() + ) ) - ) - } else if (from is PubNubDeleteUUIDMetadataEventMessageObjC) { - return PNDeleteUUIDMetadataEventMessage( - source = from.source(), - version = from.version(), - event = from.event(), - type = from.type(), - uuid = from.uuid() - ) - } else if (from is PubNubSetChannelMetadataEventMessageObjC) { - return PNSetChannelMetadataEventMessage( - source = from.source(), - version = from.version(), - event = from.event(), - type = from.type(), - data = PNChannelMetadata( - id = from.data().id(), - name = from.data().name(), - description = from.data().descr(), - custom = from.data().custom() as? Map, - updated = from.data().updated(), - eTag = from.data().eTag(), - type = from.data().type(), - status = from.data().status() + is PubNubDeleteUUIDMetadataEventMessageObjC -> + return PNDeleteUUIDMetadataEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + uuid = from.uuid() ) - ) - } else if (from is PubNubDeleteChannelMetadataEventMessageObjC) { - return PNDeleteChannelMetadataEventMessage( - source = from.source(), - version = from.version(), - event = from.event(), - type = from.type(), - channel = from.channel() - ) - } else if (from is PubNubSetMembershipEventMessageObjC) { - return PNSetMembershipEventMessage( - source = from.source(), - version = from.version(), - event = from.event(), - type = from.type(), - data = PNSetMembershipEvent( - channel = from.data().channel(), - uuid = from.data().uuid(), - custom = from.data().custom() as Map?, //TODO this will probably fail - eTag = from.data().eTag(), - updated = from.data().updated(), - status = from.data().status() + is PubNubSetChannelMetadataEventMessageObjC -> + return PNSetChannelMetadataEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + data = PNChannelMetadata( + id = from.data().id(), + name = from.data().name(), + description = from.data().descr(), + custom = from.data().custom() as? Map, + updated = from.data().updated(), + eTag = from.data().eTag(), + type = from.data().type(), + status = from.data().status() + ) ) - ) - } else if (from is PubNubDeleteMembershipEventMessageObjC) { - return PNDeleteMembershipEventMessage( - source = from.source(), - version = from.version(), - event = from.event(), - type = from.type(), - data = PNDeleteMembershipEvent( - channelId = from.data().channelId(), - uuid = from.data().uuid() + is PubNubDeleteChannelMetadataEventMessageObjC -> + return PNDeleteChannelMetadataEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + channel = from.channel() ) - ) - } else { - return null + is PubNubSetMembershipEventMessageObjC -> + return PNSetMembershipEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + data = PNSetMembershipEvent( + channel = from.data().channel(), + uuid = from.data().uuid(), + custom = from.data().custom() as? Map, // TODO: This will fail, + eTag = from.data().eTag(), + updated = from.data().updated(), + status = from.data().status() + ) + ) + is PubNubDeleteMembershipEventMessageObjC -> + return PNDeleteMembershipEventMessage( + source = from.source(), + version = from.version(), + event = from.event(), + type = from.type(), + data = PNDeleteMembershipEvent( + channelId = from.data().channelId(), + uuid = from.data().uuid() + ) + ) + else -> return null } } From 69d65709b31a6ade77c7a89a1e3336b74c3ba899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 4 Jun 2024 12:22:23 +0000 Subject: [PATCH 12/62] Message payloads, metadata & status code in exceptions (#223) * Use large GitHub runner (#219) build(runner): change runner groups * Get message payload and metadata working in iOS and tests * Disallow DTDs in XML parser (#222) * Disallow DTDs in XML parser * [Common] Add status code to PubNubException * delete unneeded codable * Fix build --------- Co-authored-by: Serhii Mamontov --- .github/workflows/commands-handler.yml | 7 +- .github/workflows/release.yml | 12 +- .github/workflows/run-tests.yml | 23 +- .github/workflows/run-validations.yml | 17 +- build-logic/gradle-plugins/build.gradle.kts | 4 + .../gradle/PubNubKotlinMultiplatformPlugin.kt | 94 ++++++ pubnub-core/pubnub-core-api/build.gradle.kts | 29 +- .../pubnub-core-api/pubnub_core_api.podspec | 54 +++ .../kotlin/com/pubnub/api/JsonElement.kt | 23 +- .../kotlin/com/pubnub/api/PubNubException.kt | 7 +- .../kotlin/com/pubnub/api/JsonElement.ios.kt | 78 ++++- .../com/pubnub/api/PubNubException.ios.kt | 11 +- .../kotlin/com/pubnub/api/JsonElement.js.kt | 33 +- .../com/pubnub/api/PubNubException.js.kt | 12 +- .../kotlin/com/pubnub/api/JsonElement.jvm.kt | 32 +- .../kotlin/com/pubnub/api/PubNubException.kt | 9 +- .../endpoints/files/UploadFileEndpoint.kt | 2 + .../pubnub-kotlin-api/build.gradle.kts | 87 +---- .../pubnub_kotlin_api.podspec | 54 +++ .../kotlin/com/pubnub/api/Endpoint.ios.kt | 4 - .../api/v2/callbacks/EventListener.ios.kt | 21 +- .../kotlin/com/pubnub/kmp/abstractions.ios.kt | 2 +- .../kotlin/com/pubnub/kmp/factories.ios.kt | 30 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 26 +- .../api/v2/callbacks/EventListener.js.kt | 1 - .../pubnub-kotlin-test/build.gradle.kts | 72 +--- .../pubnub_kotlin_test.podspec | 54 +++ .../kotlin/com.pubnub.test/FakePubNub.kt | 312 +++++++++++------- .../kotlin/com/pubnub/kmp/platform.kt | 3 + .../com/pubnub/api/ChannelMetadataTest.kt | 4 +- .../kotlin/com/pubnub/api/MembersTest.kt | 1 + .../kotlin/com/pubnub/api/MembershipsTest.kt | 1 + .../kotlin/com/pubnub/api/PublishTest.kt | 156 ++++++++- .../com/pubnub/test/BaseIntegrationTest.kt | 12 +- .../kotlin/com.pubnub.test/FakePubNub.ios.kt | 39 +++ .../kotlin/com/pubnub/kmp/platform.ios.kt | 3 + .../kotlin/com.pubnub.test/FakePubNub.js.kt | 27 ++ .../kotlin/com/pubnub/kmp/platform.js.kt | 3 + .../kotlin/com.pubnub.test/FakePubNub.jvm.kt | 42 +++ .../kotlin/com/pubnub/kmp/platform.jvm.kt | 3 + 40 files changed, 1021 insertions(+), 383 deletions(-) create mode 100644 build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt create mode 100644 pubnub-core/pubnub-core-api/pubnub_core_api.podspec create mode 100644 pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec create mode 100644 pubnub-kotlin/pubnub-kotlin-test/pubnub_kotlin_test.podspec create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com/pubnub/kmp/platform.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com/pubnub/kmp/platform.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com/pubnub/kmp/platform.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com/pubnub/kmp/platform.jvm.kt diff --git a/.github/workflows/commands-handler.yml b/.github/workflows/commands-handler.yml index 0b5d4702b..48f71d24a 100644 --- a/.github/workflows/commands-handler.yml +++ b/.github/workflows/commands-handler.yml @@ -11,7 +11,8 @@ jobs: process: name: Process command if: github.event.issue.pull_request && endsWith(github.repository, '-private') != true - runs-on: ubuntu-latest + runs-on: + group: Default steps: - name: Check referred user id: user-check @@ -23,12 +24,12 @@ jobs: run: echo -e "\033[38;2;19;181;255mThis is regular commit which should be ignored.\033[0m" - name: Checkout repository if: steps.user-check.outputs.expected-user == 'true' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: token: ${{ secrets.GH_TOKEN }} - name: Checkout release actions if: steps.user-check.outputs.expected-user == 'true' - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: pubnub/client-engineering-deployment-tools ref: v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8bba68f43..e5850a795 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,13 +8,14 @@ on: jobs: check-release: name: Check release required - runs-on: ubuntu-latest if: github.event.pull_request.merged && endsWith(github.repository, '-private') != true + runs-on: + group: Default outputs: release: ${{ steps.check.outputs.ready }} steps: - name: Checkout actions - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: pubnub/client-engineering-deployment-tools ref: v1 @@ -27,17 +28,18 @@ jobs: token: ${{ secrets.GH_TOKEN }} publish: name: Publish package - runs-on: ubuntu-latest needs: check-release if: needs.check-release.outputs.release == 'true' + runs-on: + group: Default steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # This should be the same as the one specified for on.pull_request.branches ref: master - name: Checkout actions - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: pubnub/client-engineering-deployment-tools ref: v1 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4afd01fbe..38a41e131 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -7,19 +7,20 @@ on: jobs: tests: name: Integration and Unit tests - runs-on: ubuntu-latest + runs-on: + group: Default steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout actions - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: pubnub/client-engineering-deployment-tools ref: v1 token: ${{ secrets.GH_TOKEN }} path: .github/.release/actions - name: Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.gradle/caches @@ -35,7 +36,8 @@ jobs: uses: ./.github/.release/actions/actions/utils/fast-jobs-failure acceptance-tests: name: Acceptance tests - runs-on: ubuntu-latest + runs-on: + group: Default env: pubKey: somePubKey subKey: someSubKey @@ -46,9 +48,9 @@ jobs: serverMock: true steps: - name: Checkout project - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout mock-server action - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: pubnub/client-engineering-deployment-tools ref: v1 @@ -59,7 +61,7 @@ jobs: with: token: ${{ secrets.GH_TOKEN }} - name: Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.gradle/caches @@ -75,7 +77,7 @@ jobs: - name: Run acceptance tests (required) run: ./gradlew cucumber --tests RunMainCucumberTest -Dcucumber.features="../../sdk-specifications/features/" -i - name: Expose acceptance tests reports - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: always() with: name: acceptance-test-reports @@ -86,8 +88,9 @@ jobs: uses: ./.github/.release/actions/actions/utils/fast-jobs-failure all-tests: name: Tests - runs-on: ubuntu-latest needs: [tests, acceptance-tests] + runs-on: + group: Default steps: - name: Tests summary run: echo -e "\033[38;2;95;215;0m\033[1mAll tests successfully passed" diff --git a/.github/workflows/run-validations.yml b/.github/workflows/run-validations.yml index e5d39d233..5b7fc9cc4 100644 --- a/.github/workflows/run-validations.yml +++ b/.github/workflows/run-validations.yml @@ -13,12 +13,13 @@ defaults: jobs: pubnub-yml: name: "Validate .pubnub.yml" - runs-on: ubuntu-latest + runs-on: + group: Default steps: - name: Checkout project - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Checkout validator action - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: repository: pubnub/client-engineering-deployment-tools ref: v1 @@ -33,12 +34,13 @@ jobs: uses: ./.github/.release/actions/actions/utils/fast-jobs-failure build-validation: name: Validate build - runs-on: ubuntu-latest + runs-on: + group: Default steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.gradle/caches @@ -53,8 +55,9 @@ jobs: uses: ./.github/.release/actions/actions/utils/fast-jobs-failure all-validations: name: Validations - runs-on: ubuntu-latest needs: [pubnub-yml, build-validation] + runs-on: + group: Default steps: - name: Validations summary run: echo -e "\033[38;2;95;215;0m\033[1mAll validations passed" diff --git a/build-logic/gradle-plugins/build.gradle.kts b/build-logic/gradle-plugins/build.gradle.kts index 3ffddb56d..ab8ca4839 100644 --- a/build-logic/gradle-plugins/build.gradle.kts +++ b/build-logic/gradle-plugins/build.gradle.kts @@ -46,5 +46,9 @@ gradlePlugin { id = "pubnub.ios-simulator-test" implementationClass = "com.pubnub.gradle.PubNubIosSimulatorTestPlugin" } + register("pubnubMultiplatform") { + id = "pubnub.multiplatform" + implementationClass = "com.pubnub.gradle.PubNubKotlinMultiplatformPlugin" + } } } \ No newline at end of file diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt new file mode 100644 index 000000000..613e0e70a --- /dev/null +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt @@ -0,0 +1,94 @@ +package com.pubnub.gradle + +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.plugins.ExtensionAware +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.jetbrains.dokka.DokkaDefaults.moduleName +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper +import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension +import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin +import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType + +class PubNubKotlinMultiplatformPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + apply() + apply() + + // Kotlin + extensions.configure { + jvmToolchain(8) + + js { + browser { + } + binaries.executable() + } + jvm { + compilations.all { + it.compileTaskProvider.configure { + it.compilerOptions { + freeCompilerArgs.add("-Xexpect-actual-classes") + javaParameters.set(true) + } + } + } + } + + listOf( + iosArm64(), + // iosX64(), + iosSimulatorArm64(), + ).forEach { + it.binaries { + framework { + isStatic = true + } + } + } + + (this as? ExtensionAware)?.extensions?.configure { + ios.deploymentTarget = "14" + + // Required properties + // Specify the required Pod version here. Otherwise, the Gradle project version is used. + version = "1.0" + summary = "Some description for a Kotlin/Native module" + homepage = "Link to a Kotlin/Native module homepage" + + // Maps custom Xcode configuration to NativeBuildType + xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG + xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE + +// podfile = project.file(project.file("Sample Chat app/Podfile")) + + framework { + // Required properties + // Framework name configuration. Use this property instead of deprecated 'frameworkName' + + // Optional properties + // Specify the framework linking type. It's dynamic by default. + isStatic = true + transitiveExport = true + } + + pod("PubNubSwift") { + source = git("https://github.com/pubnub/swift") { + branch = "feat/kmp" + } +// headers = "PubNub/PubNub.h" +// source = path(rootProject.file("../../swift")) +// version = "7.1.0" + + moduleName = "PubNub" + extraOpts += listOf("-compiler-option", "-fmodules") + } + } + } + + } + } +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/build.gradle.kts b/pubnub-core/pubnub-core-api/build.gradle.kts index ed999f5b9..6371f5910 100644 --- a/pubnub-core/pubnub-core-api/build.gradle.kts +++ b/pubnub-core/pubnub-core-api/build.gradle.kts @@ -2,37 +2,10 @@ plugins { alias(libs.plugins.benmanes.versions) id("pubnub.shared") id("pubnub.dokka") - kotlin("multiplatform") + id("pubnub.multiplatform") } kotlin { - js() { - browser { - } - binaries.executable() - } - jvmToolchain(8) - jvm { - compilations.all { - compilerOptions.configure { - javaParameters.set(true) - } - } - } - - listOf( - iosArm64(), -// iosX64(), - iosSimulatorArm64(), - ).forEach { - it.binaries { - framework { - baseName = "PubNubKMP" - isStatic = true - } - } - } - sourceSets { val commonMain by getting { dependencies { diff --git a/pubnub-core/pubnub-core-api/pubnub_core_api.podspec b/pubnub-core/pubnub-core-api/pubnub_core_api.podspec new file mode 100644 index 000000000..124f07d68 --- /dev/null +++ b/pubnub-core/pubnub-core-api/pubnub_core_api.podspec @@ -0,0 +1,54 @@ +Pod::Spec.new do |spec| + spec.name = 'pubnub_core_api' + spec.version = '1.0' + spec.homepage = 'Link to a Kotlin/Native module homepage' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = 'Some description for a Kotlin/Native module' + spec.vendored_frameworks = 'build/cocoapods/framework/pubnub_core_api.framework' + spec.libraries = 'c++' + spec.ios.deployment_target = '14' + spec.dependency 'PubNubSwift' + + if !Dir.exist?('build/cocoapods/framework/pubnub_core_api.framework') || Dir.empty?('build/cocoapods/framework/pubnub_core_api.framework') + raise " + + Kotlin framework 'pubnub_core_api' doesn't exist yet, so a proper Xcode project can't be generated. + 'pod install' should be executed after running ':generateDummyFramework' Gradle task: + + ./gradlew :pubnub-core:pubnub-core-api:generateDummyFramework + + Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" + end + + spec.xcconfig = { + 'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO', + } + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':pubnub-core:pubnub-core-api', + 'PRODUCT_MODULE_NAME' => 'pubnub_core_api', + } + + spec.script_phases = [ + { + :name => 'Build pubnub_core_api', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt index f255615af..a506146eb 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt @@ -1,9 +1,22 @@ package com.pubnub.api expect abstract class JsonElement -//expect class JsonObject -expect fun JsonElement.asString(): String -//expect fun JsonElement.asNumber(): Number -expect fun JsonElement.asMap(): Map -//expect fun JsonElement.asList(): List +expect fun JsonElement.isNull(): Boolean +expect fun JsonElement.asList(): List? +expect fun JsonElement.asLong(): Long? +expect fun JsonElement.asDouble(): Double? +expect fun JsonElement.asNumber(): Number? +expect fun JsonElement.asBoolean(): Boolean? +expect fun JsonElement.asString(): String? +expect fun JsonElement.asMap(): Map? + + +//fun JsonElement.decode(): Any? { +// if (isNull()) return null +// return asMap()?.mapValues { it.value.decode() } +// ?: asList()?.map { it.decode() } +// ?: asNumber() +// ?: asBoolean() +// ?: asString() +//} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt index 26ef408d4..fcf550f83 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt @@ -9,8 +9,11 @@ package com.pubnub.api * @property statusCode HTTP status code. * @property affectedCall A reference to the affected call. Useful for calling [retry][Endpoint.retry]. */ -expect class PubNubException(pubnubError: PubNubError) : Exception { - constructor(errorMessage: String?) +expect class PubNubException(errorMessage: String?, cause: Throwable? = null) : Exception { + constructor(pubnubError: PubNubError, cause: Throwable? = null) + + val statusCode: Int + companion object { fun from(e: Throwable): PubNubException } diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt index 7d18a278f..ac181b984 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt @@ -1,11 +1,79 @@ +@file:OptIn(ExperimentalForeignApi::class) + package com.pubnub.api -actual abstract class JsonElement +import cocoapods.PubNubSwift.AnyJSONObjC +import kotlinx.cinterop.ExperimentalForeignApi + +actual abstract class JsonElement(val value: Any?) + +class JsonElementImpl(value: Any?) : JsonElement(value) + +actual fun JsonElement.asString(): String? { + return when (value) { + is AnyJSONObjC -> value.asString() + is String -> value + else -> null + } +} + +actual fun JsonElement.asMap(): Map? { + return when (value) { + is AnyJSONObjC -> (value.asMap() as Map).mapValues { + JsonElementImpl(it.value) + } + is Map<*, *> -> (value as Map).mapValues { JsonElementImpl(it.value) } + else -> null + } +} + +actual fun JsonElement.isNull(): Boolean { + return value == null || (value as? AnyJSONObjC)?.isNull() == true +} + +actual fun JsonElement.asList(): List? { + return when (value) { + is AnyJSONObjC -> value.asList()?.map { + JsonElementImpl(it) + } + is List<*> -> value.map { JsonElementImpl(it) } + else -> null + } +} + +actual fun JsonElement.asLong(): Long? { + return when (value) { + is AnyJSONObjC -> value.asInt()?.longValue + is Long -> value + is Int -> value.toLong() + is Boolean -> if (value) 1 else 0 + else -> null + } +} + +actual fun JsonElement.asBoolean(): Boolean? { + return when (value) { + is AnyJSONObjC -> value.asBool()?.boolValue + is Boolean -> value + else -> null + } +} -actual fun JsonElement.asString(): String { - return TODO() +actual fun JsonElement.asDouble(): Double? { + return when (value) { + is AnyJSONObjC -> value.asDouble()?.doubleValue + is Number -> value.toDouble() + is Boolean -> if (value) 1.0 else 0.0 + else -> null + } } -actual fun JsonElement.asMap(): Map { - TODO("Not yet implemented") +actual fun JsonElement.asNumber(): Number? { + println(value.toString() + " " + value!!::class) + return when (value) { + is AnyJSONObjC -> value.asNumber() as Number + is Number -> value + is Boolean -> if (value) 1 else 0 + else -> null + } } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt index 117e84624..38db51e3e 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt @@ -9,16 +9,21 @@ package com.pubnub.api * @property statusCode HTTP status code. * @property affectedCall A reference to the affected call. Useful for calling [retry][Endpoint.retry]. */ -actual class PubNubException actual constructor(errorMessage: String?): Exception(errorMessage) { +actual class PubNubException( + actual val statusCode: Int = 0, + errorMessage: String?, + cause: Throwable? +) : Exception(errorMessage, cause) { - actual constructor(pubnubError: PubNubError) : this(pubnubError.message) + actual constructor(errorMessage: String?, cause: Throwable?): this(statusCode = 0, errorMessage, cause) + actual constructor(pubnubError: PubNubError, cause: Throwable?) : this(statusCode = 0, pubnubError.message, cause) actual companion object { actual fun from(e: Throwable): PubNubException { return if (e is PubNubException) { e } else { - PubNubException(e.message) + PubNubException(e.message, e) } } } diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt index c619cf17b..dfbed626c 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt @@ -9,10 +9,35 @@ actual abstract class JsonElement(val value: Any?) class JsonElementImpl(value: Any?) : JsonElement(value) -actual fun JsonElement.asString(): String { - return value.toString() // todo kmp +actual fun JsonElement.asString(): String? { + return value as? String } -actual fun JsonElement.asMap(): Map { - return value.unsafeCast>().toMap().mapValues { JsonElementImpl(it.value) } // todo kmp +actual fun JsonElement.asMap(): Map? { + return value.unsafeCast>().toMap().mapValues { JsonElementImpl(it.value) } +} + +actual fun JsonElement.isNull(): Boolean { + return value == null +} + +actual fun JsonElement.asList(): List? { + return (value as Array<*>).map { JsonElementImpl(it) } +} + +actual fun JsonElement.asLong(): Long? { + return (value as? Number)?.toLong() ?: (value as? String)?.toLongOrNull() +} + +actual fun JsonElement.asBoolean(): Boolean? { + return value as? Boolean +} + +actual fun JsonElement.asDouble(): Double? { + println(value.toString() + " " + value!!::class) + return (value as? Number)?.toDouble() +} + +actual fun JsonElement.asNumber(): Number? { + return value as? Number } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt index 117e84624..6018b10b9 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt @@ -9,16 +9,22 @@ package com.pubnub.api * @property statusCode HTTP status code. * @property affectedCall A reference to the affected call. Useful for calling [retry][Endpoint.retry]. */ -actual class PubNubException actual constructor(errorMessage: String?): Exception(errorMessage) { +actual class PubNubException( + actual val statusCode: Int = 0, + errorMessage: String?, + cause: Throwable? +) : Exception(errorMessage, cause) { - actual constructor(pubnubError: PubNubError) : this(pubnubError.message) + actual constructor(errorMessage: String?, cause: Throwable?): this(statusCode = 0, errorMessage, cause) + actual constructor(pubnubError: PubNubError, cause: Throwable?) : this(statusCode = 0, pubnubError.message, cause) actual companion object { actual fun from(e: Throwable): PubNubException { return if (e is PubNubException) { e } else { - PubNubException(e.message) + val statusCode = (e.asDynamic().status?.statusCode as? Int) ?: 0 + PubNubException(statusCode, e.message, e) } } } diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt index 15829c9db..29f062419 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt @@ -2,10 +2,34 @@ package com.pubnub.api actual typealias JsonElement = com.google.gson.JsonElement -actual fun JsonElement.asString(): String { - return this.asString +actual fun JsonElement.asString(): String? { + return if (this.isJsonPrimitive && this.asJsonPrimitive.isString) this.asString else null } -actual fun JsonElement.asMap(): Map { - return this.asJsonObject.asMap() +actual fun JsonElement.asMap(): Map? { + return if (this.isJsonObject) this.asJsonObject.asMap() else null +} + +actual fun JsonElement.isNull(): Boolean { + return this.isJsonNull +} + +actual fun JsonElement.asList(): List? { + return if (this.isJsonArray) this.asJsonArray.asList() else null +} + +actual fun JsonElement.asLong(): Long? { + return if (this.isJsonPrimitive && this.asJsonPrimitive.isNumber) this.asLong else null +} + +actual fun JsonElement.asBoolean(): Boolean? { + return if (this.isJsonPrimitive && this.asJsonPrimitive.isBoolean) this.asBoolean else null +} + +actual fun JsonElement.asDouble(): Double? { + return if (this.isJsonPrimitive && this.asJsonPrimitive.isNumber) this.asDouble else null +} + +actual fun JsonElement.asNumber(): Number? { + return if (this.isJsonPrimitive && this.asJsonPrimitive.isNumber) this.asNumber else null } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt index 7d11ecc5e..6c6ebbabc 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt @@ -17,7 +17,7 @@ actual data class PubNubException( val errorMessage: String? = null, val pubnubError: PubNubError? = null, val jso: String? = null, - val statusCode: Int = 0, + actual val statusCode: Int = 0, val affectedCall: Call<*>? = null, val retryAfterHeaderValue: Int? = null, val affectedChannels: List = emptyList(), @@ -34,11 +34,14 @@ actual data class PubNubException( val clientRequest: Request, ) - actual constructor(errorMessage: String?) : this(errorMessage, pubnubError = null) + @JvmOverloads + actual constructor(errorMessage: String?, cause: Throwable?) : this(errorMessage, pubnubError = null, cause = cause) - actual constructor(pubnubError: PubNubError) : this( + @JvmOverloads + actual constructor(pubnubError: PubNubError, cause: Throwable?) : this( errorMessage = pubnubError.message, pubnubError = pubnubError, + cause = cause ) constructor(pubnubError: PubNubError, message: String) : this( diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/UploadFileEndpoint.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/UploadFileEndpoint.kt index 6c15a386f..bc51f3392 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/UploadFileEndpoint.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/UploadFileEndpoint.kt @@ -160,6 +160,8 @@ internal class UploadFileEndpoint( private fun Response.readErrorMessage(): String { val dbFactory = DocumentBuilderFactory.newInstance() + dbFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true) + dbFactory.isXIncludeAware = false val dBuilder = dbFactory.newDocumentBuilder() val doc = dBuilder.parse(errorBody()!!.byteStream()) doc.documentElement.normalize() diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index 5f1161853..1b0337254 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -1,88 +1,11 @@ -import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType - plugins { alias(libs.plugins.benmanes.versions) id("pubnub.shared") id("pubnub.dokka") - kotlin("multiplatform") - kotlin("native.cocoapods") + id("pubnub.multiplatform") } kotlin { - jvmToolchain(8) - js { - browser { - } - binaries.executable() - } - jvm { - compilations.all { - compileTaskProvider.configure { - compilerOptions { - freeCompilerArgs.add("-Xexpect-actual-classes") - javaParameters.set(true) - } - } - } - } - - listOf( - iosArm64(), -// iosX64(), - iosSimulatorArm64(), - ).forEach { - it.binaries { - framework { - baseName = "PubNubKMP" - isStatic = true - } - } - } - - cocoapods { - ios.deploymentTarget = "14" - - // Required properties - // Specify the required Pod version here. Otherwise, the Gradle project version is used. - version = "1.0" - summary = "Some description for a Kotlin/Native module" - homepage = "Link to a Kotlin/Native module homepage" - - // Optional properties - // Configure the Pod name here instead of changing the Gradle project name - name = "PubNubKMP" - - // Maps custom Xcode configuration to NativeBuildType - xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG - xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE - -// podfile = project.file(project.file("Sample Chat app/Podfile")) - - framework { - // Required properties - // Framework name configuration. Use this property instead of deprecated 'frameworkName' - baseName = "PubNubKMP" - - // Optional properties - // Specify the framework linking type. It's dynamic by default. - isStatic = true - export(project(":pubnub-core:pubnub-core-api")) - transitiveExport = true - } - - pod("PubNubSwift") { - source = git("https://github.com/pubnub/swift") { - branch = "feat/kmp" - } -// headers = "PubNub/PubNub.h" -// source = path(project.file("swift")) -// version = "7.1.0" - - moduleName = "PubNub" - extraOpts += listOf("-compiler-option", "-fmodules") - } - } - sourceSets { val commonMain by getting { dependencies { @@ -103,4 +26,12 @@ kotlin { } } } +} + +kotlin { + cocoapods { + framework { + export(project(":pubnub-core:pubnub-core-api")) + } + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec b/pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec new file mode 100644 index 000000000..b0dd0413b --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec @@ -0,0 +1,54 @@ +Pod::Spec.new do |spec| + spec.name = 'pubnub_kotlin_api' + spec.version = '1.0' + spec.homepage = 'Link to a Kotlin/Native module homepage' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = 'Some description for a Kotlin/Native module' + spec.vendored_frameworks = 'build/cocoapods/framework/pubnub_kotlin_api.framework' + spec.libraries = 'c++' + spec.ios.deployment_target = '14' + spec.dependency 'PubNubSwift' + + if !Dir.exist?('build/cocoapods/framework/pubnub_kotlin_api.framework') || Dir.empty?('build/cocoapods/framework/pubnub_kotlin_api.framework') + raise " + + Kotlin framework 'pubnub_kotlin_api' doesn't exist yet, so a proper Xcode project can't be generated. + 'pod install' should be executed after running ':generateDummyFramework' Gradle task: + + ./gradlew :pubnub-kotlin:pubnub-kotlin-api:generateDummyFramework + + Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" + end + + spec.xcconfig = { + 'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO', + } + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':pubnub-kotlin:pubnub-kotlin-api', + 'PRODUCT_MODULE_NAME' => 'pubnub_kotlin_api', + } + + spec.script_phases = [ + { + :name => 'Build pubnub_kotlin_api', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt index aaba6b9a9..304ffe45b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt @@ -22,10 +22,6 @@ fun Consumer>.onSuccessReturnValue(value: T) : () -> Unit { return fun() { accept(Result.success(value)) } } -fun Consumer>.onSuccessReturnValue(value: T) : () -> Unit { - return fun() { accept(Result.success(value)) } -} - fun Consumer>.onFailureHandler(mapper: (NSError?) -> Throwable = { error: NSError? -> PubNubException(errorMessage = error?.localizedDescription) } ): (NSError?) -> Unit { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt index 700a9115f..b73a157e0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -1,7 +1,14 @@ package com.pubnub.api.v2.callbacks import cocoapods.PubNubSwift.EventListenerObjC +import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import kotlinx.cinterop.ExperimentalForeignApi /** @@ -11,9 +18,21 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) actual interface EventListener : Listener { + val onMessage: (PubNub, PNMessageResult) -> Unit + val onPresence: (PubNub, PNPresenceEventResult) -> Unit + val onSignal: (PubNub, PNSignalResult) -> Unit + val onMessageAction: (PubNub, PNMessageActionResult) -> Unit + val onObjects: (PubNub, PNObjectEventResult) -> Unit + val onFile: (PubNub, PNFileEventResult) -> Unit val underlying: EventListenerObjC } @OptIn(ExperimentalForeignApi::class) class EventListenerImpl( - override val underlying: EventListenerObjC + override val underlying: EventListenerObjC, + override val onMessage: (PubNub, PNMessageResult) -> Unit, + override val onPresence: (PubNub, PNPresenceEventResult) -> Unit, + override val onSignal: (PubNub, PNSignalResult) -> Unit, + override val onMessageAction: (PubNub, PNMessageActionResult) -> Unit, + override val onObjects: (PubNub, PNObjectEventResult) -> Unit, + override val onFile: (PubNub, PNFileEventResult) -> Unit ): EventListener {} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt index ba8b9b040..cdcdc2a32 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt @@ -1,3 +1,3 @@ package com.pubnub.kmp -actual class CustomObject \ No newline at end of file +actual class CustomObject(private val value: Any) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 0c8d7c007..47e7001c5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -13,7 +13,7 @@ import cocoapods.PubNubSwift.PubNubPresenceEventResultObjC import cocoapods.PubNubSwift.PubNubSetChannelMetadataEventMessageObjC import cocoapods.PubNubSwift.PubNubSetMembershipEventMessageObjC import cocoapods.PubNubSwift.PubNubSetUUIDMetadataEventMessageObjC -import com.pubnub.api.JsonElement +import com.pubnub.api.JsonElementImpl import com.pubnub.api.PubNub import com.pubnub.api.PubNubImpl import com.pubnub.api.models.consumer.PNStatus @@ -58,6 +58,12 @@ actual fun createEventListener( onFile: (PubNub, PNFileEventResult) -> Unit ): EventListener { return EventListenerImpl( + onMessage = onMessage, + onMessageAction = onMessageAction, + onPresence = onPresence, + onObjects = onObjects, + onFile = onFile, + onSignal = onSignal, underlying = EventListenerObjC( onMessage = { onMessage(pubnub, createMessageResult(it)) }, onPresence = { presenceEvents -> createPresenceEventResults(presenceEvents).forEach { onPresence(pubnub, it) } }, @@ -76,10 +82,10 @@ private fun createMessageResult(from: PubNubMessageObjC?): PNMessageResult { channel = from!!.channel(), subscription = from.subscription(), timetoken = from.published().toLong(), - userMetadata = from.metadata() as? JsonElement, + userMetadata = JsonElementImpl(from.metadata()), publisher = from.publisher() ), - message = from.payload() as JsonElement, + message = JsonElementImpl(from.payload()), error = null // TODO: Map error from Swift SDK to PubNubError in Kotlin SDK ) } @@ -91,10 +97,10 @@ private fun createSignalResult(from: PubNubMessageObjC?): PNSignalResult { channel = from!!.channel(), subscription = from.subscription(), timetoken = from.published().toLong(), - userMetadata = from.metadata() as? JsonElement, + userMetadata = JsonElementImpl(from.metadata()), publisher = from.publisher() ), - message = from.payload() as JsonElement + message = JsonElementImpl(from.payload()) ) } @@ -119,14 +125,14 @@ private fun createMessageActionResult(from: PubNubMessageActionObjC?): PNMessage @OptIn(ExperimentalForeignApi::class) private fun createPresenceEventResults(from: List<*>?): List { - return (from as? List)?.let { + return (from as List).let { it.map { item: PubNubPresenceEventResultObjC -> PNPresenceEventResult( event = item.event(), uuid = item.uuid(), timestamp = item.timetoken()?.longValue, occupancy = item.occupancy()?.intValue, - state = item.state() as JsonElement, + state = JsonElementImpl(item.state()), channel = item.channel() ?: "", subscription = item.subscription(), timetoken = item.timetoken()?.longValue, @@ -134,10 +140,10 @@ private fun createPresenceEventResults(from: List<*>?): List, timeout = item.timeout() as? List, hereNowRefresh = item.refreshHereNow()?.boolValue, - userMetadata = item.userMetadata() + userMetadata = JsonElementImpl(item.userMetadata()) ) } - } ?: emptyList() + } } @OptIn(ExperimentalForeignApi::class) @@ -147,7 +153,7 @@ private fun createFileEventResult(from: PubNubFileEventResultObjC?): PNFileEvent timetoken = from.timetoken()?.longValue, publisher = from.publisher(), message = from.message(), - jsonMessage = from.message() as JsonElement, + jsonMessage = JsonElementImpl(from.message()), file = PNDownloadableFile( id = from.file().id(), name = from.file().name(), @@ -164,7 +170,7 @@ private fun createObjectEvent(from: PubNubObjectEventResultObjC?): PNObjectEvent channel = from!!.channel(), subscription = from.subscription(), timetoken = from.timetoken()?.longValue, - userMetadata = from.userMetadata() as? JsonElement, + userMetadata = JsonElementImpl(from.userMetadata()), publisher = from.publisher(), ), extractedMessage = it ) @@ -264,5 +270,5 @@ actual fun createStatusListener( } actual fun createCustomObject(map: Map): CustomObject { - TODO("Not yet implemented") + return CustomObject(map) } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 75de95799..aa90dcbb8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -137,10 +137,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ttl: Int? ): Publish { return PublishImpl(jsPubNub, createJsObject { - this.message = message + this.message = message.adjustCollectionTypes()!! this.channel = channel this.storeInHistory = shouldStore - this.meta = if (meta is CustomObjectImpl) { meta.toJsObject() } else meta + this.meta = meta.adjustCollectionTypes() this.sendByPost = usePost this.ttl = ttl }) @@ -777,6 +777,28 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } +private fun Any?.adjustCollectionTypes(): Any? { + return when (this) { + is Map<*, *> -> { + val json = json() + entries.forEach { + json[it.key.toString()] = it.value.adjustCollectionTypes() + } + json + } + is Collection<*> -> { + this.map { it.adjustCollectionTypes() }.toTypedArray() + } + is Array<*> -> { + this.map { it.adjustCollectionTypes() }.toTypedArray() + } + is Long -> { + return toString() + } + else -> this + } +} + fun UUIDMetadata( name: Optional, externalId: Optional, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt index 89cd32a10..e887dd21f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt @@ -6,5 +6,4 @@ import com.pubnub.api.callbacks.Listener * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -//actual interface EventListener actual interface EventListener : Listener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts index 59e459861..b555cdb7c 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -1,24 +1,19 @@ import com.codingfeline.buildkonfig.compiler.FieldSpec.Type -import org.jetbrains.dokka.DokkaDefaults.moduleName -import org.jetbrains.kotlin.builtins.StandardNames.FqNames.target import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable import java.util.Properties -import kotlin.time.Duration.Companion.seconds -import kotlin.time.toJavaDuration plugins { alias(libs.plugins.benmanes.versions) id("pubnub.shared") id("pubnub.ios-simulator-test") - kotlin("multiplatform") - kotlin("native.cocoapods") + id("pubnub.multiplatform") + id("com.codingfeline.buildkonfig") version "0.15.1" } kotlin { - jvmToolchain(8) js { // compilations.all { // compileTaskProvider.configure { @@ -39,25 +34,8 @@ kotlin { } } } - binaries.executable() - } - jvm { - compilations.all { - compileTaskProvider.configure { - compilerOptions { - freeCompilerArgs.add("-Xexpect-actual-classes") - javaParameters.set(true) - } - } - } } - listOf( - iosArm64(), -// iosX64(), - iosSimulatorArm64(), - ) - sourceSets { val commonMain by getting { dependencies { @@ -76,54 +54,20 @@ kotlin { } } - val jvmTest by getting { + val jvmMain by getting { dependencies { - implementation(project(":pubnub-kotlin:pubnub-kotlin-impl")) + implementation(project(":pubnub-core:pubnub-core-impl")) } } - } - - cocoapods { - ios.deploymentTarget = "14" - - // Required properties - // Specify the required Pod version here. Otherwise, the Gradle project version is used. - version = "1.0" - summary = "Some description for a Kotlin/Native module" - homepage = "Link to a Kotlin/Native module homepage" - - // Optional properties - // Configure the Pod name here instead of changing the Gradle project name - name = "PubNubKMPTest" - - // Maps custom Xcode configuration to NativeBuildType - xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG - xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE - - framework { - // Required properties - // Framework name configuration. Use this property instead of deprecated 'frameworkName' - baseName = "PubNubKMPTest" - - // Optional properties - // Specify the framework linking type. It's dynamic by default. - isStatic = true - - export(":pubnub-kotlin:pubnub-kotlin-api") - export(":pubnub-core:pubnub-core-api") - transitiveExport = true - } - pod("PubNubSwift") { - source = git("https://github.com/pubnub/swift") { - branch = "feat/kmp" + val jvmTest by getting { + dependencies { + implementation(project(":pubnub-kotlin:pubnub-kotlin-impl")) } - - moduleName = "PubNub" - extraOpts += listOf("-compiler-option", "-fmodules") } } + targets.withType { if (konanTarget.family.isAppleFamily) { binaries.withType { diff --git a/pubnub-kotlin/pubnub-kotlin-test/pubnub_kotlin_test.podspec b/pubnub-kotlin/pubnub-kotlin-test/pubnub_kotlin_test.podspec new file mode 100644 index 000000000..b0edffe07 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/pubnub_kotlin_test.podspec @@ -0,0 +1,54 @@ +Pod::Spec.new do |spec| + spec.name = 'pubnub_kotlin_test' + spec.version = '1.0' + spec.homepage = 'Link to a Kotlin/Native module homepage' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = 'Some description for a Kotlin/Native module' + spec.vendored_frameworks = 'build/cocoapods/framework/pubnub_kotlin_test.framework' + spec.libraries = 'c++' + spec.ios.deployment_target = '14' + spec.dependency 'PubNubSwift' + + if !Dir.exist?('build/cocoapods/framework/pubnub_kotlin_test.framework') || Dir.empty?('build/cocoapods/framework/pubnub_kotlin_test.framework') + raise " + + Kotlin framework 'pubnub_kotlin_test' doesn't exist yet, so a proper Xcode project can't be generated. + 'pod install' should be executed after running ':generateDummyFramework' Gradle task: + + ./gradlew :pubnub-kotlin:pubnub-kotlin-test:generateDummyFramework + + Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" + end + + spec.xcconfig = { + 'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO', + } + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':pubnub-kotlin:pubnub-kotlin-test', + 'PRODUCT_MODULE_NAME' => 'pubnub_kotlin_test', + } + + spec.script_phases = [ + { + :name => 'Build pubnub_kotlin_test', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt index a0e11213d..8c74ce261 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt @@ -1,88 +1,99 @@ -//package com.pubnub.test -// -//import com.pubnub.api.JsonElement -//import com.pubnub.api.PubNub -//import com.pubnub.api.callbacks.Listener -//import com.pubnub.api.endpoints.DeleteMessages -//import com.pubnub.api.endpoints.FetchMessages -//import com.pubnub.api.endpoints.MessageCounts -//import com.pubnub.api.endpoints.Time -//import com.pubnub.api.endpoints.access.GrantToken -//import com.pubnub.api.endpoints.access.RevokeToken -//import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup -//import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup -//import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup -//import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup -//import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup -//import com.pubnub.api.endpoints.files.DeleteFile -//import com.pubnub.api.endpoints.files.GetFileUrl -//import com.pubnub.api.endpoints.files.ListFiles -//import com.pubnub.api.endpoints.files.PublishFileMessage -//import com.pubnub.api.endpoints.message_actions.AddMessageAction -//import com.pubnub.api.endpoints.message_actions.GetMessageActions -//import com.pubnub.api.endpoints.message_actions.RemoveMessageAction -//import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata -//import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata -//import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata -//import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata -//import com.pubnub.api.endpoints.objects.member.GetChannelMembers -//import com.pubnub.api.endpoints.objects.member.ManageChannelMembers -//import com.pubnub.api.endpoints.objects.membership.GetMemberships -//import com.pubnub.api.endpoints.objects.membership.ManageMemberships -//import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata -//import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata -//import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata -//import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata -//import com.pubnub.api.endpoints.presence.GetState -//import com.pubnub.api.endpoints.presence.HereNow -//import com.pubnub.api.endpoints.presence.SetState -//import com.pubnub.api.endpoints.presence.WhereNow -//import com.pubnub.api.endpoints.pubsub.Publish -//import com.pubnub.api.endpoints.pubsub.Signal -//import com.pubnub.api.endpoints.push.AddChannelsToPush -//import com.pubnub.api.endpoints.push.ListPushProvisions -//import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice -//import com.pubnub.api.endpoints.push.RemoveChannelsFromPush -//import com.pubnub.api.enums.PNPushEnvironment -//import com.pubnub.api.enums.PNPushType -//import com.pubnub.api.models.consumer.PNBoundedPage -//import com.pubnub.api.models.consumer.PNPublishResult -//import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant -//import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant -//import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant -//import com.pubnub.api.models.consumer.message_actions.PNMessageAction -//import com.pubnub.api.models.consumer.objects.PNKey -//import com.pubnub.api.models.consumer.objects.PNMemberKey -//import com.pubnub.api.models.consumer.objects.PNMembershipKey -//import com.pubnub.api.models.consumer.objects.PNPage -//import com.pubnub.api.models.consumer.objects.PNSortKey -//import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata -//import com.pubnub.api.models.consumer.objects.member.MemberInput -//import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel -//import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput -//import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -//import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -//import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -//import com.pubnub.api.models.consumer.pubsub.BasePubSubResult -//import com.pubnub.api.models.consumer.pubsub.PNEvent -//import com.pubnub.api.models.consumer.pubsub.PNMessageResult -//import com.pubnub.api.v2.PNConfiguration -//import com.pubnub.api.v2.callbacks.Consumer -//import com.pubnub.api.v2.callbacks.EventListener -//import com.pubnub.api.v2.callbacks.Result -//import com.pubnub.api.v2.callbacks.StatusListener -//import com.pubnub.kmp.CustomObject -//import kotlinx.coroutines.CoroutineScope -//import kotlinx.coroutines.SupervisorJob -//import kotlinx.coroutines.flow.MutableSharedFlow -//import kotlinx.coroutines.flow.mapNotNull -//import kotlinx.coroutines.launch -//import kotlinx.datetime.Clock -//import kotlinx.datetime.Instant -//import kotlin.coroutines.EmptyCoroutineContext -//import kotlin.time.Duration.Companion.minutes -// -// +package com.pubnub.test + +import com.pubnub.api.JsonElement +import com.pubnub.api.PubNub +import com.pubnub.api.asMap +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.endpoints.DeleteMessages +import com.pubnub.api.endpoints.FetchMessages +import com.pubnub.api.endpoints.MessageCounts +import com.pubnub.api.endpoints.Time +import com.pubnub.api.endpoints.access.GrantToken +import com.pubnub.api.endpoints.access.RevokeToken +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.GetFileUrl +import com.pubnub.api.endpoints.files.ListFiles +import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.message_actions.AddMessageAction +import com.pubnub.api.endpoints.message_actions.GetMessageActions +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +import com.pubnub.api.endpoints.objects.member.GetChannelMembers +import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +import com.pubnub.api.endpoints.objects.membership.GetMemberships +import com.pubnub.api.endpoints.objects.membership.ManageMemberships +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +import com.pubnub.api.endpoints.presence.GetState +import com.pubnub.api.endpoints.presence.HereNow +import com.pubnub.api.endpoints.presence.SetState +import com.pubnub.api.endpoints.presence.WhereNow +import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.endpoints.push.AddChannelsToPush +import com.pubnub.api.endpoints.push.ListPushProvisions +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.PNPublishResult +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNMemberKey +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.objects.member.MemberInput +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.api.models.consumer.pubsub.BasePubSubResult +import com.pubnub.api.models.consumer.pubsub.PNEvent +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.kmp.CustomObject +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.SupervisorJob +import kotlinx.coroutines.flow.MutableSharedFlow +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.collectLatest +import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.mapNotNull +import kotlinx.coroutines.flow.scan +import kotlinx.coroutines.flow.transformLatest +import kotlinx.coroutines.flow.update +import kotlinx.coroutines.launch +import kotlinx.datetime.Clock +import kotlinx.datetime.Instant +import kotlin.time.Duration.Companion.minutes + + +expect fun EventListener.emit(pubnub: PubNub, event: PNEvent) +expect fun StatusListener.emit(pubnub: PubNub, status: PNStatus) +expect fun Any.toJsonElement(): JsonElement + //class FakePubNub(override val configuration: PNConfiguration) : PubNub { // // val scope = CoroutineScope(SupervisorJob()) @@ -90,7 +101,7 @@ // fun Long.toEpochSeconds() = this / 10000000 // fun generateTimetoken() = Clock.System.now().toEpochMilliseconds() * 10000 // -// val events = MutableSharedFlow(100, 10) +// val events = MutableSharedFlow(100, 100) // val subscriptionStream = events.mapNotNull { // val tt = it.timetoken ?: return@mapNotNull null // if (Clock.System.now() < Instant.fromEpochSeconds(tt.toEpochSeconds()) - 10.minutes) { @@ -100,24 +111,71 @@ // } // } // +// private val subscribedChannelAndGroups = MutableStateFlow, Set>>(Pair(emptySet(), emptySet())) +// private val timetoken = MutableSharedFlow() +// +// init { +// scope.launch { +// subscribedChannelAndGroups.scan(Pair(setOf(), setOf())) { last: Pair, Set>, next: Pair, Set> -> +// if (last.first.isEmpty() && last.second.isEmpty() && (next.first.isNotEmpty() || next.second.isNotEmpty())) { +// //emit connected +// } else if (next.first.isEmpty() && next.second.isEmpty() && (last.first.isNotEmpty() || last.second.isNotEmpty())) { +// timetoken.emit(0) +// //emit disconnected +// } else { +// //emit changed +// } +// next +// }.collectLatest { subscriptions: Pair, Set> -> +// events.collect { event: PNEvent -> +// if (event.channel in subscriptions.first) { +// listeners.value.filterIsInstance().forEach { +// it.emit(this@FakePubNub, event) +// } +// } +// } +// } +// } +// } +// +// // val messages: MutableList = mutableListOf() // val userMetadata: MutableMap = mutableMapOf() // val channelMetadata: MutableMap = mutableMapOf() // +// private val listeners = MutableStateFlow(setOf()) +// // override fun addListener(listener: EventListener) { -// TODO("Not yet implemented") +// listeners.update { previousSet -> +// buildSet { +// addAll(previousSet) +// add(listener) +// } +// } // } // // override fun addListener(listener: StatusListener) { -// TODO("Not yet implemented") +// listeners.update { previousSet -> +// buildSet { +// addAll(previousSet) +// add(listener) +// } +// } // } // // override fun removeListener(listener: Listener) { -// TODO("Not yet implemented") +// listeners.update { previousSet -> +// buildSet { +// addAll(previousSet) +// remove(listener) +// } +// } // } // // override fun removeAllListeners() { -// TODO("Not yet implemented") +// listeners.update { +// emptySet() +// } // } // // override fun publish( @@ -137,9 +195,9 @@ // channel, // null, // generateTimetoken(), -// null, +// meta?.toJsonElement(), // configuration.userId.value -// ), message, null +// ), message.toJsonElement(), null // )) // } // } @@ -155,11 +213,11 @@ // } // // override fun getSubscribedChannels(): List { -// TODO("Not yet implemented") +// return subscribedChannelAndGroups.value.first.toList() // } // // override fun getSubscribedChannelGroups(): List { -// TODO("Not yet implemented") +// return subscribedChannelAndGroups.value.second.toList() // } // // override fun addPushNotificationsOnChannels( @@ -340,7 +398,7 @@ // externalId ?: b?.externalId, // profileUrl ?: b?.profileUrl, // email ?: b?.email, -// custom ?: b?.custom, +// custom?.toJsonElement()?.asMap() ?: b?.custom, // Clock.System.now().toString(), // null, // type ?: b?.type, @@ -407,21 +465,6 @@ // TODO("Not yet implemented") // } // -// override fun manageMemberships( -// channelsToSet: List, -// channelsToRemove: List, -// uuid: String?, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeChannelDetails: PNChannelDetailsLevel? -// ): ManageMemberships { -// TODO("Not yet implemented") -// } -// // override fun getChannelMembers( // channel: String, // limit: Int?, @@ -463,21 +506,6 @@ // TODO("Not yet implemented") // } // -// override fun manageChannelMembers( -// channel: String, -// uuidsToSet: Collection, -// uuidsToRemove: Collection, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeUUIDDetails: PNUUIDDetailsLevel? -// ): ManageChannelMembers { -// TODO("Not yet implemented") -// } -// // override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { // TODO("Not yet implemented") // } @@ -508,11 +536,41 @@ // withPresence: Boolean, // withTimetoken: Long // ) { -// TODO("Not yet implemented") +// subscribedChannelAndGroups.update { existingSubscriptions -> +// Pair( +// buildSet { +// addAll(existingSubscriptions.first) +// addAll(channels) +// if (withPresence) { +// addAll(channels.map { "${it}-pnpres" }) +// } +// }, +// buildSet { +// addAll(existingSubscriptions.second) +// addAll(channelGroups) +// if (withPresence) { +// addAll(channelGroups.map { "${it}-pnpres" }) +// } +// } +// ) +// } // } // // override fun unsubscribe(channels: List, channelGroups: List) { -// TODO("Not yet implemented") +// subscribedChannelAndGroups.update { existingSubscriptions -> +// Pair( +// buildSet { +// addAll(existingSubscriptions.first) +// removeAll(channels.toSet()) +// removeAll(channels.map { "${it}-pnpres" }.toSet()) +// }, +// buildSet { +// addAll(existingSubscriptions.second) +// removeAll(channelGroups.toSet()) +// removeAll(channelGroups.map { "${it}-pnpres" }.toSet()) +// } +// ) +// } // } // // override fun setToken(token: String?) { diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com/pubnub/kmp/platform.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com/pubnub/kmp/platform.kt new file mode 100644 index 000000000..1f697c541 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com/pubnub/kmp/platform.kt @@ -0,0 +1,3 @@ +package com.pubnub.kmp + +internal expect val PLATFORM: String \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt index 223d63c47..f7242c3d5 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt @@ -11,6 +11,7 @@ import com.pubnub.test.await import com.pubnub.test.randomString import com.pubnub.test.test import kotlinx.coroutines.test.runTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith @@ -97,9 +98,10 @@ class ChannelMetadataTest : BaseIntegrationTest() { pubnub.removeChannelMetadata(channel).await() // then - assertFailsWith { + val exception = assertFailsWith { pubnub.getChannelMetadata(channel).await() } + assertEquals(404, exception.statusCode) } @Test diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt index 846a51540..fe8110519 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt @@ -18,6 +18,7 @@ import com.pubnub.test.await import com.pubnub.test.randomString import com.pubnub.test.test import kotlinx.coroutines.test.runTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt index 709eb996f..18432d95a 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt @@ -16,6 +16,7 @@ import com.pubnub.test.await import com.pubnub.test.randomString import com.pubnub.test.test import kotlinx.coroutines.test.runTest +import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt index b07cae35e..91ef324d7 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt @@ -1,34 +1,151 @@ package com.pubnub.api +import com.pubnub.kmp.PLATFORM import com.pubnub.kmp.createCustomObject import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await import com.pubnub.test.test +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.withContext +import kotlin.js.JsExport import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue import kotlin.time.Duration.Companion.seconds +@JsExport +data class ABC ( + val aaa: Boolean = false, + val bbb: Int = 123, + val ccc: String = "platform: $PLATFORM" +) + class PublishTest : BaseIntegrationTest() { private val channel = "myChannel" @Test - fun can_publish_message() = + fun can_publish_message_string() = runTest(timeout = 10.seconds) { val result = pubnub.publish(channel, "some message").await() assertTrue { result.timetoken > 0 } } + @Test + fun can_publish_message_map() = + runTest(timeout = 10.seconds) { + val result = pubnub.publish(channel, mapOf("platform" to PLATFORM, "otherKey" to 123, "another" to true)).await() + assertTrue { result.timetoken > 0 } + } + + + @Test + fun can_publish_message_object() = + runTest(timeout = 10.seconds) { + val result = pubnub.publish(channel, ABC()).await() + assertTrue { result.timetoken > 0 } + } + @Test fun can_receive_message_with_object_metadata() = runTest(timeout = 10.seconds) { pubnub.test(backgroundScope) { - pubnub.awaitSubscribe(listOf(channel)) - pubnub.publish(channel, "some message", createCustomObject(mapOf("aa" to "bb"))).await() +// pubnub.awaitSubscribe(listOf(channel)) + pubnub.subscribe(listOf(channel)) + withContext(Dispatchers.Default) { + delay(2000) + } + val mapData = mapOf( + "stringValue" to "bbb", + "mapValue" to mapOf("innerKey" to false), + "booleanValue" to true, + "numberValue" to 124, + "float" to 1.3, + "floatThatCanBeBool" to 1.0, + "longValue" to 1000L, + "listValue" to listOf(123, "aaa", mapOf("innerK" to "innerV")) + ) + pubnub.publish(channel, "some message", createCustomObject(mapData)).await() val result = nextMessage() assertEquals("some message", result.message.asString()) - assertEquals(mapOf("aa" to "bb"), result.userMetadata?.asMap()?.mapValues { it.value.asString() }) + deepCompare(mapData, result.userMetadata!!) +// assertEquals(mapOf("aa" to "bb"), result.userMetadata?.asMap()?.mapValues { it.value.asString() }) + } + } + + @Test + fun can_receive_message_with_primitive_payload() = runTest(timeout = 10.seconds) { + pubnub.test(backgroundScope) { +// pubnub.awaitSubscribe(listOf(channel)) + pubnub.subscribe(listOf(channel)) + withContext(Dispatchers.Default) { + delay(2000) + } + pubnub.publish( + channel, + 111, + ).await() + val result = nextMessage().message + assertEquals(111, result.asLong()) + +// pubnub.publish( // TODO JS doesn't support this? +// channel, +// false, +// ).await() +// val result2 = nextMessage().message +// assertEquals(false, result2.asBoolean()) + } + } + + @Test + fun can_receive_message_with_map_payload() = runTest(timeout = 10.seconds) { + pubnub.test(backgroundScope) { +// pubnub.awaitSubscribe(listOf(channel)) + pubnub.subscribe(listOf(channel)) + withContext(Dispatchers.Default) { + delay(2000) + } + val mapData = mapOf( + "stringValue" to "bbb", + "mapValue" to mapOf("innerKey" to false), + "booleanValue" to true, + "numberValue" to 124, + "longValue" to 1000L, + "listValue" to listOf(123, "aaa", mapOf("innerK" to "innerV")) + ) + pubnub.publish( + channel, + mapData, + ).await() + val result = nextMessage().message + deepCompare(mapData, result) + } + } + + @Test + fun can_receive_message_with_payload_with_floats() = runTest(timeout = 10.seconds) { + pubnub.test(backgroundScope) { +// pubnub.awaitSubscribe(listOf(channel)) + pubnub.subscribe(listOf(channel)) + withContext(Dispatchers.Default) { + delay(2000) + } + val mapData = mapOf( + "floatValue" to 1.23f, + "doubleValue" to 1.23, + "otherValue" to 1.0f, + "otherValue1" to 1.0, + "otherValue3" to 0.0, + "otherValue4" to 0.0f, + "otherValue5" to 2.0, + ) + pubnub.publish( + channel, + mapData, + ).await() + val result = nextMessage().message + deepCompare(mapData, result) } } @@ -49,3 +166,34 @@ class PublishTest : BaseIntegrationTest() { } } } + + +private fun deepCompare(expected: Any?, actual: JsonElement) { +// println("e: " + expected.toString() + " " + expected!!::class) +// println("a: " + actual.toString()) + if (expected is Map<*, *>) { + val actualMap = actual.asMap()!! +// println(actualMap) + expected.forEach { +// println(it.key.toString() + " " + actualMap[it.key]) + deepCompare(it.value, actualMap[it.key]!!) + } + } else if (expected is List<*>) { + val actualList = actual.asList()!! + expected.forEachIndexed { index: Int, value: Any? -> + deepCompare(value, actualList[index]) + } + } else if (expected is Double) { // Double must be first, then Long for JS, as all number types except Long are the same in JS + assertEquals(expected, actual.asDouble()!!, 0.01) + } else if (expected is Long) { + assertEquals(expected, actual.asLong()!!) + } else if (expected is Int) { + assertEquals(expected.toLong(), actual.asLong()!!) + } else if (expected is Float) { + assertEquals(expected.toDouble(), actual.asDouble()!!, 0.01) + } else if (expected is String) { + assertEquals(expected, actual.asString()!!) + } else if (expected == null){ + assertTrue { actual.isNull() } + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt index da4568cdd..bf97b59c1 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt @@ -56,11 +56,11 @@ class PubNubTest( private val messageQueue = Channel(10) private val statusQueue = Channel(10) - private val statusVerificationListener = createStatusListener(pubNub) { _, status -> - backgroundScope.launch { - statusQueue.send(status) - } - } +// private val statusVerificationListener = createStatusListener(pubNub) { _, status -> +// backgroundScope.launch { +// statusQueue.send(status) +// } +// } private val eventVerificationListener = createEventListener( pubNub, onMessage = { _, event -> @@ -98,7 +98,7 @@ class PubNubTest( init { pubNub.addListener(eventVerificationListener) - pubNub.addListener(statusVerificationListener) +// pubNub.addListener(statusVerificationListener) } suspend fun PubNub.awaitSubscribe( diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt b/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt new file mode 100644 index 000000000..a0bce4fa9 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt @@ -0,0 +1,39 @@ +package com.pubnub.test + +import com.pubnub.api.JsonElement +import com.pubnub.api.PubNub +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.pubsub.PNEvent +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener + +actual fun EventListener.emit( + pubnub: PubNub, + event: PNEvent +) { + when (event) { + is PNMessageResult -> this.onMessage(pubnub, event) + is PNMessageActionResult -> this.onMessageAction(pubnub, event) + is PNFileEventResult -> this.onFile(pubnub, event) + is PNObjectEventResult -> this.onObjects(pubnub, event) + is PNSignalResult -> this.onSignal(pubnub, event) + is PNPresenceEventResult -> this.onPresence(pubnub, event) + } +} + +actual fun Any.toJsonElement(): JsonElement { + TODO("Not yet implemented") +} + +actual fun StatusListener.emit( + pubnub: PubNub, + status: PNStatus +) { + TODO("Not yet implemented") +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com/pubnub/kmp/platform.ios.kt b/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com/pubnub/kmp/platform.ios.kt new file mode 100644 index 000000000..1a4c3d9b1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com/pubnub/kmp/platform.ios.kt @@ -0,0 +1,3 @@ +package com.pubnub.kmp + +internal actual val PLATFORM: String = "iOS" \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt new file mode 100644 index 000000000..182d0b533 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt @@ -0,0 +1,27 @@ +package com.pubnub.test + +import com.pubnub.api.JsonElement +import com.pubnub.api.JsonElementImpl +import com.pubnub.api.PubNub +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.pubsub.PNEvent +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener + +actual fun EventListener.emit( + pubnub: PubNub, + event: PNEvent +) { + TODO("not implemented") +} + +actual fun Any.toJsonElement(): JsonElement { + return JsonElementImpl(this) +} + +actual fun StatusListener.emit( + pubnub: PubNub, + status: PNStatus +) { + TODO("not implemented") +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com/pubnub/kmp/platform.js.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com/pubnub/kmp/platform.js.kt new file mode 100644 index 000000000..b36e00b7b --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com/pubnub/kmp/platform.js.kt @@ -0,0 +1,3 @@ +package com.pubnub.kmp + +internal actual val PLATFORM: String = "JS" \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt new file mode 100644 index 000000000..a8e3f29d1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt @@ -0,0 +1,42 @@ +package com.pubnub.test + +import com.pubnub.api.JsonElement +import com.pubnub.api.PubNub +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.pubsub.PNEvent +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.internal.managers.MapperManager + +actual fun EventListener.emit( + pubnub: PubNub, + event: PNEvent +) { + when (event) { + is PNMessageResult -> this.message(pubnub, event) + is PNMessageActionResult -> this.messageAction(pubnub, event) + is PNFileEventResult -> this.file(pubnub, event) + is PNObjectEventResult -> this.objects(pubnub, event) + is PNSignalResult -> this.signal(pubnub, event) + is PNPresenceEventResult -> this.presence(pubnub, event) + } +} + +private val mapper = MapperManager() + +actual fun Any.toJsonElement(): JsonElement { + return mapper.toJsonTree(this) +} + +actual fun StatusListener.emit( + pubnub: PubNub, + status: PNStatus +) { + this.status(pubnub, status) +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com/pubnub/kmp/platform.jvm.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com/pubnub/kmp/platform.jvm.kt new file mode 100644 index 000000000..cf80b6fd7 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com/pubnub/kmp/platform.jvm.kt @@ -0,0 +1,3 @@ +package com.pubnub.kmp + +internal actual val PLATFORM: String = "JVM" \ No newline at end of file From 9a0d5b88f9209c9c67d0d65108346d57a15d6b70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Thu, 6 Jun 2024 20:36:49 +0200 Subject: [PATCH 13/62] Add wrapException to Result --- .../kotlin/com/pubnub/api/v2/callbacks/Result.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt index 0d9d86eb9..eeb4b3bb1 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt @@ -245,4 +245,11 @@ public inline fun T.runCatching(block: T.() -> R): Result { } catch (e: Throwable) { Result.failure(e) } +} + +public inline fun Result.wrapException(block: (PubNubException) -> PubNubException): Result { + return when { + isSuccess -> this + else -> Result.failure(block(exceptionOrNull()!!)) + } } \ No newline at end of file From 833299cc62f3f66cbe858ce30e55967351480e19 Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Fri, 7 Jun 2024 12:57:27 +0200 Subject: [PATCH 14/62] Wrapping status listener and some AppContext methods (#225) --- .../kotlin/com/pubnub/api/PubNubImpl.kt | 27 +++++-- .../objects/channel/GetChannelMetadata.ios.kt | 41 +++++++++- .../channel/RemoveChannelMetadata.ios.kt | 24 +++++- .../objects/uuid/GetAllUUIDMetadata.ios.kt | 75 ++++++++++++++++++- .../objects/uuid/GetUUIDMetadata.ios.kt | 40 ++++++++++ .../objects/uuid/RemoveUUIDMetadata.ios.kt | 21 ++++++ .../api/v2/callbacks/EventListener.ios.kt | 2 +- .../api/v2/callbacks/StatusListener.ios.kt | 22 +++++- .../kotlin/com/pubnub/kmp/factories.ios.kt | 69 ++++++++++++++--- 9 files changed, 300 insertions(+), 21 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index db3966811..56dc85ac7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -40,15 +40,20 @@ import com.pubnub.api.endpoints.message_actions.RemoveMessageActionImpl import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadataImpl import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadataImpl import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadataImpl import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata import com.pubnub.api.endpoints.objects.member.GetChannelMembers import com.pubnub.api.endpoints.objects.member.ManageChannelMembers import com.pubnub.api.endpoints.objects.membership.GetMemberships import com.pubnub.api.endpoints.objects.membership.ManageMemberships import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata import com.pubnub.api.endpoints.presence.GetState import com.pubnub.api.endpoints.presence.GetStateImpl @@ -391,7 +396,11 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { - TODO("Not yet implemented") + return GetChannelMetadataImpl( + pubnub = pubNubObjC, + channel = channel, + includeCustom = includeCustom + ) } override fun setChannelMetadata( @@ -407,7 +416,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { - TODO("Not yet implemented") + return RemoveChannelMetadataImpl(pubnub = pubNubObjC, channel = channel) } override fun getAllUUIDMetadata( @@ -418,11 +427,19 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCount: Boolean, includeCustom: Boolean ): GetAllUUIDMetadata { - TODO("Not yet implemented") + return GetAllUUIDMetadataImpl( + pubnub = pubNubObjC, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom + ) } override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { - TODO("Not yet implemented") + return GetUUIDMetadataImpl(pubnub = pubNubObjC, uuid = uuid, includeCustom = includeCustom) } override fun setUUIDMetadata( @@ -440,7 +457,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { - TODO("Not yet implemented") + return RemoveUUIDMetadataImpl(pubnub = pubNubObjC, uuid = uuid) } override fun getMemberships( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt index 26a269e4a..3db8b821c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt @@ -1,9 +1,48 @@ package com.pubnub.api.endpoints.objects.channel +import cocoapods.PubNubSwift.PubNubGetChannelMetadataResultObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.getChannelMetadataWithChannel import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.getChannelMetadata] */ -actual interface GetChannelMetadata : Endpoint \ No newline at end of file +actual interface GetChannelMetadata : Endpoint + +@OptIn(ExperimentalForeignApi::class) +class GetChannelMetadataImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val includeCustom: Boolean +): GetChannelMetadata { + override fun async(callback: Consumer>) { + pubnub.getChannelMetadataWithChannel( + channel = channel, + includeCustom = includeCustom, + onSuccess = callback.onSuccessHandler { + PNChannelMetadataResult( + status = 200, // TODO: Determine this field + data = PNChannelMetadata( + id = it?.id() ?: "", + name = it?.name(), + description = it?.descr(), + custom = it?.custom() as? Map, // TODO: Check + updated = it?.updated(), + eTag = it?.eTag(), + type = it?.type(), + status = it?.status() + ) + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt index f6acb81da..0fb908dff 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt @@ -1,6 +1,28 @@ package com.pubnub.api.endpoints.objects.channel +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.removeChannelMetadataWithChannel import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.onSuccessReturnValue +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi -actual interface RemoveChannelMetadata : Endpoint \ No newline at end of file +actual interface RemoveChannelMetadata : Endpoint + +@OptIn(ExperimentalForeignApi::class) +class RemoveChannelMetadataImpl( + private val pubnub: PubNubObjC, + private val channel: String +): RemoveChannelMetadata { + override fun async(callback: Consumer>) { + pubnub.removeChannelMetadataWithChannel( + channel = channel, + onSuccess = callback.onSuccessHandler { PNRemoveMetadataResult(200) }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt index 67faf7dd0..a180e294d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt @@ -1,9 +1,82 @@ package com.pubnub.api.endpoints.objects.uuid +import cocoapods.PubNubSwift.PubNubChannelMetadataObjC +import cocoapods.PubNubSwift.PubNubHashedPageObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.PubNubSortPropertyObjC +import cocoapods.PubNubSwift.PubNubUUIDMetadataObjC +import cocoapods.PubNubSwift.getAllChannelMetadataWithLimit +import cocoapods.PubNubSwift.getAllUUIDMetadataWithLimit import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [PubNub.getAllUUIDMetadata] */ -actual interface GetAllUUIDMetadata : Endpoint \ No newline at end of file +actual interface GetAllUUIDMetadata : Endpoint + +@OptIn(ExperimentalForeignApi::class) +class GetAllUUIDMetadataImpl( + private val pubnub: PubNubObjC, + private val limit: Int?, + private val page: PNPage?, + private val filter: String?, + private val sort: Collection>, + private val includeCount: Boolean, + private val includeCustom: Boolean +) : GetAllUUIDMetadata { + override fun async(callback: Consumer>) { + pubnub.getAllUUIDMetadataWithLimit( + limit = limit?.let { NSNumber(it) }, + page = PubNubHashedPageObjC( + start = if (page is PNPage.PNNext) { page.pageHash } else { null }, + end = if (page is PNPage.PNPrev) { page.pageHash } else { null }, + totalCount = null + ), + filter = filter, + sort = sort.map { + PubNubSortPropertyObjC( + key = it.key.fieldName, + direction = it.dir + ) + }, + includeCount = includeCount, + includeCustom = includeCustom, + onSuccess = callback.onSuccessHandler { + PNUUIDMetadataArrayResult( + status = it?.status()?.toInt() ?: 0, + data = (it?.data() as List).map { metadata -> + PNUUIDMetadata( + id = metadata.id(), + name = metadata.name(), + externalId = metadata.externalId(), + profileUrl = metadata.profileUrl(), + email = metadata.email(), + custom = metadata.custom() as? Map, + updated = metadata.updated(), + eTag = metadata.eTag(), + type = metadata.type(), + status = metadata.status() + ) + }, + totalCount = it.totalCount()?.intValue ?: 0, + next = it.next()?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = it.next()?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt index dd2440021..83d467e42 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt @@ -1,10 +1,50 @@ package com.pubnub.api.endpoints.objects.uuid +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.getUUIDMetadataWithUuid import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.getUUIDMetadata] */ actual interface GetUUIDMetadata : Endpoint { +} + +@OptIn(ExperimentalForeignApi::class) +class GetUUIDMetadataImpl( + private val pubnub: PubNubObjC, + private val uuid: String?, + private val includeCustom: Boolean +): GetUUIDMetadata { + override fun async(callback: Consumer>) { + pubnub.getUUIDMetadataWithUuid( + uuid = uuid, + includeCustom = includeCustom, + onSuccess = callback.onSuccessHandler { + PNUUIDMetadataResult( + status = 200, + data = PNUUIDMetadata( + id = it?.id() ?: "", + name = it?.name(), + externalId = it?.externalId(), + profileUrl = it?.profileUrl(), + email = it?.email(), + custom = it?.custom() as? Map, // TODO: Check + updated = it?.updated(), + eTag = it?.eTag(), + type = it?.type(), + status = it?.status() + ) + ) + }, + onFailure = callback.onFailureHandler()) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt index e6f986fd1..ebd3ced8c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt @@ -1,7 +1,28 @@ package com.pubnub.api.endpoints.objects.uuid +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.removeUUIDMetadataWithUuid import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi actual interface RemoveUUIDMetadata : Endpoint { +} + +@OptIn(ExperimentalForeignApi::class) +class RemoveUUIDMetadataImpl( + private val pubnub: PubNubObjC, + private val uuid: String? +): RemoveUUIDMetadata { + override fun async(callback: Consumer>) { + pubnub.removeUUIDMetadataWithUuid( + uuid = uuid, + onSuccess = callback.onSuccessHandler { PNRemoveMetadataResult(200) }, + onFailure = callback.onFailureHandler() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt index b73a157e0..f8b311439 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -18,13 +18,13 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) actual interface EventListener : Listener { + val underlying: EventListenerObjC val onMessage: (PubNub, PNMessageResult) -> Unit val onPresence: (PubNub, PNPresenceEventResult) -> Unit val onSignal: (PubNub, PNSignalResult) -> Unit val onMessageAction: (PubNub, PNMessageActionResult) -> Unit val onObjects: (PubNub, PNObjectEventResult) -> Unit val onFile: (PubNub, PNFileEventResult) -> Unit - val underlying: EventListenerObjC } @OptIn(ExperimentalForeignApi::class) class EventListenerImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt index feb40c8cc..306b283da 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt @@ -1,9 +1,29 @@ package com.pubnub.api.v2.callbacks +import cocoapods.PubNubSwift.StatusListenerObjC +import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import kotlinx.cinterop.ExperimentalForeignApi /** * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for * PubNub connection status changes. */ -actual interface StatusListener : Listener \ No newline at end of file +@OptIn(ExperimentalForeignApi::class) +actual interface StatusListener : Listener { + val underlying: StatusListenerObjC + val onStatusChange: (PubNub, PNStatus) -> Unit +} + +@OptIn(ExperimentalForeignApi::class) +class StatusListenerImpl( + override val underlying: StatusListenerObjC, + override val onStatusChange: (PubNub, PNStatus) -> Unit +): StatusListener {} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 47e7001c5..ff2dbfb55 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -1,6 +1,15 @@ package com.pubnub.kmp import cocoapods.PubNubSwift.EventListenerObjC +import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjC +import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCConnected +import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCConnectionError +import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCDisconnected +import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCDisconnectedUnexpectedly +import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCHeartbeatFailed +import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCHeartbeatSuccess +import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCMalformedResponseCategory +import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCSubscriptionChanged import cocoapods.PubNubSwift.PubNubDeleteChannelMetadataEventMessageObjC import cocoapods.PubNubSwift.PubNubDeleteMembershipEventMessageObjC import cocoapods.PubNubSwift.PubNubDeleteUUIDMetadataEventMessageObjC @@ -13,9 +22,12 @@ import cocoapods.PubNubSwift.PubNubPresenceEventResultObjC import cocoapods.PubNubSwift.PubNubSetChannelMetadataEventMessageObjC import cocoapods.PubNubSwift.PubNubSetMembershipEventMessageObjC import cocoapods.PubNubSwift.PubNubSetUUIDMetadataEventMessageObjC +import cocoapods.PubNubSwift.StatusListenerObjC import com.pubnub.api.JsonElementImpl import com.pubnub.api.PubNub +import com.pubnub.api.PubNubException import com.pubnub.api.PubNubImpl +import com.pubnub.api.enums.PNStatusCategory import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.files.PNDownloadableFile import com.pubnub.api.models.consumer.message_actions.PNMessageAction @@ -41,6 +53,7 @@ import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.EventListenerImpl import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.api.v2.callbacks.StatusListenerImpl import kotlinx.cinterop.ExperimentalForeignApi actual fun createPubNub(config: PNConfiguration): PubNub { @@ -58,12 +71,6 @@ actual fun createEventListener( onFile: (PubNub, PNFileEventResult) -> Unit ): EventListener { return EventListenerImpl( - onMessage = onMessage, - onMessageAction = onMessageAction, - onPresence = onPresence, - onObjects = onObjects, - onFile = onFile, - onSignal = onSignal, underlying = EventListenerObjC( onMessage = { onMessage(pubnub, createMessageResult(it)) }, onPresence = { presenceEvents -> createPresenceEventResults(presenceEvents).forEach { onPresence(pubnub, it) } }, @@ -71,7 +78,13 @@ actual fun createEventListener( onMessageAction = { onMessageAction(pubnub, createMessageActionResult(it)) }, onAppContext = { if (createObjectEvent(it) != null) { createObjectEvent(it) } else {} }, onFile = { onFile(pubnub, createFileEventResult(it)) } - ) + ), + onMessage = onMessage, + onPresence = onPresence, + onSignal = onSignal, + onMessageAction = onMessageAction, + onObjects = onObjects, + onFile = onFile ) } @@ -192,7 +205,7 @@ private fun mapObjectMessage(from: PubNubObjectEventMessageObjC?): PNObjectEvent externalId = from.data().externalId(), profileUrl = from.data().profileUrl(), email = from.data().email(), - custom = from.data().custom() as? Map, + custom = from.data().custom() as? Map, // TODO: Verify updated = from.data().updated(), eTag = from.data().eTag(), type = from.data().type(), @@ -217,7 +230,7 @@ private fun mapObjectMessage(from: PubNubObjectEventMessageObjC?): PNObjectEvent id = from.data().id(), name = from.data().name(), description = from.data().descr(), - custom = from.data().custom() as? Map, + custom = from.data().custom() as? Map, // TODO: Verify updated = from.data().updated(), eTag = from.data().eTag(), type = from.data().type(), @@ -241,7 +254,7 @@ private fun mapObjectMessage(from: PubNubObjectEventMessageObjC?): PNObjectEvent data = PNSetMembershipEvent( channel = from.data().channel(), uuid = from.data().uuid(), - custom = from.data().custom() as? Map, // TODO: This will fail, + custom = from.data().custom() as? Map, // TODO: Verify, eTag = from.data().eTag(), updated = from.data().updated(), status = from.data().status() @@ -262,11 +275,45 @@ private fun mapObjectMessage(from: PubNubObjectEventMessageObjC?): PNObjectEvent } } +@OptIn(ExperimentalForeignApi::class) actual fun createStatusListener( pubnub: PubNub, onStatus: (PubNub, PNStatus) -> Unit ): StatusListener { - TODO("Not yet implemented") + return StatusListenerImpl( + underlying = StatusListenerObjC(onStatusChange = { status -> + when (status?.category()) { + PubNubConnectionStatusCategoryObjCConnected -> + PNStatusCategory.PNConnectedCategory + PubNubConnectionStatusCategoryObjCDisconnected -> + PNStatusCategory.PNDisconnectedCategory + PubNubConnectionStatusCategoryObjCDisconnectedUnexpectedly -> + PNStatusCategory.PNUnexpectedDisconnectCategory + PubNubConnectionStatusCategoryObjCConnectionError -> + PNStatusCategory.PNConnectionError + PubNubConnectionStatusCategoryObjCMalformedResponseCategory -> + PNStatusCategory.PNMalformedResponseCategory + PubNubConnectionStatusCategoryObjCHeartbeatFailed -> + PNStatusCategory.PNHeartbeatFailed + PubNubConnectionStatusCategoryObjCHeartbeatSuccess -> + PNStatusCategory.PNHeartbeatSuccess + PubNubConnectionStatusCategoryObjCSubscriptionChanged -> + PNStatusCategory.PNSubscriptionChanged + else -> null + }?.let { category -> + onStatus( + pubnub, PNStatus( + category = category, + exception = status?.error()?.let { error -> PubNubException(errorMessage = error.localizedDescription) }, + currentTimetoken = status?.currentTimetoken()?.longValue(), + affectedChannels = status?.affectedChannels() as Set, + affectedChannelGroups = status?.affectedChannelGroups() as Set + ) + ) + } + }), + onStatusChange = onStatus + ) } actual fun createCustomObject(map: Map): CustomObject { From 8761c085e980a310341e0208515a05a59f6bcb9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Fri, 7 Jun 2024 11:04:09 +0000 Subject: [PATCH 15/62] Add creation of JsonElement to common code (#228) * Allow creation of JsonElement for tests * Merge changes from master --- .../kotlin/com/pubnub/api/JsonElement.kt | 17 +- .../push/payload/PushPayloadHelper.kt | 242 +++++++++++++++++- .../kotlin/com/pubnub/api/JsonElement.ios.kt | 4 + .../kotlin/com/pubnub/api/JsonElement.js.kt | 55 +++- .../kotlin/com/pubnub/api/JsonElement.jvm.kt | 8 + .../push/PushPayloadHelperHelperTest.kt | 214 ++++++++++++++-- .../integration/PublishIntegrationTests.java | 41 +++ .../com/pubnub/api/endpoints/FetchMessages.kt | 3 +- 8 files changed, 540 insertions(+), 44 deletions(-) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt index a506146eb..4d2bc56cb 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt @@ -11,12 +11,13 @@ expect fun JsonElement.asBoolean(): Boolean? expect fun JsonElement.asString(): String? expect fun JsonElement.asMap(): Map? +expect fun createJsonElement(any: Any?): JsonElement -//fun JsonElement.decode(): Any? { -// if (isNull()) return null -// return asMap()?.mapValues { it.value.decode() } -// ?: asList()?.map { it.decode() } -// ?: asNumber() -// ?: asBoolean() -// ?: asString() -//} \ No newline at end of file +fun JsonElement.decode(): Any? { + if (isNull()) return null + return asMap()?.mapValues { it.value.decode() } + ?: asList()?.map { it.decode() } + ?: asNumber() + ?: asBoolean() + ?: asString() +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt index 6e82fa09b..18fd6bedd 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt @@ -20,7 +20,7 @@ class PushPayloadHelper { fcmPayload?.let { it.toMap().run { if (isNotEmpty()) { - put("pn_gcm", this) + put("pn_fcm", this) } } } @@ -126,25 +126,255 @@ class PushPayloadHelper { } class FCMPayload : PushPayloadSerializer { - var custom: Map? = null var data: Map? = null var notification: Notification? = null + var android: AndroidConfig? = null + var webpush: WebpushConfig? = null + var apns: ApnsConfig? = null + var fcmOptions: FcmOptions? = null override fun toMap(): Map { return mutableMapOf().apply { - custom?.let { putAll(it) } data?.let { if (it.isNotEmpty()) { put("data", it) } } notification?.let { - it.toMap().run { - if (this.isNotEmpty()) { - put("notification", this) + it.toMap().let { map -> + if (map.isNotEmpty()) { + put("notification", map) } } } + android?.let { + it.toMap().let { map -> + if (map.isNotEmpty()) { + put("android", map) + } + } + } + webpush?.let { + it.toMap().let { map -> + if (map.isNotEmpty()) { + put("webpush", map) + } + } + } + apns?.let { + it.toMap().let { map -> + if (map.isNotEmpty()) { + put("apns", map) + } + } + } + fcmOptions?.let { + it.toMap().let { map -> + if (map.isNotEmpty()) { + put("fcm_options", map) + } + } + } + } + } + + class WebpushConfig : PushPayloadSerializer { + var headers: Map? = null + var data: Map? = null + var notification: Map? = null + var fcmOptions: WebpushFcmOptions? = null + + class WebpushFcmOptions : PushPayloadSerializer { + var link: String? = null + var analyticsLabel: String? = null + + override fun toMap(): Map { + return buildMap { + link?.let { put("link", it) } + analyticsLabel?.let { put("analytics_label", it) } + } + } + } + + override fun toMap(): Map { + return buildMap { + headers?.let { put("headers", it) } + data?.let { put("data", it) } + notification?.let { put("notification", it) } + fcmOptions?.let { put("fcm_options", it.toMap()) } + } + } + } + + class ApnsConfig : PushPayloadSerializer { + var headers: Map? = null + var payload: Map? = null + var fcmOptions: ApnsFcmOptions? = null + + class ApnsFcmOptions : PushPayloadSerializer { + var analyticsLabel: String? = null + var image: String? = null + + override fun toMap(): Map { + return buildMap { + analyticsLabel?.let { put("analytics_label", it) } + image?.let { put("image", it) } + } + } + } + + override fun toMap(): Map { + return buildMap { + headers?.let { put("headers", it) } + payload?.let { put("payload", it) } + fcmOptions?.let { put("fcm_options", it.toMap()) } + } + } + } + + class FcmOptions : PushPayloadSerializer { + var analyticsLabel: String? = null + + override fun toMap(): Map { + return buildMap { + analyticsLabel?.let { put("analytics_label", it) } + } + } + } + + class AndroidConfig : PushPayloadSerializer { + var collapseKey: String? = null + var priority: AndroidMessagePriority = AndroidMessagePriority.NORMAL + var ttl: String? = null + var restrictedPackageName: String? = null + var data: Map? = null + var notification: AndroidNotification? = null + var fcmOptions: AndroidFcmOptions? = null + var directBootOk: Boolean = false + + class AndroidFcmOptions : PushPayloadSerializer { + var analyticsLabel: String? = null + + override fun toMap(): Map { + return buildMap { + analyticsLabel?.let { put("analytics_label", it) } + } + } + } + + class AndroidNotification : PushPayloadSerializer { + var title: String? = null + var body: String? = null + var icon: String? = null + var color: String? = null + var sound: String? = null + var tag: String? = null + var clickAction: String? = null + var bodyLocKey: String? = null + var bodyLocArgs: List? = null + var titleLocKey: String? = null + var titleLocArgs: List? = null + var channelId: String? = null + var ticker: String? = null + var sticky: Boolean = false + var eventTime: String? = null + var localOnly: Boolean? = null + var notificationPriority: NotificationPriority = NotificationPriority.PRIORITY_DEFAULT + var defaultSound: Boolean? = null + var defaultVibrateTimings: Boolean? = null + var defaultLightSettings: Boolean? = null + var vibrateTimings: List? = null + var visibility: Visibility? = null + var notificationCount: Int? = null + var lightSettings: LightSettings? = null + var image: String? = null + + class LightSettings : PushPayloadSerializer { + var color: Color? = null + var lightOnDuration: String? = null + var lightOffDuration: String? = null + + class Color(val red: Float, val green: Float, val blue: Float, val alpha: Float) : PushPayloadSerializer { + override fun toMap(): Map { + return buildMap { + put("red", red) + put("green", green) + put("blue", blue) + put("alpha", alpha) + } + } + } + + override fun toMap(): Map { + return buildMap { + color?.let { put("color", it.toMap()) } + lightOnDuration?.let { put("light_on_duration", it) } + lightOffDuration?.let { put("light_off_duration", it) } + } + } + } + + enum class Visibility { + VISIBILITY_UNSPECIFIED, + PRIVATE, + PUBLIC, + SECRET, + } + + enum class NotificationPriority { + PRIORITY_UNSPECIFIED, + PRIORITY_MIN, + PRIORITY_LOW, + PRIORITY_DEFAULT, + PRIORITY_HIGH, + PRIORITY_MAX + } + + override fun toMap(): Map = buildMap { + title?.let { put("title", it) } + body?.let { put("body", it) } + icon?.let { put("icon", it) } + color?.let { put("color", it) } + sound?.let { put("sound", it) } + tag?.let { put("tag", it) } + clickAction?.let { put("click_action", it) } + bodyLocKey?.let { put("body_loc_key", it) } + bodyLocArgs?.let { put("body_loc_args", it) } + titleLocKey?.let { put("title_loc_key", it) } + titleLocArgs?.let { put("title_loc_args", it) } + channelId?.let { put("channel_id", it) } + ticker?.let { put("ticker", it) } + put("sticky", sticky) + eventTime?.let { put("event_time", it) } + localOnly?.let { put("local_only", it) } + put("notification_priority", notificationPriority.name) + defaultSound?.let { put("default_sound", it) } + defaultVibrateTimings?.let { put("default_vibrate_timings", it) } + defaultLightSettings?.let { put("default_light_settings", it) } + vibrateTimings?.let { put("vibrate_timings", it) } + visibility?.let { put("visibility", it.name) } + notificationCount?.let { put("notification_count", it) } + lightSettings?.let { put("light_settings", it.toMap()) } + image?.let { put("image", it) } + } + } + + enum class AndroidMessagePriority { + NORMAL, + HIGH + } + + override fun toMap(): Map { + return buildMap { + collapseKey?.let { put("collapse_key", it) } + put("priority", priority.name) + ttl?.let { put("ttl", it) } + restrictedPackageName?.let { put("restricted_package_name", it) } + data?.let { put("data", it) } + notification?.let { put("notification", it.toMap()) } + fcmOptions?.let { put("fcm_options", it.toMap()) } + put("direct_boot_ok", directBootOk) + } } } diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt index ac181b984..f66f23ff0 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt @@ -76,4 +76,8 @@ actual fun JsonElement.asNumber(): Number? { is Boolean -> if (value) 1 else 0 else -> null } +} + +actual fun createJsonElement(any: Any?): JsonElement { + return JsonElementImpl(AnyJSONObjC(any)) } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt index dfbed626c..549cdcb4f 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt @@ -4,10 +4,15 @@ package com.pubnub.api import com.pubnub.kmp.JsMap import com.pubnub.kmp.toMap +import kotlin.js.json actual abstract class JsonElement(val value: Any?) -class JsonElementImpl(value: Any?) : JsonElement(value) +class JsonElementImpl(value: Any?) : JsonElement(value) { + override fun toString(): String { + return "JsonElementImpl(${value.toString()} : ${value?.let { it::class }})" + } +} actual fun JsonElement.asString(): String? { return value as? String @@ -34,10 +39,56 @@ actual fun JsonElement.asBoolean(): Boolean? { } actual fun JsonElement.asDouble(): Double? { - println(value.toString() + " " + value!!::class) return (value as? Number)?.toDouble() } actual fun JsonElement.asNumber(): Number? { return value as? Number +} + +actual fun createJsonElement(any: Any?): JsonElement { + return JsonElementImpl(any.adjustCollectionTypes()) +} + +internal fun Any?.adjustCollectionTypes(): Any? { + return when (this) { + is Map<*, *> -> { + val json = json() + entries.forEach { + val value = it.value.adjustCollectionTypes() + if (value is JsonElementImpl) { + json[it.key.toString()] = value.value + } else { + json[it.key.toString()] = value + } + } + json + } + + is Collection<*> -> { + this.map { it.adjustCollectionTypes() }.map { + if (it is JsonElementImpl) { + it.value + } else { + it + } + }.toTypedArray() + } + + is Array<*> -> { + this.map { it.adjustCollectionTypes() }.map { + if (it is JsonElementImpl) { + it.value + } else { + it + } + }.toTypedArray() + } + + is Long -> { + return toString() + } + + else -> this + } } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt index 29f062419..43f9baf7a 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt @@ -1,5 +1,9 @@ package com.pubnub.api +import com.google.gson.Gson +import com.google.gson.GsonBuilder +import com.google.gson.JsonObject + actual typealias JsonElement = com.google.gson.JsonElement actual fun JsonElement.asString(): String? { @@ -32,4 +36,8 @@ actual fun JsonElement.asDouble(): Double? { actual fun JsonElement.asNumber(): Number? { return if (this.isJsonPrimitive && this.asJsonPrimitive.isNumber) this.asNumber else null +} + +actual fun createJsonElement(any: Any?): JsonElement { + return GsonBuilder().serializeNulls().create().toJsonTree(any) } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt index 172105d73..359c8d332 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt @@ -1,5 +1,6 @@ package com.pubnub.api.legacy.endpoints.push +import com.google.gson.GsonBuilder import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.legacy.BaseTest import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper @@ -7,6 +8,16 @@ import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.APNSPayload import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.APNSPayload.APNS2Configuration import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.APNSPayload.APS import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.AndroidConfig.AndroidFcmOptions +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.AndroidConfig.AndroidMessagePriority +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.AndroidConfig.AndroidNotification.LightSettings +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.AndroidConfig.AndroidNotification.NotificationPriority +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.AndroidConfig.AndroidNotification.Visibility +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.ApnsConfig +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.ApnsConfig.ApnsFcmOptions +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.FcmOptions +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.WebpushConfig +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.WebpushConfig.WebpushFcmOptions import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.MPNSPayload import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse @@ -282,34 +293,185 @@ class PushPayloadHelperHelperTest : BaseTest() { pushPayloadHelper.fcmPayload = FCMPayload().apply { + data = mapOf("data_1" to "aa") notification = FCMPayload.Notification().apply { body = "Notification body" - image = null + image = "image" title = "" } - custom = mapOf("a" to "a", "b" to 1) - data = mapOf("data_1" to "a", "data_2" to 1) + android = FCMPayload.AndroidConfig().apply { + collapseKey = "collapseKey" + priority = AndroidMessagePriority.HIGH + ttl = "ttl" + restrictedPackageName = "restricted" + data = mapOf("android_data_1" to "a") + notification = FCMPayload.AndroidConfig.AndroidNotification().apply { + title = "title" + body = "body" + icon = "icon" + color = "color" + sound = "sound" + tag = "tag" + clickAction = "clickAction_1" + bodyLocKey = "bodyLocKey" + bodyLocArgs = listOf("a", "b") + titleLocKey = "titleLocKey" + titleLocArgs = listOf("b", "c") + channelId = "channelId" + ticker = "ticker" + sticky = true + eventTime = "eventTime" + localOnly = false + notificationPriority = NotificationPriority.PRIORITY_LOW + defaultSound = true + defaultVibrateTimings = true + defaultLightSettings = true + vibrateTimings = listOf("d", "e") + visibility = Visibility.SECRET + notificationCount = 4 + lightSettings = LightSettings().apply { + this.color = LightSettings.Color(1f, 1f, 1f, 1f) + this.lightOnDuration = "4" + this.lightOffDuration = "5" + } + image = "image" + } + fcmOptions = AndroidFcmOptions().apply { + this.analyticsLabel = "analytics_1" + } + directBootOk = true + } + webpush = WebpushConfig().apply { + headers = mapOf("header_1" to "aaa") + data = mapOf("web_data_1" to "") + notification = mapOf("notification" to "aaa") + fcmOptions = WebpushFcmOptions().apply { + link = "link" + analyticsLabel = "analytics_2" + } + } + apns = ApnsConfig().apply { + headers = mapOf("header_2" to "bbb") + payload = mapOf("payload_2" to "ccc") + fcmOptions = ApnsFcmOptions().apply { + analyticsLabel = "analytics_3" + image = "image" + } + } + fcmOptions = FcmOptions().apply { + analyticsLabel = "analytics_4" + } } val map = pushPayloadHelper.build() + val gson = GsonBuilder().setPrettyPrinting().create() + val json = gson.toJson(map) + + val expected = """ + { + "pn_fcm": { + "data": { + "data_1": "aa" + }, + "notification": { + "title": "", + "body": "Notification body", + "image": "image" + }, + "android": { + "collapse_key": "collapseKey", + "priority": "HIGH", + "ttl": "ttl", + "restricted_package_name": "restricted", + "data": { + "android_data_1": "a" + }, + "notification": { + "title": "title", + "body": "body", + "icon": "icon", + "color": "color", + "sound": "sound", + "tag": "tag", + "click_action": "clickAction_1", + "body_loc_key": "bodyLocKey", + "body_loc_args": [ + "a", + "b" + ], + "title_loc_key": "titleLocKey", + "title_loc_args": [ + "b", + "c" + ], + "channel_id": "channelId", + "ticker": "ticker", + "sticky": true, + "event_time": "eventTime", + "local_only": false, + "notification_priority": "PRIORITY_LOW", + "default_sound": true, + "default_vibrate_timings": true, + "default_light_settings": true, + "vibrate_timings": [ + "d", + "e" + ], + "visibility": "SECRET", + "notification_count": 4, + "light_settings": { + "color": { + "red": 1.0, + "green": 1.0, + "blue": 1.0, + "alpha": 1.0 + }, + "light_on_duration": "4", + "light_off_duration": "5" + }, + "image": "image" + }, + "fcm_options": { + "analytics_label": "analytics_1" + }, + "direct_boot_ok": true + }, + "webpush": { + "headers": { + "header_1": "aaa" + }, + "data": { + "web_data_1": "" + }, + "notification": { + "notification": "aaa" + }, + "fcm_options": { + "link": "link", + "analytics_label": "analytics_2" + } + }, + "apns": { + "headers": { + "header_2": "bbb" + }, + "payload": { + "payload_2": "ccc" + }, + "fcm_options": { + "analytics_label": "analytics_3", + "image": "image" + } + }, + "fcm_options": { + "analytics_label": "analytics_4" + } + } + } + """.trimIndent() - val pnFcmMap = map["pn_gcm"] as Map<*, *> - assertNotNull(pnFcmMap) - - val pnFcmDataMap = pnFcmMap["data"] as Map<*, *> - val pnFcmNotificationsMap = pnFcmMap["notification"] as Map<*, *> - - assertNotNull(pnFcmDataMap) - assertNotNull(pnFcmNotificationsMap) - - assertEquals(pnFcmMap["a"], "a") - assertEquals(pnFcmMap["b"], 1) - assertEquals(pnFcmDataMap["data_1"], "a") - assertEquals(pnFcmDataMap["data_2"], 1) - assertEquals(pnFcmNotificationsMap["body"], "Notification body") - assertEquals(pnFcmNotificationsMap["image"], null) - assertEquals(pnFcmNotificationsMap["title"], "") + assertEquals(expected, json) } @Test @@ -318,7 +480,7 @@ class PushPayloadHelperHelperTest : BaseTest() { val fcmPayload = FCMPayload() pushPayloadHelper.fcmPayload = fcmPayload val map = pushPayloadHelper.build() - val pnFcmMap = map["pn_gcm"] + val pnFcmMap = map["pn_fcm"] assertNull(pnFcmMap) } @@ -331,10 +493,10 @@ class PushPayloadHelperHelperTest : BaseTest() { customMap["key_2"] = 2 val fcmPayload = FCMPayload() fcmPayload.notification = notification - fcmPayload.custom = customMap + fcmPayload.data = customMap pushPayloadHelper.fcmPayload = fcmPayload val map = pushPayloadHelper.build() - val pnFcmMap = map["pn_gcm"] as Map<*, *> + val pnFcmMap = map["pn_fcm"] as Map<*, *> val pnFcmNotificationMap = pnFcmMap["notification"] assertNull(pnFcmNotificationMap) } @@ -347,7 +509,7 @@ class PushPayloadHelperHelperTest : BaseTest() { fcmPayload.data = dataMap pushPayloadHelper.fcmPayload = fcmPayload val map = pushPayloadHelper.build() - val pnFcmMap = map["pn_gcm"] + val pnFcmMap = map["pn_fcm"] assertNull(pnFcmMap) } @@ -367,7 +529,7 @@ class PushPayloadHelperHelperTest : BaseTest() { pushPayloadHelper.fcmPayload = fcmPayload val map = pushPayloadHelper.build() - val pnFcmMap = map["pn_gcm"] as Map<*, *> + val pnFcmMap = map["pn_fcm"] as Map<*, *> val pnFcmDataMap = pnFcmMap["data"] as Map<*, *> assertNotNull(pnFcmDataMap) assertFalse(pnFcmDataMap.isEmpty()) @@ -386,7 +548,7 @@ class PushPayloadHelperHelperTest : BaseTest() { val pushPayloadHelper = PushPayloadHelper() pushPayloadHelper.fcmPayload = FCMPayload().apply { - custom = + data = mapOf( "key_1" to "value_1", "key_2" to 2, @@ -396,7 +558,7 @@ class PushPayloadHelperHelperTest : BaseTest() { } val map = pushPayloadHelper.build() - val pnFcmMap = map["pn_gcm"] as Map<*, *> + val pnFcmMap = (map["pn_fcm"] as Map<*, *>)["data"] as Map assertNotNull(pnFcmMap) assertFalse(pnFcmMap.isEmpty()) assertTrue(pnFcmMap.containsKey("key_1")) diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PublishIntegrationTests.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PublishIntegrationTests.java index 1a393f051..238da8828 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PublishIntegrationTests.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PublishIntegrationTests.java @@ -10,6 +10,7 @@ import com.pubnub.api.crypto.CryptoModule; import com.pubnub.api.enums.PNStatusCategory; import com.pubnub.api.integration.util.BaseIntegrationTest; +import com.pubnub.api.models.consumer.PNPublishResult; import com.pubnub.api.models.consumer.PNStatus; import com.pubnub.api.models.consumer.history.PNFetchMessagesResult; import com.pubnub.api.models.consumer.history.PNHistoryResult; @@ -23,6 +24,7 @@ import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; import com.pubnub.api.v2.PNConfiguration; import com.pubnub.api.v2.PNConfigurationOverride; +import com.pubnub.api.v2.callbacks.Result; import com.pubnub.api.v2.entities.Channel; import com.pubnub.api.v2.subscriptions.Subscription; import org.awaitility.Awaitility; @@ -44,6 +46,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class PublishIntegrationTests extends BaseIntegrationTest { @@ -108,6 +111,44 @@ public void testPublishUsingChannelEntity() throws InterruptedException, PubNubE } + @Test + public void testPublishUsingChannelEntityInAsyncMode() throws InterruptedException, PubNubException { + AtomicBoolean messageSent = new AtomicBoolean(false); + AtomicBoolean signalSent = new AtomicBoolean(false); + AtomicBoolean fireSent = new AtomicBoolean(false); + String channelName = randomChannel(); + Channel channel = pubNub.channel(channelName); + + Subscription subscription = channel.subscription(); + subscription.subscribe(); + Thread.sleep(1000); + + channel.publish("My message").meta("meta").async((Result result) -> { + result.onSuccess( (PNPublishResult res) -> { + assertTrue(result.getOrNull().getTimetoken() != 0); + messageSent.set(true); + }).onFailure( (PubNubException exception) -> { + System.out.println("Exception occurred: " + exception.getMessage()); + }); + }); + + channel.signal("My signal").async((Result result) ->{ + assertTrue(result.isSuccess()); + assertTrue(result.getOrNull().getTimetoken() != 0); + signalSent.set(true); + }); + + channel.fire("My fire").async((Result result) -> { + assertTrue(result.isSuccess()); + assertTrue(result.getOrNull().getTimetoken() != 0); + fireSent.set(true); + }); + + Awaitility.await().atMost(Durations.FIVE_SECONDS).untilAtomic(messageSent, Matchers.equalTo(true)); + Awaitility.await().atMost(Durations.FIVE_SECONDS).untilAtomic(signalSent, Matchers.equalTo(true)); + Awaitility.await().atMost(Durations.FIVE_SECONDS).untilAtomic(fireSent, Matchers.equalTo(true)); + } + @Test public void testPublishMessageHistory() throws PubNubException { final AtomicBoolean success = new AtomicBoolean(); diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt index 6e3706447..c862f61c5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.history.PNFetchMessagesResult /** * @see [PubNub.fetchMessages] */ -expect interface FetchMessages : Endpoint { -} \ No newline at end of file +expect interface FetchMessages : Endpoint \ No newline at end of file From 46939f1f36177c171dc67c0b36984ec6f4ae1478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Mon, 10 Jun 2024 10:51:57 +0000 Subject: [PATCH 16/62] Add Swift git submodule (#230) --- .gitmodules | 4 ++++ .../com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt | 8 ++++---- swift | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .gitmodules create mode 160000 swift diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..0d0f41a47 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "swift"] + path = swift + url = https://github.com/pubnub/swift + branch = feat/kmp diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt index 613e0e70a..44aea2d29 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt @@ -76,11 +76,11 @@ class PubNubKotlinMultiplatformPlugin : Plugin { } pod("PubNubSwift") { - source = git("https://github.com/pubnub/swift") { - branch = "feat/kmp" - } +// source = git("https://github.com/pubnub/swift") { +// branch = "feat/kmp" +// } // headers = "PubNub/PubNub.h" -// source = path(rootProject.file("../../swift")) + source = path(rootProject.file("swift")) // version = "7.1.0" moduleName = "PubNub" diff --git a/swift b/swift new file mode 160000 index 000000000..557365ac2 --- /dev/null +++ b/swift @@ -0,0 +1 @@ +Subproject commit 557365ac2a04a27673ec5aef8ab6b6138daec4e2 From 9db073a87181bbe52ebbcc231e029d166d51d4b5 Mon Sep 17 00:00:00 2001 From: marcin-cebo <102806110+marcin-cebo@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:59:02 +0200 Subject: [PATCH 17/62] Added constructor for testing purpose. (#231) --- .../commonMain/kotlin/com/pubnub/api/PubNubException.kt | 3 ++- .../iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt | 5 ++++- .../jsMain/kotlin/com/pubnub/api/PubNubException.js.kt | 5 ++++- .../src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt | 8 ++++++++ 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt index fcf550f83..f551d754a 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt @@ -11,7 +11,8 @@ package com.pubnub.api */ expect class PubNubException(errorMessage: String?, cause: Throwable? = null) : Exception { constructor(pubnubError: PubNubError, cause: Throwable? = null) - + // test only + constructor(errorMessage: String?, statusCode: Int, cause: Throwable? = null) val statusCode: Int companion object { diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt index 38db51e3e..0b6e82bcb 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt @@ -15,9 +15,12 @@ actual class PubNubException( cause: Throwable? ) : Exception(errorMessage, cause) { - actual constructor(errorMessage: String?, cause: Throwable?): this(statusCode = 0, errorMessage, cause) + actual constructor(errorMessage: String?, cause: Throwable?) : this(statusCode = 0, errorMessage, cause) actual constructor(pubnubError: PubNubError, cause: Throwable?) : this(statusCode = 0, pubnubError.message, cause) + // test only + actual constructor(errorMessage: String?, statusCode: Int, cause: Throwable?) : this(statusCode, errorMessage,cause) + actual companion object { actual fun from(e: Throwable): PubNubException { return if (e is PubNubException) { diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt index 6018b10b9..fb8edd38a 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt @@ -15,9 +15,12 @@ actual class PubNubException( cause: Throwable? ) : Exception(errorMessage, cause) { - actual constructor(errorMessage: String?, cause: Throwable?): this(statusCode = 0, errorMessage, cause) + actual constructor(errorMessage: String?, cause: Throwable?) : this(statusCode = 0, errorMessage, cause) actual constructor(pubnubError: PubNubError, cause: Throwable?) : this(statusCode = 0, pubnubError.message, cause) + // test only + actual constructor(errorMessage: String?, statusCode: Int, cause: Throwable?) : this(statusCode, errorMessage, cause) + actual companion object { actual fun from(e: Throwable): PubNubException { return if (e is PubNubException) { diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt index 6c6ebbabc..8fe09f9bc 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt @@ -49,6 +49,14 @@ actual data class PubNubException( pubnubError = pubnubError, ) + // test only + actual constructor( errorMessage: String?, statusCode: Int, cause: Throwable?) : this( + statusCode = statusCode, + errorMessage = errorMessage, + cause = cause, + pubnubError = null + ) + actual companion object { actual fun from(e: Throwable): PubNubException = if (e is PubNubException) { From 625b53647976f460e10ac0a37e693851be7b4194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 11 Jun 2024 12:08:38 +0000 Subject: [PATCH 18/62] Merge master changes to kmp branch (#234) * Use large GitHub runner (#219) build(runner): change runner groups * Disallow DTDs in XML parser (#222) * Disallow DTDs in XML parser * GCM to FCM migration in PushPayloadHelper (#227) * GCM to FCM migration in PushPayloadHelper * Mc/add integ test (#226) * v.9.2.0 release with FCMPayloadV2 * Enforce string-only values in data * Fix enum values and use deprecation instead of breaking change * PubNub SDK v9.2.0 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> --------- Co-authored-by: Serhii Mamontov Co-authored-by: marcin-cebo <102806110+marcin-cebo@users.noreply.github.com> Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> --- .pubnub.yml | 15 ++- CHANGELOG.md | 9 ++ README.md | 4 +- gradle.properties | 4 +- .../push/payload/PushPayloadHelper.kt | 66 ++++++++++- .../com/pubnub/api/legacy/PubNubCoreTest.kt | 2 +- .../push/PushPayloadHelperHelperTest.kt | 105 ++++++++++++------ 7 files changed, 159 insertions(+), 46 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index 9fc4229e3..312abc3b3 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,9 +1,9 @@ name: kotlin -version: 9.1.1 +version: 9.2.0 schema: 1 scm: github.com/pubnub/kotlin files: - - build/libs/pubnub-kotlin-9.1.1-all.jar + - build/libs/pubnub-kotlin-9.2.0-all.jar sdks: - type: library @@ -23,8 +23,8 @@ sdks: - distribution-type: library distribution-repository: maven - package-name: pubnub-kotlin-9.1.1 - location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/9.1.1/pubnub-kotlin-9.1.1.jar + package-name: pubnub-kotlin-9.2.0 + location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/9.2.0/pubnub-kotlin-9.2.0.jar supported-platforms: supported-operating-systems: Android: @@ -114,6 +114,13 @@ sdks: license-url: https://www.apache.org/licenses/LICENSE-2.0.txt is-required: Required changelog: + - date: 2024-06-11 + version: v9.2.0 + changes: + - type: feature + text: "Add new FCMPayloadV2 for required new FCM push message format." + - type: bug + text: "Disallow DTD in XML parser and enable SecureRandom." - date: 2024-04-15 version: v9.1.1 changes: diff --git a/CHANGELOG.md b/CHANGELOG.md index 714635c15..4459c4655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## v9.2.0 +June 11 2024 + +#### Added +- Add new FCMPayloadV2 for required new FCM push message format. + +#### Fixed +- Disallow DTD in XML parser and enable SecureRandom. + ## v9.1.1 April 15 2024 diff --git a/README.md b/README.md index f1ff8a26a..f79edf725 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,13 @@ You will need the publish and subscribe keys to authenticate your app. Get your com.pubnub pubnub-kotlin - 9.1.1 + 9.2.0 ``` * for Gradle, add the following dependency in your `gradle.build`: ```groovy - implementation 'com.pubnub:pubnub-kotlin:9.1.1' + implementation 'com.pubnub:pubnub-kotlin:9.2.0' ``` 2. Configure your keys and create PubNub instance: diff --git a/gradle.properties b/gradle.properties index 24b0bf128..2296f83e9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,11 +15,11 @@ org.gradle.parallel=true kotlin.code.style=official org.gradle.unsafe.configuration-cache=false -RELEASE_SIGNING_ENABLED=false +RELEASE_SIGNING_ENABLED=true SONATYPE_HOST=DEFAULT SONATYPE_AUTOMATIC_RELEASE=false GROUP=com.pubnub -VERSION_NAME=9.2-DEV +VERSION_NAME=9.2.0 POM_PACKAGING=jar POM_NAME=PubNub SDK diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt index 18fd6bedd..8ca3d0018 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt @@ -4,7 +4,14 @@ import com.pubnub.api.enums.PNPushEnvironment class PushPayloadHelper { var commonPayload: Map? = null + + @Deprecated( + replaceWith = ReplaceWith("fcmPayloadV2"), + message = "The legacy GCM/FCM payload is deprecated and will" + + "be removed in the next major release. Use `fcmPayloadV2` with the `FCMPayloadV2` message body instead." + ) var fcmPayload: FCMPayload? = null + var fcmPayloadV2: FCMPayloadV2? = null var mpnsPayload: MPNSPayload? = null var apnsPayload: APNSPayload? = null @@ -18,6 +25,13 @@ class PushPayloadHelper { } } fcmPayload?.let { + it.toMap().run { + if (isNotEmpty()) { + put("pn_gcm", this) + } + } + } + fcmPayloadV2?.let { it.toMap().run { if (isNotEmpty()) { put("pn_fcm", this) @@ -126,8 +140,46 @@ class PushPayloadHelper { } class FCMPayload : PushPayloadSerializer { + var custom: Map? = null var data: Map? = null var notification: Notification? = null + + override fun toMap(): Map { + return mutableMapOf().apply { + custom?.let { putAll(it) } + data?.let { + if (it.isNotEmpty()) { + put("data", it) + } + } + notification?.let { + it.toMap().run { + if (this.isNotEmpty()) { + put("notification", this) + } + } + } + } + } + + class Notification : PushPayloadSerializer { + var title: String? = null + var body: String? = null + var image: String? = null + + override fun toMap(): Map { + return mutableMapOf().apply { + title?.let { put("title", it) } + body?.let { put("body", it) } + image?.let { put("image", it) } + } + } + } + } + + class FCMPayloadV2 : PushPayloadSerializer { + var data: Map? = null + var notification: Notification? = null var android: AndroidConfig? = null var webpush: WebpushConfig? = null var apns: ApnsConfig? = null @@ -315,14 +367,16 @@ class PushPayloadHelper { } enum class Visibility { - VISIBILITY_UNSPECIFIED, PRIVATE, PUBLIC, - SECRET, + SECRET; + + override fun toString(): String { + return name.lowercase() + } } enum class NotificationPriority { - PRIORITY_UNSPECIFIED, PRIORITY_MIN, PRIORITY_LOW, PRIORITY_DEFAULT, @@ -361,7 +415,11 @@ class PushPayloadHelper { enum class AndroidMessagePriority { NORMAL, - HIGH + HIGH; + + override fun toString(): String { + return name.lowercase() + } } override fun toMap(): Map { diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt index e7021d6d6..57fbc8a19 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt @@ -66,7 +66,7 @@ class PubNubCoreTest : BaseTest() { fun getVersionAndTimeStamp() { val version = PubNubCore.SDK_VERSION val timeStamp = PubNubCore.timestamp() - assertEquals("9.2-DEV", version) + assertEquals("9.2.0", version) assertTrue(timeStamp > 0) } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt index 359c8d332..fb64dcfbf 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt @@ -8,16 +8,17 @@ import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.APNSPayload import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.APNSPayload.APNS2Configuration import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.APNSPayload.APS import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload -import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.AndroidConfig.AndroidFcmOptions -import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.AndroidConfig.AndroidMessagePriority -import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.AndroidConfig.AndroidNotification.LightSettings -import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.AndroidConfig.AndroidNotification.NotificationPriority -import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.AndroidConfig.AndroidNotification.Visibility -import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.ApnsConfig -import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.ApnsConfig.ApnsFcmOptions -import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.FcmOptions -import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.WebpushConfig -import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayload.WebpushConfig.WebpushFcmOptions +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayloadV2 +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayloadV2.AndroidConfig.AndroidFcmOptions +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayloadV2.AndroidConfig.AndroidMessagePriority +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayloadV2.AndroidConfig.AndroidNotification.LightSettings +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayloadV2.AndroidConfig.AndroidNotification.NotificationPriority +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayloadV2.AndroidConfig.AndroidNotification.Visibility +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayloadV2.ApnsConfig +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayloadV2.ApnsConfig.ApnsFcmOptions +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayloadV2.FcmOptions +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayloadV2.WebpushConfig +import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.FCMPayloadV2.WebpushConfig.WebpushFcmOptions import com.pubnub.api.models.consumer.push.payload.PushPayloadHelper.MPNSPayload import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse @@ -40,6 +41,7 @@ class PushPayloadHelperHelperTest : BaseTest() { pushPayloadHelper.apnsPayload = null pushPayloadHelper.commonPayload = null pushPayloadHelper.fcmPayload = null + pushPayloadHelper.fcmPayloadV2 = null pushPayloadHelper.mpnsPayload = null val map = pushPayloadHelper.build() assertTrue(map.isEmpty()) @@ -51,6 +53,7 @@ class PushPayloadHelperHelperTest : BaseTest() { pushPayloadHelper.apnsPayload = APNSPayload() pushPayloadHelper.commonPayload = HashMap() pushPayloadHelper.fcmPayload = FCMPayload() + pushPayloadHelper.fcmPayloadV2 = FCMPayloadV2() pushPayloadHelper.mpnsPayload = MPNSPayload() val map = pushPayloadHelper.build() assertTrue(map.isEmpty()) @@ -288,25 +291,61 @@ class PushPayloadHelperHelperTest : BaseTest() { } @Test - fun testGoogle_Valid_1() { + fun testGoogle_Valid_legacy1() { val pushPayloadHelper = PushPayloadHelper() pushPayloadHelper.fcmPayload = FCMPayload().apply { - data = mapOf("data_1" to "aa") notification = FCMPayload.Notification().apply { + body = "Notification body" + image = null + title = "" + } + custom = mapOf("a" to "a", "b" to 1) + data = mapOf("data_1" to "a", "data_2" to 1) + } + + val map = pushPayloadHelper.build() + + val pnFcmMap = map["pn_gcm"] as Map<*, *> + assertNotNull(pnFcmMap) + + val pnFcmDataMap = pnFcmMap["data"] as Map<*, *> + val pnFcmNotificationsMap = pnFcmMap["notification"] as Map<*, *> + + assertNotNull(pnFcmDataMap) + assertNotNull(pnFcmNotificationsMap) + + assertEquals(pnFcmMap["a"], "a") + assertEquals(pnFcmMap["b"], 1) + assertEquals(pnFcmDataMap["data_1"], "a") + assertEquals(pnFcmDataMap["data_2"], 1) + assertEquals(pnFcmNotificationsMap["body"], "Notification body") + assertEquals(pnFcmNotificationsMap["image"], null) + assertEquals(pnFcmNotificationsMap["title"], "") + } + + @Test + fun testGoogle_Valid_1() { + val pushPayloadHelper = PushPayloadHelper() + + pushPayloadHelper.fcmPayloadV2 = + FCMPayloadV2().apply { + data = mapOf("data_1" to "aa") + notification = + FCMPayloadV2.Notification().apply { body = "Notification body" image = "image" title = "" } - android = FCMPayload.AndroidConfig().apply { + android = FCMPayloadV2.AndroidConfig().apply { collapseKey = "collapseKey" priority = AndroidMessagePriority.HIGH ttl = "ttl" restrictedPackageName = "restricted" data = mapOf("android_data_1" to "a") - notification = FCMPayload.AndroidConfig.AndroidNotification().apply { + notification = FCMPayloadV2.AndroidConfig.AndroidNotification().apply { title = "title" body = "body" icon = "icon" @@ -477,8 +516,8 @@ class PushPayloadHelperHelperTest : BaseTest() { @Test fun testGoogle_Empty() { val pushPayloadHelper = PushPayloadHelper() - val fcmPayload = FCMPayload() - pushPayloadHelper.fcmPayload = fcmPayload + val fcmPayload = FCMPayloadV2() + pushPayloadHelper.fcmPayloadV2 = fcmPayload val map = pushPayloadHelper.build() val pnFcmMap = map["pn_fcm"] assertNull(pnFcmMap) @@ -487,14 +526,14 @@ class PushPayloadHelperHelperTest : BaseTest() { @Test fun testGoogle_EmptyNotification() { val pushPayloadHelper = PushPayloadHelper() - val notification = FCMPayload.Notification() - val customMap = HashMap() + val notification = FCMPayloadV2.Notification() + val customMap = HashMap() customMap["key_1"] = "1" - customMap["key_2"] = 2 - val fcmPayload = FCMPayload() + customMap["key_2"] = "2" + val fcmPayload = FCMPayloadV2() fcmPayload.notification = notification fcmPayload.data = customMap - pushPayloadHelper.fcmPayload = fcmPayload + pushPayloadHelper.fcmPayloadV2 = fcmPayload val map = pushPayloadHelper.build() val pnFcmMap = map["pn_fcm"] as Map<*, *> val pnFcmNotificationMap = pnFcmMap["notification"] @@ -504,10 +543,10 @@ class PushPayloadHelperHelperTest : BaseTest() { @Test fun testGoogle_EmptyData() { val pushPayloadHelper = PushPayloadHelper() - val fcmPayload = FCMPayload() - val dataMap = HashMap() + val fcmPayload = FCMPayloadV2() + val dataMap = HashMap() fcmPayload.data = dataMap - pushPayloadHelper.fcmPayload = fcmPayload + pushPayloadHelper.fcmPayloadV2 = fcmPayload val map = pushPayloadHelper.build() val pnFcmMap = map["pn_fcm"] assertNull(pnFcmMap) @@ -517,16 +556,16 @@ class PushPayloadHelperHelperTest : BaseTest() { fun testGoogle_Valid_2() { val pushPayloadHelper = PushPayloadHelper() val fcmPayload = - FCMPayload().apply { + FCMPayloadV2().apply { data = mapOf( "key_1" to "value_1", - "key_2" to 2, - "key_3" to true, + "key_2" to "2", + "key_3" to "true", "key_4" to "", ) } - pushPayloadHelper.fcmPayload = fcmPayload + pushPayloadHelper.fcmPayloadV2 = fcmPayload val map = pushPayloadHelper.build() val pnFcmMap = map["pn_fcm"] as Map<*, *> @@ -546,19 +585,19 @@ class PushPayloadHelperHelperTest : BaseTest() { @Test fun testGoogle_Custom() { val pushPayloadHelper = PushPayloadHelper() - pushPayloadHelper.fcmPayload = - FCMPayload().apply { + pushPayloadHelper.fcmPayloadV2 = + FCMPayloadV2().apply { data = mapOf( "key_1" to "value_1", - "key_2" to 2, - "key_3" to true, + "key_2" to "2", + "key_3" to "true", "key_4" to "", ) } val map = pushPayloadHelper.build() - val pnFcmMap = (map["pn_fcm"] as Map<*, *>)["data"] as Map + val pnFcmMap = (map["pn_fcm"] as Map<*, *>)["data"] as Map assertNotNull(pnFcmMap) assertFalse(pnFcmMap.isEmpty()) assertTrue(pnFcmMap.containsKey("key_1")) From 14d33485fdefb3456f564388ca042d3c58b25f22 Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Wed, 12 Jun 2024 09:42:02 +0200 Subject: [PATCH 19/62] Wrapping next AppContext methods (#229) --- .../kotlin/com/pubnub/api/Endpoint.ios.kt | 32 +++++++--- .../kotlin/com/pubnub/api/PubNubImpl.kt | 26 ++++++++- .../channel/GetAllChannelMetadata.ios.kt | 16 ++--- .../objects/channel/GetChannelMetadata.ios.kt | 1 - .../objects/channel/SetChannelMetadata.ios.kt | 53 ++++++++++++++++- .../objects/uuid/GetAllUUIDMetadata.ios.kt | 15 ++--- .../objects/uuid/SetUUIDMetadata.ios.kt | 58 ++++++++++++++++++- .../kotlin/com/pubnub/kmp/abstractions.ios.kt | 2 +- 8 files changed, 174 insertions(+), 29 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt index 304ffe45b..cc6d817e2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt @@ -9,17 +9,33 @@ actual interface Endpoint { } fun Consumer>.onSuccessHandler(mapper: (T) -> U) : (T) -> Unit { - return fun(input: T) { accept( - try { - Result.success(mapper(input)) - } catch (e: Exception) { - Result.failure(e) - } - ) } + return { input: T -> + accept( + try { + Result.success(mapper(input)) + } catch (e: Exception) { + Result.failure(e) + } + ) + } +} + +fun Consumer>.onSuccessHandler3(mapper: (T, X, Y) -> U) : (T, X, Y) -> Unit { + return { input: T, secondInput: X, thirdInput: Y -> + accept( + try { + Result.success(mapper(input, secondInput, thirdInput)) + } catch (e: Exception) { + Result.failure(e) + } + ) + } } fun Consumer>.onSuccessReturnValue(value: T) : () -> Unit { - return fun() { accept(Result.success(value)) } + return { + accept(Result.success(value)) + } } fun Consumer>.onFailureHandler(mapper: (NSError?) -> Throwable = { error: NSError? -> diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 56dc85ac7..4f34cabcf 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -44,6 +44,7 @@ import com.pubnub.api.endpoints.objects.channel.GetChannelMetadataImpl import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadataImpl import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadataImpl import com.pubnub.api.endpoints.objects.member.GetChannelMembers import com.pubnub.api.endpoints.objects.member.ManageChannelMembers import com.pubnub.api.endpoints.objects.membership.GetMemberships @@ -55,6 +56,7 @@ import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadataImpl import com.pubnub.api.endpoints.presence.GetState import com.pubnub.api.endpoints.presence.GetStateImpl import com.pubnub.api.endpoints.presence.HereNow @@ -412,7 +414,16 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { type: String?, status: String? ): SetChannelMetadata { - TODO("Not yet implemented") + return SetChannelMetadataImpl( + pubnub = pubNubObjC, + channel = channel, + name = name, + description = description, + custom = custom, + includeCustom = includeCustom, + type = type, + status = status + ) } override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { @@ -453,7 +464,18 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { type: String?, status: String? ): SetUUIDMetadata { - TODO("Not yet implemented") + return SetUUIDMetadataImpl( + pubnub = pubNubObjC, + uuid = uuid, + name = name, + externalId = externalId, + profileUrl = profileUrl, + email = email, + custom = custom, + includeCustom = includeCustom, + type = type, + status = status + ) } override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt index 4d6f4dd49..32a90f0f2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt @@ -1,7 +1,6 @@ package com.pubnub.api.endpoints.objects.channel import cocoapods.PubNubSwift.PubNubChannelMetadataObjC -import cocoapods.PubNubSwift.PubNubGetChannelMetadataResultObjC import cocoapods.PubNubSwift.PubNubHashedPageObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.PubNubSortPropertyObjC @@ -14,6 +13,7 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult import com.pubnub.api.onFailureHandler import com.pubnub.api.onSuccessHandler +import com.pubnub.api.onSuccessHandler3 import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -51,24 +51,24 @@ class GetAllChannelMetadataImpl( }, includeCount = includeCount, includeCustom = includeCustom, - onSuccess = callback.onSuccessHandler { + onSuccess = callback.onSuccessHandler3() { data, totalCount, next -> PNChannelMetadataArrayResult( - status = it?.status()?.toInt() ?: 0, - data = (it?.data() as List).map { metadata -> + status = 200, + data = (data as List).map { metadata -> PNChannelMetadata( id = metadata.id(), name = metadata.name(), description = metadata.descr(), - custom = metadata.custom() as? Map, + custom = metadata.custom() as? Map, // TODO: Verify updated = metadata.updated(), eTag = metadata.eTag(), type = metadata.type(), status = metadata.status() ) }, - totalCount = it.totalCount()?.intValue ?: 0, - next = it.next()?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, - prev = it.next()?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + totalCount = totalCount?.intValue, + next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt index 3db8b821c..4cd925c90 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt @@ -1,6 +1,5 @@ package com.pubnub.api.endpoints.objects.channel -import cocoapods.PubNubSwift.PubNubGetChannelMetadataResultObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getChannelMetadataWithChannel import com.pubnub.api.Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt index 1ab95a261..b4cb43f60 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt @@ -1,9 +1,60 @@ package com.pubnub.api.endpoints.objects.channel +import cocoapods.PubNubSwift.AnyJSONObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.setChannelMetadataWithChannel import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.CustomObject +import kotlinx.cinterop.ExperimentalForeignApi +import platform.posix.stat /** * @see [PubNub.setChannelMetadata] */ -actual interface SetChannelMetadata : Endpoint \ No newline at end of file +actual interface SetChannelMetadata : Endpoint + +@OptIn(ExperimentalForeignApi::class) +class SetChannelMetadataImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val name: String?, + private val description: String?, + private val custom: CustomObject?, + private val includeCustom: Boolean, + private val type: String?, + private val status: String? +): SetChannelMetadata { + override fun async(callback: Consumer>) { + pubnub.setChannelMetadataWithChannel( + channel = channel, + name = name, + description = description, + custom = AnyJSONObjC(value = custom?.value), + includeCustom = includeCustom, + type = type, + status = status, + onSuccess = callback.onSuccessHandler { + PNChannelMetadataResult( + status = 200, + data = PNChannelMetadata( + id = it?.id() ?: "", + name = it?.name(), + description = it?.descr(), + custom = it?.custom()?.asMap() as? Map, // TODO: Verify + updated = it?.updated(), + eTag = it?.eTag(), + type = it?.type(), + status = it?.status() + ) + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt index a180e294d..73b46af95 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt @@ -17,6 +17,7 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult import com.pubnub.api.onFailureHandler import com.pubnub.api.onSuccessHandler +import com.pubnub.api.onSuccessHandler3 import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -54,26 +55,26 @@ class GetAllUUIDMetadataImpl( }, includeCount = includeCount, includeCustom = includeCustom, - onSuccess = callback.onSuccessHandler { + onSuccess = callback.onSuccessHandler3() { data, totalCount, next -> PNUUIDMetadataArrayResult( - status = it?.status()?.toInt() ?: 0, - data = (it?.data() as List).map { metadata -> + status = 200, + data = (data as List).map { metadata -> PNUUIDMetadata( id = metadata.id(), name = metadata.name(), externalId = metadata.externalId(), profileUrl = metadata.profileUrl(), email = metadata.email(), - custom = metadata.custom() as? Map, + custom = metadata.custom() as? Map, // TODO: Verify updated = metadata.updated(), eTag = metadata.eTag(), type = metadata.type(), status = metadata.status() ) }, - totalCount = it.totalCount()?.intValue ?: 0, - next = it.next()?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, - prev = it.next()?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + totalCount = totalCount?.intValue ?: 0, + next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt index ed963f67b..263676872 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt @@ -1,9 +1,65 @@ package com.pubnub.api.endpoints.objects.uuid +import cocoapods.PubNubSwift.AnyJSONObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.setUUIDMetadataWithUuid import com.pubnub.api.Endpoint +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.api.onFailureHandler +import com.pubnub.api.onSuccessHandler +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.CustomObject +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.setUUIDMetadata] */ -actual interface SetUUIDMetadata : Endpoint \ No newline at end of file +actual interface SetUUIDMetadata : Endpoint + +@OptIn(ExperimentalForeignApi::class) +class SetUUIDMetadataImpl( + private val pubnub: PubNubObjC, + private val uuid: String?, + private val name: String?, + private val externalId: String?, + private val profileUrl: String?, + private val email: String?, + private val custom: CustomObject?, + private val includeCustom: Boolean, + private val type: String?, + private val status: String? +): SetUUIDMetadata { + override fun async(callback: Consumer>) { + pubnub.setUUIDMetadataWithUuid( + uuid = uuid, + name = name, + externalId = externalId, + profileUrl = profileUrl, + email = email, + custom = AnyJSONObjC(value = custom?.value), + includeCustom = includeCustom, + type = type, + status = status, + onSuccess = callback.onSuccessHandler { + PNUUIDMetadataResult( + status = 200, + data = PNUUIDMetadata( + id = it?.id() ?: "", + name = it?.name(), + externalId = it?.externalId(), + profileUrl = it?.profileUrl(), + email = it?.email(), + custom = it?.custom()?.asMap() as? Map, // TODO: Verify + updated = it?.updated(), + eTag = it?.eTag(), + type = it?.type(), + status = it?.status() + ) + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt index cdcdc2a32..fb862ec85 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt @@ -1,3 +1,3 @@ package com.pubnub.kmp -actual class CustomObject(private val value: Any) \ No newline at end of file +actual class CustomObject(val value: Any) \ No newline at end of file From 161c608d5dac448126124af4978ff27c9ce19bfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:44:28 +0000 Subject: [PATCH 20/62] [KMP] Move tests and make more tests work on iOS (#235) --- kotlin-js-store/yarn.lock | 5 - .../pubnub-kotlin-api/build.gradle.kts | 36 + .../com/pubnub/api/ChannelMetadataTest.kt | 0 .../kotlin/com/pubnub/api/MembersTest.kt | 0 .../kotlin/com/pubnub/api/MembershipsTest.kt | 0 .../kotlin/com/pubnub/api/PublishTest.kt | 28 +- .../kotlin/com/pubnub/api/UserMetadataTest.kt | 0 .../kotlin/com/pubnub/kmp/platform.kt | 0 .../com/pubnub/test/BaseIntegrationTest.kt | 12 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 6 +- .../kotlin/com/pubnub/kmp/platform.ios.kt | 0 .../src/iosTest/kotlin/testlauncher.kt | 0 .../kotlin/com/pubnub/kmp/platform.js.kt | 0 .../kotlin/com/pubnub/kmp/platform.jvm.kt | 0 .../pubnub-kotlin-test/build.gradle.kts | 98 +- .../kotlin/com.pubnub.test/FakePubNub.kt | 1778 ++++++++--------- .../kotlin/com.pubnub.test/FakePubNub.ios.kt | 78 +- .../kotlin/com.pubnub.test/FakePubNub.js.kt | 54 +- .../kotlin/com.pubnub.test/FakePubNub.jvm.kt | 84 +- 19 files changed, 1091 insertions(+), 1088 deletions(-) rename pubnub-kotlin/{pubnub-kotlin-test => pubnub-kotlin-api}/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt (100%) rename pubnub-kotlin/{pubnub-kotlin-test => pubnub-kotlin-api}/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt (100%) rename pubnub-kotlin/{pubnub-kotlin-test => pubnub-kotlin-api}/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt (100%) rename pubnub-kotlin/{pubnub-kotlin-test => pubnub-kotlin-api}/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt (86%) rename pubnub-kotlin/{pubnub-kotlin-test => pubnub-kotlin-api}/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt (100%) rename pubnub-kotlin/{pubnub-kotlin-test/src/commonMain => pubnub-kotlin-api/src/commonTest}/kotlin/com/pubnub/kmp/platform.kt (100%) rename pubnub-kotlin/{pubnub-kotlin-test => pubnub-kotlin-api}/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt (96%) rename pubnub-kotlin/{pubnub-kotlin-test/src/iosMain => pubnub-kotlin-api/src/iosTest}/kotlin/com/pubnub/kmp/platform.ios.kt (100%) rename pubnub-kotlin/{pubnub-kotlin-test => pubnub-kotlin-api}/src/iosTest/kotlin/testlauncher.kt (100%) rename pubnub-kotlin/{pubnub-kotlin-test/src/jsMain => pubnub-kotlin-api/src/jsTest}/kotlin/com/pubnub/kmp/platform.js.kt (100%) rename pubnub-kotlin/{pubnub-kotlin-test/src/jvmMain => pubnub-kotlin-api/src/jvmTest}/kotlin/com/pubnub/kmp/platform.jvm.kt (100%) diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index f8ef7df39..022f3c998 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -64,11 +64,6 @@ "@jridgewell/resolve-uri" "^3.1.0" "@jridgewell/sourcemap-codec" "^1.4.14" -"@js-joda/core@3.2.0": - version "3.2.0" - resolved "https://registry.yarnpkg.com/@js-joda/core/-/core-3.2.0.tgz#3e61e21b7b2b8a6be746df1335cf91d70db2a273" - integrity sha512-PMqgJ0sw5B7FKb2d5bWYIoxjri+QlW/Pys7+Rw82jSH0QN3rB05jZ/VrrsUdh1w4+i2kw9JOejXGq/KhDOX7Kg== - "@jsonjoy.com/base64@^1.1.1": version "1.1.2" resolved "https://registry.yarnpkg.com/@jsonjoy.com/base64/-/base64-1.1.2.tgz#cf8ea9dcb849b81c95f14fc0aaa151c6b54d2578" diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index 1b0337254..d86e61367 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -1,11 +1,25 @@ +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable + plugins { alias(libs.plugins.benmanes.versions) id("pubnub.shared") id("pubnub.dokka") id("pubnub.multiplatform") + id("pubnub.ios-simulator-test") + } kotlin { + js { + browser { + testTask { + useMocha { + timeout = "30s" + } + } + } + } sourceSets { val commonMain by getting { dependencies { @@ -25,6 +39,28 @@ kotlin { implementation(npm("pubnub", "8.1.0")) } } + + val commonTest by getting { + dependencies { + implementation(project(":pubnub-kotlin:pubnub-kotlin-test")) + implementation(kotlin("test")) + implementation(libs.coroutines.test) + } + } + + val jvmTest by getting { + dependencies { + implementation(project(":pubnub-kotlin:pubnub-kotlin-impl")) + } + } + } + + targets.withType { + if (konanTarget.family.isAppleFamily) { + binaries.withType { + freeCompilerArgs += listOf("-e", "testlauncher.mainBackground") + } + } } } diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt similarity index 86% rename from pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt index 91ef324d7..938ac3f12 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt @@ -5,10 +5,7 @@ import com.pubnub.kmp.createCustomObject import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await import com.pubnub.test.test -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.delay import kotlinx.coroutines.test.runTest -import kotlinx.coroutines.withContext import kotlin.js.JsExport import kotlin.test.Ignore import kotlin.test.Test @@ -51,11 +48,7 @@ class PublishTest : BaseIntegrationTest() { @Test fun can_receive_message_with_object_metadata() = runTest(timeout = 10.seconds) { pubnub.test(backgroundScope) { -// pubnub.awaitSubscribe(listOf(channel)) - pubnub.subscribe(listOf(channel)) - withContext(Dispatchers.Default) { - delay(2000) - } + pubnub.awaitSubscribe(listOf(channel)) val mapData = mapOf( "stringValue" to "bbb", "mapValue" to mapOf("innerKey" to false), @@ -70,18 +63,13 @@ class PublishTest : BaseIntegrationTest() { val result = nextMessage() assertEquals("some message", result.message.asString()) deepCompare(mapData, result.userMetadata!!) -// assertEquals(mapOf("aa" to "bb"), result.userMetadata?.asMap()?.mapValues { it.value.asString() }) } } @Test fun can_receive_message_with_primitive_payload() = runTest(timeout = 10.seconds) { pubnub.test(backgroundScope) { -// pubnub.awaitSubscribe(listOf(channel)) - pubnub.subscribe(listOf(channel)) - withContext(Dispatchers.Default) { - delay(2000) - } + pubnub.awaitSubscribe(listOf(channel)) pubnub.publish( channel, 111, @@ -101,11 +89,7 @@ class PublishTest : BaseIntegrationTest() { @Test fun can_receive_message_with_map_payload() = runTest(timeout = 10.seconds) { pubnub.test(backgroundScope) { -// pubnub.awaitSubscribe(listOf(channel)) - pubnub.subscribe(listOf(channel)) - withContext(Dispatchers.Default) { - delay(2000) - } + pubnub.awaitSubscribe(listOf(channel)) val mapData = mapOf( "stringValue" to "bbb", "mapValue" to mapOf("innerKey" to false), @@ -126,11 +110,7 @@ class PublishTest : BaseIntegrationTest() { @Test fun can_receive_message_with_payload_with_floats() = runTest(timeout = 10.seconds) { pubnub.test(backgroundScope) { -// pubnub.awaitSubscribe(listOf(channel)) - pubnub.subscribe(listOf(channel)) - withContext(Dispatchers.Default) { - delay(2000) - } + pubnub.awaitSubscribe(listOf(channel)) val mapData = mapOf( "floatValue" to 1.23f, "doubleValue" to 1.23, diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com/pubnub/kmp/platform.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/kmp/platform.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com/pubnub/kmp/platform.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/kmp/platform.kt diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt similarity index 96% rename from pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt index bf97b59c1..da4568cdd 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt @@ -56,11 +56,11 @@ class PubNubTest( private val messageQueue = Channel(10) private val statusQueue = Channel(10) -// private val statusVerificationListener = createStatusListener(pubNub) { _, status -> -// backgroundScope.launch { -// statusQueue.send(status) -// } -// } + private val statusVerificationListener = createStatusListener(pubNub) { _, status -> + backgroundScope.launch { + statusQueue.send(status) + } + } private val eventVerificationListener = createEventListener( pubNub, onMessage = { _, event -> @@ -98,7 +98,7 @@ class PubNubTest( init { pubNub.addListener(eventVerificationListener) -// pubNub.addListener(statusVerificationListener) + pubNub.addListener(statusVerificationListener) } suspend fun PubNub.awaitSubscribe( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 4f34cabcf..531fc49ac 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -1,6 +1,8 @@ package com.pubnub.api import cocoapods.PubNubSwift.addEventListenerWithListener +import cocoapods.PubNubSwift.addStatusListenerWithListener +import cocoapods.PubNubSwift.removeEventListenerWithListener import cocoapods.PubNubSwift.setWithToken import cocoapods.PubNubSwift.subscribeWithChannels import cocoapods.PubNubSwift.subscribedChannelGroups @@ -111,11 +113,11 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun addListener(listener: StatusListener) { - TODO("Not yet implemented") + pubNubObjC.addStatusListenerWithListener(listener = listener.underlying) } override fun removeListener(listener: Listener) { - TODO("Not yet implemented") +// pubNubObjC.removeEventListenerWithListener(listener) } override fun removeAllListeners() { diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com/pubnub/kmp/platform.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/com/pubnub/kmp/platform.ios.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com/pubnub/kmp/platform.ios.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/com/pubnub/kmp/platform.ios.kt diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/iosTest/kotlin/testlauncher.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/testlauncher.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-test/src/iosTest/kotlin/testlauncher.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/testlauncher.kt diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com/pubnub/kmp/platform.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsTest/kotlin/com/pubnub/kmp/platform.js.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com/pubnub/kmp/platform.js.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jsTest/kotlin/com/pubnub/kmp/platform.js.kt diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com/pubnub/kmp/platform.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmTest/kotlin/com/pubnub/kmp/platform.jvm.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com/pubnub/kmp/platform.jvm.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmTest/kotlin/com/pubnub/kmp/platform.jvm.kt diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts index b555cdb7c..b9c06bed9 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -8,77 +8,67 @@ plugins { alias(libs.plugins.benmanes.versions) id("pubnub.shared") id("pubnub.ios-simulator-test") - id("pubnub.multiplatform") +// id("pubnub.multiplatform") + kotlin("multiplatform") id("com.codingfeline.buildkonfig") version "0.15.1" } kotlin { - js { -// compilations.all { -// compileTaskProvider.configure { -// kotlinOptions { -// target = "es2015" -// } -// } -// } + jvmToolchain(8) + js { browser { -// dceTask { -// keep("com.pubnub.api", "com.pubnub.kmp") -// } - - testTask { - useMocha { - timeout = "30s" - } - } } + binaries.executable() } + jvm() + iosArm64() + iosSimulatorArm64() sourceSets { - val commonMain by getting { - dependencies { - api(project(":pubnub-kotlin:pubnub-kotlin-api")) - api(project(":pubnub-core:pubnub-core-api")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") - implementation(libs.datetime) - } - } - - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1") - implementation(libs.coroutines.test) - } - } - - val jvmMain by getting { - dependencies { - implementation(project(":pubnub-core:pubnub-core-impl")) - } - } - - val jvmTest by getting { - dependencies { - implementation(project(":pubnub-kotlin:pubnub-kotlin-impl")) - } - } +// val commonMain by getting { +// dependencies { +// api(project(":pubnub-kotlin:pubnub-kotlin-api")) +// api(project(":pubnub-core:pubnub-core-api")) +// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") +// implementation(libs.datetime) +// } +// } +// +// val commonTest by getting { +// dependencies { +// implementation(kotlin("test")) +// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1") +// implementation(libs.coroutines.test) +// } +// } +// +// val jvmMain by getting { +// dependencies { +// implementation(project(":pubnub-core:pubnub-core-impl")) +// } +// } +// +// val jvmTest by getting { +// dependencies { +// implementation(project(":pubnub-kotlin:pubnub-kotlin-impl")) +// } +// } } - targets.withType { - if (konanTarget.family.isAppleFamily) { - binaries.withType { - freeCompilerArgs += listOf("-e", "testlauncher.mainBackground") - } - } - } +// targets.withType { +// if (konanTarget.family.isAppleFamily) { +// binaries.withType { +// freeCompilerArgs += listOf("-e", "testlauncher.mainBackground") +// } +// } +// } buildkonfig { packageName = "com.pubnub.test" - objectName = "Keys" + exposeObjectWithName = "Keys" defaultConfigs { val testProps = Properties() diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt index 8c74ce261..4a317db8c 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt @@ -1,635 +1,181 @@ -package com.pubnub.test - -import com.pubnub.api.JsonElement -import com.pubnub.api.PubNub -import com.pubnub.api.asMap -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.endpoints.DeleteMessages -import com.pubnub.api.endpoints.FetchMessages -import com.pubnub.api.endpoints.MessageCounts -import com.pubnub.api.endpoints.Time -import com.pubnub.api.endpoints.access.GrantToken -import com.pubnub.api.endpoints.access.RevokeToken -import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup -import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup -import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup -import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup -import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup -import com.pubnub.api.endpoints.files.DeleteFile -import com.pubnub.api.endpoints.files.GetFileUrl -import com.pubnub.api.endpoints.files.ListFiles -import com.pubnub.api.endpoints.files.PublishFileMessage -import com.pubnub.api.endpoints.message_actions.AddMessageAction -import com.pubnub.api.endpoints.message_actions.GetMessageActions -import com.pubnub.api.endpoints.message_actions.RemoveMessageAction -import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata -import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata -import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata -import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata -import com.pubnub.api.endpoints.objects.member.GetChannelMembers -import com.pubnub.api.endpoints.objects.member.ManageChannelMembers -import com.pubnub.api.endpoints.objects.membership.GetMemberships -import com.pubnub.api.endpoints.objects.membership.ManageMemberships -import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata -import com.pubnub.api.endpoints.presence.GetState -import com.pubnub.api.endpoints.presence.HereNow -import com.pubnub.api.endpoints.presence.SetState -import com.pubnub.api.endpoints.presence.WhereNow -import com.pubnub.api.endpoints.pubsub.Publish -import com.pubnub.api.endpoints.pubsub.Signal -import com.pubnub.api.endpoints.push.AddChannelsToPush -import com.pubnub.api.endpoints.push.ListPushProvisions -import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice -import com.pubnub.api.endpoints.push.RemoveChannelsFromPush -import com.pubnub.api.enums.PNPushEnvironment -import com.pubnub.api.enums.PNPushType -import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant -import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant -import com.pubnub.api.models.consumer.message_actions.PNMessageAction -import com.pubnub.api.models.consumer.objects.PNKey -import com.pubnub.api.models.consumer.objects.PNMemberKey -import com.pubnub.api.models.consumer.objects.PNMembershipKey -import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.models.consumer.objects.PNSortKey -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata -import com.pubnub.api.models.consumer.objects.member.MemberInput -import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel -import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput -import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -import com.pubnub.api.models.consumer.pubsub.BasePubSubResult -import com.pubnub.api.models.consumer.pubsub.PNEvent -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.v2.PNConfiguration -import com.pubnub.api.v2.callbacks.Consumer -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.Result -import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.kmp.CustomObject -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.SupervisorJob -import kotlinx.coroutines.flow.MutableSharedFlow -import kotlinx.coroutines.flow.MutableStateFlow -import kotlinx.coroutines.flow.collectLatest -import kotlinx.coroutines.flow.combine -import kotlinx.coroutines.flow.mapNotNull -import kotlinx.coroutines.flow.scan -import kotlinx.coroutines.flow.transformLatest -import kotlinx.coroutines.flow.update -import kotlinx.coroutines.launch -import kotlinx.datetime.Clock -import kotlinx.datetime.Instant -import kotlin.time.Duration.Companion.minutes - - -expect fun EventListener.emit(pubnub: PubNub, event: PNEvent) -expect fun StatusListener.emit(pubnub: PubNub, status: PNStatus) -expect fun Any.toJsonElement(): JsonElement - -//class FakePubNub(override val configuration: PNConfiguration) : PubNub { -// -// val scope = CoroutineScope(SupervisorJob()) -// -// fun Long.toEpochSeconds() = this / 10000000 -// fun generateTimetoken() = Clock.System.now().toEpochMilliseconds() * 10000 -// -// val events = MutableSharedFlow(100, 100) -// val subscriptionStream = events.mapNotNull { -// val tt = it.timetoken ?: return@mapNotNull null -// if (Clock.System.now() < Instant.fromEpochSeconds(tt.toEpochSeconds()) - 10.minutes) { -// it -// } else { -// null -// } -// } -// -// private val subscribedChannelAndGroups = MutableStateFlow, Set>>(Pair(emptySet(), emptySet())) -// private val timetoken = MutableSharedFlow() -// -// init { -// scope.launch { -// subscribedChannelAndGroups.scan(Pair(setOf(), setOf())) { last: Pair, Set>, next: Pair, Set> -> -// if (last.first.isEmpty() && last.second.isEmpty() && (next.first.isNotEmpty() || next.second.isNotEmpty())) { -// //emit connected -// } else if (next.first.isEmpty() && next.second.isEmpty() && (last.first.isNotEmpty() || last.second.isNotEmpty())) { -// timetoken.emit(0) -// //emit disconnected -// } else { -// //emit changed -// } -// next -// }.collectLatest { subscriptions: Pair, Set> -> -// events.collect { event: PNEvent -> -// if (event.channel in subscriptions.first) { -// listeners.value.filterIsInstance().forEach { -// it.emit(this@FakePubNub, event) -// } -// } -// } -// } -// } -// } -// -// -// val messages: MutableList = mutableListOf() -// val userMetadata: MutableMap = mutableMapOf() -// val channelMetadata: MutableMap = mutableMapOf() -// -// private val listeners = MutableStateFlow(setOf()) -// -// override fun addListener(listener: EventListener) { -// listeners.update { previousSet -> -// buildSet { -// addAll(previousSet) -// add(listener) -// } -// } -// } -// -// override fun addListener(listener: StatusListener) { -// listeners.update { previousSet -> -// buildSet { -// addAll(previousSet) -// add(listener) -// } -// } -// } -// -// override fun removeListener(listener: Listener) { -// listeners.update { previousSet -> -// buildSet { -// addAll(previousSet) -// remove(listener) -// } -// } -// } -// -// override fun removeAllListeners() { -// listeners.update { -// emptySet() -// } -// } -// -// override fun publish( -// channel: String, -// message: Any, -// meta: Any?, -// shouldStore: Boolean?, -// usePost: Boolean, -// replicate: Boolean, -// ttl: Int? -// ): Publish { -// return object : Publish { -// override fun async(callback: Consumer>) { -// scope.launch { -// events.emit(PNMessageResult( -// BasePubSubResult( -// channel, -// null, -// generateTimetoken(), -// meta?.toJsonElement(), -// configuration.userId.value -// ), message.toJsonElement(), null -// )) -// } -// } -// } -// } -// -// override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { -// TODO("Not yet implemented") -// } -// -// override fun signal(channel: String, message: Any): Signal { -// TODO("Not yet implemented") -// } -// -// override fun getSubscribedChannels(): List { -// return subscribedChannelAndGroups.value.first.toList() -// } -// -// override fun getSubscribedChannelGroups(): List { -// return subscribedChannelAndGroups.value.second.toList() -// } -// -// override fun addPushNotificationsOnChannels( -// pushType: PNPushType, -// channels: List, -// deviceId: String, -// topic: String?, -// environment: PNPushEnvironment -// ): AddChannelsToPush { -// TODO("Not yet implemented") -// } -// -// override fun auditPushChannelProvisions( -// pushType: PNPushType, -// deviceId: String, -// topic: String?, -// environment: PNPushEnvironment -// ): ListPushProvisions { -// TODO("Not yet implemented") -// } -// -// override fun removePushNotificationsFromChannels( -// pushType: PNPushType, -// channels: List, -// deviceId: String, -// topic: String?, -// environment: PNPushEnvironment -// ): RemoveChannelsFromPush { -// TODO("Not yet implemented") -// } -// -// override fun removeAllPushNotificationsFromDeviceWithPushToken( -// pushType: PNPushType, -// deviceId: String, -// topic: String?, -// environment: PNPushEnvironment -// ): RemoveAllPushChannelsForDevice { -// TODO("Not yet implemented") -// } -// -// override fun fetchMessages( -// channels: List, -// page: PNBoundedPage, -// includeUUID: Boolean, -// includeMeta: Boolean, -// includeMessageActions: Boolean, -// includeMessageType: Boolean -// ): FetchMessages { -// TODO("Not yet implemented") -// } -// -// override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { -// TODO("Not yet implemented") -// } -// -// override fun messageCounts(channels: List, channelsTimetoken: List): MessageCounts { -// TODO("Not yet implemented") -// } -// -// override fun hereNow( -// channels: List, -// channelGroups: List, -// includeState: Boolean, -// includeUUIDs: Boolean -// ): HereNow { -// TODO("Not yet implemented") -// } -// -// override fun whereNow(uuid: String): WhereNow { -// TODO("Not yet implemented") -// } -// -// override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { -// TODO("Not yet implemented") -// } -// -// override fun presence(channels: List, channelGroups: List, connected: Boolean) { -// TODO("Not yet implemented") -// } -// -// override fun addMessageAction(channel: String, messageAction: PNMessageAction): AddMessageAction { -// TODO("Not yet implemented") -// } -// -// override fun removeMessageAction( -// channel: String, -// messageTimetoken: Long, -// actionTimetoken: Long -// ): RemoveMessageAction { -// TODO("Not yet implemented") -// } -// -// override fun getMessageActions(channel: String, page: PNBoundedPage): GetMessageActions { -// TODO("Not yet implemented") -// } -// -// override fun addChannelsToChannelGroup(channels: List, channelGroup: String): AddChannelChannelGroup { -// TODO("Not yet implemented") -// } -// -// override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { -// TODO("Not yet implemented") -// } -// -// override fun removeChannelsFromChannelGroup( -// channels: List, -// channelGroup: String -// ): RemoveChannelChannelGroup { -// TODO("Not yet implemented") -// } -// -// override fun listAllChannelGroups(): ListAllChannelGroup { -// TODO("Not yet implemented") -// } -// -// override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { -// TODO("Not yet implemented") -// } -// -// override fun revokeToken(token: String): RevokeToken { -// TODO("Not yet implemented") -// } -// -// override fun time(): Time { -// TODO("Not yet implemented") -// } -// -// override fun getAllChannelMetadata( -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean -// ): GetAllChannelMetadata { -// TODO("Not yet implemented") -// } -// -// override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { -// TODO("Not yet implemented") -// } -// -// override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { -// TODO("Not yet implemented") -// } -// -// override fun getAllUUIDMetadata( -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean -// ): GetAllUUIDMetadata { -// TODO("Not yet implemented") -// } -// -// override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { -// TODO("Not yet implemented") -// } -// -// override fun setUUIDMetadata( -// uuid: String?, -// name: String?, -// externalId: String?, -// profileUrl: String?, -// email: String?, -// custom: CustomObject?, -// includeCustom: Boolean, -// type: String?, -// status: String? -// ): SetUUIDMetadata { -// val actualUuid = uuid ?: configuration.userId.value -// val result = userMetadata.compute(actualUuid) { a: String, b: PNUUIDMetadata? -> -// PNUUIDMetadata( -// actualUuid, -// name ?: b?.name, -// externalId ?: b?.externalId, -// profileUrl ?: b?.profileUrl, -// email ?: b?.email, -// custom?.toJsonElement()?.asMap() ?: b?.custom, -// Clock.System.now().toString(), -// null, -// type ?: b?.type, -// status ?: b?.status -// ) -// } -// return object : SetUUIDMetadata { -// override fun async(callback: Consumer>) { -// callback.accept(Result.success(PNUUIDMetadataResult( -// 200, -// if (!includeCustom) { -// result?.copy(custom = null) -// } else { -// result -// } -// ) -// )) -// } -// } -// } -// -// override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { -// TODO("Not yet implemented") -// } -// -// override fun getMemberships( -// uuid: String?, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeChannelDetails: PNChannelDetailsLevel? -// ): GetMemberships { -// TODO("Not yet implemented") -// } -// -// override fun setMemberships( -// channels: List, -// uuid: String?, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeChannelDetails: PNChannelDetailsLevel? -// ): ManageMemberships { -// TODO("Not yet implemented") -// } -// -// override fun removeMemberships( -// channels: List, -// uuid: String?, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeChannelDetails: PNChannelDetailsLevel? -// ): ManageMemberships { -// TODO("Not yet implemented") -// } -// -// override fun getChannelMembers( -// channel: String, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeUUIDDetails: PNUUIDDetailsLevel? -// ): GetChannelMembers { -// TODO("Not yet implemented") -// } -// -// override fun setChannelMembers( -// channel: String, -// uuids: List, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeUUIDDetails: PNUUIDDetailsLevel? -// ): ManageChannelMembers { -// TODO("Not yet implemented") -// } -// -// override fun removeChannelMembers( -// channel: String, -// uuids: List, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeUUIDDetails: PNUUIDDetailsLevel? -// ): ManageChannelMembers { -// TODO("Not yet implemented") -// } -// -// override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { -// TODO("Not yet implemented") -// } -// -// override fun getFileUrl(channel: String, fileName: String, fileId: String): GetFileUrl { -// TODO("Not yet implemented") -// } -// -// override fun deleteFile(channel: String, fileName: String, fileId: String): DeleteFile { -// TODO("Not yet implemented") -// } -// -// override fun publishFileMessage( -// channel: String, -// fileName: String, -// fileId: String, -// message: Any?, -// meta: Any?, -// ttl: Int?, -// shouldStore: Boolean? -// ): PublishFileMessage { -// TODO("Not yet implemented") -// } -// -// override fun subscribe( -// channels: List, -// channelGroups: List, -// withPresence: Boolean, -// withTimetoken: Long -// ) { -// subscribedChannelAndGroups.update { existingSubscriptions -> -// Pair( -// buildSet { -// addAll(existingSubscriptions.first) -// addAll(channels) -// if (withPresence) { -// addAll(channels.map { "${it}-pnpres" }) -// } -// }, -// buildSet { -// addAll(existingSubscriptions.second) -// addAll(channelGroups) -// if (withPresence) { -// addAll(channelGroups.map { "${it}-pnpres" }) -// } -// } -// ) -// } -// } -// -// override fun unsubscribe(channels: List, channelGroups: List) { -// subscribedChannelAndGroups.update { existingSubscriptions -> -// Pair( -// buildSet { -// addAll(existingSubscriptions.first) -// removeAll(channels.toSet()) -// removeAll(channels.map { "${it}-pnpres" }.toSet()) -// }, -// buildSet { -// addAll(existingSubscriptions.second) -// removeAll(channelGroups.toSet()) -// removeAll(channelGroups.map { "${it}-pnpres" }.toSet()) -// } -// ) -// } -// } -// -// override fun setToken(token: String?) { -// TODO("Not yet implemented") -// } -// -// override fun setPresenceState(channels: List, channelGroups: List, state: Any): SetState { -// TODO("Not yet implemented") -// } -// -// override fun grantToken( -// ttl: Int, -// meta: CustomObject?, -// authorizedUUID: String?, -// channels: List, -// channelGroups: List, -// uuids: List -// ): GrantToken { -// TODO("Not yet implemented") -// } -// -// override fun setChannelMetadata( -// channel: String, -// name: String?, -// description: String?, -// custom: CustomObject?, -// includeCustom: Boolean, -// type: String?, -// status: String? -// ): SetChannelMetadata { -// TODO("Not yet implemented") -// } -// -// override fun unsubscribeAll() { -// TODO("Not yet implemented") -// } -// -// override fun destroy() { -// TODO("Not yet implemented") -// } -// -//} +//package com.pubnub.test +// +//import com.pubnub.api.JsonElement +//import com.pubnub.api.PubNub +//import com.pubnub.api.asMap +//import com.pubnub.api.callbacks.Listener +//import com.pubnub.api.endpoints.DeleteMessages +//import com.pubnub.api.endpoints.FetchMessages +//import com.pubnub.api.endpoints.MessageCounts +//import com.pubnub.api.endpoints.Time +//import com.pubnub.api.endpoints.access.GrantToken +//import com.pubnub.api.endpoints.access.RevokeToken +//import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +//import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +//import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +//import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +//import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +//import com.pubnub.api.endpoints.files.DeleteFile +//import com.pubnub.api.endpoints.files.GetFileUrl +//import com.pubnub.api.endpoints.files.ListFiles +//import com.pubnub.api.endpoints.files.PublishFileMessage +//import com.pubnub.api.endpoints.message_actions.AddMessageAction +//import com.pubnub.api.endpoints.message_actions.GetMessageActions +//import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +//import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +//import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +//import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +//import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +//import com.pubnub.api.endpoints.objects.member.GetChannelMembers +//import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +//import com.pubnub.api.endpoints.objects.membership.GetMemberships +//import com.pubnub.api.endpoints.objects.membership.ManageMemberships +//import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +//import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +//import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +//import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +//import com.pubnub.api.endpoints.presence.GetState +//import com.pubnub.api.endpoints.presence.HereNow +//import com.pubnub.api.endpoints.presence.SetState +//import com.pubnub.api.endpoints.presence.WhereNow +//import com.pubnub.api.endpoints.pubsub.Publish +//import com.pubnub.api.endpoints.pubsub.Signal +//import com.pubnub.api.endpoints.push.AddChannelsToPush +//import com.pubnub.api.endpoints.push.ListPushProvisions +//import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +//import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +//import com.pubnub.api.enums.PNPushEnvironment +//import com.pubnub.api.enums.PNPushType +//import com.pubnub.api.models.consumer.PNBoundedPage +//import com.pubnub.api.models.consumer.PNPublishResult +//import com.pubnub.api.models.consumer.PNStatus +//import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +//import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +//import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +//import com.pubnub.api.models.consumer.message_actions.PNMessageAction +//import com.pubnub.api.models.consumer.objects.PNKey +//import com.pubnub.api.models.consumer.objects.PNMemberKey +//import com.pubnub.api.models.consumer.objects.PNMembershipKey +//import com.pubnub.api.models.consumer.objects.PNPage +//import com.pubnub.api.models.consumer.objects.PNSortKey +//import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +//import com.pubnub.api.models.consumer.objects.member.MemberInput +//import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +//import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +//import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +//import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +//import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +//import com.pubnub.api.models.consumer.pubsub.BasePubSubResult +//import com.pubnub.api.models.consumer.pubsub.PNEvent +//import com.pubnub.api.models.consumer.pubsub.PNMessageResult +//import com.pubnub.api.v2.PNConfiguration +//import com.pubnub.api.v2.callbacks.Consumer +//import com.pubnub.api.v2.callbacks.EventListener +//import com.pubnub.api.v2.callbacks.Result +//import com.pubnub.api.v2.callbacks.StatusListener +//import com.pubnub.kmp.CustomObject +//import kotlinx.coroutines.CoroutineScope +//import kotlinx.coroutines.SupervisorJob +//import kotlinx.coroutines.flow.MutableSharedFlow +//import kotlinx.coroutines.flow.MutableStateFlow +//import kotlinx.coroutines.flow.collectLatest +//import kotlinx.coroutines.flow.combine +//import kotlinx.coroutines.flow.mapNotNull +//import kotlinx.coroutines.flow.scan +//import kotlinx.coroutines.flow.transformLatest +//import kotlinx.coroutines.flow.update +//import kotlinx.coroutines.launch +//import kotlinx.datetime.Clock +//import kotlinx.datetime.Instant +//import kotlin.time.Duration.Companion.minutes +// +// +//expect fun EventListener.emit(pubnub: PubNub, event: PNEvent) +//expect fun StatusListener.emit(pubnub: PubNub, status: PNStatus) +//expect fun Any.toJsonElement(): JsonElement +// +////class FakePubNub(override val configuration: PNConfiguration) : PubNub { +//// +//// val scope = CoroutineScope(SupervisorJob()) +//// +//// fun Long.toEpochSeconds() = this / 10000000 +//// fun generateTimetoken() = Clock.System.now().toEpochMilliseconds() * 10000 +//// +//// val events = MutableSharedFlow(100, 100) +//// val subscriptionStream = events.mapNotNull { +//// val tt = it.timetoken ?: return@mapNotNull null +//// if (Clock.System.now() < Instant.fromEpochSeconds(tt.toEpochSeconds()) - 10.minutes) { +//// it +//// } else { +//// null +//// } +//// } +//// +//// private val subscribedChannelAndGroups = MutableStateFlow, Set>>(Pair(emptySet(), emptySet())) +//// private val timetoken = MutableSharedFlow() +//// +//// init { +//// scope.launch { +//// subscribedChannelAndGroups.scan(Pair(setOf(), setOf())) { last: Pair, Set>, next: Pair, Set> -> +//// if (last.first.isEmpty() && last.second.isEmpty() && (next.first.isNotEmpty() || next.second.isNotEmpty())) { +//// //emit connected +//// } else if (next.first.isEmpty() && next.second.isEmpty() && (last.first.isNotEmpty() || last.second.isNotEmpty())) { +//// timetoken.emit(0) +//// //emit disconnected +//// } else { +//// //emit changed +//// } +//// next +//// }.collectLatest { subscriptions: Pair, Set> -> +//// events.collect { event: PNEvent -> +//// if (event.channel in subscriptions.first) { +//// listeners.value.filterIsInstance().forEach { +//// it.emit(this@FakePubNub, event) +//// } +//// } +//// } +//// } +//// } +//// } //// -// //// -//// /** -//// * Remove a listener. -//// * -//// * @param listener The listener to be removed, previously added with [addListener]. -//// */ +//// val messages: MutableList = mutableListOf() +//// val userMetadata: MutableMap = mutableMapOf() +//// val channelMetadata: MutableMap = mutableMapOf() +//// +//// private val listeners = MutableStateFlow(setOf()) +//// +//// override fun addListener(listener: EventListener) { +//// listeners.update { previousSet -> +//// buildSet { +//// addAll(previousSet) +//// add(listener) +//// } +//// } +//// } +//// +//// override fun addListener(listener: StatusListener) { +//// listeners.update { previousSet -> +//// buildSet { +//// addAll(previousSet) +//// add(listener) +//// } +//// } +//// } +//// //// override fun removeListener(listener: Listener) { -//// TODO("Not yet implemented") +//// listeners.update { previousSet -> +//// buildSet { +//// addAll(previousSet) +//// remove(listener) +//// } +//// } //// } //// -//// /** -//// * Removes all listeners. -//// */ //// override fun removeAllListeners() { -//// TODO("Not yet implemented") +//// listeners.update { +//// emptySet() +//// } //// } //// //// override fun publish( @@ -641,89 +187,77 @@ expect fun Any.toJsonElement(): JsonElement //// replicate: Boolean, //// ttl: Int? //// ): Publish { -//// return createEndpoint { -//// val tt = Clock.System.now().toEpochMilliseconds() / 1000 -//// messages.add( -//// PNMessageResult( -//// BasePubSubResult(channel, null, tt, null, configuration.userId.value), -//// message as JsonElement, -//// null -//// ) -//// ) -//// PNPublishResult(tt) +//// return object : Publish { +//// override fun async(callback: Consumer>) { +//// scope.launch { +//// events.emit(PNMessageResult( +//// BasePubSubResult( +//// channel, +//// null, +//// generateTimetoken(), +//// meta?.toJsonElement(), +//// configuration.userId.value +//// ), message.toJsonElement(), null +//// )) +//// } +//// } //// } -//// // TODO emit message //// } //// -//// -//// override fun fire( -//// channel: String, -//// message: Any, -//// meta: Any?, -//// usePost: Boolean, -//// ttl: Int? -//// ): Endpoint { +//// override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { //// TODO("Not yet implemented") //// } //// -//// -//// override fun signal(channel: String, message: Any): Endpoint { +//// override fun signal(channel: String, message: Any): Signal { //// TODO("Not yet implemented") //// } //// -//// //// override fun getSubscribedChannels(): List { -//// TODO("Not yet implemented") +//// return subscribedChannelAndGroups.value.first.toList() //// } //// -//// //// override fun getSubscribedChannelGroups(): List { -//// TODO("Not yet implemented") +//// return subscribedChannelAndGroups.value.second.toList() //// } //// -//// //// override fun addPushNotificationsOnChannels( //// pushType: PNPushType, //// channels: List, //// deviceId: String, //// topic: String?, //// environment: PNPushEnvironment -//// ): Endpoint { +//// ): AddChannelsToPush { //// TODO("Not yet implemented") //// } //// -//// //// override fun auditPushChannelProvisions( //// pushType: PNPushType, //// deviceId: String, //// topic: String?, //// environment: PNPushEnvironment -//// ): Endpoint { +//// ): ListPushProvisions { //// TODO("Not yet implemented") //// } //// -//// //// override fun removePushNotificationsFromChannels( //// pushType: PNPushType, //// channels: List, //// deviceId: String, //// topic: String?, //// environment: PNPushEnvironment -//// ): Endpoint { +//// ): RemoveChannelsFromPush { //// TODO("Not yet implemented") //// } //// -//// //// override fun removeAllPushNotificationsFromDeviceWithPushToken( //// pushType: PNPushType, //// deviceId: String, //// topic: String?, //// environment: PNPushEnvironment -//// ): Endpoint { +//// ): RemoveAllPushChannelsForDevice { //// TODO("Not yet implemented") //// } //// -//// //// override fun fetchMessages( //// channels: List, //// page: PNBoundedPage, @@ -731,176 +265,86 @@ expect fun Any.toJsonElement(): JsonElement //// includeMeta: Boolean, //// includeMessageActions: Boolean, //// includeMessageType: Boolean -//// ): Endpoint { +//// ): FetchMessages { //// TODO("Not yet implemented") //// } //// -//// -//// override fun deleteMessages(channels: List, start: Long?, end: Long?): Endpoint { +//// override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { //// TODO("Not yet implemented") //// } //// -//// -//// override fun messageCounts(channels: List, channelsTimetoken: List): Endpoint { +//// override fun messageCounts(channels: List, channelsTimetoken: List): MessageCounts { //// TODO("Not yet implemented") //// } //// -//// //// override fun hereNow( //// channels: List, //// channelGroups: List, //// includeState: Boolean, //// includeUUIDs: Boolean -//// ): Endpoint { +//// ): HereNow { //// TODO("Not yet implemented") //// } //// -//// -//// override fun whereNow(uuid: String): Endpoint { +//// override fun whereNow(uuid: String): WhereNow { //// TODO("Not yet implemented") //// } //// -//// -//// override fun setPresenceState( -//// channels: List, -//// channelGroups: List, -//// state: Any, -//// uuid: String -//// ): Endpoint { -//// TODO("Not yet implemented") -//// } -//// -//// -//// override fun getPresenceState( -//// channels: List, -//// channelGroups: List, -//// uuid: String -//// ): Endpoint { +//// override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { //// TODO("Not yet implemented") //// } //// -//// //// override fun presence(channels: List, channelGroups: List, connected: Boolean) { //// TODO("Not yet implemented") //// } //// -//// -//// override fun addMessageAction(channel: String, messageAction: PNMessageAction): Endpoint { +//// override fun addMessageAction(channel: String, messageAction: PNMessageAction): AddMessageAction { //// TODO("Not yet implemented") //// } //// -//// //// override fun removeMessageAction( //// channel: String, //// messageTimetoken: Long, //// actionTimetoken: Long -//// ): Endpoint { +//// ): RemoveMessageAction { //// TODO("Not yet implemented") //// } //// -//// -//// override fun getMessageActions(channel: String, page: PNBoundedPage): Endpoint { +//// override fun getMessageActions(channel: String, page: PNBoundedPage): GetMessageActions { //// TODO("Not yet implemented") //// } //// -//// -//// override fun addChannelsToChannelGroup( -//// channels: List, -//// channelGroup: String -//// ): Endpoint { +//// override fun addChannelsToChannelGroup(channels: List, channelGroup: String): AddChannelChannelGroup { //// TODO("Not yet implemented") //// } //// -//// -//// override fun listChannelsForChannelGroup(channelGroup: String): Endpoint { +//// override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { //// TODO("Not yet implemented") //// } //// -//// //// override fun removeChannelsFromChannelGroup( //// channels: List, //// channelGroup: String -//// ): Endpoint { +//// ): RemoveChannelChannelGroup { //// TODO("Not yet implemented") //// } //// -//// -//// override fun listAllChannelGroups(): Endpoint { +//// override fun listAllChannelGroups(): ListAllChannelGroup { //// TODO("Not yet implemented") //// } //// -//// -//// override fun deleteChannelGroup(channelGroup: String): Endpoint { +//// override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { //// TODO("Not yet implemented") //// } //// -//// -//// override fun grant( -//// read: Boolean, -//// write: Boolean, -//// manage: Boolean, -//// delete: Boolean, -//// ttl: Int, -//// authKeys: List, -//// channels: List, -//// channelGroups: List, -//// uuids: List -//// ): Endpoint { +//// override fun revokeToken(token: String): RevokeToken { //// TODO("Not yet implemented") //// } //// -//// -//// override fun grant( -//// read: Boolean, -//// write: Boolean, -//// manage: Boolean, -//// delete: Boolean, -//// get: Boolean, -//// update: Boolean, -//// join: Boolean, -//// ttl: Int, -//// authKeys: List, -//// channels: List, -//// channelGroups: List, -//// uuids: List -//// ): Endpoint { -//// TODO("Not yet implemented") -//// } -//// -//// -//// override fun grantToken( -//// ttl: Int, -//// meta: Any?, -//// authorizedUUID: String?, -//// channels: List, -//// channelGroups: List, -//// uuids: List -//// ): Endpoint { -//// TODO("Not yet implemented") -//// } -//// -//// -//// override fun grantToken( -//// ttl: Int, -//// meta: Any?, -//// authorizedUserId: UserId?, -//// spacesPermissions: List, -//// usersPermissions: List -//// ): Endpoint { +//// override fun time(): Time { //// TODO("Not yet implemented") //// } //// -//// -//// override fun revokeToken(token: String): Endpoint { -//// TODO("Not yet implemented") -//// } -//// -//// -//// override fun time(): Endpoint { -//// TODO("Not yet implemented") -//// } -//// -//// //// override fun getAllChannelMetadata( //// limit: Int?, //// page: PNPage?, @@ -908,34 +352,18 @@ expect fun Any.toJsonElement(): JsonElement //// sort: Collection>, //// includeCount: Boolean, //// includeCustom: Boolean -//// ): Endpoint { +//// ): GetAllChannelMetadata { //// TODO("Not yet implemented") //// } //// -//// -//// override fun getChannelMetadata(channel: String, includeCustom: Boolean): Endpoint { +//// override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { //// TODO("Not yet implemented") //// } //// -//// -//// override fun setChannelMetadata( -//// channel: String, -//// name: String?, -//// description: String?, -//// custom: Any?, -//// includeCustom: Boolean, -//// type: String?, -//// status: String? -//// ): Endpoint { -//// TODO("Not yet implemented") -//// } -//// -//// -//// override fun removeChannelMetadata(channel: String): Endpoint { +//// override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { //// TODO("Not yet implemented") //// } //// -//// //// override fun getAllUUIDMetadata( //// limit: Int?, //// page: PNPage?, @@ -943,37 +371,57 @@ expect fun Any.toJsonElement(): JsonElement //// sort: Collection>, //// includeCount: Boolean, //// includeCustom: Boolean -//// ): Endpoint { -//// return createEndpoint { -//// PNUUIDMetadataArrayResult(200, userMetadata.values, userMetadata.size, null, null) -//// } +//// ): GetAllUUIDMetadata { +//// TODO("Not yet implemented") //// } //// +//// override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { +//// TODO("Not yet implemented") +//// } //// -//// override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): Endpoint { -//// return createEndpoint { +//// override fun setUUIDMetadata( +//// uuid: String?, +//// name: String?, +//// externalId: String?, +//// profileUrl: String?, +//// email: String?, +//// custom: CustomObject?, +//// includeCustom: Boolean, +//// type: String?, +//// status: String? +//// ): SetUUIDMetadata { //// val actualUuid = uuid ?: configuration.userId.value -//// val result = userMetadata[actualUuid] -//// -//// PNUUIDMetadataResult( -//// 200, -//// if (!includeCustom) { -//// result?.copy(custom = null) -//// } else { -//// result -//// } -//// ) +//// val result = userMetadata.compute(actualUuid) { a: String, b: PNUUIDMetadata? -> +//// PNUUIDMetadata( +//// actualUuid, +//// name ?: b?.name, +//// externalId ?: b?.externalId, +//// profileUrl ?: b?.profileUrl, +//// email ?: b?.email, +//// custom?.toJsonElement()?.asMap() ?: b?.custom, +//// Clock.System.now().toString(), +//// null, +//// type ?: b?.type, +//// status ?: b?.status +//// ) +//// } +//// return object : SetUUIDMetadata { +//// override fun async(callback: Consumer>) { +//// callback.accept(Result.success(PNUUIDMetadataResult( +//// 200, +//// if (!includeCustom) { +//// result?.copy(custom = null) +//// } else { +//// result +//// } +//// ) +//// )) +//// } //// } //// } //// -//// -//// -//// override fun removeUUIDMetadata(uuid: String?): Endpoint { -//// val actualUuid = uuid ?: configuration.userId.value -//// return createEndpoint { -//// userMetadata.remove(actualUuid) -//// PNRemoveMetadataResult(200) -//// } +//// override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { +//// TODO("Not yet implemented") //// } //// //// override fun getMemberships( @@ -985,11 +433,10 @@ expect fun Any.toJsonElement(): JsonElement //// includeCount: Boolean, //// includeCustom: Boolean, //// includeChannelDetails: PNChannelDetailsLevel? -//// ): Endpoint { +//// ): GetMemberships { //// TODO("Not yet implemented") //// } //// -//// //// override fun setMemberships( //// channels: List, //// uuid: String?, @@ -1000,11 +447,10 @@ expect fun Any.toJsonElement(): JsonElement //// includeCount: Boolean, //// includeCustom: Boolean, //// includeChannelDetails: PNChannelDetailsLevel? -//// ): Endpoint { +//// ): ManageMemberships { //// TODO("Not yet implemented") //// } //// -//// //// override fun removeMemberships( //// channels: List, //// uuid: String?, @@ -1015,27 +461,10 @@ expect fun Any.toJsonElement(): JsonElement //// includeCount: Boolean, //// includeCustom: Boolean, //// includeChannelDetails: PNChannelDetailsLevel? -//// ): Endpoint { -//// TODO("Not yet implemented") -//// } -//// -//// -//// override fun manageMemberships( -//// channelsToSet: List, -//// channelsToRemove: List, -//// uuid: String?, -//// limit: Int?, -//// page: PNPage?, -//// filter: String?, -//// sort: Collection>, -//// includeCount: Boolean, -//// includeCustom: Boolean, -//// includeChannelDetails: PNChannelDetailsLevel? -//// ): Endpoint { +//// ): ManageMemberships { //// TODO("Not yet implemented") //// } //// -//// //// override fun getChannelMembers( //// channel: String, //// limit: Int?, @@ -1045,11 +474,10 @@ expect fun Any.toJsonElement(): JsonElement //// includeCount: Boolean, //// includeCustom: Boolean, //// includeUUIDDetails: PNUUIDDetailsLevel? -//// ): Endpoint { +//// ): GetChannelMembers { //// TODO("Not yet implemented") //// } //// -//// //// override fun setChannelMembers( //// channel: String, //// uuids: List, @@ -1060,11 +488,10 @@ expect fun Any.toJsonElement(): JsonElement //// includeCount: Boolean, //// includeCustom: Boolean, //// includeUUIDDetails: PNUUIDDetailsLevel? -//// ): Endpoint { +//// ): ManageChannelMembers { //// TODO("Not yet implemented") //// } //// -//// //// override fun removeChannelMembers( //// channel: String, //// uuids: List, @@ -1075,42 +502,22 @@ expect fun Any.toJsonElement(): JsonElement //// includeCount: Boolean, //// includeCustom: Boolean, //// includeUUIDDetails: PNUUIDDetailsLevel? -//// ): Endpoint { -//// TODO("Not yet implemented") -//// } -//// -//// -//// override fun manageChannelMembers( -//// channel: String, -//// uuidsToSet: Collection, -//// uuidsToRemove: Collection, -//// limit: Int?, -//// page: PNPage?, -//// filter: String?, -//// sort: Collection>, -//// includeCount: Boolean, -//// includeCustom: Boolean, -//// includeUUIDDetails: PNUUIDDetailsLevel? -//// ): Endpoint { +//// ): ManageChannelMembers { //// TODO("Not yet implemented") //// } //// -//// -//// override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): Endpoint { +//// override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { //// TODO("Not yet implemented") //// } //// -//// -//// override fun getFileUrl(channel: String, fileName: String, fileId: String): Endpoint { +//// override fun getFileUrl(channel: String, fileName: String, fileId: String): GetFileUrl { //// TODO("Not yet implemented") //// } //// -//// -//// override fun deleteFile(channel: String, fileName: String, fileId: String): Endpoint { +//// override fun deleteFile(channel: String, fileName: String, fileId: String): DeleteFile { //// TODO("Not yet implemented") //// } //// -//// //// override fun publishFileMessage( //// channel: String, //// fileName: String, @@ -1119,59 +526,652 @@ expect fun Any.toJsonElement(): JsonElement //// meta: Any?, //// ttl: Int?, //// shouldStore: Boolean? -//// ): Endpoint { +//// ): PublishFileMessage { //// TODO("Not yet implemented") //// } //// -//// //// override fun subscribe( //// channels: List, //// channelGroups: List, //// withPresence: Boolean, //// withTimetoken: Long //// ) { +//// subscribedChannelAndGroups.update { existingSubscriptions -> +//// Pair( +//// buildSet { +//// addAll(existingSubscriptions.first) +//// addAll(channels) +//// if (withPresence) { +//// addAll(channels.map { "${it}-pnpres" }) +//// } +//// }, +//// buildSet { +//// addAll(existingSubscriptions.second) +//// addAll(channelGroups) +//// if (withPresence) { +//// addAll(channelGroups.map { "${it}-pnpres" }) +//// } +//// } +//// ) +//// } +//// } +//// +//// override fun unsubscribe(channels: List, channelGroups: List) { +//// subscribedChannelAndGroups.update { existingSubscriptions -> +//// Pair( +//// buildSet { +//// addAll(existingSubscriptions.first) +//// removeAll(channels.toSet()) +//// removeAll(channels.map { "${it}-pnpres" }.toSet()) +//// }, +//// buildSet { +//// addAll(existingSubscriptions.second) +//// removeAll(channelGroups.toSet()) +//// removeAll(channelGroups.map { "${it}-pnpres" }.toSet()) +//// } +//// ) +//// } +//// } +//// +//// override fun setToken(token: String?) { //// TODO("Not yet implemented") //// } //// +//// override fun setPresenceState(channels: List, channelGroups: List, state: Any): SetState { +//// TODO("Not yet implemented") +//// } //// -//// override fun unsubscribe(channels: List, channelGroups: List) { +//// override fun grantToken( +//// ttl: Int, +//// meta: CustomObject?, +//// authorizedUUID: String?, +//// channels: List, +//// channelGroups: List, +//// uuids: List +//// ): GrantToken { //// TODO("Not yet implemented") //// } //// -//// override fun setToken(token: String?) { +//// override fun setChannelMetadata( +//// channel: String, +//// name: String?, +//// description: String?, +//// custom: CustomObject?, +//// includeCustom: Boolean, +//// type: String?, +//// status: String? +//// ): SetChannelMetadata { //// TODO("Not yet implemented") //// } //// -//// override fun addListener(listener: EventListener) { +//// override fun unsubscribeAll() { //// TODO("Not yet implemented") //// } //// -//// override fun addListener(listener: StatusListener) { +//// override fun destroy() { //// TODO("Not yet implemented") //// } +//// +////} +////// +//// +////// +////// /** +////// * Remove a listener. +////// * +////// * @param listener The listener to be removed, previously added with [addListener]. +////// */ +////// override fun removeListener(listener: Listener) { +////// TODO("Not yet implemented") +////// } +////// +////// /** +////// * Removes all listeners. +////// */ +////// override fun removeAllListeners() { +////// TODO("Not yet implemented") +////// } +////// +////// override fun publish( +////// channel: String, +////// message: Any, +////// meta: Any?, +////// shouldStore: Boolean?, +////// usePost: Boolean, +////// replicate: Boolean, +////// ttl: Int? +////// ): Publish { +////// return createEndpoint { +////// val tt = Clock.System.now().toEpochMilliseconds() / 1000 +////// messages.add( +////// PNMessageResult( +////// BasePubSubResult(channel, null, tt, null, configuration.userId.value), +////// message as JsonElement, +////// null +////// ) +////// ) +////// PNPublishResult(tt) +////// } +////// // TODO emit message +////// } +////// +////// +////// override fun fire( +////// channel: String, +////// message: Any, +////// meta: Any?, +////// usePost: Boolean, +////// ttl: Int? +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun signal(channel: String, message: Any): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun getSubscribedChannels(): List { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun getSubscribedChannelGroups(): List { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun addPushNotificationsOnChannels( +////// pushType: PNPushType, +////// channels: List, +////// deviceId: String, +////// topic: String?, +////// environment: PNPushEnvironment +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun auditPushChannelProvisions( +////// pushType: PNPushType, +////// deviceId: String, +////// topic: String?, +////// environment: PNPushEnvironment +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun removePushNotificationsFromChannels( +////// pushType: PNPushType, +////// channels: List, +////// deviceId: String, +////// topic: String?, +////// environment: PNPushEnvironment +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun removeAllPushNotificationsFromDeviceWithPushToken( +////// pushType: PNPushType, +////// deviceId: String, +////// topic: String?, +////// environment: PNPushEnvironment +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun fetchMessages( +////// channels: List, +////// page: PNBoundedPage, +////// includeUUID: Boolean, +////// includeMeta: Boolean, +////// includeMessageActions: Boolean, +////// includeMessageType: Boolean +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun deleteMessages(channels: List, start: Long?, end: Long?): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun messageCounts(channels: List, channelsTimetoken: List): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun hereNow( +////// channels: List, +////// channelGroups: List, +////// includeState: Boolean, +////// includeUUIDs: Boolean +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun whereNow(uuid: String): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun setPresenceState( +////// channels: List, +////// channelGroups: List, +////// state: Any, +////// uuid: String +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun getPresenceState( +////// channels: List, +////// channelGroups: List, +////// uuid: String +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun presence(channels: List, channelGroups: List, connected: Boolean) { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun addMessageAction(channel: String, messageAction: PNMessageAction): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun removeMessageAction( +////// channel: String, +////// messageTimetoken: Long, +////// actionTimetoken: Long +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun getMessageActions(channel: String, page: PNBoundedPage): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun addChannelsToChannelGroup( +////// channels: List, +////// channelGroup: String +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun listChannelsForChannelGroup(channelGroup: String): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun removeChannelsFromChannelGroup( +////// channels: List, +////// channelGroup: String +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun listAllChannelGroups(): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun deleteChannelGroup(channelGroup: String): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun grant( +////// read: Boolean, +////// write: Boolean, +////// manage: Boolean, +////// delete: Boolean, +////// ttl: Int, +////// authKeys: List, +////// channels: List, +////// channelGroups: List, +////// uuids: List +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun grant( +////// read: Boolean, +////// write: Boolean, +////// manage: Boolean, +////// delete: Boolean, +////// get: Boolean, +////// update: Boolean, +////// join: Boolean, +////// ttl: Int, +////// authKeys: List, +////// channels: List, +////// channelGroups: List, +////// uuids: List +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun grantToken( +////// ttl: Int, +////// meta: Any?, +////// authorizedUUID: String?, +////// channels: List, +////// channelGroups: List, +////// uuids: List +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun grantToken( +////// ttl: Int, +////// meta: Any?, +////// authorizedUserId: UserId?, +////// spacesPermissions: List, +////// usersPermissions: List +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun revokeToken(token: String): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun time(): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun getAllChannelMetadata( +////// limit: Int?, +////// page: PNPage?, +////// filter: String?, +////// sort: Collection>, +////// includeCount: Boolean, +////// includeCustom: Boolean +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun getChannelMetadata(channel: String, includeCustom: Boolean): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun setChannelMetadata( +////// channel: String, +////// name: String?, +////// description: String?, +////// custom: Any?, +////// includeCustom: Boolean, +////// type: String?, +////// status: String? +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun removeChannelMetadata(channel: String): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun getAllUUIDMetadata( +////// limit: Int?, +////// page: PNPage?, +////// filter: String?, +////// sort: Collection>, +////// includeCount: Boolean, +////// includeCustom: Boolean +////// ): Endpoint { +////// return createEndpoint { +////// PNUUIDMetadataArrayResult(200, userMetadata.values, userMetadata.size, null, null) +////// } +////// } +////// +////// +////// override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): Endpoint { +////// return createEndpoint { +////// val actualUuid = uuid ?: configuration.userId.value +////// val result = userMetadata[actualUuid] +////// +////// PNUUIDMetadataResult( +////// 200, +////// if (!includeCustom) { +////// result?.copy(custom = null) +////// } else { +////// result +////// } +////// ) +////// } +////// } +////// +////// +////// +////// override fun removeUUIDMetadata(uuid: String?): Endpoint { +////// val actualUuid = uuid ?: configuration.userId.value +////// return createEndpoint { +////// userMetadata.remove(actualUuid) +////// PNRemoveMetadataResult(200) +////// } +////// } +////// +////// override fun getMemberships( +////// uuid: String?, +////// limit: Int?, +////// page: PNPage?, +////// filter: String?, +////// sort: Collection>, +////// includeCount: Boolean, +////// includeCustom: Boolean, +////// includeChannelDetails: PNChannelDetailsLevel? +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun setMemberships( +////// channels: List, +////// uuid: String?, +////// limit: Int?, +////// page: PNPage?, +////// filter: String?, +////// sort: Collection>, +////// includeCount: Boolean, +////// includeCustom: Boolean, +////// includeChannelDetails: PNChannelDetailsLevel? +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun removeMemberships( +////// channels: List, +////// uuid: String?, +////// limit: Int?, +////// page: PNPage?, +////// filter: String?, +////// sort: Collection>, +////// includeCount: Boolean, +////// includeCustom: Boolean, +////// includeChannelDetails: PNChannelDetailsLevel? +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun manageMemberships( +////// channelsToSet: List, +////// channelsToRemove: List, +////// uuid: String?, +////// limit: Int?, +////// page: PNPage?, +////// filter: String?, +////// sort: Collection>, +////// includeCount: Boolean, +////// includeCustom: Boolean, +////// includeChannelDetails: PNChannelDetailsLevel? +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun getChannelMembers( +////// channel: String, +////// limit: Int?, +////// page: PNPage?, +////// filter: String?, +////// sort: Collection>, +////// includeCount: Boolean, +////// includeCustom: Boolean, +////// includeUUIDDetails: PNUUIDDetailsLevel? +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun setChannelMembers( +////// channel: String, +////// uuids: List, +////// limit: Int?, +////// page: PNPage?, +////// filter: String?, +////// sort: Collection>, +////// includeCount: Boolean, +////// includeCustom: Boolean, +////// includeUUIDDetails: PNUUIDDetailsLevel? +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun removeChannelMembers( +////// channel: String, +////// uuids: List, +////// limit: Int?, +////// page: PNPage?, +////// filter: String?, +////// sort: Collection>, +////// includeCount: Boolean, +////// includeCustom: Boolean, +////// includeUUIDDetails: PNUUIDDetailsLevel? +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun manageChannelMembers( +////// channel: String, +////// uuidsToSet: Collection, +////// uuidsToRemove: Collection, +////// limit: Int?, +////// page: PNPage?, +////// filter: String?, +////// sort: Collection>, +////// includeCount: Boolean, +////// includeCustom: Boolean, +////// includeUUIDDetails: PNUUIDDetailsLevel? +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun getFileUrl(channel: String, fileName: String, fileId: String): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun deleteFile(channel: String, fileName: String, fileId: String): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun publishFileMessage( +////// channel: String, +////// fileName: String, +////// fileId: String, +////// message: Any?, +////// meta: Any?, +////// ttl: Int?, +////// shouldStore: Boolean? +////// ): Endpoint { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun subscribe( +////// channels: List, +////// channelGroups: List, +////// withPresence: Boolean, +////// withTimetoken: Long +////// ) { +////// TODO("Not yet implemented") +////// } +////// +////// +////// override fun unsubscribe(channels: List, channelGroups: List) { +////// TODO("Not yet implemented") +////// } +////// +////// override fun setToken(token: String?) { +////// TODO("Not yet implemented") +////// } +////// +////// override fun addListener(listener: EventListener) { +////// TODO("Not yet implemented") +////// } +////// +////// override fun addListener(listener: StatusListener) { +////// TODO("Not yet implemented") +////// } +//////} +////// +////private fun MutableMap.compute( +//// key: K, +//// remappingFunction: (K, V?) -> V +////): V? { +//// val oldValue: V? = get(key) +//// +//// val newValue: V = remappingFunction(key, oldValue) +//// if (newValue == null) { +//// // delete mapping +//// if (oldValue != null || containsKey(key)) { +//// // something to remove +//// remove(key) +//// return null +//// } else { +//// // nothing to do. Leave things as they were. +//// return null +//// } +//// } else { +//// // add or replace old mapping +//// put(key, newValue) +//// return newValue +//// } ////} //// -//private fun MutableMap.compute( -// key: K, -// remappingFunction: (K, V?) -> V -//): V? { -// val oldValue: V? = get(key) -// -// val newValue: V = remappingFunction(key, oldValue) -// if (newValue == null) { -// // delete mapping -// if (oldValue != null || containsKey(key)) { -// // something to remove -// remove(key) -// return null -// } else { -// // nothing to do. Leave things as they were. -// return null -// } -// } else { -// // add or replace old mapping -// put(key, newValue) -// return newValue -// } -//} -// diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt b/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt index a0bce4fa9..08292c2d0 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt @@ -1,39 +1,39 @@ -package com.pubnub.test - -import com.pubnub.api.JsonElement -import com.pubnub.api.PubNub -import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.api.models.consumer.pubsub.PNEvent -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -import com.pubnub.api.models.consumer.pubsub.PNSignalResult -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.StatusListener - -actual fun EventListener.emit( - pubnub: PubNub, - event: PNEvent -) { - when (event) { - is PNMessageResult -> this.onMessage(pubnub, event) - is PNMessageActionResult -> this.onMessageAction(pubnub, event) - is PNFileEventResult -> this.onFile(pubnub, event) - is PNObjectEventResult -> this.onObjects(pubnub, event) - is PNSignalResult -> this.onSignal(pubnub, event) - is PNPresenceEventResult -> this.onPresence(pubnub, event) - } -} - -actual fun Any.toJsonElement(): JsonElement { - TODO("Not yet implemented") -} - -actual fun StatusListener.emit( - pubnub: PubNub, - status: PNStatus -) { - TODO("Not yet implemented") -} \ No newline at end of file +//package com.pubnub.test +// +//import com.pubnub.api.JsonElement +//import com.pubnub.api.PubNub +//import com.pubnub.api.models.consumer.PNStatus +//import com.pubnub.api.models.consumer.pubsub.PNEvent +//import com.pubnub.api.models.consumer.pubsub.PNMessageResult +//import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +//import com.pubnub.api.models.consumer.pubsub.PNSignalResult +//import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +//import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +//import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +//import com.pubnub.api.v2.callbacks.EventListener +//import com.pubnub.api.v2.callbacks.StatusListener +// +//actual fun EventListener.emit( +// pubnub: PubNub, +// event: PNEvent +//) { +// when (event) { +// is PNMessageResult -> this.onMessage(pubnub, event) +// is PNMessageActionResult -> this.onMessageAction(pubnub, event) +// is PNFileEventResult -> this.onFile(pubnub, event) +// is PNObjectEventResult -> this.onObjects(pubnub, event) +// is PNSignalResult -> this.onSignal(pubnub, event) +// is PNPresenceEventResult -> this.onPresence(pubnub, event) +// } +//} +// +//actual fun Any.toJsonElement(): JsonElement { +// TODO("Not yet implemented") +//} +// +//actual fun StatusListener.emit( +// pubnub: PubNub, +// status: PNStatus +//) { +// TODO("Not yet implemented") +//} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt index 182d0b533..8acd2a877 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt @@ -1,27 +1,27 @@ -package com.pubnub.test - -import com.pubnub.api.JsonElement -import com.pubnub.api.JsonElementImpl -import com.pubnub.api.PubNub -import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.api.models.consumer.pubsub.PNEvent -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.StatusListener - -actual fun EventListener.emit( - pubnub: PubNub, - event: PNEvent -) { - TODO("not implemented") -} - -actual fun Any.toJsonElement(): JsonElement { - return JsonElementImpl(this) -} - -actual fun StatusListener.emit( - pubnub: PubNub, - status: PNStatus -) { - TODO("not implemented") -} \ No newline at end of file +//package com.pubnub.test +// +//import com.pubnub.api.JsonElement +//import com.pubnub.api.JsonElementImpl +//import com.pubnub.api.PubNub +//import com.pubnub.api.models.consumer.PNStatus +//import com.pubnub.api.models.consumer.pubsub.PNEvent +//import com.pubnub.api.v2.callbacks.EventListener +//import com.pubnub.api.v2.callbacks.StatusListener +// +//actual fun EventListener.emit( +// pubnub: PubNub, +// event: PNEvent +//) { +// TODO("not implemented") +//} +// +//actual fun Any.toJsonElement(): JsonElement { +// return JsonElementImpl(this) +//} +// +//actual fun StatusListener.emit( +// pubnub: PubNub, +// status: PNStatus +//) { +// TODO("not implemented") +//} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt index a8e3f29d1..b5b18984f 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt @@ -1,42 +1,42 @@ -package com.pubnub.test - -import com.pubnub.api.JsonElement -import com.pubnub.api.PubNub -import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.api.models.consumer.pubsub.PNEvent -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -import com.pubnub.api.models.consumer.pubsub.PNSignalResult -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.internal.managers.MapperManager - -actual fun EventListener.emit( - pubnub: PubNub, - event: PNEvent -) { - when (event) { - is PNMessageResult -> this.message(pubnub, event) - is PNMessageActionResult -> this.messageAction(pubnub, event) - is PNFileEventResult -> this.file(pubnub, event) - is PNObjectEventResult -> this.objects(pubnub, event) - is PNSignalResult -> this.signal(pubnub, event) - is PNPresenceEventResult -> this.presence(pubnub, event) - } -} - -private val mapper = MapperManager() - -actual fun Any.toJsonElement(): JsonElement { - return mapper.toJsonTree(this) -} - -actual fun StatusListener.emit( - pubnub: PubNub, - status: PNStatus -) { - this.status(pubnub, status) -} \ No newline at end of file +//package com.pubnub.test +// +//import com.pubnub.api.JsonElement +//import com.pubnub.api.PubNub +//import com.pubnub.api.models.consumer.PNStatus +//import com.pubnub.api.models.consumer.pubsub.PNEvent +//import com.pubnub.api.models.consumer.pubsub.PNMessageResult +//import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +//import com.pubnub.api.models.consumer.pubsub.PNSignalResult +//import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +//import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +//import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +//import com.pubnub.api.v2.callbacks.EventListener +//import com.pubnub.api.v2.callbacks.StatusListener +//import com.pubnub.internal.managers.MapperManager +// +//actual fun EventListener.emit( +// pubnub: PubNub, +// event: PNEvent +//) { +// when (event) { +// is PNMessageResult -> this.message(pubnub, event) +// is PNMessageActionResult -> this.messageAction(pubnub, event) +// is PNFileEventResult -> this.file(pubnub, event) +// is PNObjectEventResult -> this.objects(pubnub, event) +// is PNSignalResult -> this.signal(pubnub, event) +// is PNPresenceEventResult -> this.presence(pubnub, event) +// } +//} +// +//private val mapper = MapperManager() +// +//actual fun Any.toJsonElement(): JsonElement { +// return mapper.toJsonTree(this) +//} +// +//actual fun StatusListener.emit( +// pubnub: PubNub, +// status: PNStatus +//) { +// this.status(pubnub, status) +//} \ No newline at end of file From 49a46c3df5d717ff97bb00d535d8c6afe7113ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Fri, 14 Jun 2024 12:19:55 +0000 Subject: [PATCH 21/62] [JS] Add files related methods (#236) * [JS] Add all file methods * PNFuture chaining methods * More PNFuture composing functions * PNFuture.awaitAll types fix * Merge fixes --- build.gradle.kts | 1 + gradle/libs.versions.toml | 2 + pubnub-core/pubnub-core-api/build.gradle.kts | 13 +- .../kotlin/com/pubnub/api/UserId.kt | 3 + .../endpoints/remoteaction/RemoteAction.kt | 5 +- .../consumer/files/PNDownloadFileResult.kt | 4 +- .../kotlin/com/pubnub/kmp/Downloadable.kt | 3 + .../kotlin/com/pubnub/kmp/PNFuture.kt | 4 +- .../kotlin/com/pubnub/kmp/futures.kt | 112 ++++++++++++++++++ .../kotlin/com/pubnub/kmp/PNFutureTest.kt | 68 +++++++++++ .../kotlin/com/pubnub/kmp/Downloadable.ios.kt | 3 + .../kotlin/com/pubnub/kmp/Downloadable.js.kt | 5 + .../kotlin/com/pubnub/kmp/Downloadable.jvm.kt | 5 + .../kotlin/com/pubnub/api/PubNub.kt | 28 ++++- .../pubnub/api/endpoints/DeleteMessages.kt | 4 +- .../com/pubnub/api/endpoints/FetchMessages.kt | 4 +- .../com/pubnub/api/endpoints/MessageCounts.kt | 4 +- .../kotlin/com/pubnub/api/endpoints/Time.kt | 4 +- .../pubnub/api/endpoints/access/GrantToken.kt | 4 +- .../api/endpoints/access/RevokeToken.kt | 4 +- .../channel_groups/AddChannelChannelGroup.kt | 4 +- .../channel_groups/AllChannelsChannelGroup.kt | 4 +- .../channel_groups/DeleteChannelGroup.kt | 4 +- .../channel_groups/ListAllChannelGroup.kt | 4 +- .../RemoveChannelChannelGroup.kt | 4 +- .../pubnub/api/endpoints/files/DeleteFile.kt | 4 +- .../api/endpoints/files/DownloadFile.kt | 11 ++ .../pubnub/api/endpoints/files/GetFileUrl.kt | 4 +- .../pubnub/api/endpoints/files/ListFiles.kt | 4 +- .../api/endpoints/files/PublishFileMessage.kt | 4 +- .../pubnub/api/endpoints/files/SendFile.kt | 10 ++ .../message_actions/AddMessageAction.kt | 4 +- .../message_actions/GetMessageActions.kt | 4 +- .../message_actions/RemoveMessageAction.kt | 4 +- .../objects/channel/GetAllChannelMetadata.kt | 4 +- .../objects/channel/GetChannelMetadata.kt | 4 +- .../objects/channel/RemoveChannelMetadata.kt | 4 +- .../objects/channel/SetChannelMetadata.kt | 4 +- .../objects/member/GetChannelMembers.kt | 4 +- .../objects/member/ManageChannelMembers.kt | 4 +- .../objects/membership/GetMemberships.kt | 4 +- .../objects/membership/ManageMemberships.kt | 4 +- .../objects/uuid/GetAllUUIDMetadata.kt | 4 +- .../endpoints/objects/uuid/GetUUIDMetadata.kt | 4 +- .../objects/uuid/RemoveUUIDMetadata.kt | 4 +- .../endpoints/objects/uuid/SetUUIDMetadata.kt | 4 +- .../pubnub/api/endpoints/presence/GetState.kt | 4 +- .../pubnub/api/endpoints/presence/HereNow.kt | 4 +- .../pubnub/api/endpoints/presence/SetState.kt | 4 +- .../pubnub/api/endpoints/presence/WhereNow.kt | 4 +- .../pubnub/api/endpoints/pubsub/Publish.kt | 4 +- .../com/pubnub/api/endpoints/pubsub/Signal.kt | 4 +- .../api/endpoints/push/AddChannelsToPush.kt | 4 +- .../api/endpoints/push/ListPushProvisions.kt | 4 +- .../push/RemoveAllPushChannelsForDevice.kt | 4 +- .../endpoints/push/RemoveChannelsFromPush.kt | 4 +- .../kotlin/com/pubnub/kmp/abstractions.kt | 4 +- .../com/pubnub/test/BaseIntegrationTest.kt | 4 +- .../kotlin/com/pubnub/api/PubNub.ios.kt | 21 ++++ .../kotlin/com/pubnub/api/PubNubImpl.kt | 20 ++++ .../api/endpoints/DeleteMessages.ios.kt | 8 +- .../pubnub/api/endpoints/FetchMessages.ios.kt | 8 +- .../pubnub/api/endpoints/MessageCounts.ios.kt | 8 +- .../com/pubnub/api/endpoints/Time.ios.kt | 8 +- .../api/endpoints/access/GrantToken.ios.kt | 4 +- .../api/endpoints/access/RevokeToken.ios.kt | 4 +- .../AddChannelChannelGroup.ios.kt | 9 +- .../AllChannelsChannelGroup.ios.kt | 8 +- .../channel_groups/DeleteChannelGroup.ios.kt | 8 +- .../channel_groups/ListAllChannelGroup.ios.kt | 8 +- .../RemoveChannelChannelGroup.ios.kt | 9 +- .../api/endpoints/files/DeleteFile.ios.kt | 4 +- .../api/endpoints/files/DownloadFile.ios.kt | 9 ++ .../api/endpoints/files/GetFileUrl.ios.kt | 4 +- .../api/endpoints/files/ListFiles.ios.kt | 4 +- .../endpoints/files/PublishFileMessage.ios.kt | 4 +- .../api/endpoints/files/SendFile.ios.kt | 9 ++ .../message_actions/AddMessageAction.ios.kt | 8 +- .../message_actions/GetMessageActions.ios.kt | 8 +- .../RemoveMessageAction.ios.kt | 8 +- .../channel/GetAllChannelMetadata.ios.kt | 10 +- .../objects/channel/GetChannelMetadata.ios.kt | 8 +- .../channel/RemoveChannelMetadata.ios.kt | 9 +- .../objects/channel/SetChannelMetadata.ios.kt | 8 +- .../objects/member/GetChannelMembers.ios.kt | 4 +- .../member/ManageChannelMembers.ios.kt | 4 +- .../objects/membership/GetMemberships.ios.kt | 4 +- .../membership/ManageMemberships.ios.kt | 4 +- .../objects/uuid/GetAllUUIDMetadata.ios.kt | 13 +- .../objects/uuid/GetUUIDMetadata.ios.kt | 9 +- .../objects/uuid/RemoveUUIDMetadata.ios.kt | 8 +- .../objects/uuid/SetUUIDMetadata.ios.kt | 8 +- .../api/endpoints/presence/GetState.ios.kt | 8 +- .../api/endpoints/presence/HereNow.ios.kt | 8 +- .../api/endpoints/presence/SetState.ios.kt | 4 +- .../api/endpoints/presence/WhereNow.ios.kt | 12 +- .../api/endpoints/pubsub/Publish.ios.kt | 8 +- .../pubnub/api/endpoints/pubsub/Signal.ios.kt | 8 +- .../endpoints/push/AddChannelsToPush.ios.kt | 8 +- .../endpoints/push/ListPushProvisions.ios.kt | 8 +- .../RemoveAllPushChannelsForDevice.ios.kt | 9 +- .../push/RemoveChannelsFromPush.ios.kt | 8 +- .../kotlin/com/pubnub/kmp/abstractions.ios.kt | 4 +- .../Endpoint.ios.kt => kmp/results.ios.kt} | 7 +- .../src/jsMain/kotlin/Pubnub.d.kt | 4 +- .../kotlin/com/pubnub/api/Endpoint.js.kt | 6 +- .../kotlin/com/pubnub/api/EndpointImpl.kt | 3 +- .../jsMain/kotlin/com/pubnub/api/PubNub.js.kt | 21 ++++ .../kotlin/com/pubnub/api/PubNubImpl.kt | 84 ++++++++++--- .../pubnub/api/endpoints/DeleteMessages.js.kt | 4 +- .../pubnub/api/endpoints/FetchMessages.js.kt | 4 +- .../pubnub/api/endpoints/MessageCounts.js.kt | 4 +- .../com/pubnub/api/endpoints/Time.js.kt | 4 +- .../api/endpoints/access/GrantToken.js.kt | 4 +- .../api/endpoints/access/RevokeToken.js.kt | 4 +- .../AddChannelChannelGroup.js.kt | 4 +- .../AllChannelsChannelGroup.js.kt | 4 +- .../channel_groups/DeleteChannelGroup.js.kt | 4 +- .../channel_groups/ListAllChannelGroup.js.kt | 4 +- .../RemoveChannelChannelGroup.js.kt | 4 +- .../api/endpoints/files/DeleteFile.js.kt | 4 +- .../api/endpoints/files/DeleteFileImpl.kt | 15 +++ .../api/endpoints/files/DownloadFile.js.kt | 9 ++ .../api/endpoints/files/DownloadFileImpl.kt | 19 +++ .../api/endpoints/files/GetFileUrl.js.kt | 4 +- .../api/endpoints/files/GetFileUrlImpl.kt | 22 ++++ .../api/endpoints/files/ListFiles.js.kt | 4 +- .../api/endpoints/files/ListFilesImpl.kt | 27 +++++ .../endpoints/files/PublishFileMessage.js.kt | 4 +- .../endpoints/files/PublishFileMessageImpl.kt | 12 ++ .../pubnub/api/endpoints/files/SendFile.js.kt | 9 ++ .../api/endpoints/files/SendFileImpl.kt | 20 ++++ .../message_actions/AddMessageAction.js.kt | 4 +- .../message_actions/GetMessageActions.js.kt | 4 +- .../message_actions/RemoveMessageAction.js.kt | 4 +- .../channel/GetAllChannelMetadata.js.kt | 4 +- .../objects/channel/GetChannelMetadata.js.kt | 4 +- .../channel/RemoveChannelMetadata.js.kt | 4 +- .../objects/channel/SetChannelMetadata.js.kt | 4 +- .../objects/member/GetChannelMembers.js.kt | 4 +- .../objects/member/ManageChannelMembers.js.kt | 4 +- .../objects/membership/GetMemberships.js.kt | 4 +- .../membership/ManageMemberships.js.kt | 4 +- .../objects/uuid/GetAllUUIDMetadata.js.kt | 4 +- .../objects/uuid/GetUUIDMetadata.js.kt | 4 +- .../objects/uuid/RemoveUUIDMetadata.js.kt | 4 +- .../objects/uuid/SetUUIDMetadata.js.kt | 4 +- .../api/endpoints/presence/GetState.js.kt | 4 +- .../api/endpoints/presence/HereNow.js.kt | 4 +- .../api/endpoints/presence/SetState.js.kt | 4 +- .../api/endpoints/presence/WhereNow.js.kt | 4 +- .../pubnub/api/endpoints/pubsub/Publish.js.kt | 4 +- .../pubnub/api/endpoints/pubsub/Signal.js.kt | 4 +- .../endpoints/push/AddChannelsToPush.js.kt | 4 +- .../endpoints/push/ListPushProvisions.js.kt | 4 +- .../push/RemoveAllPushChannelsForDevice.js.kt | 4 +- .../push/RemoveChannelsFromPush.js.kt | 4 +- .../com/pubnub/api/v2/PNConfiguration.js.kt | 1 + .../kotlin/com/pubnub/kmp/abstractions.js.kt | 6 +- .../jvmMain/kotlin/com/pubnub/api/Endpoint.kt | 2 +- .../jvmMain/kotlin/com/pubnub/api/PubNub.kt | 16 +-- .../api/endpoints/files/DownloadFile.kt | 2 +- .../pubnub/api/endpoints/files/SendFile.kt | 2 +- .../kotlin/com/pubnub/kmp/abstractions.jvm.kt | 6 +- swift | 2 +- 165 files changed, 888 insertions(+), 367 deletions(-) rename pubnub-core/pubnub-core-api/src/{jvmMain => commonMain}/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt (60%) create mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt rename pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/Endpoint.kt => pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt (70%) create mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt create mode 100644 pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt create mode 100644 pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt create mode 100644 pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt create mode 100644 pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt rename pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/{api/Endpoint.ios.kt => kmp/results.ios.kt} (90%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFileImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFileImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrlImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFilesImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessageImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFile.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFileImpl.kt diff --git a/build.gradle.kts b/build.gradle.kts index 1ac49775f..8035c5990 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,6 +5,7 @@ plugins { alias(libs.plugins.vanniktech.maven.publish) apply false alias(libs.plugins.dokka) alias(libs.plugins.gradle.nexus.publish) + alias(libs.plugins.kotlinx.atomicfu) apply false } nexusPublishing { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 544906fe3..e48586d62 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -22,6 +22,7 @@ gson = { module = "com.google.code.gson:gson", version = "2.10.1" } slf4j = { module = "org.slf4j:slf4j-api", version = "1.7.36" } cbor = { module = "co.nstant.in:cbor", version = "0.9" } jetbrains-annotations = { module = "org.jetbrains:annotations", version = "24.1.0" } +kotlinx-atomicfu = { module = "org.jetbrains.kotlinx:atomicfu", version = "0.24.0" } # tests wiremock = { module = "com.github.tomakehurst:wiremock", version = "2.27.2" } @@ -51,6 +52,7 @@ dokka-gradlePlugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", versi [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } +kotlinx-atomicfu = { id = "org.jetbrains.kotlin.plugin.atomicfu", version.ref = "kotlin" } # shadow = { id = "com.github.johnrengelman.shadow", version = "7.1.2" } ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" } dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } diff --git a/pubnub-core/pubnub-core-api/build.gradle.kts b/pubnub-core/pubnub-core-api/build.gradle.kts index 6371f5910..4843098eb 100644 --- a/pubnub-core/pubnub-core-api/build.gradle.kts +++ b/pubnub-core/pubnub-core-api/build.gradle.kts @@ -3,13 +3,14 @@ plugins { id("pubnub.shared") id("pubnub.dokka") id("pubnub.multiplatform") + alias(libs.plugins.kotlinx.atomicfu) } kotlin { sourceSets { val commonMain by getting { dependencies { - + implementation(libs.kotlinx.atomicfu) } } @@ -23,5 +24,15 @@ kotlin { implementation(libs.slf4j) } } + + val commonTest by getting { + dependencies { + implementation(kotlin("test")) + } + } } } + +//atomicfu { +// dependenciesVersion = "0.24.0" +//} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/UserId.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/UserId.kt index 60d30b7fe..060b4face 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/UserId.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/UserId.kt @@ -1,5 +1,8 @@ package com.pubnub.api +import kotlin.js.JsExport + +@JsExport data class UserId @Throws(PubNubException::class) constructor(val value: String) { diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt index dcec07d41..63cd199ca 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt @@ -4,6 +4,7 @@ import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNOperationType import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture interface ExtendedRemoteAction : RemoteAction { /** @@ -12,7 +13,7 @@ interface ExtendedRemoteAction : RemoteAction { fun operationType(): PNOperationType } -interface RemoteAction : Cancelable { +interface RemoteAction : PNFuture, Cancelable { /** * Run the action synchronously, potentially blocking the calling thread. * @return returns the result of the action @@ -39,7 +40,7 @@ interface RemoteAction : Cancelable { * } * ``` */ - fun async(callback: Consumer>) + override fun async(callback: Consumer>) /** * Attempt to retry the action and deliver the result to a callback registered with a previous call to [async]. diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt similarity index 60% rename from pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt index 2be27a649..235697bbe 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt @@ -1,8 +1,8 @@ package com.pubnub.api.models.consumer.files -import java.io.InputStream +import com.pubnub.kmp.Downloadable data class PNDownloadFileResult( val fileName: String, - val byteStream: InputStream?, + val byteStream: Downloadable?, ) \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt new file mode 100644 index 000000000..124c3d165 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt @@ -0,0 +1,3 @@ +package com.pubnub.kmp + +expect abstract class Downloadable \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/Endpoint.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt similarity index 70% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/Endpoint.kt rename to pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt index 53a898005..d82a0157c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/Endpoint.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt @@ -1,8 +1,8 @@ -package com.pubnub.api +package com.pubnub.kmp import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result -expect interface Endpoint { +interface PNFuture { fun async(callback: Consumer>) } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt new file mode 100644 index 000000000..25b048a56 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt @@ -0,0 +1,112 @@ +@file:JvmName("PNFutures") + +import com.pubnub.api.PubNubException +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.api.v2.callbacks.mapCatching +import com.pubnub.kmp.PNFuture +import kotlinx.atomicfu.atomic +import kotlin.jvm.JvmName + +fun PubNubException.asFuture(): PNFuture = object : PNFuture { + override fun async(callback: Consumer>) { + callback.accept(Result.failure(this@asFuture)) + } +} + +fun T.asFuture(): PNFuture = object : PNFuture { + override fun async(callback: Consumer>) { + callback.accept(Result.success(this@asFuture)) + } +} + +fun Result.asFuture(): PNFuture = object : PNFuture { + override fun async(callback: Consumer>) { + callback.accept(this@asFuture) + } +} + +fun PNFuture.then(action: (T) -> U): PNFuture = object : PNFuture { + override fun async(callback: Consumer>) { + this@then.async { it: Result -> + callback.accept(it.mapCatching(action)) + } + } +} + +fun PNFuture.thenAsync(action: (T) -> PNFuture): PNFuture = object : PNFuture { + override fun async(callback: Consumer>) { + this@thenAsync.async { firstFutureResult: Result -> + val intermediateResult: Result> = firstFutureResult.mapCatching(action) + intermediateResult.onFailure { + callback.accept(Result.failure(it)) + }.onSuccess { secondFuture: PNFuture -> + secondFuture.async(callback) + } + } + } +} + +/** + * Execute a second PNFuture after this PNFuture completes successfully, + * and return the *original* value of this PNFuture after the second PNFuture completes successfully. + * + * Failures are propagated to the resulting PNFuture. + */ +fun PNFuture.alsoAsync(action: (T) -> PNFuture<*>): PNFuture = + this@alsoAsync.thenAsync { outerResult: T -> + action(outerResult).then { _ -> + outerResult + } + } + + +fun PNFuture.catch(action: (Exception) -> Result): PNFuture = object : PNFuture { + override fun async(callback: Consumer>) { + this@catch.async { result: Result -> + result.onSuccess { + callback.accept(result) + }.onFailure { + try { + callback.accept(action(it)) + } catch (e: Exception) { + callback.accept(Result.failure(e)) + } + } + } + } +} + +fun Collection>.awaitAll(): PNFuture> = object : PNFuture> { + override fun async(callback: Consumer>>) { + val counter = atomic(0) + val failed = atomic(false) + val array = Array(size) { null } + forEachIndexed { index, future -> + future.async { res -> + res.onSuccess { value -> + array[index] = value + val counterIncremented = counter.incrementAndGet() + if (counterIncremented == size) { + callback.accept(Result.success(array as Array)) + } + }.onFailure { exception -> + val failedWasSetPreviously = failed.getAndSet(true) + if (!failedWasSetPreviously) { + callback.accept(Result.failure(exception)) + } + } + } + } + } +} + +@Suppress("UNCHECKED_CAST") +fun awaitAll(future1: PNFuture, future2: PNFuture): PNFuture> = listOf(future1 as PNFuture, future2 as PNFuture).awaitAll().then { it: Array -> + Pair(it[0] as T, it[1] as U) +} + +@Suppress("UNCHECKED_CAST") +fun awaitAll(future1: PNFuture, future2: PNFuture, future3: PNFuture): PNFuture> = listOf(future1 as PNFuture, future2 as PNFuture, future3 as PNFuture).awaitAll().then { it: Array -> + Triple(it[0] as T, it[1] as U, it[2] as X) +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt new file mode 100644 index 000000000..901e68391 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt @@ -0,0 +1,68 @@ +package com.pubnub.kmp + +import asFuture +import awaitAll +import com.pubnub.api.v2.callbacks.Result +import then +import thenAsync +import kotlin.test.Test +import kotlin.test.assertContentEquals +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class PNFutureTest { + + @Test + fun asFuture1() { + val value = true + var set = false + value.asFuture().async { result -> + assertTrue { result.isSuccess } + result.onSuccess { value -> + set = value + } + } + assertEquals(value, set) + } + + @Test + fun then() { + val value = true + var set: String? = null + value.asFuture().then { it.toString() }.async { result -> + assertTrue { result.isSuccess } + result.onSuccess { value -> + set = value + } + } + assertEquals(value.toString(), set) + } + + @Test + fun thenAsync() { + val value = true + var set: String? = null + value.asFuture().thenAsync { it.toString().asFuture() }.async { result -> + assertTrue { result.isSuccess } + result.onSuccess { value -> + set = value + } + } + assertEquals(value.toString(), set) + } + + @Test + fun awaitAll() { + val value1 = true + val value2 = 1 + val value3: Any? = null + var set: Array? = null + listOf>(value1.asFuture(), value2.asFuture(), value3.asFuture()).awaitAll().async { result: Result> -> + assertTrue { result.isSuccess } + result.onSuccess { + set = it + } + } + assertContentEquals(arrayOf(value1, value2, value3), set) + } +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt new file mode 100644 index 000000000..8593b0fae --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt @@ -0,0 +1,3 @@ +package com.pubnub.kmp + +actual abstract class Downloadable \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt new file mode 100644 index 000000000..b61cb7571 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt @@ -0,0 +1,5 @@ +package com.pubnub.kmp + +actual abstract class Downloadable(val pubnubFile: Any) + +class DownloadableImpl(pubnubFile: Any) : Downloadable(pubnubFile) \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt new file mode 100644 index 000000000..510d69843 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt @@ -0,0 +1,5 @@ +package com.pubnub.kmp + +import java.io.InputStream + +actual typealias Downloadable = InputStream \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt index 903a57248..bf2aa850d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt @@ -13,9 +13,11 @@ import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.DownloadFile import com.pubnub.api.endpoints.files.GetFileUrl import com.pubnub.api.endpoints.files.ListFiles import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.message_actions.AddMessageAction import com.pubnub.api.endpoints.message_actions.GetMessageActions import com.pubnub.api.endpoints.message_actions.RemoveMessageAction @@ -47,6 +49,7 @@ import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.files.PNDownloadFileResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNMemberKey @@ -61,6 +64,7 @@ import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.Uploadable expect interface PubNub { val configuration: PNConfiguration @@ -381,12 +385,24 @@ expect interface PubNub { fileId: String, ): GetFileUrl - // fun downloadFile( -// channel: String, -// fileName: String, -// fileId: String, -// cipherKey: String? = null, -// ): Endpoint // TODO inputstream + fun sendFile( + channel: String, + fileName: String, + inputStream: Uploadable, + message: Any? = null, + meta: Any? = null, + ttl: Int? = null, + shouldStore: Boolean? = null, + cipherKey: String? = null, + ): SendFile + + fun downloadFile( + channel: String, + fileName: String, + fileId: String, + cipherKey: String? = null, + ): DownloadFile + fun deleteFile( channel: String, fileName: String, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt index f0bd9c7a4..54caa24ef 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult /** * @see [com.pubnub.api.PubNub.deleteMessages] */ -expect interface DeleteMessages : Endpoint \ No newline at end of file +expect interface DeleteMessages : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt index c862f61c5..549c7444a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints -import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.history.PNFetchMessagesResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.fetchMessages] */ -expect interface FetchMessages : Endpoint \ No newline at end of file +expect interface FetchMessages : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt index 31b56a358..367f682d7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNMessageCountResult /** * @see [PubNub.messageCounts] */ -expect interface MessageCounts : Endpoint \ No newline at end of file +expect interface MessageCounts : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/Time.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/Time.kt index abb353d19..464515963 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/Time.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/Time.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNTimeResult /** * @see [PubNub.time] */ -expect interface Time : Endpoint \ No newline at end of file +expect interface Time : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt index eacb620c9..8105bd07b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt @@ -1,7 +1,7 @@ package com.pubnub.api.endpoints.access -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult -expect interface GrantToken : Endpoint { +expect interface GrantToken : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt index 701fbbade..0d097c01f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt @@ -1,5 +1,5 @@ package com.pubnub.api.endpoints.access -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture -expect interface RevokeToken : Endpoint \ No newline at end of file +expect interface RevokeToken : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt index 92fde21aa..d27bda3c9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult /** * @see [PubNub.addChannelsToChannelGroup] */ -expect interface AddChannelChannelGroup : Endpoint \ No newline at end of file +expect interface AddChannelChannelGroup : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt index f2b0337e6..7cdadeda3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult /** * @see [PubNub.listChannelsForChannelGroup] */ -expect interface AllChannelsChannelGroup : Endpoint \ No newline at end of file +expect interface AllChannelsChannelGroup : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt index c8421da68..fc1b42955 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult /** * @see [PubNub.deleteChannelGroup] */ -expect interface DeleteChannelGroup : Endpoint \ No newline at end of file +expect interface DeleteChannelGroup : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt index 0860718f0..c13159796 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult /** * @see [PubNub.listAllChannelGroups] */ -expect interface ListAllChannelGroup : Endpoint \ No newline at end of file +expect interface ListAllChannelGroup : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt index 4bbb27471..95b1d847b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.channel_groups -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult /** * @see [PubNub.removeChannelsFromChannelGroup] */ -expect interface RemoveChannelChannelGroup : Endpoint { +expect interface RemoveChannelChannelGroup : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt index b9d662890..6664f6f9c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNDeleteFileResult /** * @see [PubNub.deleteFile] */ -expect interface DeleteFile : Endpoint \ No newline at end of file +expect interface DeleteFile : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt new file mode 100644 index 000000000..d0b90e3fe --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt @@ -0,0 +1,11 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction +import com.pubnub.api.models.consumer.files.PNDownloadFileResult +import com.pubnub.api.models.consumer.files.PNFileUploadResult +import com.pubnub.kmp.PNFuture + +/** + * @see [PubNub.sendFile] + */ +expect interface DownloadFile : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt index fe58a6221..237b4d580 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNFileUrlResult /** * @see [PubNub.getFileUrl] */ -expect interface GetFileUrl : Endpoint \ No newline at end of file +expect interface GetFileUrl : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt index ad5b26b24..0bf689162 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNListFilesResult /** * @see [PubNub.listFiles] */ -expect interface ListFiles : Endpoint \ No newline at end of file +expect interface ListFiles : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt index 1fccf9263..639090323 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult /** * @see [PubNub.publishFileMessage] */ -expect interface PublishFileMessage : Endpoint \ No newline at end of file +expect interface PublishFileMessage : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt new file mode 100644 index 000000000..a026f925a --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt @@ -0,0 +1,10 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction +import com.pubnub.api.models.consumer.files.PNFileUploadResult +import com.pubnub.kmp.PNFuture + +/** + * @see [PubNub.sendFile] + */ +expect interface SendFile : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt index 805693dd9..64e023bd5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.message_actions -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult /** * @see [PubNub.addMessageAction] */ -expect interface AddMessageAction : Endpoint { +expect interface AddMessageAction : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt index 9578456b0..e94606f9e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.message_actions -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult /** * @see [PubNub.getMessageActions] */ -expect interface GetMessageActions : Endpoint { +expect interface GetMessageActions : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt index 7419e1518..2cd7b3aa2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.message_actions -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult /** * @see [PubNub.removeMessageAction] */ -expect interface RemoveMessageAction : Endpoint { +expect interface RemoveMessageAction : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt index f1ec80946..ec3adb74a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.objects.channel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult /** * @see [PubNub.getAllChannelMetadata] */ expect interface GetAllChannelMetadata : - Endpoint \ No newline at end of file + PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt index 9001d76cd..33386e935 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.channel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult /** * @see [PubNub.getChannelMetadata] */ -expect interface GetChannelMetadata : Endpoint \ No newline at end of file +expect interface GetChannelMetadata : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt index fcdefef90..6dc6a21da 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.objects.channel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -expect interface RemoveChannelMetadata : Endpoint \ No newline at end of file +expect interface RemoveChannelMetadata : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt index 2d0ed08e6..cc88f24e6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.channel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult /** * @see [PubNub.setChannelMetadata] */ -expect interface SetChannelMetadata : Endpoint \ No newline at end of file +expect interface SetChannelMetadata : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt index 16da70b9c..8a7685817 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.member -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult /** * @see [PubNub.getChannelMembers] */ -expect interface GetChannelMembers : Endpoint \ No newline at end of file +expect interface GetChannelMembers : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt index c47b6034c..de9973f0f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.member -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult /** * @see [PubNub.manageChannelMembers] */ -expect interface ManageChannelMembers : Endpoint \ No newline at end of file +expect interface ManageChannelMembers : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt index add1d26f5..632c177a1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.membership -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult /** * @see [PubNub.getMemberships] */ -expect interface GetMemberships : Endpoint \ No newline at end of file +expect interface GetMemberships : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt index 2c43038d1..87e256ff0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.membership -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult /** * @see [PubNub.manageMemberships] */ -expect interface ManageMemberships : Endpoint \ No newline at end of file +expect interface ManageMemberships : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt index d42c784e3..033421de0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.uuid -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult /** * @see [PubNub.getAllUUIDMetadata] */ -expect interface GetAllUUIDMetadata : Endpoint \ No newline at end of file +expect interface GetAllUUIDMetadata : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt index 93e76b3bf..4bfd2e3e3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.objects.uuid -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult /** * @see [PubNub.getUUIDMetadata] */ -expect interface GetUUIDMetadata : Endpoint { +expect interface GetUUIDMetadata : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt index b30d322af..c33a924f2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt @@ -1,7 +1,7 @@ package com.pubnub.api.endpoints.objects.uuid -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -expect interface RemoveUUIDMetadata : Endpoint { +expect interface RemoveUUIDMetadata : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt index 6470a9a2a..2521b7659 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.uuid -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult /** * @see [PubNub.setUUIDMetadata] */ -expect interface SetUUIDMetadata : Endpoint \ No newline at end of file +expect interface SetUUIDMetadata : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt index ed2fdb6d3..c37e4ec74 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.presence -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNGetStateResult /** * @see [PubNub.getPresenceState] */ -expect interface GetState : Endpoint { +expect interface GetState : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt index eabef86a0..24f791e1f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.presence -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNHereNowResult /** * @see [PubNub.hereNow] */ -expect interface HereNow : Endpoint { +expect interface HereNow : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt index 4f4c61dc6..2dcd8165d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.presence -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNSetStateResult /** * @see [PubNub.setPresenceState] */ -expect interface SetState : Endpoint { +expect interface SetState : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt index a810bfb49..65a38a200 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.presence -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNWhereNowResult /** * @see [PubNub.whereNow] */ -expect interface WhereNow : Endpoint { +expect interface WhereNow : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt index ddf89abf8..9c6ab41e7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.pubsub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNPublishResult /** * @see [PubNub.publish] */ -expect interface Publish : Endpoint \ No newline at end of file +expect interface Publish : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt index 81e9b6569..70ca99a25 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.pubsub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNPublishResult /** * @see [PubNub.signal] */ -expect interface Signal : Endpoint \ No newline at end of file +expect interface Signal : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt index 0c3b0fb7e..b00bb0708 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.push -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushAddChannelResult /** * @see [PubNub.addPushNotificationsOnChannels] */ -expect interface AddChannelsToPush : Endpoint \ No newline at end of file +expect interface AddChannelsToPush : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt index 10c046b19..c872f3b15 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.push -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult /** * @see [PubNub.auditPushChannelProvisions] */ -expect interface ListPushProvisions : Endpoint \ No newline at end of file +expect interface ListPushProvisions : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt index bd391522c..8b7aea173 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.push -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult /** * @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken] */ -expect interface RemoveAllPushChannelsForDevice : Endpoint \ No newline at end of file +expect interface RemoveAllPushChannelsForDevice : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt index 569d60054..a6af5e679 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.push -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult /** * @see [PubNub.removePushNotificationsFromChannels] */ -expect interface RemoveChannelsFromPush : Endpoint \ No newline at end of file +expect interface RemoveChannelsFromPush : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt index a9e844b1b..09a27fe81 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt @@ -1,3 +1,5 @@ package com.pubnub.kmp -expect class CustomObject \ No newline at end of file +expect class CustomObject + +expect abstract class Uploadable \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt index da4568cdd..9a32af776 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt @@ -1,6 +1,5 @@ package com.pubnub.test -import com.pubnub.api.Endpoint import com.pubnub.api.PubNub import com.pubnub.api.UserId import com.pubnub.api.enums.PNStatusCategory @@ -8,6 +7,7 @@ import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNEvent import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.v2.createPNConfiguration +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.createEventListener import com.pubnub.kmp.createPubNub import com.pubnub.kmp.createStatusListener @@ -37,7 +37,7 @@ abstract class BaseIntegrationTest { } } -suspend fun Endpoint.await() = suspendCancellableCoroutine { cont -> +suspend fun PNFuture.await() = suspendCancellableCoroutine { cont -> async { result -> result.onSuccess { cont.resume(it) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt index 0e8080d50..dd1a9226b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt @@ -13,9 +13,11 @@ import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.DownloadFile import com.pubnub.api.endpoints.files.GetFileUrl import com.pubnub.api.endpoints.files.ListFiles import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.message_actions.AddMessageAction import com.pubnub.api.endpoints.message_actions.GetMessageActions import com.pubnub.api.endpoints.message_actions.RemoveMessageAction @@ -61,6 +63,7 @@ import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.Uploadable actual interface PubNub { actual val configuration: PNConfiguration @@ -397,5 +400,23 @@ actual interface PubNub { actual fun destroy() actual fun unsubscribeAll() + actual fun sendFile( + channel: String, + fileName: String, + inputStream: Uploadable, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, + cipherKey: String? + ): SendFile + + actual fun downloadFile( + channel: String, + fileName: String, + fileId: String, + cipherKey: String? + ): DownloadFile + } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 531fc49ac..3e82d2aad 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -30,9 +30,11 @@ import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroupImpl import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.DownloadFile import com.pubnub.api.endpoints.files.GetFileUrl import com.pubnub.api.endpoints.files.ListFiles import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.message_actions.AddMessageAction import com.pubnub.api.endpoints.message_actions.AddMessageActionImpl import com.pubnub.api.endpoints.message_actions.GetMessageActions @@ -98,6 +100,7 @@ import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.Uploadable import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) @@ -652,4 +655,21 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { override fun unsubscribeAll() { // TODO("Not yet implemented") } + + override fun sendFile( + channel: String, + fileName: String, + inputStream: Uploadable, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, + cipherKey: String? + ): SendFile { + TODO("Not yet implemented") + } + + override fun downloadFile(channel: String, fileName: String, fileId: String, cipherKey: String?): DownloadFile { + TODO("Not yet implemented") + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt index 746c60c12..27d9ead40 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt @@ -2,10 +2,10 @@ package com.pubnub.api.endpoints import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.deleteMessagesFrom -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessReturnValue +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessReturnValue import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -14,7 +14,7 @@ import platform.Foundation.NSNumber /** * @see [com.pubnub.api.PubNub.deleteMessages] */ -actual interface DeleteMessages : Endpoint +actual interface DeleteMessages : PNFuture @OptIn(ExperimentalForeignApi::class) class DeleteMessagesImpl ( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt index cad9fb4e5..0e76cd518 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt @@ -5,15 +5,15 @@ import cocoapods.PubNubSwift.PubNubMessageActionObjC import cocoapods.PubNubSwift.PubNubMessageObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.fetchMessagesFrom -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.JsonElement import com.pubnub.api.PubNubError import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.HistoryMessageType import com.pubnub.api.models.consumer.history.PNFetchMessageItem import com.pubnub.api.models.consumer.history.PNFetchMessagesResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -22,7 +22,7 @@ import platform.Foundation.NSNumber /** * @see [PubNub.fetchMessages] */ -actual interface FetchMessages : Endpoint {} +actual interface FetchMessages : PNFuture {} @OptIn(ExperimentalForeignApi::class) open class FetchMessagesImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt index 698fc13a7..4c418d936 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt @@ -2,10 +2,10 @@ package com.pubnub.api.endpoints import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.messageCountsFor -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNMessageCountResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -13,7 +13,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.messageCounts] */ -actual interface MessageCounts : Endpoint +actual interface MessageCounts : PNFuture @OptIn(ExperimentalForeignApi::class) class MessageCountsImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt index aa91fd7bc..e2981cab6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt @@ -2,11 +2,11 @@ package com.pubnub.api.endpoints import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.timeOnSuccess -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNTimeResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -14,7 +14,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.time] */ -actual interface Time : Endpoint +actual interface Time : PNFuture @OptIn(ExperimentalForeignApi::class) class TimeImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt index 0f81aa098..1b0b0f300 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt @@ -1,7 +1,7 @@ package com.pubnub.api.endpoints.access -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult -actual interface GrantToken : Endpoint { +actual interface GrantToken : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt index 68574fb0e..6e58a2afb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt @@ -1,5 +1,5 @@ package com.pubnub.api.endpoints.access -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture -actual interface RevokeToken : Endpoint \ No newline at end of file +actual interface RevokeToken : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt index cc741a364..b1154eea5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt @@ -2,10 +2,10 @@ package com.pubnub.api.endpoints.channel_groups import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.addChannelsTo -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -13,8 +13,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.addChannelsToChannelGroup] */ -actual interface AddChannelChannelGroup : Endpoint { -} +actual interface AddChannelChannelGroup : PNFuture @OptIn(ExperimentalForeignApi::class) class AddChannelChannelGroupImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt index 94f5ed9e4..f88a85d6f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt @@ -2,10 +2,10 @@ package com.pubnub.api.endpoints.channel_groups import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.listChannelsFor -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -13,7 +13,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.listChannelsForChannelGroup] */ -actual interface AllChannelsChannelGroup : Endpoint { +actual interface AllChannelsChannelGroup : PNFuture { } @OptIn(ExperimentalForeignApi::class) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt index e19d81926..f0570a6cf 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt @@ -2,10 +2,10 @@ package com.pubnub.api.endpoints.channel_groups import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.deleteWithChannelGroup -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -13,7 +13,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.deleteChannelGroup] */ -actual interface DeleteChannelGroup : Endpoint +actual interface DeleteChannelGroup : PNFuture @OptIn(ExperimentalForeignApi::class) class DeleteChannelGroupImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt index 038fca34a..0736a2d1c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt @@ -2,10 +2,10 @@ package com.pubnub.api.endpoints.channel_groups import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.listChannelGroupsOnSuccess -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -13,7 +13,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.listAllChannelGroups] */ -actual interface ListAllChannelGroup : Endpoint +actual interface ListAllChannelGroup : PNFuture @OptIn(ExperimentalForeignApi::class) class ListAllChannelGroupImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt index f5fd5863e..e32a93c98 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt @@ -2,11 +2,10 @@ package com.pubnub.api.endpoints.channel_groups import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeWithChannels -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler -import com.pubnub.api.onSuccessReturnValue +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -14,7 +13,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.removeChannelsFromChannelGroup] */ -actual interface RemoveChannelChannelGroup : Endpoint { +actual interface RemoveChannelChannelGroup : PNFuture { } @OptIn(ExperimentalForeignApi::class) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt index df58b5133..736d296c6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNDeleteFileResult /** * @see [PubNub.deleteFile] */ -actual interface DeleteFile : Endpoint \ No newline at end of file +actual interface DeleteFile : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt new file mode 100644 index 000000000..5dd93aa8c --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.models.consumer.files.PNDownloadFileResult +import com.pubnub.kmp.PNFuture + +/** + * @see [PubNub.sendFile] + */ +actual interface DownloadFile : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt index b15d6b85d..870b4f841 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNFileUrlResult /** * @see [PubNub.getFileUrl] */ -actual interface GetFileUrl : Endpoint \ No newline at end of file +actual interface GetFileUrl : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt index d6afdd889..035b73026 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNListFilesResult /** * @see [PubNub.listFiles] */ -actual interface ListFiles : Endpoint \ No newline at end of file +actual interface ListFiles : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt index eeed730c4..b20314c65 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult /** * @see [PubNub.publishFileMessage] */ -actual interface PublishFileMessage : Endpoint \ No newline at end of file +actual interface PublishFileMessage : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt new file mode 100644 index 000000000..333925128 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.models.consumer.files.PNFileUploadResult +import com.pubnub.kmp.PNFuture + +/** + * @see [PubNub.sendFile] + */ +actual interface SendFile : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt index 077677bcd..a43767cb8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt @@ -2,11 +2,11 @@ package com.pubnub.api.endpoints.message_actions import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.addMessageActionWithChannel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -14,7 +14,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.addMessageAction] */ -actual interface AddMessageAction : Endpoint { +actual interface AddMessageAction : PNFuture { } @OptIn(ExperimentalForeignApi::class) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt index 08036fe86..0de613d43 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt @@ -3,12 +3,12 @@ package com.pubnub.api.endpoints.message_actions import cocoapods.PubNubSwift.PubNubBoundedPageObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getMessageActionsFrom -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -17,7 +17,7 @@ import platform.Foundation.NSNumber /** * @see [PubNub.getMessageActions] */ -actual interface GetMessageActions : Endpoint { +actual interface GetMessageActions : PNFuture { } @OptIn(ExperimentalForeignApi::class) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt index cc3390df8..b5731b03a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt @@ -2,11 +2,11 @@ package com.pubnub.api.endpoints.message_actions import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeMessageActionWithChannel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessReturnValue +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessReturnValue import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -14,7 +14,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.removeMessageAction] */ -actual interface RemoveMessageAction : Endpoint { +actual interface RemoveMessageAction : PNFuture { } @OptIn(ExperimentalForeignApi::class) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt index 32a90f0f2..3ced0fa12 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt @@ -5,15 +5,15 @@ import cocoapods.PubNubSwift.PubNubHashedPageObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.PubNubSortPropertyObjC import cocoapods.PubNubSwift.getAllChannelMetadataWithLimit -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.PNSortKey import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler -import com.pubnub.api.onSuccessHandler3 +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler +import com.pubnub.kmp.onSuccessHandler3 import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -22,7 +22,7 @@ import platform.Foundation.NSNumber /** * @see [PubNub.getAllChannelMetadata] */ -actual interface GetAllChannelMetadata : Endpoint +actual interface GetAllChannelMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class GetAllChannelMetadataImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt index 4cd925c90..64ecf87d6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt @@ -2,11 +2,11 @@ package com.pubnub.api.endpoints.objects.channel import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getChannelMetadataWithChannel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -14,7 +14,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.getChannelMetadata] */ -actual interface GetChannelMetadata : Endpoint +actual interface GetChannelMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class GetChannelMetadataImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt index 0fb908dff..bc1679987 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt @@ -2,16 +2,15 @@ package com.pubnub.api.endpoints.objects.channel import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeChannelMetadataWithChannel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler -import com.pubnub.api.onSuccessReturnValue +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi -actual interface RemoveChannelMetadata : Endpoint +actual interface RemoveChannelMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class RemoveChannelMetadataImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt index b4cb43f60..d8f73c658 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt @@ -3,11 +3,11 @@ package com.pubnub.api.endpoints.objects.channel import cocoapods.PubNubSwift.AnyJSONObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.setChannelMetadataWithChannel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.CustomObject @@ -17,7 +17,7 @@ import platform.posix.stat /** * @see [PubNub.setChannelMetadata] */ -actual interface SetChannelMetadata : Endpoint +actual interface SetChannelMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class SetChannelMetadataImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt index cf41affdd..abf839697 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.member -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult /** * @see [PubNub.getChannelMembers] */ -actual interface GetChannelMembers : Endpoint \ No newline at end of file +actual interface GetChannelMembers : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt index 6f27c02af..3281708c3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.member -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult /** * @see [PubNub.manageChannelMembers] */ -actual interface ManageChannelMembers : Endpoint \ No newline at end of file +actual interface ManageChannelMembers : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt index 8cec56fd6..97ea07564 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.membership -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult /** * @see [PubNub.getMemberships] */ -actual interface GetMemberships : Endpoint \ No newline at end of file +actual interface GetMemberships : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt index a7af4557b..ca64156d4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.membership -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult /** * @see [PubNub.manageMemberships] */ -actual interface ManageMemberships : Endpoint \ No newline at end of file +actual interface ManageMemberships : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt index 73b46af95..b4be3715c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt @@ -1,32 +1,27 @@ package com.pubnub.api.endpoints.objects.uuid -import cocoapods.PubNubSwift.PubNubChannelMetadataObjC import cocoapods.PubNubSwift.PubNubHashedPageObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.PubNubSortPropertyObjC import cocoapods.PubNubSwift.PubNubUUIDMetadataObjC -import cocoapods.PubNubSwift.getAllChannelMetadataWithLimit import cocoapods.PubNubSwift.getAllUUIDMetadataWithLimit -import com.pubnub.api.Endpoint import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.PNSortKey -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler -import com.pubnub.api.onSuccessHandler3 import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler3 import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSNumber /** * @see [PubNub.getAllUUIDMetadata] */ -actual interface GetAllUUIDMetadata : Endpoint +actual interface GetAllUUIDMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class GetAllUUIDMetadataImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt index 83d467e42..d1f2c8e3f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt @@ -2,12 +2,11 @@ package com.pubnub.api.endpoints.objects.uuid import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getUUIDMetadataWithUuid -import com.pubnub.api.Endpoint -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -15,7 +14,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.getUUIDMetadata] */ -actual interface GetUUIDMetadata : Endpoint { +actual interface GetUUIDMetadata : PNFuture { } @OptIn(ExperimentalForeignApi::class) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt index ebd3ced8c..1535a8fa5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt @@ -2,15 +2,15 @@ package com.pubnub.api.endpoints.objects.uuid import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeUUIDMetadataWithUuid -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi -actual interface RemoveUUIDMetadata : Endpoint { +actual interface RemoveUUIDMetadata : PNFuture { } @OptIn(ExperimentalForeignApi::class) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt index 263676872..f36616c97 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt @@ -3,11 +3,11 @@ package com.pubnub.api.endpoints.objects.uuid import cocoapods.PubNubSwift.AnyJSONObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.setUUIDMetadataWithUuid -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.CustomObject @@ -16,7 +16,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.setUUIDMetadata] */ -actual interface SetUUIDMetadata : Endpoint +actual interface SetUUIDMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class SetUUIDMetadataImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt index aa220b74d..b137a875c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt @@ -2,11 +2,11 @@ package com.pubnub.api.endpoints.presence import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getPresenceStateWithChannels -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.JsonElement import com.pubnub.api.models.consumer.presence.PNGetStateResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -14,7 +14,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.getPresenceState] */ -actual interface GetState : Endpoint { +actual interface GetState : PNFuture { } @OptIn(ExperimentalForeignApi::class) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt index 034fa2eb2..766c563d3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt @@ -4,13 +4,13 @@ import cocoapods.PubNubSwift.PubNubHereNowChannelDataObjC import cocoapods.PubNubSwift.PubNubHereNowOccupantDataObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.hereNowWithChannels -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.JsonElement import com.pubnub.api.models.consumer.presence.PNHereNowChannelData import com.pubnub.api.models.consumer.presence.PNHereNowOccupantData import com.pubnub.api.models.consumer.presence.PNHereNowResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -18,7 +18,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.hereNow] */ -actual interface HereNow : Endpoint { +actual interface HereNow : PNFuture { } @OptIn(ExperimentalForeignApi::class) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt index 9325e0785..f2db8e2e2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.presence -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNSetStateResult /** * @see [PubNub.setPresenceState] */ -actual interface SetState : Endpoint { +actual interface SetState : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt index d83d02228..caeb30e85 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt @@ -2,10 +2,10 @@ package com.pubnub.api.endpoints.presence import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.whereNowWithUuid -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNWhereNowResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -13,13 +13,13 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.whereNow] */ -actual interface WhereNow : Endpoint { +actual interface WhereNow : PNFuture { } @OptIn(ExperimentalForeignApi::class) class WhereNowImpl( - public val pubnub: PubNubObjC, - public val uuid: String + private val pubnub: PubNubObjC, + private val uuid: String ): WhereNow { override fun async(callback: Consumer>) { pubnub.whereNowWithUuid( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt index a90033ff5..cb405799e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt @@ -2,11 +2,11 @@ package com.pubnub.api.endpoints.pubsub import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.publishWithChannel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -15,7 +15,7 @@ import platform.Foundation.NSNumber /** * @see [PubNub.publish] */ -actual interface Publish : Endpoint +actual interface Publish : PNFuture @OptIn(ExperimentalForeignApi::class) class PublishImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt index 0251f3719..f509ab37f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt @@ -2,10 +2,10 @@ package com.pubnub.api.endpoints.pubsub import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.signalWithChannel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import kotlinx.cinterop.ExperimentalForeignApi @@ -13,7 +13,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.signal] */ -actual interface Signal : Endpoint +actual interface Signal : PNFuture @OptIn(ExperimentalForeignApi::class) class SignalImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt index df416b57c..0bd099383 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt @@ -2,11 +2,11 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.addChannelsToPushNotificationsWithChannels -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException import com.pubnub.api.models.consumer.push.PNPushAddChannelResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.toNSData @@ -15,7 +15,7 @@ import platform.Foundation.NSData /** * @see [PubNub.addPushNotificationsOnChannels] */ -actual interface AddChannelsToPush : Endpoint +actual interface AddChannelsToPush : PNFuture @OptIn(ExperimentalForeignApi::class) class AddChannelsToPushImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt index f391a6eed..742cf98ce 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.listPushChannelsWithDeviceId -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.toNSData @@ -17,7 +17,7 @@ import platform.Foundation.NSData /** * @see [PubNub.auditPushChannelProvisions] */ -actual interface ListPushProvisions : Endpoint +actual interface ListPushProvisions : PNFuture @OptIn(ExperimentalForeignApi::class) class ListPushProvisionsImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt index 3d09f99c4..8e81b6753 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt @@ -2,13 +2,12 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeAllChannelsFromPushWithPushType -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushType -import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessReturnValue +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessReturnValue import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.toNSData @@ -18,7 +17,7 @@ import platform.Foundation.NSData /** * @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken] */ -actual interface RemoveAllPushChannelsForDevice : Endpoint +actual interface RemoveAllPushChannelsForDevice : PNFuture @OptIn(ExperimentalForeignApi::class) class RemoveAllPushChannelsForDeviceImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt index f4f14842c..b792d4f8e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeChannelsFromPushWithChannels -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult -import com.pubnub.api.onFailureHandler -import com.pubnub.api.onSuccessHandler +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.toNSData @@ -17,7 +17,7 @@ import platform.Foundation.NSData /** * @see [PubNub.removePushNotificationsFromChannels] */ -actual interface RemoveChannelsFromPush : Endpoint +actual interface RemoveChannelsFromPush : PNFuture @OptIn(ExperimentalForeignApi::class) class RemoveChannelsFromPushImpl( private val pubnub: PubNubObjC, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt index fb862ec85..b829b6eb4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt @@ -1,3 +1,5 @@ package com.pubnub.kmp -actual class CustomObject(val value: Any) \ No newline at end of file +actual class CustomObject(val value: Any) + +actual abstract class Uploadable \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt similarity index 90% rename from pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt index cc6d817e2..15d4a7bf7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/Endpoint.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt @@ -1,13 +1,10 @@ -package com.pubnub.api +package com.pubnub.kmp +import com.pubnub.api.PubNubException import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import platform.Foundation.NSError -actual interface Endpoint { - actual fun async(callback: Consumer>) -} - fun Consumer>.onSuccessHandler(mapper: (T) -> U) : (T) -> Unit { return { input: T -> accept( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt index 8a5a00499..dbadc1371 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt @@ -869,7 +869,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { } - interface `T$29` { + interface UploadedFile { var name: String var id: String var size: Number @@ -878,7 +878,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface ListFilesResponse { var status: Number - var data: Array<`T$29`> + var data: Array var next: String var count: Number } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt index f7bef87b4..f5c56ca23 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt @@ -3,6 +3,6 @@ package com.pubnub.api import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result -actual interface Endpoint { - actual fun async(callback: Consumer>) -} \ No newline at end of file +//actual interface PNFuture { +// actual fun async(callback: Consumer>) +//} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt index 975bdafde..914ff7df9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt @@ -2,10 +2,11 @@ package com.pubnub.api import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture import kotlin.js.Promise open class EndpointImpl(private val promiseFactory: () -> Promise, private val responseMapping: (T) -> U): - Endpoint { + PNFuture { override fun async(callback: Consumer>) { promiseFactory().then( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt index a4a934018..49cd1de59 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt @@ -13,9 +13,11 @@ import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.DownloadFile import com.pubnub.api.endpoints.files.GetFileUrl import com.pubnub.api.endpoints.files.ListFiles import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.message_actions.AddMessageAction import com.pubnub.api.endpoints.message_actions.GetMessageActions import com.pubnub.api.endpoints.message_actions.RemoveMessageAction @@ -61,6 +63,7 @@ import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.Uploadable actual interface PubNub { @@ -345,4 +348,22 @@ actual interface PubNub { actual fun setToken(token: String?) actual fun destroy() + actual fun sendFile( + channel: String, + fileName: String, + inputStream: Uploadable, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, + cipherKey: String? + ): SendFile + + actual fun downloadFile( + channel: String, + fileName: String, + fileId: String, + cipherKey: String? + ): DownloadFile + } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index aa90dcbb8..494aea273 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -22,9 +22,17 @@ import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroupImpl import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.DeleteFileImpl +import com.pubnub.api.endpoints.files.DownloadFile +import com.pubnub.api.endpoints.files.DownloadFileImpl import com.pubnub.api.endpoints.files.GetFileUrl +import com.pubnub.api.endpoints.files.GetFileUrlImpl import com.pubnub.api.endpoints.files.ListFiles +import com.pubnub.api.endpoints.files.ListFilesImpl import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.files.PublishFileMessageImpl +import com.pubnub.api.endpoints.files.SendFile +import com.pubnub.api.endpoints.files.SendFileImpl import com.pubnub.api.endpoints.message_actions.AddMessageAction import com.pubnub.api.endpoints.message_actions.AddMessageActionImpl import com.pubnub.api.endpoints.message_actions.GetMessageActionImpl @@ -101,6 +109,7 @@ import com.pubnub.api.v2.callbacks.StatusListener import com.pubnub.kmp.CustomObject import com.pubnub.kmp.CustomObjectImpl import com.pubnub.kmp.Optional +import com.pubnub.kmp.Uploadable import com.pubnub.kmp.createJsObject import com.pubnub.kmp.toJsMap import com.pubnub.kmp.toOptional @@ -137,10 +146,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ttl: Int? ): Publish { return PublishImpl(jsPubNub, createJsObject { - this.message = message.adjustCollectionTypes()!! + this.message = message.adjustCollectionTypes() this.channel = channel this.storeInHistory = shouldStore - this.meta = meta.adjustCollectionTypes() + this.meta = meta?.adjustCollectionTypes() this.sendByPost = usePost this.ttl = ttl }) @@ -719,15 +728,29 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { // } override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { - TODO("Not yet implemented") + return ListFilesImpl(jsPubNub, createJsObject { + this.channel = channel + this.limit = limit + if (next != null) { + this.next = next.pageHash + } + }) } override fun getFileUrl(channel: String, fileName: String, fileId: String): GetFileUrl { - TODO("Not yet implemented") + return GetFileUrlImpl(jsPubNub, createJsObject { + this.channel = channel + this.name = fileName + this.id = fileId + }) } override fun deleteFile(channel: String, fileName: String, fileId: String): DeleteFile { - TODO("Not yet implemented") + return DeleteFileImpl(jsPubNub, createJsObject { + this.channel = channel + this.name = fileName + this.id = fileId + }) } override fun publishFileMessage( @@ -739,7 +762,15 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ttl: Int?, shouldStore: Boolean? ): PublishFileMessage { - TODO("Not yet implemented") + return PublishFileMessageImpl(jsPubNub, createJsObject { + this.channel = channel + this.fileName = fileName + this.fileId = fileId + this.message = message?.adjustCollectionTypes() + this.meta = meta?.adjustCollectionTypes() + this.ttl = ttl + this.storeInHistory = shouldStore + }) } override fun subscribe( @@ -775,22 +806,51 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } + override fun sendFile( + channel: String, + fileName: String, + inputStream: Uploadable, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, + cipherKey: String? + ): SendFile { + return SendFileImpl(jsPubNub, createJsObject { + this.channel = channel + this.file = inputStream.fileInput + this.message = message + this.meta = meta + this.ttl = ttl + this.storeInHistory = shouldStore + this.cipherKey = cipherKey + }) + } + + override fun downloadFile(channel: String, fileName: String, fileId: String, cipherKey: String?): DownloadFile { + return DownloadFileImpl(jsPubNub, createJsObject { + this.channel = channel + this.name = fileName + this.id = fileId + this.cipherKey = cipherKey + }) + } } -private fun Any?.adjustCollectionTypes(): Any? { +private fun Any.adjustCollectionTypes(): Any { return when (this) { is Map<*, *> -> { val json = json() entries.forEach { - json[it.key.toString()] = it.value.adjustCollectionTypes() + json[it.key.toString()] = it.value?.adjustCollectionTypes() } json } is Collection<*> -> { - this.map { it.adjustCollectionTypes() }.toTypedArray() + this.map { it?.adjustCollectionTypes() }.toTypedArray() } is Array<*> -> { - this.map { it.adjustCollectionTypes() }.toTypedArray() + this.map { it?.adjustCollectionTypes() }.toTypedArray() } is Long -> { return toString() @@ -835,10 +895,6 @@ fun ChannelMetadata( return result } - - - - fun Map.toJsObject(): PubNubJs.CustomObject { val custom = createJsObject { } entries.forEach { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt index 780e50eaf..bc1e75326 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult /** * @see [com.pubnub.api.PubNub.deleteMessages] */ -actual interface DeleteMessages : Endpoint \ No newline at end of file +actual interface DeleteMessages : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt index 830477c95..9e58c4e17 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNFetchMessagesResult /** * @see [PubNub.fetchMessages] */ -actual interface FetchMessages : Endpoint +actual interface FetchMessages : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt index e2ae91b26..a813a7067 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNMessageCountResult /** * @see [PubNub.messageCounts] */ -actual interface MessageCounts : Endpoint \ No newline at end of file +actual interface MessageCounts : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt index 297940ec9..507888d85 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNTimeResult /** * @see [PubNub.time] */ -actual interface Time : Endpoint \ No newline at end of file +actual interface Time : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt index a6e9676e3..74512c8be 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.access -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult -actual interface GrantToken : Endpoint \ No newline at end of file +actual interface GrantToken : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt index 68574fb0e..6e58a2afb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt @@ -1,5 +1,5 @@ package com.pubnub.api.endpoints.access -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture -actual interface RevokeToken : Endpoint \ No newline at end of file +actual interface RevokeToken : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt index 40559bd2c..e2749d194 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints.channel_groups import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult /** * @see [PubNub.addChannelsToChannelGroup] */ -actual interface AddChannelChannelGroup : Endpoint +actual interface AddChannelChannelGroup : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt index 820b22f61..f4fc6dcbf 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints.channel_groups import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult /** * @see [PubNub.listChannelsForChannelGroup] */ -actual interface AllChannelsChannelGroup : Endpoint +actual interface AllChannelsChannelGroup : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt index 9d871d3d5..bbf6014c9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.channel_groups import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult /** * @see [PubNub.deleteChannelGroup] */ -actual interface DeleteChannelGroup : Endpoint \ No newline at end of file +actual interface DeleteChannelGroup : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt index e6b896fcf..06460bfe7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints.channel_groups import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult /** * @see [PubNub.listAllChannelGroups] */ -actual interface ListAllChannelGroup : Endpoint +actual interface ListAllChannelGroup : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt index cd72984e8..d5f54e8ed 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.channel_groups import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult /** * @see [PubNub.removeChannelsFromChannelGroup] */ -actual interface RemoveChannelChannelGroup : Endpoint +actual interface RemoveChannelChannelGroup : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt index e44e32bbc..3b3953e91 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.files import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNDeleteFileResult /** * @see [PubNub.deleteFile] */ -actual interface DeleteFile : Endpoint \ No newline at end of file +actual interface DeleteFile : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFileImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFileImpl.kt new file mode 100644 index 000000000..0f497bbec --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFileImpl.kt @@ -0,0 +1,15 @@ +package com.pubnub.api.endpoints.files + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.files.PNDeleteFileResult +import com.pubnub.api.models.consumer.files.PNFileUrlResult +import kotlin.js.Promise + +class DeleteFileImpl(pubnub: PubNub, params: PubNub.FileInputParameters) : DeleteFile, + EndpointImpl( + promiseFactory = { pubnub.deleteFile(params) }, + responseMapping = { result -> + PNDeleteFileResult(result.status.toInt()) + } + ) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.js.kt new file mode 100644 index 000000000..5dd93aa8c --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.models.consumer.files.PNDownloadFileResult +import com.pubnub.kmp.PNFuture + +/** + * @see [PubNub.sendFile] + */ +actual interface DownloadFile : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFileImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFileImpl.kt new file mode 100644 index 000000000..71ce14712 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFileImpl.kt @@ -0,0 +1,19 @@ +package com.pubnub.api.endpoints.files + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.files.PNBaseFile +import com.pubnub.api.models.consumer.files.PNDownloadFileResult +import com.pubnub.api.models.consumer.files.PNFileUploadResult +import com.pubnub.kmp.Downloadable +import com.pubnub.kmp.DownloadableImpl + +class DownloadFileImpl(pubnub: PubNub, params: PubNub.DownloadFileParameters) : DownloadFile, EndpointImpl( + promiseFactory = { pubnub.downloadFile(params) }, + responseMapping = { + PNDownloadFileResult( + params.name, + DownloadableImpl(it) + ) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt index 854691183..4f590feea 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.files import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNFileUrlResult /** * @see [PubNub.getFileUrl] */ -actual interface GetFileUrl : Endpoint \ No newline at end of file +actual interface GetFileUrl : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrlImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrlImpl.kt new file mode 100644 index 000000000..cdd316af9 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrlImpl.kt @@ -0,0 +1,22 @@ +package com.pubnub.api.endpoints.files + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.files.PNFileUrlResult +import kotlin.js.Promise + +class GetFileUrlImpl(pubnub: PubNub, params: PubNub.FileInputParameters) : GetFileUrl, + EndpointImpl( + promiseFactory = { + Promise { resolve, reject -> + try { + resolve(pubnub.getFileUrl(params)) + } catch (e: Exception) { + reject(e) + } + } + }, + responseMapping = { result -> + PNFileUrlResult(result) + } + ) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt index 8008d03fa..eeefac15e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.files import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNListFilesResult /** * @see [PubNub.listFiles] */ -actual interface ListFiles : Endpoint \ No newline at end of file +actual interface ListFiles : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFilesImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFilesImpl.kt new file mode 100644 index 000000000..8d8616762 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFilesImpl.kt @@ -0,0 +1,27 @@ +package com.pubnub.api.endpoints.files + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.files.PNListFilesResult +import com.pubnub.api.models.consumer.files.PNUploadedFile +import com.pubnub.api.models.consumer.objects.PNPage + +class ListFilesImpl(pubnub: PubNub, params: PubNub.ListFilesParameters) : ListFiles, + EndpointImpl( + promiseFactory = { pubnub.listFiles(params) }, + responseMapping = { result -> + PNListFilesResult( + result.count.toInt(), + PNPage.PNNext(result.next), + result.status.toInt(), + result.data.map { file -> + PNUploadedFile( + file.id, + file.name, + file.size.toInt(), + file.created + ) + } + ) + } + ) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt index 4b6ffa4ec..f4610da0b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.files import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult /** * @see [PubNub.publishFileMessage] */ -actual interface PublishFileMessage : Endpoint \ No newline at end of file +actual interface PublishFileMessage : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessageImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessageImpl.kt new file mode 100644 index 000000000..b8abf02dc --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessageImpl.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.endpoints.files + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult + +class PublishFileMessageImpl(pubnub: PubNub, params: PubNub.PublishFileParameters) : PublishFileMessage, EndpointImpl( + promiseFactory = { pubnub.publishFile(params) }, + responseMapping = { + PNPublishFileMessageResult(it.timetoken.toLong()) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFile.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFile.js.kt new file mode 100644 index 000000000..333925128 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFile.js.kt @@ -0,0 +1,9 @@ +package com.pubnub.api.endpoints.files + +import com.pubnub.api.models.consumer.files.PNFileUploadResult +import com.pubnub.kmp.PNFuture + +/** + * @see [PubNub.sendFile] + */ +actual interface SendFile : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFileImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFileImpl.kt new file mode 100644 index 000000000..a2bf93722 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFileImpl.kt @@ -0,0 +1,20 @@ +package com.pubnub.api.endpoints.files + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.files.PNBaseFile +import com.pubnub.api.models.consumer.files.PNFileUploadResult + +class SendFileImpl(pubnub: PubNub, params: PubNub.SendFileParameters) : SendFile, EndpointImpl( + promiseFactory = { pubnub.sendFile(params) }, + responseMapping = { + PNFileUploadResult( + it.timetoken.toLong(), + 200, //TODO anything else possible here? + PNBaseFile( + it.id, + it.name + ) + ) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt index a4685777a..1b49af2fa 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints.message_actions import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult /** * @see [PubNub.addMessageAction] */ -actual interface AddMessageAction : Endpoint +actual interface AddMessageAction : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt index 8894b0f54..79d93685a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.message_actions import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult /** * @see [PubNub.getMessageActions] */ -actual interface GetMessageActions : Endpoint +actual interface GetMessageActions : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt index a204f7876..9210f4df0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints.message_actions import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult /** * @see [PubNub.removeMessageAction] */ -actual interface RemoveMessageAction : Endpoint +actual interface RemoveMessageAction : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt index 39bebe9d4..68f6dd76c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints.objects.channel import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult /** * @see [PubNub.getAllChannelMetadata] */ actual interface GetAllChannelMetadata : - Endpoint \ No newline at end of file + PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt index 82a462b25..bc6402e5e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.objects.channel import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult /** * @see [PubNub.getChannelMetadata] */ -actual interface GetChannelMetadata : Endpoint \ No newline at end of file +actual interface GetChannelMetadata : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt index f6acb81da..ea0645459 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.objects.channel -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -actual interface RemoveChannelMetadata : Endpoint \ No newline at end of file +actual interface RemoveChannelMetadata : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt index f37c3a6ca..3c7b96b16 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.objects.channel import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult /** * @see [PubNub.setChannelMetadata] */ -actual interface SetChannelMetadata : Endpoint \ No newline at end of file +actual interface SetChannelMetadata : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt index bf5080f34..885783c31 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.objects.member import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult /** * @see [PubNub.getChannelMembers] */ -actual interface GetChannelMembers : Endpoint +actual interface GetChannelMembers : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt index 642b078a2..80faa4b9e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.objects.member import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult /** * @see [PubNub.manageChannelMembers] */ -actual interface ManageChannelMembers : Endpoint \ No newline at end of file +actual interface ManageChannelMembers : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt index 82a9ef1de..15d5c253b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.objects.membership import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult /** * @see [PubNub.getMemberships] */ -actual interface GetMemberships : Endpoint \ No newline at end of file +actual interface GetMemberships : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt index e00979f1a..e6ca955a8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.objects.membership import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult /** * @see [PubNub.manageMemberships] */ -actual interface ManageMemberships : Endpoint \ No newline at end of file +actual interface ManageMemberships : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt index 518b97e6f..499762daa 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.objects.uuid import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult /** * @see [PubNub.getAllUUIDMetadata] */ -actual interface GetAllUUIDMetadata : Endpoint \ No newline at end of file +actual interface GetAllUUIDMetadata : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt index be3d30708..ba1818f1f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.objects.uuid import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult /** * @see [PubNub.getUUIDMetadata] */ -actual interface GetUUIDMetadata : Endpoint +actual interface GetUUIDMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt index 34574a844..777ed0926 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.objects.uuid -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -actual interface RemoveUUIDMetadata : Endpoint +actual interface RemoveUUIDMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt index 70a316cef..a45e71561 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints.objects.uuid import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult /** * @see [PubNub.setUUIDMetadata] */ -actual interface SetUUIDMetadata : Endpoint +actual interface SetUUIDMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt index 6621c6bb9..2ad4df8d3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints.presence import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNGetStateResult /** * @see [PubNub.getPresenceState] */ -actual interface GetState : Endpoint { +actual interface GetState : PNFuture { } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt index 4891f36dd..33243e23f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints.presence import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNHereNowResult /** * @see [PubNub.hereNow] */ -actual interface HereNow : Endpoint +actual interface HereNow : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt index 7e8624c55..ebac124cb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.presence import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNSetStateResult /** * @see [PubNub.setPresenceState] */ -actual interface SetState : Endpoint \ No newline at end of file +actual interface SetState : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt index 71f074007..dd0faff39 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints.presence import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNWhereNowResult /** * @see [PubNub.whereNow] */ -actual interface WhereNow : Endpoint +actual interface WhereNow : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt index 90903c4e1..3f170518e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.pubsub import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNPublishResult /** * @see [PubNub.publish] */ -actual interface Publish : Endpoint +actual interface Publish : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt index 69279ef4a..69fe1b035 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt @@ -1,11 +1,11 @@ package com.pubnub.api.endpoints.pubsub import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNPublishResult /** * @see [PubNub.signal] */ -actual interface Signal : Endpoint +actual interface Signal : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt index 3eb2988bd..0fda98573 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.push import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushAddChannelResult /** * @see [PubNub.addPushNotificationsOnChannels] */ -actual interface AddChannelsToPush : Endpoint \ No newline at end of file +actual interface AddChannelsToPush : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt index fc0c8cdad..60d031572 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.push import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult /** * @see [PubNub.auditPushChannelProvisions] */ -actual interface ListPushProvisions : Endpoint \ No newline at end of file +actual interface ListPushProvisions : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt index 1d7642bdd..0646d3f39 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.push import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult /** * @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken] */ -actual interface RemoveAllPushChannelsForDevice : Endpoint \ No newline at end of file +actual interface RemoveAllPushChannelsForDevice : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt index 91c47e4b1..a99c6e8fe 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.push import PubNub -import com.pubnub.api.Endpoint +import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult /** * @see [PubNub.removePushNotificationsFromChannels] */ -actual interface RemoveChannelsFromPush : Endpoint \ No newline at end of file +actual interface RemoveChannelsFromPush : PNFuture \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt index 569331ff0..0bc47c56a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt @@ -2,6 +2,7 @@ package com.pubnub.api.v2 import com.pubnub.api.UserId +@JsExport actual interface PNConfiguration { actual val userId: UserId actual val subscribeKey: String diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt index 8a4a78b7d..793464383 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt @@ -2,4 +2,8 @@ package com.pubnub.kmp actual typealias CustomObject = CustomObjectImpl -class CustomObjectImpl(map: Map = emptyMap()) : Map by map \ No newline at end of file +class CustomObjectImpl(map: Map = emptyMap()) : Map by map + +actual abstract class Uploadable(val fileInput: Any) + +class UploadableImpl(fileInput: Any): Uploadable(fileInput) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/Endpoint.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/Endpoint.kt index bd4b65ec4..dc0945516 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/Endpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/Endpoint.kt @@ -4,7 +4,7 @@ import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.PNConfigurationOverride -actual interface Endpoint : ExtendedRemoteAction { +interface Endpoint : ExtendedRemoteAction { /** * Allows to override certain configuration options (see [PNConfigurationOverride.Builder]) for this request only. * diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index 5541747a3..5b0ef2b3d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -1387,15 +1387,15 @@ actual interface PubNub : * @param cipherKey Key to be used to encrypt uploaded data. If not provided, * cipherKey in @see [PNConfiguration] will be used, if provided. */ - fun sendFile( + actual fun sendFile( channel: String, fileName: String, inputStream: InputStream, - message: Any? = null, - meta: Any? = null, - ttl: Int? = null, - shouldStore: Boolean? = null, - cipherKey: String? = null, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, + cipherKey: String?, ): SendFile /** @@ -1433,11 +1433,11 @@ actual interface PubNub : * @param cipherKey Key to be used to decrypt downloaded data. If a key is not provided, * the SDK uses the cipherKey from the @see [PNConfiguration]. */ - fun downloadFile( + actual fun downloadFile( channel: String, fileName: String, fileId: String, - cipherKey: String? = null, + cipherKey: String?, ): DownloadFile /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt index a6da719e0..a9f02da41 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt @@ -6,4 +6,4 @@ import com.pubnub.api.models.consumer.files.PNDownloadFileResult /** * @see [PubNub.downloadFile] */ -interface DownloadFile : Endpoint +actual interface DownloadFile : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt index 4e91c2614..cf21d6410 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt @@ -6,4 +6,4 @@ import com.pubnub.api.models.consumer.files.PNFileUploadResult /** * @see [PubNub.sendFile] */ -interface SendFile : ExtendedRemoteAction +actual interface SendFile : ExtendedRemoteAction diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt index 5fb9d86f8..75382b86b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt @@ -1,3 +1,7 @@ package com.pubnub.kmp -actual typealias CustomObject = Any \ No newline at end of file +import java.io.InputStream + +actual typealias CustomObject = Any + +actual typealias Uploadable = InputStream \ No newline at end of file diff --git a/swift b/swift index 557365ac2..f0a76488b 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit 557365ac2a04a27673ec5aef8ab6b6138daec4e2 +Subproject commit f0a76488baca51c4a5378d6bb33e4a281064fc7e From 730aa28fa6106fb7c8f0a67e8930c132c304cea0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Fri, 14 Jun 2024 14:41:16 +0200 Subject: [PATCH 22/62] Fix futures package --- .../src/commonMain/kotlin/com/pubnub/kmp/futures.kt | 3 ++- .../src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt index 25b048a56..8aee3db64 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt @@ -1,10 +1,11 @@ @file:JvmName("PNFutures") +package com.pubnub.kmp + import com.pubnub.api.PubNubException import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.api.v2.callbacks.mapCatching -import com.pubnub.kmp.PNFuture import kotlinx.atomicfu.atomic import kotlin.jvm.JvmName diff --git a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt index 901e68391..8cae29657 100644 --- a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt +++ b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt @@ -1,10 +1,6 @@ package com.pubnub.kmp -import asFuture -import awaitAll import com.pubnub.api.v2.callbacks.Result -import then -import thenAsync import kotlin.test.Test import kotlin.test.assertContentEquals import kotlin.test.assertEquals From 461fd45ad6f5ff787d8f91d2f320230aa74a2278 Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Tue, 18 Jun 2024 10:35:24 +0200 Subject: [PATCH 23/62] Wrapping remaining AppContext methods + Files API (#237) --- .../kotlin/com/pubnub/api/PubNubImpl.kt | 225 +++++++++++++----- .../api/endpoints/files/DeleteFile.ios.kt | 27 ++- .../api/endpoints/files/GetFileUrl.ios.kt | 27 ++- .../api/endpoints/files/ListFiles.ios.kt | 47 +++- .../endpoints/files/PublishFileMessage.ios.kt | 36 ++- .../channel/GetAllChannelMetadata.ios.kt | 40 +--- .../objects/channel/GetChannelMetadata.ios.kt | 14 +- .../objects/channel/SetChannelMetadata.ios.kt | 12 +- .../objects/member/GetChannelMembers.ios.kt | 55 ++++- .../member/ManageChannelMembers.ios.kt | 99 +++++++- .../objects/membership/GetMemberships.ios.kt | 55 ++++- .../membership/ManageMemberships.ios.kt | 98 +++++++- .../objects/uuid/GetAllUUIDMetadata.ios.kt | 37 +-- .../objects/uuid/GetUUIDMetadata.ios.kt | 18 +- .../objects/uuid/SetUUIDMetadata.ios.kt | 15 +- .../api/endpoints/presence/SetState.ios.kt | 28 ++- .../endpoints/push/AddChannelsToPush.ios.kt | 5 +- .../endpoints/push/ListPushProvisions.ios.kt | 2 +- .../kotlin/com/pubnub/kmp/Converters.kt | 99 +++++++- .../kotlin/com/pubnub/kmp/factories.ios.kt | 2 +- .../kotlin/com/pubnub/kmp/results.ios.kt | 12 + swift | 2 +- 22 files changed, 774 insertions(+), 181 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 3e82d2aad..b7b5f5d50 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -2,11 +2,12 @@ package com.pubnub.api import cocoapods.PubNubSwift.addEventListenerWithListener import cocoapods.PubNubSwift.addStatusListenerWithListener -import cocoapods.PubNubSwift.removeEventListenerWithListener +import cocoapods.PubNubSwift.disconnect import cocoapods.PubNubSwift.setWithToken import cocoapods.PubNubSwift.subscribeWithChannels import cocoapods.PubNubSwift.subscribedChannelGroups import cocoapods.PubNubSwift.subscribedChannels +import cocoapods.PubNubSwift.unsubscribeAll import cocoapods.PubNubSwift.unsubscribeFrom import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages @@ -30,10 +31,14 @@ import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroupImpl import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroupImpl import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.DeleteFileImpl import com.pubnub.api.endpoints.files.DownloadFile import com.pubnub.api.endpoints.files.GetFileUrl +import com.pubnub.api.endpoints.files.GetFileUrlImpl import com.pubnub.api.endpoints.files.ListFiles +import com.pubnub.api.endpoints.files.ListFilesImpl import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.files.PublishFileMessageImpl import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.message_actions.AddMessageAction import com.pubnub.api.endpoints.message_actions.AddMessageActionImpl @@ -50,9 +55,15 @@ import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadataImpl import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata import com.pubnub.api.endpoints.objects.channel.SetChannelMetadataImpl import com.pubnub.api.endpoints.objects.member.GetChannelMembers +import com.pubnub.api.endpoints.objects.member.GetChannelMembersImpl import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +import com.pubnub.api.endpoints.objects.member.RemoveChannelMembersImpl +import com.pubnub.api.endpoints.objects.member.SetChannelMembersImpl +import com.pubnub.api.endpoints.objects.membership.AddMembershipsImpl import com.pubnub.api.endpoints.objects.membership.GetMemberships +import com.pubnub.api.endpoints.objects.membership.GetMembershipsImpl import com.pubnub.api.endpoints.objects.membership.ManageMemberships +import com.pubnub.api.endpoints.objects.membership.RemoveMembershipsImpl import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadataImpl import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata @@ -66,6 +77,7 @@ import com.pubnub.api.endpoints.presence.GetStateImpl import com.pubnub.api.endpoints.presence.HereNow import com.pubnub.api.endpoints.presence.HereNowImpl import com.pubnub.api.endpoints.presence.SetState +import com.pubnub.api.endpoints.presence.SetStateImpl import com.pubnub.api.endpoints.presence.WhereNow import com.pubnub.api.endpoints.presence.WhereNowImpl import com.pubnub.api.endpoints.pubsub.Publish @@ -160,18 +172,21 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun signal(channel: String, message: Any): Signal { - return SignalImpl(pubnub = pubNubObjC, channel = channel, message = message) + return SignalImpl( + pubnub = pubNubObjC, + channel = channel, + message = message + ) } override fun getSubscribedChannels(): List { - return pubNubObjC.subscribedChannels() as List + return pubNubObjC.subscribedChannels().filterIsInstance() } override fun getSubscribedChannelGroups(): List { - return pubNubObjC.subscribedChannelGroups() as List + return pubNubObjC.subscribedChannelGroups().filterIsInstance() } - // TODO: Missing pushType (PushService like APNS, GCM, etc) parameter // TODO: Why do we need topic parameter here? override fun addPushNotificationsOnChannels( pushType: PNPushType, @@ -183,21 +198,26 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { return AddChannelsToPushImpl( pubnub = pubNubObjC, channels = channels, - deviceId = deviceId + deviceId = deviceId, + pushType = pushType ) } - // TODO: topic and environment parameters are not present in Swift SDK + // TODO: Why do we need topic and environment parameters here? override fun auditPushChannelProvisions( pushType: PNPushType, deviceId: String, topic: String?, environment: PNPushEnvironment ): ListPushProvisions { - return ListPushProvisionsImpl(pubnub = pubNubObjC, deviceId = deviceId, pushType = pushType) + return ListPushProvisionsImpl( + pubnub = pubNubObjC, + deviceId = deviceId, + pushType = pushType + ) } - // TODO: topic and environment parameters are not present in Swift SDK + // TODO: Why do we need topic and environment parameters here? override fun removePushNotificationsFromChannels( pushType: PNPushType, channels: List, @@ -278,7 +298,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun whereNow(uuid: String): WhereNow { - return WhereNowImpl(pubnub = pubNubObjC, uuid = uuid) + return WhereNowImpl( + pubnub = pubNubObjC, + uuid = uuid + ) } override fun setPresenceState( @@ -286,7 +309,12 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { channelGroups: List, state: Any, ): SetState { - TODO("Not yet implemented") + return SetStateImpl( + pubnub = pubNubObjC, + channels = channels, + channelGroups = channelGroups, + state = state + ) } override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { @@ -342,7 +370,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { - return AllChannelsChannelGroupImpl(pubnub = pubNubObjC, channelGroup = channelGroup) + return AllChannelsChannelGroupImpl( + pubnub = pubNubObjC, + channelGroup = channelGroup + ) } override fun removeChannelsFromChannelGroup( @@ -361,7 +392,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { - return DeleteChannelGroupImpl(pubnub = pubNubObjC, channelGroup = channelGroup) + return DeleteChannelGroupImpl( + pubnub = pubNubObjC, + channelGroup = channelGroup + ) } override fun grantToken( @@ -432,7 +466,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { - return RemoveChannelMetadataImpl(pubnub = pubNubObjC, channel = channel) + return RemoveChannelMetadataImpl( + pubnub = pubNubObjC, + channel = channel + ) } override fun getAllUUIDMetadata( @@ -455,7 +492,11 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { - return GetUUIDMetadataImpl(pubnub = pubNubObjC, uuid = uuid, includeCustom = includeCustom) + return GetUUIDMetadataImpl( + pubnub = pubNubObjC, + uuid = uuid, + includeCustom = includeCustom + ) } override fun setUUIDMetadata( @@ -484,7 +525,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { - return RemoveUUIDMetadataImpl(pubnub = pubNubObjC, uuid = uuid) + return RemoveUUIDMetadataImpl( + pubnub = pubNubObjC, + uuid = uuid + ) } override fun getMemberships( @@ -497,7 +541,17 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel? ): GetMemberships { - TODO("Not yet implemented") + return GetMembershipsImpl( + pubnub = pubNubObjC, + uuid = uuid, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeChannelDetails = includeChannelDetails + ) } override fun setMemberships( @@ -511,7 +565,18 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel? ): ManageMemberships { - TODO("Not yet implemented") + return AddMembershipsImpl( + pubnub = pubNubObjC, + channels = channels, + uuid = uuid, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeChannelDetails = includeChannelDetails + ) } override fun removeMemberships( @@ -525,24 +590,20 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel? ): ManageMemberships { - TODO("Not yet implemented") + return RemoveMembershipsImpl( + pubnub = pubNubObjC, + channels = channels, + uuid = uuid, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeChannelDetails = includeChannelDetails + ) } -// override fun manageMemberships( -// channelsToSet: List, -// channelsToRemove: List, -// uuid: String?, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeChannelDetails: PNChannelDetailsLevel? -// ): ManageMemberships { -// TODO("Not yet implemented") -// } - override fun getChannelMembers( channel: String, limit: Int?, @@ -553,7 +614,17 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel? ): GetChannelMembers { - TODO("Not yet implemented") + return GetChannelMembersImpl( + pubnub = pubNubObjC, + channel = channel, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeUUIDDetails = includeUUIDDetails + ) } override fun setChannelMembers( @@ -567,7 +638,18 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel? ): ManageChannelMembers { - TODO("Not yet implemented") + return SetChannelMembersImpl( + pubnub = pubNubObjC, + channel = channel, + uuids = uuids, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeUUIDDetails = includeUUIDDetails + ) } override fun removeChannelMembers( @@ -581,34 +663,45 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel? ): ManageChannelMembers { - TODO("Not yet implemented") + return RemoveChannelMembersImpl( + pubnub = pubNubObjC, + channel = channel, + uuids = uuids, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeUUIDDetails = includeUUIDDetails + ) } -// override fun manageChannelMembers( -// channel: String, -// uuidsToSet: Collection, -// uuidsToRemove: Collection, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeUUIDDetails: PNUUIDDetailsLevel? -// ): ManageChannelMembers { -// TODO("Not yet implemented") -// } - override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { - TODO("Not yet implemented") + return ListFilesImpl( + pubnub = pubNubObjC, + channel = channel, + limit = limit, + next = next + ) } override fun getFileUrl(channel: String, fileName: String, fileId: String): GetFileUrl { - TODO("Not yet implemented") + return GetFileUrlImpl( + pubnub = pubNubObjC, + channel = channel, + fileName = fileName, + fileId = fileId + ) } override fun deleteFile(channel: String, fileName: String, fileId: String): DeleteFile { - TODO("Not yet implemented") + return DeleteFileImpl( + pubnub = pubNubObjC, + channel = channel, + fileName = fileName, + fileId = fileId + ) } override fun publishFileMessage( @@ -620,7 +713,16 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ttl: Int?, shouldStore: Boolean? ): PublishFileMessage { - TODO("Not yet implemented") + return PublishFileMessageImpl( + pubnub = pubNubObjC, + channel = channel, + fileName = fileName, + fileId = fileId, + message = message, + meta = meta, + ttl = ttl, + shouldStore = shouldStore + ) } override fun subscribe( @@ -638,22 +740,25 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun unsubscribe(channels: List, channelGroups: List) { - pubNubObjC.unsubscribeFrom(channels = channels, channelGroups = channelGroups) + pubNubObjC.unsubscribeFrom( + channels = channels, + channelGroups = channelGroups + ) } // TODO: Why token is optional? What's the desired behavior for a null value? override fun setToken(token: String?) { token?.let { - pubNubObjC.setWithToken(token) + pubNubObjC.setWithToken(it) } } override fun destroy() { -// TODO("Not yet implemented") + pubNubObjC.disconnect() } override fun unsubscribeAll() { -// TODO("Not yet implemented") + pubNubObjC.unsubscribeAll() } override fun sendFile( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt index 736d296c6..8e3d97271 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt @@ -1,9 +1,34 @@ package com.pubnub.api.endpoints.files +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.deleteFileWithChannel import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNDeleteFileResult +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessReturnValue +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.deleteFile] */ -actual interface DeleteFile : PNFuture \ No newline at end of file +actual interface DeleteFile : PNFuture + +@OptIn(ExperimentalForeignApi::class) +class DeleteFileImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val fileName: String, + private val fileId: String +): DeleteFile { + override fun async(callback: Consumer>) { + pubnub.deleteFileWithChannel( + channel = channel, + fileName = fileName, + fileId = fileId, + onSuccess = callback.onSuccessReturnValue(PNDeleteFileResult(200)), + onFailure = callback.onFailureHandler() + ) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt index 870b4f841..393f2de3d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt @@ -1,9 +1,34 @@ package com.pubnub.api.endpoints.files +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.getFileUrlWithChannel import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNFileUrlResult +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.getFileUrl] */ -actual interface GetFileUrl : PNFuture \ No newline at end of file +actual interface GetFileUrl : PNFuture + +@OptIn(ExperimentalForeignApi::class) +class GetFileUrlImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val fileName: String, + private val fileId: String +): GetFileUrl { + override fun async(callback: Consumer>) { + pubnub.getFileUrlWithChannel( + channel = channel, + fileName = fileName, + fileId = fileId, + onSuccess = callback.onSuccessHandler { PNFileUrlResult(url = it ?: "") }, + onFailure = callback.onFailureHandler() + ) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt index 035b73026..ae257b171 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt @@ -1,9 +1,54 @@ package com.pubnub.api.endpoints.files +import cocoapods.PubNubSwift.PubNubFileObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.listFilesWithChannel import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNListFilesResult +import com.pubnub.api.models.consumer.files.PNUploadedFile +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.createPubNubHashedPage +import com.pubnub.kmp.filterAndMap +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler2 +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [PubNub.listFiles] */ -actual interface ListFiles : PNFuture \ No newline at end of file +actual interface ListFiles : PNFuture + +@OptIn(ExperimentalForeignApi::class) +class ListFilesImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val limit: Int?, + private val next: PNPage.PNNext? +): ListFiles { + override fun async(callback: Consumer>) { + pubnub.listFilesWithChannel( + channel = channel, + limit = limit?.let { NSNumber(it) }, + next = createPubNubHashedPage(from = next), + onSuccess = callback.onSuccessHandler2 { files, nextPageHash -> + PNListFilesResult( + count = files?.size ?: 0, // TODO: count property is not retrieved from ListFilesSuccessResponse in Swift SDK + next = nextPageHash?.let { PNPage.PNNext(pageHash = it) }, + status = 200, + data = files.filterAndMap { rawValue: PubNubFileObjC -> + PNUploadedFile( + id = rawValue.id(), + name = rawValue.name(), + size = rawValue.size().toInt(), + created = rawValue.createdDate().toString() // TODO: Map to expected date format + ) + } + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt index b20314c65..47556ab8c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt @@ -1,9 +1,43 @@ package com.pubnub.api.endpoints.files +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.publishFileMessageWithChannel +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [PubNub.publishFileMessage] */ -actual interface PublishFileMessage : PNFuture \ No newline at end of file +actual interface PublishFileMessage : PNFuture + +@OptIn(ExperimentalForeignApi::class) +class PublishFileMessageImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val fileName: String, + private val fileId: String, + private val message: Any?, + private val meta: Any?, + private val ttl: Int?, + private val shouldStore: Boolean? +): PublishFileMessage { + override fun async(callback: Consumer>) { + pubnub.publishFileMessageWithChannel( + channel = channel, + fileName = fileName, + fileId = fileId, + message = message, + meta = meta, + ttl = ttl?.let { NSNumber(it) }, + shouldStore = shouldStore?.let { NSNumber(bool = it) }, + onSuccess = callback.onSuccessHandler { PNPublishFileMessageResult(it.toLong()) }, + onFailure = callback.onFailureHandler() + ) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt index 3ced0fa12..f2a4c01c1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt @@ -1,21 +1,21 @@ package com.pubnub.api.endpoints.objects.channel import cocoapods.PubNubSwift.PubNubChannelMetadataObjC -import cocoapods.PubNubSwift.PubNubHashedPageObjC import cocoapods.PubNubSwift.PubNubObjC -import cocoapods.PubNubSwift.PubNubSortPropertyObjC import cocoapods.PubNubSwift.getAllChannelMetadataWithLimit import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.PNSortKey -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler -import com.pubnub.kmp.onSuccessHandler3 import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.createObjectSortProperties +import com.pubnub.kmp.createPNChannelMetadata +import com.pubnub.kmp.createPubNubHashedPage +import com.pubnub.kmp.filterAndMap +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler3 import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSNumber @@ -37,35 +37,15 @@ class GetAllChannelMetadataImpl( override fun async(callback: Consumer>) { pubnub.getAllChannelMetadataWithLimit( limit = limit?.let { NSNumber(it) }, - page = PubNubHashedPageObjC( - start = if (page is PNPage.PNNext) { page.pageHash } else { null }, - end = if (page is PNPage.PNPrev) { page.pageHash } else { null }, - totalCount = null - ), + page = createPubNubHashedPage(from = page), filter = filter, - sort = sort.map { - PubNubSortPropertyObjC( - key = it.key.fieldName, - direction = it.dir - ) - }, + sort = createObjectSortProperties(from = sort), includeCount = includeCount, includeCustom = includeCustom, - onSuccess = callback.onSuccessHandler3() { data, totalCount, next -> + onSuccess = callback.onSuccessHandler3 { channels, totalCount, next -> PNChannelMetadataArrayResult( status = 200, - data = (data as List).map { metadata -> - PNChannelMetadata( - id = metadata.id(), - name = metadata.name(), - description = metadata.descr(), - custom = metadata.custom() as? Map, // TODO: Verify - updated = metadata.updated(), - eTag = metadata.eTag(), - type = metadata.type(), - status = metadata.status() - ) - }, + data = channels.filterAndMap { rawValue: PubNubChannelMetadataObjC -> createPNChannelMetadata(rawValue) }, totalCount = totalCount?.intValue, next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt index 64ecf87d6..4f6c25b6b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt @@ -9,6 +9,7 @@ import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.createPNChannelMetadata import kotlinx.cinterop.ExperimentalForeignApi /** @@ -28,17 +29,8 @@ class GetChannelMetadataImpl( includeCustom = includeCustom, onSuccess = callback.onSuccessHandler { PNChannelMetadataResult( - status = 200, // TODO: Determine this field - data = PNChannelMetadata( - id = it?.id() ?: "", - name = it?.name(), - description = it?.descr(), - custom = it?.custom() as? Map, // TODO: Check - updated = it?.updated(), - eTag = it?.eTag(), - type = it?.type(), - status = it?.status() - ) + status = 200, + data = it?.let { rawValue -> createPNChannelMetadata(from = rawValue) } ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt index d8f73c658..fd76c8424 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt @@ -11,6 +11,7 @@ import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.createPNChannelMetadata import kotlinx.cinterop.ExperimentalForeignApi import platform.posix.stat @@ -42,16 +43,7 @@ class SetChannelMetadataImpl( onSuccess = callback.onSuccessHandler { PNChannelMetadataResult( status = 200, - data = PNChannelMetadata( - id = it?.id() ?: "", - name = it?.name(), - description = it?.descr(), - custom = it?.custom()?.asMap() as? Map, // TODO: Verify - updated = it?.updated(), - eTag = it?.eTag(), - type = it?.type(), - status = it?.status() - ) + data = it?.let { rawValue -> createPNChannelMetadata(from = rawValue) } ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt index abf839697..aa810f6c9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt @@ -1,9 +1,62 @@ package com.pubnub.api.endpoints.objects.member +import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.getChannelMembersWithChannel +import com.pubnub.api.models.consumer.objects.PNMemberKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.createPNMember +import com.pubnub.kmp.createPubNubHashedPage +import com.pubnub.kmp.filterAndMap +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler3 +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [PubNub.getChannelMembers] */ -actual interface GetChannelMembers : PNFuture \ No newline at end of file +actual interface GetChannelMembers : PNFuture + +@OptIn(ExperimentalForeignApi::class) +class GetChannelMembersImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val limit: Int?, + private val page: PNPage?, + private val filter: String?, + private val sort: Collection>, + private val includeCount: Boolean, + private val includeCustom: Boolean, + private val includeUUIDDetails: PNUUIDDetailsLevel? +) : GetChannelMembers { + override fun async(callback: Consumer>) { + pubnub.getChannelMembersWithChannel( + channel = channel, + limit = limit?.let { NSNumber(it) }, + page = createPubNubHashedPage(from = page), + filter = filter, + sort = sort.map { it.key.fieldName }, + includeCount = includeCount, + includeCustom = includeCustom, + includeUUIDFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, + includeUUIDCustomFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, + onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> + PNMemberArrayResult( + status = 200, + data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNMember(rawValue) }, + totalCount = totalCount?.intValue, + next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt index 3281708c3..e4fd75a77 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt @@ -1,9 +1,106 @@ package com.pubnub.api.endpoints.objects.member +import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.PubNubUUIDMetadataObjC +import cocoapods.PubNubSwift.removeChannelMembersWithChannel +import cocoapods.PubNubSwift.setChannelMembersWithChannel +import com.pubnub.api.models.consumer.objects.PNMemberKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.member.MemberInput import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.createPNMember +import com.pubnub.kmp.createPubNubHashedPage +import com.pubnub.kmp.filterAndMap +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler3 +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [PubNub.manageChannelMembers] */ -actual interface ManageChannelMembers : PNFuture \ No newline at end of file +actual interface ManageChannelMembers : PNFuture + +@OptIn(ExperimentalForeignApi::class) +class SetChannelMembersImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val uuids: List, + private val limit: Int?, + private val page: PNPage?, + private val filter: String?, + private val sort: Collection>, + private val includeCount: Boolean, + private val includeCustom: Boolean, + private val includeUUIDDetails: PNUUIDDetailsLevel? +): ManageChannelMembers { + override fun async(callback: Consumer>) { + pubnub.setChannelMembersWithChannel( + channel = channel, + uuids = uuids.map { PubNubUUIDMetadataObjC(id = it.uuid, custom = it.custom?.value, status = it.status) }, + limit = limit?.let { NSNumber(it) }, + page = createPubNubHashedPage(from = page), + filter = filter, + sort = sort.map { it.key.fieldName }, + includeCount = includeCount, + includeCustom = includeCustom, + includeUUIDFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, + includeUUIDCustomFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, + onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> + PNMemberArrayResult( + status = 200, + data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNMember(rawValue) }, + totalCount = totalCount?.intValue, + next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} + +@OptIn(ExperimentalForeignApi::class) +class RemoveChannelMembersImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val uuids: List, + private val limit: Int?, + private val page: PNPage?, + private val filter: String?, + private val sort: Collection>, + private val includeCount: Boolean, + private val includeCustom: Boolean, + private val includeUUIDDetails: PNUUIDDetailsLevel? +): ManageChannelMembers { + override fun async(callback: Consumer>) { + pubnub.removeChannelMembersWithChannel( + channel = channel, + uuids = uuids, + limit = limit?.let { NSNumber(it) }, + page = createPubNubHashedPage(from = page), + filter = filter, + sort = sort.map { it.key.fieldName }, + includeCount = includeCount, + includeCustom = includeCustom, + includeUUIDFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, + includeUUIDCustomFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, + onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> + PNMemberArrayResult( + status = 200, + data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNMember(rawValue) }, + totalCount = totalCount?.intValue, + next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt index 97ea07564..92459a923 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt @@ -1,9 +1,62 @@ package com.pubnub.api.endpoints.objects.membership +import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.getMembershipsWithUuid +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.createPNChannelMembership +import com.pubnub.kmp.createPubNubHashedPage +import com.pubnub.kmp.filterAndMap +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler3 +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [PubNub.getMemberships] */ -actual interface GetMemberships : PNFuture \ No newline at end of file +actual interface GetMemberships : PNFuture + +@OptIn(ExperimentalForeignApi::class) +class GetMembershipsImpl( + private val pubnub: PubNubObjC, + private val uuid: String?, + private val limit: Int?, + private val page: PNPage?, + private val filter: String?, + private val sort: Collection>, + private val includeCount: Boolean, + private val includeCustom: Boolean, + private val includeChannelDetails: PNChannelDetailsLevel? +): GetMemberships { + override fun async(callback: Consumer>) { + pubnub.getMembershipsWithUuid( + uuid = uuid, + limit = limit?.let { NSNumber(it) }, + page = createPubNubHashedPage(from = page), + filter = filter, + sort = sort.map { it.key.fieldName }, + includeCount = includeCount, + includeCustom = includeCustom, + includeChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL || includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, + includeChannelCustomFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, + onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> + PNChannelMembershipArrayResult( + status = 200, + data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNChannelMembership(rawValue) }, + totalCount = totalCount?.intValue, + next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt index ca64156d4..b866373ca 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt @@ -1,9 +1,105 @@ package com.pubnub.api.endpoints.objects.membership +import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.removeMembershipsWithChannels +import cocoapods.PubNubSwift.setMembershipsWithChannels +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.createPNChannelMembership +import com.pubnub.kmp.createPubNubHashedPage +import com.pubnub.kmp.filterAndMap +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler3 +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSNumber /** * @see [PubNub.manageMemberships] */ -actual interface ManageMemberships : PNFuture \ No newline at end of file +actual interface ManageMemberships : PNFuture + +@OptIn(ExperimentalForeignApi::class) +class AddMembershipsImpl( + private val pubnub: PubNubObjC, + private val channels: List, + private val uuid: String?, + private val limit: Int?, + private val page: PNPage?, + private val filter: String?, + private val sort: Collection>, + private val includeCount: Boolean, + private val includeCustom: Boolean, + private val includeChannelDetails: PNChannelDetailsLevel? +): ManageMemberships { + override fun async(callback: Consumer>) { + pubnub.setMembershipsWithChannels( + channels = channels, + uuid = uuid, + limit = limit?.let { NSNumber(it) }, + page = createPubNubHashedPage(from = page), + filter = filter, + sort = sort.map { it.key.fieldName }, + includeCount = includeCount, + includeCustom = includeCustom, + includeChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL || includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, + includeChannelCustomFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, + onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> + PNChannelMembershipArrayResult( + status = 200, + data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNChannelMembership(rawValue) }, + totalCount = totalCount?.intValue, + next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} + +@OptIn(ExperimentalForeignApi::class) +class RemoveMembershipsImpl( + private val pubnub: PubNubObjC, + private val channels: List, + private val uuid: String?, + private val limit: Int?, + private val page: PNPage?, + private val filter: String?, + private val sort: Collection>, + private val includeCount: Boolean, + private val includeCustom: Boolean, + private val includeChannelDetails: PNChannelDetailsLevel? +): ManageMemberships { + override fun async(callback: Consumer>) { + pubnub.removeMembershipsWithChannels( + channels = channels, + uuid = uuid, + limit = limit?.let { NSNumber(it) }, + page = createPubNubHashedPage(from = page), + filter = filter, + sort = sort.map { it.key.fieldName }, + includeCount = includeCount, + includeCustom = includeCustom, + includeChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL || includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, + includeChannelCustomFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, + onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> + PNChannelMembershipArrayResult( + status = 200, + data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNChannelMembership(rawValue) }, + totalCount = totalCount?.intValue, + next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + ) + }, + onFailure = callback.onFailureHandler() + ) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt index b4be3715c..d1b7e998a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt @@ -1,18 +1,19 @@ package com.pubnub.api.endpoints.objects.uuid -import cocoapods.PubNubSwift.PubNubHashedPageObjC import cocoapods.PubNubSwift.PubNubObjC -import cocoapods.PubNubSwift.PubNubSortPropertyObjC import cocoapods.PubNubSwift.PubNubUUIDMetadataObjC import cocoapods.PubNubSwift.getAllUUIDMetadataWithLimit import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.PNSortKey -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.createObjectSortProperties +import com.pubnub.kmp.createPNUUIDMetadata +import com.pubnub.kmp.createPubNubHashedPage +import com.pubnub.kmp.filterAndMap import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler3 import kotlinx.cinterop.ExperimentalForeignApi @@ -36,37 +37,15 @@ class GetAllUUIDMetadataImpl( override fun async(callback: Consumer>) { pubnub.getAllUUIDMetadataWithLimit( limit = limit?.let { NSNumber(it) }, - page = PubNubHashedPageObjC( - start = if (page is PNPage.PNNext) { page.pageHash } else { null }, - end = if (page is PNPage.PNPrev) { page.pageHash } else { null }, - totalCount = null - ), + page = createPubNubHashedPage(from = page), filter = filter, - sort = sort.map { - PubNubSortPropertyObjC( - key = it.key.fieldName, - direction = it.dir - ) - }, + sort = createObjectSortProperties(from = sort), includeCount = includeCount, includeCustom = includeCustom, - onSuccess = callback.onSuccessHandler3() { data, totalCount, next -> + onSuccess = callback.onSuccessHandler3 { uuids, totalCount, next -> PNUUIDMetadataArrayResult( status = 200, - data = (data as List).map { metadata -> - PNUUIDMetadata( - id = metadata.id(), - name = metadata.name(), - externalId = metadata.externalId(), - profileUrl = metadata.profileUrl(), - email = metadata.email(), - custom = metadata.custom() as? Map, // TODO: Verify - updated = metadata.updated(), - eTag = metadata.eTag(), - type = metadata.type(), - status = metadata.status() - ) - }, + data = uuids.filterAndMap { rawValue: PubNubUUIDMetadataObjC -> createPNUUIDMetadata(from = rawValue) }, totalCount = totalCount?.intValue ?: 0, next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt index d1f2c8e3f..c659dc548 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt @@ -3,12 +3,12 @@ package com.pubnub.api.endpoints.objects.uuid import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getUUIDMetadataWithUuid import com.pubnub.kmp.PNFuture -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.createPNUUIDMetadata import kotlinx.cinterop.ExperimentalForeignApi /** @@ -30,20 +30,10 @@ class GetUUIDMetadataImpl( onSuccess = callback.onSuccessHandler { PNUUIDMetadataResult( status = 200, - data = PNUUIDMetadata( - id = it?.id() ?: "", - name = it?.name(), - externalId = it?.externalId(), - profileUrl = it?.profileUrl(), - email = it?.email(), - custom = it?.custom() as? Map, // TODO: Check - updated = it?.updated(), - eTag = it?.eTag(), - type = it?.type(), - status = it?.status() - ) + data = it?.let { createPNUUIDMetadata(from = it) } ) }, - onFailure = callback.onFailureHandler()) + onFailure = callback.onFailureHandler() + ) } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt index f36616c97..497e4fb23 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt @@ -4,13 +4,13 @@ import cocoapods.PubNubSwift.AnyJSONObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.setUUIDMetadataWithUuid import com.pubnub.kmp.PNFuture -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.createPNUUIDMetadata import kotlinx.cinterop.ExperimentalForeignApi /** @@ -45,18 +45,7 @@ class SetUUIDMetadataImpl( onSuccess = callback.onSuccessHandler { PNUUIDMetadataResult( status = 200, - data = PNUUIDMetadata( - id = it?.id() ?: "", - name = it?.name(), - externalId = it?.externalId(), - profileUrl = it?.profileUrl(), - email = it?.email(), - custom = it?.custom()?.asMap() as? Map, // TODO: Verify - updated = it?.updated(), - eTag = it?.eTag(), - type = it?.type(), - status = it?.status() - ) + data = it?.let { createPNUUIDMetadata(from = it) } ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt index f2db8e2e2..361efdeaf 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt @@ -1,10 +1,36 @@ package com.pubnub.api.endpoints.presence +import cocoapods.PubNubSwift.AnyJSONObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.setPresenceStateWithChannels +import com.pubnub.api.JsonElementImpl +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNSetStateResult +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.setPresenceState] */ -actual interface SetState : PNFuture { +actual interface SetState : PNFuture + +@OptIn(ExperimentalForeignApi::class) +class SetStateImpl( + private val pubnub: PubNubObjC, + private val channels: List, + private val channelGroups: List, + private val state: Any, +): SetState { + override fun async(callback: Consumer>) { + pubnub.setPresenceStateWithChannels( + channels = channels, + channelGroups = channelGroups, + state = AnyJSONObjC(value = state), + onSuccess = callback.onSuccessHandler { PNSetStateResult(state = JsonElementImpl(it)) }, + onFailure = callback.onFailureHandler() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt index 0bd099383..991f5a680 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt @@ -4,6 +4,7 @@ import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.addChannelsToPushNotificationsWithChannels import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException +import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushAddChannelResult import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler @@ -21,13 +22,15 @@ actual interface AddChannelsToPush : PNFuture class AddChannelsToPushImpl( private val pubnub: PubNubObjC, private val channels: List, - private val deviceId: String + private val deviceId: String, + private val pushType: PNPushType ): AddChannelsToPush { override fun async(callback: Consumer>) { deviceId.toNSData()?.let { data: NSData -> pubnub.addChannelsToPushNotificationsWithChannels( channels = channels, deviceId = data, + pushType = pushType.toParamString(), onSuccess = callback.onSuccessHandler { PNPushAddChannelResult() }, onFailure = callback.onFailureHandler() ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt index 742cf98ce..59a0c6cd9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt @@ -30,7 +30,7 @@ class ListPushProvisionsImpl( pubnub.listPushChannelsWithDeviceId( deviceId = data, pushType = pushType.toParamString(), - onSuccess = callback.onSuccessHandler { PNPushListProvisionsResult(channels = it as List) }, + onSuccess = callback.onSuccessHandler { PNPushListProvisionsResult(channels = it?.filterIsInstance() ?: emptyList()) }, onFailure = callback.onFailureHandler() ) } ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId"))) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt index 89e79900a..3226617e8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt @@ -1,10 +1,107 @@ package com.pubnub.kmp +import cocoapods.PubNubSwift.PubNubChannelMetadataObjC +import cocoapods.PubNubSwift.PubNubHashedPageObjC +import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC +import cocoapods.PubNubSwift.PubNubSortPropertyObjC +import cocoapods.PubNubSwift.PubNubUUIDMetadataObjC +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.objects.member.PNMember +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSData import platform.Foundation.NSString import platform.Foundation.NSUTF8StringEncoding import platform.Foundation.dataUsingEncoding -fun String.toNSData(): NSData? { +internal fun String.toNSData(): NSData? { return (this as NSString).dataUsingEncoding(NSUTF8StringEncoding) +} + +@OptIn(ExperimentalForeignApi::class) +internal fun createPubNubHashedPage(from: PNPage?): PubNubHashedPageObjC { + return PubNubHashedPageObjC( + start = if (from is PNPage.PNNext) { from.pageHash } else { null }, + end = if (from is PNPage.PNPrev) { from.pageHash } else { null }, + totalCount = null + ) +} + +@OptIn(ExperimentalForeignApi::class) +internal fun createPNUUIDMetadata(from: PubNubUUIDMetadataObjC): PNUUIDMetadata { + return PNUUIDMetadata( + id = from.id(), + name = from.name(), + externalId = from.externalId(), + profileUrl = from.profileUrl(), + email = from.email(), + custom = from.custom()?.asMap() as? Map, // TODO: Verify + updated = from.updated(), + eTag = from.eTag(), + type = from.type(), + status = from.status() + ) +} + +@OptIn(ExperimentalForeignApi::class) +internal fun createPNChannelMetadata(from: PubNubChannelMetadataObjC): PNChannelMetadata { + return PNChannelMetadata( + id = from.id(), + name = from.name(), + description = from.descr(), + custom = from.custom()?.asMap() as? Map, // TODO: Verify + updated = from.updated(), + eTag = from.eTag(), + type = from.type(), + status = from.status() + ) +} + +@OptIn(ExperimentalForeignApi::class) +internal fun createObjectSortProperties(from: Collection>) : List { + return from.map { + PubNubSortPropertyObjC( + key = it.key.fieldName, + direction = it.dir + ) + } +} + +@OptIn(ExperimentalForeignApi::class) +internal fun createPNChannelMembership(from: PubNubMembershipMetadataObjC): PNChannelMembership { + return PNChannelMembership( + channel = PNChannelMetadata( + id = from.channel()?.id() ?: "", + name = from.channel()?.name() ?: "", + description = from.channel()?.descr() ?: "", + custom = from.channel()?.custom()?.asMap() as? Map, // TODO: Verify + updated = from.channel()?.updated(), + eTag = from.channel()?.eTag(), + type = from.channel()?.type(), + status = from.channel()?.status() + ), + custom = from.custom() as? Map, // TODO: Verify + updated = from.updated() ?: "", + eTag = from.eTag() ?: "", + status = from.status() + ) +} + +@OptIn(ExperimentalForeignApi::class) +internal fun createPNMember(from: PubNubMembershipMetadataObjC): PNMember { + return PNMember( + uuid = from.uuid()?.let { createPNUUIDMetadata(from = it) }, + custom = from.custom() as? Map, // TODO: Verify + updated = from.updated() ?: "", + eTag = from.eTag() ?: "", + status = from.status() + ) +} + +internal inline fun List<*>?.filterAndMap(mapper: (T) -> U): Collection { + return this?.filterIsInstance()?.map(mapper) ?: emptyList() } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index ff2dbfb55..025d4c381 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -170,7 +170,7 @@ private fun createFileEventResult(from: PubNubFileEventResultObjC?): PNFileEvent file = PNDownloadableFile( id = from.file().id(), name = from.file().name(), - url = from.file().url() + url = from.file().url()?.absoluteString ?: "" ) ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt index 15d4a7bf7..2ffed932d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt @@ -29,6 +29,18 @@ fun Consumer>.onSuccessHandler3(mapper: (T, X, Y) -> U) : } } +fun Consumer>.onSuccessHandler2(mapper: (T, X) -> Y) : (T, X) -> Unit { + return { input: T, secondInput: X -> + accept( + try { + Result.success(mapper(input, secondInput)) + } catch (e: Exception) { + Result.failure(e) + } + ) + } +} + fun Consumer>.onSuccessReturnValue(value: T) : () -> Unit { return { accept(Result.success(value)) diff --git a/swift b/swift index f0a76488b..2718c2b14 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit f0a76488baca51c4a5378d6bb33e4a281064fc7e +Subproject commit 2718c2b14821e01bff066175b769e1dcf1c37807 From dbdecb0dcb40584a2448eb0f98f9c4e402f44106 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:09:40 +0000 Subject: [PATCH 24/62] Finish rest of required JS wrapper methods (basic entity/subscription support) (#238) * Commonize entities and subscriptions * Remove expect/actual PubNub interfaces * [JS] Basic channel entity and subscription * [JS] Add missing methods * Alias c.p.kmp.PubNub and import c.p.api.PubNub --- .../com/pubnub/api/enums/PNPushEnvironment.kt | 5 + .../api/v2/subscriptions/BaseSubscription.kt | 1 - .../kotlin/com/pubnub/kmp/PNFuture.kt | 2 +- .../kotlin/com/pubnub/api/BasePubNub.kt | 6 +- .../pubnub/api/v2/callbacks/EventEmitter.kt | 0 .../pubnub/api/v2/callbacks/EventListener.kt | 2 +- .../pubnub/api/v2/callbacks/StatusListener.kt | 2 - .../com/pubnub/api/v2/entities/Channel.kt | 5 +- .../pubnub/api/v2/entities/ChannelGroup.kt | 0 .../pubnub/api/v2/entities/ChannelMetadata.kt | 0 .../pubnub/api/v2/entities/UserMetadata.kt | 0 .../api/v2/subscriptions/Subscription.kt | 0 .../api/v2/subscriptions/SubscriptionSet.kt | 0 .../kotlin/com/pubnub/{api => kmp}/PubNub.kt | 34 +- .../kotlin/com/pubnub/kmp/factories.kt | 1 - .../com/pubnub/test/BaseIntegrationTest.kt | 2 +- .../kotlin/com/pubnub/api/PubNub.ios.kt | 422 ------------------ .../kotlin/com/pubnub/api/PubNubImpl.kt | 36 ++ .../com/pubnub/api/endpoints/Time.ios.kt | 1 - .../message_actions/GetMessageActions.ios.kt | 1 - .../RemoveMessageAction.ios.kt | 1 - .../api/endpoints/pubsub/Publish.ios.kt | 1 - .../api/v2/callbacks/EventListener.ios.kt | 5 +- .../api/v2/callbacks/StatusListener.ios.kt | 8 +- .../kotlin/com/pubnub/kmp/factories.ios.kt | 1 - .../src/jsMain/kotlin/Pubnub.d.kt | 2 +- .../jsMain/kotlin/com/pubnub/api/PubNub.js.kt | 369 --------------- .../kotlin/com/pubnub/api/PubNubImpl.kt | 89 +++- .../api/endpoints/DeleteMessagesImpl.kt | 17 + .../pubnub/api/endpoints/MessageCountsImpl.kt | 18 + .../endpoints/push/AddChannelsToPushImpl.kt | 12 + .../endpoints/push/ListPushProvisionsImpl.kt | 13 + .../RemoveAllPushChannelsForDeviceImpl.kt | 14 + .../push/RemoveChannelsFromPushImpl.kt | 12 + .../api/v2/callbacks/EventListener.js.kt | 2 +- .../internal/v2/entities/ChannelImpl.kt | 59 +++ .../v2/subscriptions/SubscriptionImpl.kt | 70 +++ .../kotlin/com/pubnub/kmp/factories.js.kt | 1 - .../jvmMain/kotlin/com/pubnub/api/PubNub.kt | 109 ++--- .../kotlin/com/pubnub/kmp/factories.jvm.kt | 23 +- 40 files changed, 444 insertions(+), 902 deletions(-) rename pubnub-kotlin/pubnub-kotlin-api/src/{jvmMain => commonMain}/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{jvmMain => commonMain}/kotlin/com/pubnub/api/v2/entities/Channel.kt (98%) rename pubnub-kotlin/pubnub-kotlin-api/src/{jvmMain => commonMain}/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{jvmMain => commonMain}/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{jvmMain => commonMain}/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{jvmMain => commonMain}/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/{jvmMain => commonMain}/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt (100%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/{api => kmp}/PubNub.kt (94%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessagesImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCountsImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPushImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisionsImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPushImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt index 023c472ae..e145db68b 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt @@ -3,4 +3,9 @@ package com.pubnub.api.enums enum class PNPushEnvironment { DEVELOPMENT, PRODUCTION, + ; + + fun toParamString(): String { + return name.lowercase() + } } diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt index 11f452a2f..e51aeeae0 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt @@ -15,5 +15,4 @@ import com.pubnub.api.v2.callbacks.BaseEventListener * This class implements the [AutoCloseable] interface to help you release resources by calling [unsubscribe] * and removing all listeners on [close]. Remember to always call [close] when you no longer need this Subscription. */ -@OptIn(ExperimentalStdlibApi::class) interface BaseSubscription : BaseEventEmitter, SubscribeCapable, AutoCloseable diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt index d82a0157c..4c0944f49 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt @@ -3,6 +3,6 @@ package com.pubnub.kmp import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result -interface PNFuture { +fun interface PNFuture { fun async(callback: Consumer>) } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt index 5302c0486..20c9a0886 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt @@ -118,9 +118,9 @@ interface BasePubNub< * @return a [SubscriptionSet] containing subscriptions for the given [channels] and [channelGroups] */ fun subscriptionSetOf( - channels: Set = emptySet(), - channelGroups: Set = emptySet(), - options: SubscriptionOptions = EmptyOptions, + channels: Set, + channelGroups: Set, + options: SubscriptionOptions, ): SubscriptionSet /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt index 2d61024fa..9867239d8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt @@ -6,4 +6,4 @@ import com.pubnub.api.callbacks.Listener * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -expect interface EventListener : Listener \ No newline at end of file +expect interface EventListener : BaseEventListener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt index 03c3c98a1..c123cfee7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt @@ -1,8 +1,6 @@ package com.pubnub.api.v2.callbacks -import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener -import com.pubnub.api.models.consumer.PNStatus /** * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/Channel.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt similarity index 98% rename from pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/Channel.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt index 48318e9dc..27529c03e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/Channel.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt @@ -1,13 +1,12 @@ package com.pubnub.api.v2.entities -import com.pubnub.api.PNConfiguration import com.pubnub.api.endpoints.files.DeleteFile import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.pubsub.Publish import com.pubnub.api.endpoints.pubsub.Signal import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.subscriptions.Subscription -import java.io.InputStream +import com.pubnub.kmp.Uploadable /** * A representation of a PubNub channel identified by its [name]. @@ -142,7 +141,7 @@ interface Channel : BaseChannel { */ fun sendFile( fileName: String, - inputStream: InputStream, + inputStream: Uploadable, message: Any? = null, meta: Any? = null, ttl: Int? = null, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt similarity index 94% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt index bf2aa850d..5fc7919cb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt @@ -1,4 +1,4 @@ -package com.pubnub.api +package com.pubnub.kmp import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages @@ -49,7 +49,6 @@ import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant -import com.pubnub.api.models.consumer.files.PNDownloadFileResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNMemberKey @@ -63,10 +62,16 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.kmp.CustomObject -import com.pubnub.kmp.Uploadable - -expect interface PubNub { +import com.pubnub.api.v2.entities.Channel +import com.pubnub.api.v2.entities.ChannelGroup +import com.pubnub.api.v2.entities.ChannelMetadata +import com.pubnub.api.v2.entities.UserMetadata +import com.pubnub.api.v2.subscriptions.EmptyOptions +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.api.v2.subscriptions.SubscriptionSet + +interface PubNub { val configuration: PNConfiguration fun addListener(listener: EventListener) fun addListener(listener: StatusListener) @@ -436,4 +441,21 @@ expect interface PubNub { fun setToken(token: String?) fun destroy() + + fun channel(name: String): Channel + + fun channelGroup(name: String): ChannelGroup + + fun channelMetadata(id: String): ChannelMetadata + + fun userMetadata(id: String): UserMetadata + + fun subscriptionSetOf(subscriptions: Set): SubscriptionSet + + fun subscriptionSetOf( + channels: Set = emptySet(), + channelGroups: Set = emptySet(), + options: SubscriptionOptions = EmptyOptions, + ): SubscriptionSet + } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt index 0642ffe31..560e7e26b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt @@ -1,6 +1,5 @@ package com.pubnub.kmp -import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt index 9a32af776..5e1a248ca 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt @@ -1,6 +1,5 @@ package com.pubnub.test -import com.pubnub.api.PubNub import com.pubnub.api.UserId import com.pubnub.api.enums.PNStatusCategory import com.pubnub.api.models.consumer.PNStatus @@ -8,6 +7,7 @@ import com.pubnub.api.models.consumer.pubsub.PNEvent import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.v2.createPNConfiguration import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.PubNub import com.pubnub.kmp.createEventListener import com.pubnub.kmp.createPubNub import com.pubnub.kmp.createStatusListener diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt deleted file mode 100644 index dd1a9226b..000000000 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNub.ios.kt +++ /dev/null @@ -1,422 +0,0 @@ -package com.pubnub.api - -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.endpoints.DeleteMessages -import com.pubnub.api.endpoints.FetchMessages -import com.pubnub.api.endpoints.MessageCounts -import com.pubnub.api.endpoints.Time -import com.pubnub.api.endpoints.access.GrantToken -import com.pubnub.api.endpoints.access.RevokeToken -import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup -import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup -import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup -import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup -import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup -import com.pubnub.api.endpoints.files.DeleteFile -import com.pubnub.api.endpoints.files.DownloadFile -import com.pubnub.api.endpoints.files.GetFileUrl -import com.pubnub.api.endpoints.files.ListFiles -import com.pubnub.api.endpoints.files.PublishFileMessage -import com.pubnub.api.endpoints.files.SendFile -import com.pubnub.api.endpoints.message_actions.AddMessageAction -import com.pubnub.api.endpoints.message_actions.GetMessageActions -import com.pubnub.api.endpoints.message_actions.RemoveMessageAction -import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata -import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata -import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata -import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata -import com.pubnub.api.endpoints.objects.member.GetChannelMembers -import com.pubnub.api.endpoints.objects.member.ManageChannelMembers -import com.pubnub.api.endpoints.objects.membership.GetMemberships -import com.pubnub.api.endpoints.objects.membership.ManageMemberships -import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata -import com.pubnub.api.endpoints.presence.GetState -import com.pubnub.api.endpoints.presence.HereNow -import com.pubnub.api.endpoints.presence.SetState -import com.pubnub.api.endpoints.presence.WhereNow -import com.pubnub.api.endpoints.pubsub.Publish -import com.pubnub.api.endpoints.pubsub.Signal -import com.pubnub.api.endpoints.push.AddChannelsToPush -import com.pubnub.api.endpoints.push.ListPushProvisions -import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice -import com.pubnub.api.endpoints.push.RemoveChannelsFromPush -import com.pubnub.api.enums.PNPushEnvironment -import com.pubnub.api.enums.PNPushType -import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant -import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant -import com.pubnub.api.models.consumer.message_actions.PNMessageAction -import com.pubnub.api.models.consumer.objects.PNKey -import com.pubnub.api.models.consumer.objects.PNMemberKey -import com.pubnub.api.models.consumer.objects.PNMembershipKey -import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.models.consumer.objects.PNSortKey -import com.pubnub.api.models.consumer.objects.member.MemberInput -import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel -import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput -import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.api.v2.PNConfiguration -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.kmp.CustomObject -import com.pubnub.kmp.Uploadable - -actual interface PubNub { - actual val configuration: PNConfiguration - actual fun addListener(listener: EventListener) - actual fun addListener(listener: StatusListener) - actual fun removeListener(listener: Listener) - actual fun removeAllListeners() - actual fun publish( - channel: String, - message: Any, - meta: Any?, - shouldStore: Boolean?, - usePost: Boolean, - replicate: Boolean, - ttl: Int? - ): Publish - - actual fun fire( - channel: String, - message: Any, - meta: Any?, - usePost: Boolean, - ttl: Int? - ): Publish - - actual fun signal(channel: String, message: Any): Signal - actual fun getSubscribedChannels(): List - actual fun getSubscribedChannelGroups(): List - actual fun addPushNotificationsOnChannels( - pushType: PNPushType, - channels: List, - deviceId: String, - topic: String?, - environment: PNPushEnvironment - ): AddChannelsToPush - - actual fun auditPushChannelProvisions( - pushType: PNPushType, - deviceId: String, - topic: String?, - environment: PNPushEnvironment - ): ListPushProvisions - - actual fun removePushNotificationsFromChannels( - pushType: PNPushType, - channels: List, - deviceId: String, - topic: String?, - environment: PNPushEnvironment - ): RemoveChannelsFromPush - - actual fun removeAllPushNotificationsFromDeviceWithPushToken( - pushType: PNPushType, - deviceId: String, - topic: String?, - environment: PNPushEnvironment - ): RemoveAllPushChannelsForDevice - - actual fun fetchMessages( - channels: List, - page: PNBoundedPage, - includeUUID: Boolean, - includeMeta: Boolean, - includeMessageActions: Boolean, - includeMessageType: Boolean - ): FetchMessages - - actual fun deleteMessages( - channels: List, - start: Long?, - end: Long? - ): DeleteMessages - - actual fun messageCounts( - channels: List, - channelsTimetoken: List - ): MessageCounts - - actual fun hereNow( - channels: List, - channelGroups: List, - includeState: Boolean, - includeUUIDs: Boolean - ): HereNow - - actual fun whereNow(uuid: String): WhereNow - actual fun setPresenceState( - channels: List, - channelGroups: List, - state: Any, - ): SetState - - actual fun getPresenceState( - channels: List, - channelGroups: List, - uuid: String - ): GetState - - actual fun presence( - channels: List, - channelGroups: List, - connected: Boolean - ) - - actual fun addMessageAction( - channel: String, - messageAction: PNMessageAction - ): AddMessageAction - - actual fun removeMessageAction( - channel: String, - messageTimetoken: Long, - actionTimetoken: Long - ): RemoveMessageAction - - actual fun getMessageActions( - channel: String, - page: PNBoundedPage - ): GetMessageActions - - actual fun addChannelsToChannelGroup( - channels: List, - channelGroup: String - ): AddChannelChannelGroup - - actual fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup - actual fun removeChannelsFromChannelGroup( - channels: List, - channelGroup: String - ): RemoveChannelChannelGroup - - actual fun listAllChannelGroups(): ListAllChannelGroup - actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup - actual fun grantToken( - ttl: Int, - meta: CustomObject?, - authorizedUUID: String?, - channels: List, - channelGroups: List, - uuids: List - ): GrantToken - - actual fun revokeToken(token: String): RevokeToken - actual fun time(): Time - actual fun getAllChannelMetadata( - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean - ): GetAllChannelMetadata - - actual fun getChannelMetadata( - channel: String, - includeCustom: Boolean - ): GetChannelMetadata - - actual fun setChannelMetadata( - channel: String, - name: String?, - description: String?, - custom: CustomObject?, - includeCustom: Boolean, - type: String?, - status: String? - ): SetChannelMetadata - - actual fun removeChannelMetadata(channel: String): RemoveChannelMetadata - actual fun getAllUUIDMetadata( - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean - ): GetAllUUIDMetadata - - actual fun getUUIDMetadata( - uuid: String?, - includeCustom: Boolean - ): GetUUIDMetadata - - actual fun setUUIDMetadata( - uuid: String?, - name: String?, - externalId: String?, - profileUrl: String?, - email: String?, - custom: CustomObject?, - includeCustom: Boolean, - type: String?, - status: String? - ): SetUUIDMetadata - - actual fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata - actual fun getMemberships( - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? - ): GetMemberships - - actual fun setMemberships( - channels: List, - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? - ): ManageMemberships - - actual fun removeMemberships( - channels: List, - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? - ): ManageMemberships - -// actual fun manageMemberships( -// channelsToSet: List, -// channelsToRemove: List, -// uuid: String?, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeChannelDetails: PNChannelDetailsLevel? -// ): ManageMemberships - - actual fun getChannelMembers( - channel: String, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? - ): GetChannelMembers - - actual fun setChannelMembers( - channel: String, - uuids: List, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? - ): ManageChannelMembers - - actual fun removeChannelMembers( - channel: String, - uuids: List, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? - ): ManageChannelMembers - -// actual fun manageChannelMembers( -// channel: String, -// uuidsToSet: Collection, -// uuidsToRemove: Collection, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeUUIDDetails: PNUUIDDetailsLevel? -// ): ManageChannelMembers - - actual fun listFiles( - channel: String, - limit: Int?, - next: PNPage.PNNext? - ): ListFiles - - actual fun getFileUrl( - channel: String, - fileName: String, - fileId: String - ): GetFileUrl - - actual fun deleteFile( - channel: String, - fileName: String, - fileId: String - ): DeleteFile - - actual fun publishFileMessage( - channel: String, - fileName: String, - fileId: String, - message: Any?, - meta: Any?, - ttl: Int?, - shouldStore: Boolean? - ): PublishFileMessage - - actual fun subscribe( - channels: List, - channelGroups: List, - withPresence: Boolean, - withTimetoken: Long - ) - - actual fun unsubscribe( - channels: List, - channelGroups: List - ) - - actual fun setToken(token: String?) - actual fun destroy() - actual fun unsubscribeAll() - - actual fun sendFile( - channel: String, - fileName: String, - inputStream: Uploadable, - message: Any?, - meta: Any?, - ttl: Int?, - shouldStore: Boolean?, - cipherKey: String? - ): SendFile - - actual fun downloadFile( - channel: String, - fileName: String, - fileId: String, - cipherKey: String? - ): DownloadFile - -} - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index b7b5f5d50..8a8ba6b28 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -111,7 +111,15 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.api.v2.entities.Channel +import com.pubnub.api.v2.entities.ChannelGroup +import com.pubnub.api.v2.entities.ChannelMetadata +import com.pubnub.api.v2.entities.UserMetadata +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.PubNub import com.pubnub.kmp.Uploadable import kotlinx.cinterop.ExperimentalForeignApi @@ -757,6 +765,34 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { pubNubObjC.disconnect() } + override fun channel(name: String): Channel { + TODO("Not yet implemented") + } + + override fun channelGroup(name: String): ChannelGroup { + TODO("Not yet implemented") + } + + override fun channelMetadata(id: String): ChannelMetadata { + TODO("Not yet implemented") + } + + override fun userMetadata(id: String): UserMetadata { + TODO("Not yet implemented") + } + + override fun subscriptionSetOf(subscriptions: Set): SubscriptionSet { + TODO("Not yet implemented") + } + + override fun subscriptionSetOf( + channels: Set, + channelGroups: Set, + options: SubscriptionOptions + ): SubscriptionSet { + TODO("Not yet implemented") + } + override fun unsubscribeAll() { pubNubObjC.unsubscribeAll() } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt index e2981cab6..6b5c8d803 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt @@ -3,7 +3,6 @@ package com.pubnub.api.endpoints import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.timeOnSuccess import com.pubnub.kmp.PNFuture -import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNTimeResult import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt index 0de613d43..8f838a663 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt @@ -4,7 +4,6 @@ import cocoapods.PubNubSwift.PubNubBoundedPageObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getMessageActionsFrom import com.pubnub.kmp.PNFuture -import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult import com.pubnub.kmp.onFailureHandler diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt index b5731b03a..2c8d01881 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt @@ -3,7 +3,6 @@ package com.pubnub.api.endpoints.message_actions import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeMessageActionWithChannel import com.pubnub.kmp.PNFuture -import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessReturnValue diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt index cb405799e..1bf6d81a4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt @@ -3,7 +3,6 @@ package com.pubnub.api.endpoints.pubsub import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.publishWithChannel import com.pubnub.kmp.PNFuture -import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNPublishResult import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt index f8b311439..08f41f9c8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -1,14 +1,13 @@ package com.pubnub.api.v2.callbacks import cocoapods.PubNubSwift.EventListenerObjC -import com.pubnub.api.PubNub -import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.kmp.PubNub import kotlinx.cinterop.ExperimentalForeignApi /** @@ -17,7 +16,7 @@ import kotlinx.cinterop.ExperimentalForeignApi */ @OptIn(ExperimentalForeignApi::class) -actual interface EventListener : Listener { +actual interface EventListener : BaseEventListener { val underlying: EventListenerObjC val onMessage: (PubNub, PNMessageResult) -> Unit val onPresence: (PubNub, PNPresenceEventResult) -> Unit diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt index 306b283da..a89ff7120 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt @@ -1,15 +1,9 @@ package com.pubnub.api.v2.callbacks import cocoapods.PubNubSwift.StatusListenerObjC -import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -import com.pubnub.api.models.consumer.pubsub.PNSignalResult -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.kmp.PubNub import kotlinx.cinterop.ExperimentalForeignApi /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 025d4c381..640a26401 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -24,7 +24,6 @@ import cocoapods.PubNubSwift.PubNubSetMembershipEventMessageObjC import cocoapods.PubNubSwift.PubNubSetUUIDMetadataEventMessageObjC import cocoapods.PubNubSwift.StatusListenerObjC import com.pubnub.api.JsonElementImpl -import com.pubnub.api.PubNub import com.pubnub.api.PubNubException import com.pubnub.api.PubNubImpl import com.pubnub.api.enums.PNStatusCategory diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt index dbadc1371..30c4383b9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt @@ -481,7 +481,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface MessageCountsParameters { var channels: Array - var channelTimetokens: dynamic /* Array | Array */ + var channelTimetokens: Array } interface MessageCountsResponse { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt deleted file mode 100644 index 49cd1de59..000000000 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNub.js.kt +++ /dev/null @@ -1,369 +0,0 @@ -package com.pubnub.api - -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.endpoints.DeleteMessages -import com.pubnub.api.endpoints.FetchMessages -import com.pubnub.api.endpoints.MessageCounts -import com.pubnub.api.endpoints.Time -import com.pubnub.api.endpoints.access.GrantToken -import com.pubnub.api.endpoints.access.RevokeToken -import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup -import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup -import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup -import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup -import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup -import com.pubnub.api.endpoints.files.DeleteFile -import com.pubnub.api.endpoints.files.DownloadFile -import com.pubnub.api.endpoints.files.GetFileUrl -import com.pubnub.api.endpoints.files.ListFiles -import com.pubnub.api.endpoints.files.PublishFileMessage -import com.pubnub.api.endpoints.files.SendFile -import com.pubnub.api.endpoints.message_actions.AddMessageAction -import com.pubnub.api.endpoints.message_actions.GetMessageActions -import com.pubnub.api.endpoints.message_actions.RemoveMessageAction -import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata -import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata -import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata -import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata -import com.pubnub.api.endpoints.objects.member.GetChannelMembers -import com.pubnub.api.endpoints.objects.member.ManageChannelMembers -import com.pubnub.api.endpoints.objects.membership.GetMemberships -import com.pubnub.api.endpoints.objects.membership.ManageMemberships -import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata -import com.pubnub.api.endpoints.presence.GetState -import com.pubnub.api.endpoints.presence.HereNow -import com.pubnub.api.endpoints.presence.SetState -import com.pubnub.api.endpoints.presence.WhereNow -import com.pubnub.api.endpoints.pubsub.Publish -import com.pubnub.api.endpoints.pubsub.Signal -import com.pubnub.api.endpoints.push.AddChannelsToPush -import com.pubnub.api.endpoints.push.ListPushProvisions -import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice -import com.pubnub.api.endpoints.push.RemoveChannelsFromPush -import com.pubnub.api.enums.PNPushEnvironment -import com.pubnub.api.enums.PNPushType -import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant -import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant -import com.pubnub.api.models.consumer.message_actions.PNMessageAction -import com.pubnub.api.models.consumer.objects.PNKey -import com.pubnub.api.models.consumer.objects.PNMemberKey -import com.pubnub.api.models.consumer.objects.PNMembershipKey -import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.models.consumer.objects.PNSortKey -import com.pubnub.api.models.consumer.objects.member.MemberInput -import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel -import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput -import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.api.v2.PNConfiguration -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.kmp.CustomObject -import com.pubnub.kmp.Uploadable - -actual interface PubNub { - - actual val configuration: PNConfiguration - actual fun addListener(listener: EventListener) - actual fun addListener(listener: StatusListener) - actual fun removeListener(listener: Listener) - actual fun removeAllListeners() - actual fun publish( - channel: String, - message: Any, - meta: Any?, - shouldStore: Boolean?, - usePost: Boolean, - replicate: Boolean, - ttl: Int? - ): Publish - - actual fun fire( - channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int? - ): Publish - - actual fun signal(channel: String, message: Any): Signal - actual fun getSubscribedChannels(): List - actual fun getSubscribedChannelGroups(): List - actual fun addPushNotificationsOnChannels( - pushType: PNPushType, channels: List, deviceId: String, topic: String?, environment: PNPushEnvironment - ): AddChannelsToPush - - actual fun auditPushChannelProvisions( - pushType: PNPushType, deviceId: String, topic: String?, environment: PNPushEnvironment - ): ListPushProvisions - - actual fun removePushNotificationsFromChannels( - pushType: PNPushType, channels: List, deviceId: String, topic: String?, environment: PNPushEnvironment - ): RemoveChannelsFromPush - - actual fun removeAllPushNotificationsFromDeviceWithPushToken( - pushType: PNPushType, deviceId: String, topic: String?, environment: PNPushEnvironment - ): RemoveAllPushChannelsForDevice - - actual fun fetchMessages( - channels: List, - page: PNBoundedPage, - includeUUID: Boolean, - includeMeta: Boolean, - includeMessageActions: Boolean, - includeMessageType: Boolean - ): FetchMessages - - actual fun deleteMessages( - channels: List, start: Long?, end: Long? - ): DeleteMessages - - actual fun messageCounts( - channels: List, channelsTimetoken: List - ): MessageCounts - - actual fun hereNow( - channels: List, channelGroups: List, includeState: Boolean, includeUUIDs: Boolean - ): HereNow - - actual fun whereNow(uuid: String): WhereNow - actual fun setPresenceState( - channels: List, channelGroups: List, state: Any - ): SetState - - actual fun getPresenceState( - channels: List, channelGroups: List, uuid: String - ): GetState - - actual fun presence( - channels: List, channelGroups: List, connected: Boolean - ) - - actual fun addMessageAction( - channel: String, messageAction: PNMessageAction - ): AddMessageAction - - actual fun removeMessageAction( - channel: String, messageTimetoken: Long, actionTimetoken: Long - ): RemoveMessageAction - - actual fun getMessageActions( - channel: String, page: PNBoundedPage - ): GetMessageActions - - actual fun addChannelsToChannelGroup( - channels: List, channelGroup: String - ): AddChannelChannelGroup - - actual fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup - actual fun removeChannelsFromChannelGroup( - channels: List, channelGroup: String - ): RemoveChannelChannelGroup - - actual fun listAllChannelGroups(): ListAllChannelGroup - actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup - actual fun grantToken( - ttl: Int, - meta: CustomObject?, - authorizedUUID: String?, - channels: List, - channelGroups: List, - uuids: List - ): GrantToken - - actual fun revokeToken(token: String): RevokeToken - actual fun time(): Time - actual fun getAllChannelMetadata( - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean - ): GetAllChannelMetadata - - actual fun getChannelMetadata( - channel: String, includeCustom: Boolean - ): GetChannelMetadata - - actual fun setChannelMetadata( - channel: String, - name: String?, - description: String?, - custom: CustomObject?, - includeCustom: Boolean, - type: String?, - status: String? - ): SetChannelMetadata - - actual fun removeChannelMetadata(channel: String): RemoveChannelMetadata - actual fun getAllUUIDMetadata( - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean - ): GetAllUUIDMetadata - - actual fun getUUIDMetadata( - uuid: String?, includeCustom: Boolean - ): GetUUIDMetadata - - actual fun setUUIDMetadata( - uuid: String?, - name: String?, - externalId: String?, - profileUrl: String?, - email: String?, - custom: CustomObject?, - includeCustom: Boolean, - type: String?, - status: String? - ): SetUUIDMetadata - - actual fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata - actual fun getMemberships( - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? - ): GetMemberships - - actual fun setMemberships( - channels: List, - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? - ): ManageMemberships - - actual fun removeMemberships( - channels: List, - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? - ): ManageMemberships - -// actual fun manageMemberships( -// channelsToSet: List, -// channelsToRemove: List, -// uuid: String?, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeChannelDetails: PNChannelDetailsLevel? -// ): ManageMemberships - - actual fun getChannelMembers( - channel: String, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? - ): GetChannelMembers - - actual fun setChannelMembers( - channel: String, - uuids: List, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? - ): ManageChannelMembers - - actual fun removeChannelMembers( - channel: String, - uuids: List, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? - ): ManageChannelMembers - -// actual fun manageChannelMembers( -// channel: String, -// uuidsToSet: Collection, -// uuidsToRemove: Collection, -// limit: Int?, -// page: PNPage?, -// filter: String?, -// sort: Collection>, -// includeCount: Boolean, -// includeCustom: Boolean, -// includeUUIDDetails: PNUUIDDetailsLevel? -// ): ManageChannelMembers - - actual fun listFiles( - channel: String, limit: Int?, next: PNPage.PNNext? - ): ListFiles - - actual fun getFileUrl( - channel: String, fileName: String, fileId: String - ): GetFileUrl - - actual fun deleteFile( - channel: String, fileName: String, fileId: String - ): DeleteFile - - actual fun publishFileMessage( - channel: String, fileName: String, fileId: String, message: Any?, meta: Any?, ttl: Int?, shouldStore: Boolean? - ): PublishFileMessage - - actual fun subscribe( - channels: List, channelGroups: List, withPresence: Boolean, withTimetoken: Long - ) - - actual fun unsubscribe( - channels: List, channelGroups: List - ) - - actual fun unsubscribeAll() - - actual fun setToken(token: String?) - actual fun destroy() - - actual fun sendFile( - channel: String, - fileName: String, - inputStream: Uploadable, - message: Any?, - meta: Any?, - ttl: Int?, - shouldStore: Boolean?, - cipherKey: String? - ): SendFile - - actual fun downloadFile( - channel: String, - fileName: String, - fileId: String, - cipherKey: String? - ): DownloadFile - -} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 494aea273..4a9b9a46a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -2,9 +2,11 @@ package com.pubnub.api import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages +import com.pubnub.api.endpoints.DeleteMessagesImpl import com.pubnub.api.endpoints.FetchMessages import com.pubnub.api.endpoints.FetchMessagesImpl import com.pubnub.api.endpoints.MessageCounts +import com.pubnub.api.endpoints.MessageCountsImpl import com.pubnub.api.endpoints.Time import com.pubnub.api.endpoints.TimeImpl import com.pubnub.api.endpoints.access.GrantToken @@ -79,9 +81,13 @@ import com.pubnub.api.endpoints.pubsub.PublishImpl import com.pubnub.api.endpoints.pubsub.Signal import com.pubnub.api.endpoints.pubsub.SignalImpl import com.pubnub.api.endpoints.push.AddChannelsToPush +import com.pubnub.api.endpoints.push.AddChannelsToPushImpl import com.pubnub.api.endpoints.push.ListPushProvisions +import com.pubnub.api.endpoints.push.ListPushProvisionsImpl import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDeviceImpl import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.endpoints.push.RemoveChannelsFromPushImpl import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage @@ -106,9 +112,17 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.api.v2.entities.Channel +import com.pubnub.api.v2.entities.ChannelGroup +import com.pubnub.api.v2.entities.ChannelMetadata +import com.pubnub.api.v2.entities.UserMetadata +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.api.v2.subscriptions.SubscriptionSet +import com.pubnub.internal.v2.entities.ChannelImpl import com.pubnub.kmp.CustomObject -import com.pubnub.kmp.CustomObjectImpl import com.pubnub.kmp.Optional +import com.pubnub.kmp.PubNub import com.pubnub.kmp.Uploadable import com.pubnub.kmp.createJsObject import com.pubnub.kmp.toJsMap @@ -182,7 +196,13 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { topic: String?, environment: PNPushEnvironment ): AddChannelsToPush { - TODO("Not yet implemented") + return AddChannelsToPushImpl(jsPubNub, createJsObject { + this.pushGateway = pushType.toParamString() + this.channels = channels.toTypedArray() + this.device = deviceId + this.topic = topic + this.environment = environment.name.lowercase() + }) } override fun auditPushChannelProvisions( @@ -191,7 +211,12 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { topic: String?, environment: PNPushEnvironment ): ListPushProvisions { - TODO("Not yet implemented") + return ListPushProvisionsImpl(jsPubNub, createJsObject { + this.pushGateway = pushType.toParamString() + this.device = deviceId + this.topic = topic + this.topic = topic + }) } override fun removePushNotificationsFromChannels( @@ -201,7 +226,13 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { topic: String?, environment: PNPushEnvironment ): RemoveChannelsFromPush { - TODO("Not yet implemented") + return RemoveChannelsFromPushImpl(jsPubNub, createJsObject { + this.pushGateway = pushType.toParamString() + this.channels = channels.toTypedArray() + this.device = deviceId + this.topic = topic + this.environment = environment.toParamString() + }) } override fun removeAllPushNotificationsFromDeviceWithPushToken( @@ -210,7 +241,12 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { topic: String?, environment: PNPushEnvironment ): RemoveAllPushChannelsForDevice { - TODO("Not yet implemented") + return RemoveAllPushChannelsForDeviceImpl(jsPubNub, createJsObject { + this.pushGateway = pushType.toParamString() + this.device = deviceId + this.topic = topic + this.environment = environment.toParamString() + }) } override fun fetchMessages( @@ -223,8 +259,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ): FetchMessages { return FetchMessagesImpl(jsPubNub, createJsObject { this.channels = channels.toTypedArray() - this.start = page.start.toString() - this.end = page.end.toString() + this.start = page.start?.toString() + this.end = page.end?.toString() this.count = page.limit this.includeUUID = includeUUID this.includeMeta = includeMeta @@ -236,11 +272,18 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { - TODO("Not yet implemented") + return DeleteMessagesImpl(jsPubNub, createJsObject { + this.channel = channels.first()// channels.toTypedArray() todo JS doesn't accept multiple channels here! + this.start = start?.toString() + this.end = end?.toString() + }) } override fun messageCounts(channels: List, channelsTimetoken: List): MessageCounts { - TODO("Not yet implemented") + return MessageCountsImpl(jsPubNub, createJsObject { + this.channels = channels.toTypedArray() + this.channelTimetokens = channelsTimetoken.map { it.toString() }.toTypedArray() + }) } override fun hereNow( @@ -806,6 +849,34 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } + override fun channel(name: String): Channel { + return ChannelImpl(jsPubNub.asDynamic().channel(name)) + } + + override fun channelGroup(name: String): ChannelGroup { + TODO("Not yet implemented") + } + + override fun channelMetadata(id: String): ChannelMetadata { + TODO("Not yet implemented") + } + + override fun userMetadata(id: String): UserMetadata { + TODO("Not yet implemented") + } + + override fun subscriptionSetOf(subscriptions: Set): SubscriptionSet { + TODO("Not yet implemented") + } + + override fun subscriptionSetOf( + channels: Set, + channelGroups: Set, + options: SubscriptionOptions + ): SubscriptionSet { + TODO("Not yet implemented") + } + override fun sendFile( channel: String, fileName: String, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessagesImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessagesImpl.kt new file mode 100644 index 000000000..c7b48ad69 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessagesImpl.kt @@ -0,0 +1,17 @@ +package com.pubnub.api.endpoints + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.JsonElementImpl +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.history.HistoryMessageType +import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult +import com.pubnub.api.models.consumer.history.PNFetchMessageItem +import com.pubnub.api.models.consumer.history.PNFetchMessagesResult +import com.pubnub.kmp.toMap + +class DeleteMessagesImpl(pubnub: PubNub, params: PubNub.DeleteMessagesParameters) : DeleteMessages, + EndpointImpl(promiseFactory = { pubnub.deleteMessages(params) }, + responseMapping = { + PNDeleteMessagesResult() + }) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCountsImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCountsImpl.kt new file mode 100644 index 000000000..a61d45a66 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCountsImpl.kt @@ -0,0 +1,18 @@ +package com.pubnub.api.endpoints + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.JsonElementImpl +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.history.HistoryMessageType +import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult +import com.pubnub.api.models.consumer.history.PNFetchMessageItem +import com.pubnub.api.models.consumer.history.PNFetchMessagesResult +import com.pubnub.api.models.consumer.history.PNMessageCountResult +import com.pubnub.kmp.toMap + +class MessageCountsImpl(pubnub: PubNub, params: PubNub.MessageCountsParameters) : MessageCounts, + EndpointImpl(promiseFactory = { pubnub.messageCounts(params) }, + responseMapping = { + PNMessageCountResult(it.channels.toMap().mapValues { entry -> entry.value.toLong() }) + }) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPushImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPushImpl.kt new file mode 100644 index 000000000..bce980c63 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPushImpl.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.endpoints.push + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.push.PNPushAddChannelResult + +class AddChannelsToPushImpl(pubnub: PubNub, params: PubNub.PushChannelParameters) : AddChannelsToPush, EndpointImpl( + promiseFactory = { pubnub.push.addChannels(params) }, + responseMapping = { + PNPushAddChannelResult() + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisionsImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisionsImpl.kt new file mode 100644 index 000000000..0b0c76e17 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisionsImpl.kt @@ -0,0 +1,13 @@ +package com.pubnub.api.endpoints.push + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.push.PNPushAddChannelResult +import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult + +class ListPushProvisionsImpl(pubnub: PubNub, params: PubNub.PushDeviceParameters) : ListPushProvisions, EndpointImpl( + promiseFactory = { pubnub.push.listChannels(params) }, + responseMapping = { + PNPushListProvisionsResult(it.channels.toList()) + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt new file mode 100644 index 000000000..dd74c06a0 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt @@ -0,0 +1,14 @@ +package com.pubnub.api.endpoints.push + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.push.PNPushAddChannelResult +import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult +import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult + +class RemoveAllPushChannelsForDeviceImpl(pubnub: PubNub, params: PubNub.PushDeviceParameters) : RemoveAllPushChannelsForDevice, EndpointImpl( + promiseFactory = { pubnub.push.deleteDevice(params) }, + responseMapping = { + PNPushRemoveAllChannelsResult() + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPushImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPushImpl.kt new file mode 100644 index 000000000..94402ee3b --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPushImpl.kt @@ -0,0 +1,12 @@ +package com.pubnub.api.endpoints.push + +import PubNub +import com.pubnub.api.EndpointImpl +import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult + +class RemoveChannelsFromPushImpl(pubnub: PubNub, params: PubNub.PushChannelParameters) : RemoveChannelsFromPush, EndpointImpl( + promiseFactory = { pubnub.push.removeChannels(params) }, + responseMapping = { + PNPushRemoveChannelResult() + } +) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt index e887dd21f..4b6776b2f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt @@ -6,4 +6,4 @@ import com.pubnub.api.callbacks.Listener * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -actual interface EventListener : Listener \ No newline at end of file +actual interface EventListener : BaseEventListener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt new file mode 100644 index 000000000..e7b71317b --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt @@ -0,0 +1,59 @@ +package com.pubnub.internal.v2.entities + +import PubNub +import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.SendFile +import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.v2.entities.Channel +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.v2.subscriptions.SubscriptionImpl +import com.pubnub.kmp.Uploadable + +class ChannelImpl( private val jsChannel: dynamic): Channel { + + override fun publish( + message: Any, + meta: Any?, + shouldStore: Boolean?, + usePost: Boolean, + replicate: Boolean, + ttl: Int? + ): Publish { + TODO("Not yet implemented") + } + + override fun signal(message: Any): Signal { + TODO("Not yet implemented") + } + + override fun fire(message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { + TODO("Not yet implemented") + } + + + override fun sendFile( + fileName: String, + inputStream: Uploadable, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, + cipherKey: String? + ): SendFile { + TODO("Not yet implemented") + } + + override fun deleteFile(fileName: String, fileId: String): DeleteFile { + TODO("Not yet implemented") + } + + override val name: String + get() = jsChannel.name + + override fun subscription(options: SubscriptionOptions): Subscription { //todo use options + return SubscriptionImpl(jsChannel.subscription()) + } + +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt new file mode 100644 index 000000000..4e7e38611 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt @@ -0,0 +1,70 @@ +package com.pubnub.internal.v2.subscriptions + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionCursor +import com.pubnub.api.v2.subscriptions.SubscriptionSet + +class SubscriptionImpl(private val jsSubscription: dynamic) : Subscription { + + override fun close() { + unsubscribe() + } + + override fun plus(subscription: Subscription): SubscriptionSet { + TODO("Not yet implemented") + } + + override fun addListener(listener: EventListener) { + jsSubscription.addListener(listener) + } + + + override fun removeListener(listener: Listener) { + jsSubscription.removeListener(listener) + } + + override fun removeAllListeners() { + TODO("Not yet implemented") //todo js doesn't support this? + } + + override fun subscribe(cursor: SubscriptionCursor) { // todo use cursor + jsSubscription.subscribe() + } + + override fun unsubscribe() { + jsSubscription.unsubscribe() + } + + override var onMessage: ((PNMessageResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + + override var onPresence: ((PNPresenceEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + + override var onSignal: ((PNSignalResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + + override var onMessageAction: ((PNMessageActionResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + + override var onObjects: ((PNObjectEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + + override var onFile: ((PNFileEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt index 2d39662f1..89ec315d2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt @@ -1,7 +1,6 @@ package com.pubnub.kmp import com.pubnub.api.JsonElementImpl -import com.pubnub.api.PubNub import com.pubnub.api.PubNubImpl import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.files.PNDownloadableFile diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index 5b0ef2b3d..1b51bf96b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -77,7 +77,8 @@ import com.pubnub.internal.BasePubNubImpl import com.pubnub.kmp.CustomObject import java.io.InputStream -actual interface PubNub : +interface PubNub : + com.pubnub.kmp.PubNub, BasePubNub, EventEmitter { companion object { @@ -130,7 +131,7 @@ actual interface PubNub : * Modifying the values in this configuration is not advised, as it may lead * to undefined behavior. */ - actual val configuration: com.pubnub.api.v2.PNConfiguration + override val configuration: com.pubnub.api.v2.PNConfiguration /** * Add a legacy listener for both client status and events. @@ -186,7 +187,7 @@ actual interface PubNub : * - If ttl isn't specified, then expiration of the message defaults * back to the expiry value for the key. */ - actual fun publish( + override fun publish( channel: String, message: Any, meta: Any?, @@ -226,7 +227,7 @@ actual interface PubNub : * - If ttl isn't specified, then expiration of the message defaults * back to the expiry value for the key. */ - actual fun fire( + override fun fire( channel: String, message: Any, meta: Any?, @@ -244,7 +245,7 @@ actual interface PubNub : * @param channel The channel which the signal will be sent to. * @param message The payload which will be serialized and sent. */ - actual fun signal( + override fun signal( channel: String, message: Any, ): Signal @@ -254,14 +255,14 @@ actual interface PubNub : * * @return A list of channels the client is currently subscribed to. */ - actual fun getSubscribedChannels(): List + override fun getSubscribedChannels(): List /** * Queries the local subscribe loop for channel groups currently in the mix. * * @return A list of channel groups the client is currently subscribed to. */ - actual fun getSubscribedChannelGroups(): List + override fun getSubscribedChannelGroups(): List /** * Enable push notifications on provided set of channels. @@ -275,7 +276,7 @@ actual interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - actual fun addPushNotificationsOnChannels( + override fun addPushNotificationsOnChannels( pushType: PNPushType, channels: List, deviceId: String, @@ -293,7 +294,7 @@ actual interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - actual fun auditPushChannelProvisions( + override fun auditPushChannelProvisions( pushType: PNPushType, deviceId: String, topic: String?, @@ -311,7 +312,7 @@ actual interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - actual fun removePushNotificationsFromChannels( + override fun removePushNotificationsFromChannels( pushType: PNPushType, channels: List, deviceId: String, @@ -329,7 +330,7 @@ actual interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - actual fun removeAllPushNotificationsFromDeviceWithPushToken( + override fun removeAllPushNotificationsFromDeviceWithPushToken( pushType: PNPushType, deviceId: String, topic: String?, @@ -472,7 +473,7 @@ actual interface PubNub : * @param includeMessageType Whether to include message type in response. * Defaults to `false`. */ - actual fun fetchMessages( + override fun fetchMessages( channels: List, page: PNBoundedPage, includeUUID: Boolean, @@ -494,7 +495,7 @@ actual interface PubNub : * @param start Timetoken delimiting the start of time slice (exclusive) to delete messages from. * @param end Time token delimiting the end of time slice (inclusive) to delete messages from. */ - actual fun deleteMessages( + override fun deleteMessages( channels: List, start: Long?, end: Long?, @@ -510,7 +511,7 @@ actual interface PubNub : * Specify a single timetoken to apply it to all channels. * Otherwise, the list of timetokens must be the same length as the list of channels. */ - actual fun messageCounts( + override fun messageCounts( channels: List, channelsTimetoken: List, ): MessageCounts @@ -528,7 +529,7 @@ actual interface PubNub : * @param includeUUIDs Whether the response should include UUIDs od connected clients. * Defaults to `true`. */ - actual fun hereNow( + override fun hereNow( channels: List, channelGroups: List, includeState: Boolean, @@ -541,7 +542,7 @@ actual interface PubNub : * @param uuid UUID of the user to get its current channel subscriptions. Defaults to the UUID of the client. * @see [PNConfiguration.uuid] */ - actual fun whereNow(uuid: String): WhereNow + override fun whereNow(uuid: String): WhereNow /** * Set state information specific to a subscriber UUID. @@ -556,7 +557,7 @@ actual interface PubNub : * * @param channels Channels to set the state to. * @param channelGroups Channel groups to set the state to. - * @param state The actual state object to set. + * @param state The override state object to set. * NOTE: Presence state must be expressed as a JsonObject. * When calling [PubNub.setPresenceState], be sure to supply an initialized JsonObject * or POJO which can be serialized to a JsonObject. @@ -583,12 +584,12 @@ actual interface PubNub : * * @param channels Channels to set the state to. * @param channelGroups Channel groups to set the state to. - * @param state The actual state object to set. + * @param state The override state object to set. * NOTE: Presence state must be expressed as a JsonObject. * When calling [PubNub.setPresenceState], be sure to supply an initialized JsonObject * or POJO which can be serialized to a JsonObject. */ - actual fun setPresenceState( + override fun setPresenceState( channels: List, channelGroups: List, state: Any, @@ -604,7 +605,7 @@ actual interface PubNub : * @param uuid UUID of the user to get the state from. Defaults to the UUID of the client. * @see [PNConfiguration.uuid] */ - actual fun getPresenceState( + override fun getPresenceState( channels: List, channelGroups: List, uuid: String, @@ -619,7 +620,7 @@ actual interface PubNub : * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. */ - actual fun presence( + override fun presence( channels: List, channelGroups: List, connected: Boolean, @@ -632,7 +633,7 @@ actual interface PubNub : * @param messageAction The message action object containing the message action's type, * value and the publish timetoken of the original message. */ - actual fun addMessageAction( + override fun addMessageAction( channel: String, messageAction: PNMessageAction, ): AddMessageAction @@ -644,7 +645,7 @@ actual interface PubNub : * @param messageTimetoken The publish timetoken of the original message. * @param actionTimetoken The publish timetoken of the message action to be removed. */ - actual fun removeMessageAction( + override fun removeMessageAction( channel: String, messageTimetoken: Long, actionTimetoken: Long, @@ -682,7 +683,7 @@ actual interface PubNub : * @param channel Channel to fetch message actions from. * @param page The paging object used for pagination. @see [PNBoundedPage] */ - actual fun getMessageActions( + override fun getMessageActions( channel: String, page: PNBoundedPage, ): GetMessageActions @@ -693,7 +694,7 @@ actual interface PubNub : * @param channels The channels to add to the channel group. * @param channelGroup The channel group to add the channels to. */ - actual fun addChannelsToChannelGroup( + override fun addChannelsToChannelGroup( channels: List, channelGroup: String, ): AddChannelChannelGroup @@ -703,7 +704,7 @@ actual interface PubNub : * * @param channelGroup Channel group to fetch the belonging channels. */ - actual fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup + override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup /** * Removes channels from a channel group. @@ -711,7 +712,7 @@ actual interface PubNub : * @param channelGroup The channel group to remove channels from * @param channels The channels to remove from the channel group. */ - actual fun removeChannelsFromChannelGroup( + override fun removeChannelsFromChannelGroup( channels: List, channelGroup: String, ): RemoveChannelChannelGroup @@ -719,14 +720,14 @@ actual interface PubNub : /** * Lists all registered channel groups for the subscribe key. */ - actual fun listAllChannelGroups(): ListAllChannelGroup + override fun listAllChannelGroups(): ListAllChannelGroup /** * Removes the channel group. * * @param channelGroup The channel group to remove. */ - actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup + override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup /** * This function establishes access permissions for PubNub Access Manager (PAM) by setting the `read` or `write` @@ -818,7 +819,7 @@ actual interface PubNub : * @param uuids List of all uuid grants */ - actual fun grantToken( + override fun grantToken( ttl: Int, meta: Any?, authorizedUUID: String?, @@ -856,12 +857,12 @@ actual interface PubNub : * * @param token Existing token with embedded permissions. */ - actual fun revokeToken(token: String): RevokeToken + override fun revokeToken(token: String): RevokeToken /** * Returns a 17 digit precision Unix epoch from the server. */ - actual fun time(): Time + override fun time(): Time /** * Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each. @@ -881,7 +882,7 @@ actual interface PubNub : * Default is `false`. * @param includeCustom Include respective additional fields in the response. */ - actual fun getAllChannelMetadata( + override fun getAllChannelMetadata( limit: Int?, page: PNPage?, filter: String?, @@ -896,7 +897,7 @@ actual interface PubNub : * @param channel Channel name. * @param includeCustom Include respective additional fields in the response. */ - actual fun getChannelMetadata( + override fun getChannelMetadata( channel: String, includeCustom: Boolean, ): GetChannelMetadata @@ -910,7 +911,7 @@ actual interface PubNub : * @param custom Object with supported data types. * @param includeCustom Include respective additional fields in the response. */ - actual fun setChannelMetadata( + override fun setChannelMetadata( channel: String, name: String?, description: String?, @@ -925,7 +926,7 @@ actual interface PubNub : * * @param channel Channel name. */ - actual fun removeChannelMetadata(channel: String): RemoveChannelMetadata + override fun removeChannelMetadata(channel: String): RemoveChannelMetadata /** * Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each. @@ -945,7 +946,7 @@ actual interface PubNub : * Default is `false`. * @param includeCustom Include respective additional fields in the response. */ - actual fun getAllUUIDMetadata( + override fun getAllUUIDMetadata( limit: Int?, page: PNPage?, filter: String?, @@ -960,7 +961,7 @@ actual interface PubNub : * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. * @param includeCustom Include respective additional fields in the response. */ - actual fun getUUIDMetadata( + override fun getUUIDMetadata( uuid: String?, includeCustom: Boolean, ): GetUUIDMetadata @@ -976,7 +977,7 @@ actual interface PubNub : * @param custom Object with supported data types. * @param includeCustom Include respective additional fields in the response. */ - actual fun setUUIDMetadata( + override fun setUUIDMetadata( uuid: String?, name: String?, externalId: String?, @@ -993,7 +994,7 @@ actual interface PubNub : * * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. */ - actual fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata + override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata /** * The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions. @@ -1015,7 +1016,7 @@ actual interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - actual fun getMemberships( + override fun getMemberships( uuid: String?, limit: Int?, page: PNPage?, @@ -1073,7 +1074,7 @@ actual interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - actual fun setMemberships( + override fun setMemberships( channels: List, uuid: String?, limit: Int?, @@ -1106,7 +1107,7 @@ actual interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - actual fun removeMemberships( + override fun removeMemberships( channels: List, uuid: String?, limit: Int?, @@ -1198,7 +1199,7 @@ actual interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - actual fun getChannelMembers( + override fun getChannelMembers( channel: String, limit: Int?, page: PNPage?, @@ -1256,7 +1257,7 @@ actual interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - actual fun setChannelMembers( + override fun setChannelMembers( channel: String, uuids: List, limit: Int?, @@ -1314,7 +1315,7 @@ actual interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - actual fun removeChannelMembers( + override fun removeChannelMembers( channel: String, uuids: List, limit: Int?, @@ -1387,7 +1388,7 @@ actual interface PubNub : * @param cipherKey Key to be used to encrypt uploaded data. If not provided, * cipherKey in @see [PNConfiguration] will be used, if provided. */ - actual fun sendFile( + override fun sendFile( channel: String, fileName: String, inputStream: InputStream, @@ -1405,7 +1406,7 @@ actual interface PubNub : * @param limit Number of files to return. Minimum value is 1, and maximum is 100. Default value is 100. * @param next Previously-returned cursor bookmark for fetching the next page. @see [PNPage.PNNext] */ - actual fun listFiles( + override fun listFiles( channel: String, limit: Int?, next: PNPage.PNNext?, @@ -1418,7 +1419,7 @@ actual interface PubNub : * @param fileName Name under which the uploaded file is stored. * @param fileId Unique identifier for the file, assigned during upload. */ - actual fun getFileUrl( + override fun getFileUrl( channel: String, fileName: String, fileId: String, @@ -1433,7 +1434,7 @@ actual interface PubNub : * @param cipherKey Key to be used to decrypt downloaded data. If a key is not provided, * the SDK uses the cipherKey from the @see [PNConfiguration]. */ - actual fun downloadFile( + override fun downloadFile( channel: String, fileName: String, fileId: String, @@ -1447,7 +1448,7 @@ actual interface PubNub : * @param fileName Name under which the uploaded file is stored. * @param fileId Unique identifier for the file, assigned during upload. */ - actual fun deleteFile( + override fun deleteFile( channel: String, fileName: String, fileId: String, @@ -1477,7 +1478,7 @@ actual interface PubNub : * If not specified, then the history configuration of the key is used. * */ - actual fun publishFileMessage( + override fun publishFileMessage( channel: String, fileName: String, fileId: String, @@ -1505,7 +1506,7 @@ actual interface PubNub : * @param withPresence Also subscribe to related presence channel. * @param withTimetoken A timetoken to start the subscribe loop from. */ - actual fun subscribe( + override fun subscribe( channels: List, channelGroups: List, withPresence: Boolean, @@ -1529,7 +1530,7 @@ actual interface PubNub : * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. */ - actual fun unsubscribe( + override fun unsubscribe( channels: List, channelGroups: List, ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt index 8765015ed..d0fa7244d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt @@ -1,6 +1,5 @@ package com.pubnub.kmp -import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult @@ -11,19 +10,21 @@ import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.api.PubNub +import com.pubnub.kmp.PubNub as PubNubKmp -actual fun createPubNub(config: PNConfiguration): PubNub { +actual fun createPubNub(config: PNConfiguration): PubNubKmp { return PubNub.create(config) } actual fun createEventListener( - pubnub: PubNub, - onMessage: (PubNub, PNMessageResult) -> Unit, - onPresence: (PubNub, PNPresenceEventResult) -> Unit, - onSignal: (PubNub, PNSignalResult) -> Unit, - onMessageAction: (PubNub, PNMessageActionResult) -> Unit, - onObjects: (PubNub, PNObjectEventResult) -> Unit, - onFile: (PubNub, PNFileEventResult) -> Unit + pubnub: PubNubKmp, + onMessage: (PubNubKmp, PNMessageResult) -> Unit, + onPresence: (PubNubKmp, PNPresenceEventResult) -> Unit, + onSignal: (PubNubKmp, PNSignalResult) -> Unit, + onMessageAction: (PubNubKmp, PNMessageActionResult) -> Unit, + onObjects: (PubNubKmp, PNObjectEventResult) -> Unit, + onFile: (PubNubKmp, PNFileEventResult) -> Unit ): EventListener { return object : EventListener { override fun message(pubnub: PubNub, result: PNMessageResult) { @@ -53,8 +54,8 @@ actual fun createEventListener( } actual fun createStatusListener( - pubnub: PubNub, - onStatus: (PubNub, PNStatus) -> Unit + pubnub: PubNubKmp, + onStatus: (PubNubKmp, PNStatus) -> Unit ): StatusListener { return object : StatusListener { override fun status(pubnub: PubNub, status: PNStatus) { From 340db40a2875dc7b456210fa161fe8d255ae8eb6 Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Wed, 19 Jun 2024 15:25:12 +0200 Subject: [PATCH 25/62] File download + File upload (#239) --- .../kotlin/com/pubnub/kmp/Downloadable.ios.kt | 8 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 21 ++++- .../api/endpoints/files/DownloadFile.ios.kt | 34 ++++++++- .../api/endpoints/files/SendFile.ios.kt | 76 ++++++++++++++++++- .../kotlin/com/pubnub/kmp/abstractions.ios.kt | 20 ++++- swift | 2 +- 6 files changed, 154 insertions(+), 7 deletions(-) diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt index 8593b0fae..c5e183ff8 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt @@ -1,3 +1,9 @@ package com.pubnub.kmp -actual abstract class Downloadable \ No newline at end of file +import platform.Foundation.NSInputStream + +actual abstract class Downloadable + +class DownloadableImpl( + private val inputStream: NSInputStream +): Downloadable() \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 8a8ba6b28..21851d85c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -33,6 +33,7 @@ import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroupImpl import com.pubnub.api.endpoints.files.DeleteFile import com.pubnub.api.endpoints.files.DeleteFileImpl import com.pubnub.api.endpoints.files.DownloadFile +import com.pubnub.api.endpoints.files.DownloadFileImpl import com.pubnub.api.endpoints.files.GetFileUrl import com.pubnub.api.endpoints.files.GetFileUrlImpl import com.pubnub.api.endpoints.files.ListFiles @@ -40,6 +41,7 @@ import com.pubnub.api.endpoints.files.ListFilesImpl import com.pubnub.api.endpoints.files.PublishFileMessage import com.pubnub.api.endpoints.files.PublishFileMessageImpl import com.pubnub.api.endpoints.files.SendFile +import com.pubnub.api.endpoints.files.SendFileImpl import com.pubnub.api.endpoints.message_actions.AddMessageAction import com.pubnub.api.endpoints.message_actions.AddMessageActionImpl import com.pubnub.api.endpoints.message_actions.GetMessageActions @@ -797,6 +799,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { pubNubObjC.unsubscribeAll() } + // TODO: cipherKey is used from PubNubConfiguration in Swift SDK override fun sendFile( channel: String, fileName: String, @@ -807,10 +810,24 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { shouldStore: Boolean?, cipherKey: String? ): SendFile { - TODO("Not yet implemented") + return SendFileImpl( + pubnub = pubNubObjC, + channel = channel, + fileName = fileName, + inputStream = inputStream, + message = message, + meta = meta, + ttl = ttl, + shouldStore = shouldStore + ) } override fun downloadFile(channel: String, fileName: String, fileId: String, cipherKey: String?): DownloadFile { - TODO("Not yet implemented") + return DownloadFileImpl( + pubnub = pubNubObjC, + channel = channel, + fileName = fileName, + fileId = fileId + ) } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt index 5dd93aa8c..e5d55f9aa 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt @@ -1,9 +1,41 @@ package com.pubnub.api.endpoints.files +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.downloadFileWithChannel +import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.files.PNDownloadFileResult +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.DownloadableImpl import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler +import kotlinx.cinterop.ExperimentalForeignApi +import platform.Foundation.NSInputStream /** * @see [PubNub.sendFile] */ -actual interface DownloadFile : PNFuture \ No newline at end of file +actual interface DownloadFile : PNFuture + +@OptIn(ExperimentalForeignApi::class) +class DownloadFileImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val fileName: String, + private val fileId: String +): DownloadFile { + override fun async(callback: Consumer>) { + pubnub.downloadFileWithChannel( + channel = channel, + fileName = fileName, + fileId = fileId, + onSuccess = callback.onSuccessHandler { + PNDownloadFileResult( + fileName = it?.name() ?: "", + byteStream = it?.url()?.let { url -> DownloadableImpl(inputStream = NSInputStream(uRL = url)) } + )}, + onFailure = callback.onFailureHandler() + ) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt index 333925128..683800292 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt @@ -1,9 +1,83 @@ package com.pubnub.api.endpoints.files +import cocoapods.PubNubSwift.PubNubDataContentObjC +import cocoapods.PubNubSwift.PubNubFileContentObjC +import cocoapods.PubNubSwift.PubNubInputStreamContentObjC +import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.PubNubUploadableObjC import com.pubnub.api.models.consumer.files.PNFileUploadResult +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.PNFuture +import kotlinx.cinterop.ExperimentalForeignApi +import cocoapods.PubNubSwift.sendFileWithChannel +import com.pubnub.api.PubNubException +import com.pubnub.api.models.consumer.files.PNBaseFile +import com.pubnub.kmp.DataUploadContent +import com.pubnub.kmp.FileUploadContent +import com.pubnub.kmp.StreamUploadContent +import com.pubnub.kmp.Uploadable +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler2 +import platform.Foundation.NSInputStream +import platform.Foundation.NSNumber /** * @see [PubNub.sendFile] */ -actual interface SendFile : PNFuture \ No newline at end of file +actual interface SendFile : PNFuture + +@OptIn(ExperimentalForeignApi::class) +class SendFileImpl( + private val pubnub: PubNubObjC, + private val channel: String, + private val fileName: String, + private val inputStream: Uploadable, + private val message: Any?, + private val meta: Any?, + private val ttl: Int?, + private val shouldStore: Boolean?, +): SendFile { + override fun async(callback: Consumer>) { + mapContent(inputStream)?.let { content -> + pubnub.sendFileWithChannel( + channel = channel, + fileName = fileName, + message = message, + content = content, + meta = meta, + ttl = ttl?.let { NSNumber(it) }, + shouldStore = shouldStore?.let { NSNumber(it) }, + onSuccess = callback.onSuccessHandler2 { uploadedFile, timetoken -> + PNFileUploadResult( + status = 200, + timetoken = timetoken.toLong(), + file = PNBaseFile( + id = uploadedFile?.id().orEmpty(), + name = uploadedFile?.name().orEmpty() + ) + ) + }, + onFailure = callback.onFailureHandler() + ) + } ?: callback.accept(Result.failure(PubNubException("Invalid argument $inputStream"))) + } + + private fun mapContent(content: Uploadable): PubNubUploadableObjC? { + return when (content) { + is DataUploadContent -> return PubNubDataContentObjC( + data = content.data, + contentType = content.contentType + ) + is FileUploadContent -> PubNubFileContentObjC( + fileURL = content.url + ) + is StreamUploadContent -> PubNubInputStreamContentObjC( + stream = NSInputStream(content.url), + contentType = content.contentType, + contentLength = content.contentLength.toLong() + ) + else -> null + } + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt index b829b6eb4..859a277a3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt @@ -1,5 +1,23 @@ package com.pubnub.kmp +import platform.Foundation.NSData +import platform.Foundation.NSURL + actual class CustomObject(val value: Any) -actual abstract class Uploadable \ No newline at end of file +actual abstract class Uploadable + +data class DataUploadContent( + val data: NSData, + val contentType: String? +): Uploadable() + +data class FileUploadContent( + val url: NSURL +) : Uploadable() + +data class StreamUploadContent( + val url: NSURL, + val contentType: String?, + val contentLength: Int +) : Uploadable() diff --git a/swift b/swift index 2718c2b14..2e9fd11ef 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit 2718c2b14821e01bff066175b769e1dcf1c37807 +Subproject commit 2e9fd11ef7f045398e365593abedbcf1bbab2472 From 482c1b58d8dbb22e2afdc296e63174e8f34ab2da Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Mon, 24 Jun 2024 12:33:56 +0200 Subject: [PATCH 26/62] Wrapping entities and Subscription/SubscriptionSet (#241) --- .../kotlin/com/pubnub/api/PubNubImpl.kt | 12 +- .../pubnub/api/endpoints/FetchMessages.ios.kt | 2 +- .../pubnub/api/endpoints/MessageCounts.ios.kt | 2 +- .../AllChannelsChannelGroup.ios.kt | 2 +- .../channel_groups/ListAllChannelGroup.ios.kt | 2 +- .../api/endpoints/files/DownloadFile.ios.kt | 1 - .../message_actions/AddMessageAction.ios.kt | 6 +- .../message_actions/GetMessageActions.ios.kt | 24 ++- .../api/endpoints/presence/HereNow.ios.kt | 2 +- .../api/endpoints/presence/WhereNow.ios.kt | 2 +- .../api/v2/callbacks/EventListener.ios.kt | 8 +- .../api/v2/callbacks/StatusListener.ios.kt | 6 +- .../internal/entities/ChannelGroupImpl.kt | 22 +++ .../pubnub/internal/entities/ChannelImpl.kt | 62 ++++++++ .../internal/entities/ChannelMetadataImpl.kt | 23 +++ .../internal/entities/UserMetadataImpl.kt | 22 +++ .../internal/subscription/SubscriptionImpl.kt | 69 +++++++++ .../subscription/SubscriptionSetImpl.kt | 86 +++++++++++ .../kotlin/com/pubnub/kmp/Converters.kt | 6 +- .../kotlin/com/pubnub/kmp/factories.ios.kt | 140 +++++++++--------- swift | 2 +- 21 files changed, 400 insertions(+), 101 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 21851d85c..7656dbf5c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -2,6 +2,9 @@ package com.pubnub.api import cocoapods.PubNubSwift.addEventListenerWithListener import cocoapods.PubNubSwift.addStatusListenerWithListener +import cocoapods.PubNubSwift.channelGroupWith +import cocoapods.PubNubSwift.channelMetadataWith +import cocoapods.PubNubSwift.channelWith import cocoapods.PubNubSwift.disconnect import cocoapods.PubNubSwift.setWithToken import cocoapods.PubNubSwift.subscribeWithChannels @@ -120,6 +123,9 @@ import com.pubnub.api.v2.entities.UserMetadata import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet +import com.pubnub.internal.entities.ChannelGroupImpl +import com.pubnub.internal.entities.ChannelImpl +import com.pubnub.internal.entities.ChannelMetadataImpl import com.pubnub.kmp.CustomObject import com.pubnub.kmp.PubNub import com.pubnub.kmp.Uploadable @@ -768,15 +774,15 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun channel(name: String): Channel { - TODO("Not yet implemented") + return ChannelImpl(channel = pubNubObjC.channelWith(name = name)) } override fun channelGroup(name: String): ChannelGroup { - TODO("Not yet implemented") + return ChannelGroupImpl(channelGroup = pubNubObjC.channelGroupWith(name = name)) } override fun channelMetadata(id: String): ChannelMetadata { - TODO("Not yet implemented") + return ChannelMetadataImpl(channelMetadata = pubNubObjC.channelMetadataWith(id = id)) } override fun userMetadata(id: String): UserMetadata { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt index 0e76cd518..07e24a5e0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt @@ -76,7 +76,7 @@ open class FetchMessagesImpl( } private fun mapMessageActions(rawValue: List<*>): Map>> { - return (rawValue as? List)?.groupBy { messageAction -> + return rawValue.filterIsInstance().groupBy { messageAction -> messageAction.actionType() }?.mapValues { entry -> entry.value.groupBy { groupedMessageAction -> diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt index 4c418d936..228c0933a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt @@ -25,7 +25,7 @@ class MessageCountsImpl( pubnub.messageCountsFor( channels = channels, channelsTimetokens = channelsTimetoken, - onSuccess = callback.onSuccessHandler { PNMessageCountResult(it?.channels() as Map) }, + onSuccess = callback.onSuccessHandler { PNMessageCountResult(it as Map) }, onFailure = callback.onFailureHandler() ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt index f88a85d6f..c80b19e74 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt @@ -24,7 +24,7 @@ class AllChannelsChannelGroupImpl( override fun async(callback: Consumer>) { pubnub.listChannelsFor( channelGroup = channelGroup, - onSuccess = callback.onSuccessHandler { PNChannelGroupsAllChannelsResult(channels = it as List) }, + onSuccess = callback.onSuccessHandler { PNChannelGroupsAllChannelsResult(channels = it?.filterIsInstance() ?: emptyList()) }, onFailure = callback.onFailureHandler() ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt index 0736a2d1c..7582c178d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt @@ -21,7 +21,7 @@ class ListAllChannelGroupImpl( ): ListAllChannelGroup { override fun async(callback: Consumer>) { pubnub.listChannelGroupsOnSuccess( - onSuccess = callback.onSuccessHandler { PNChannelGroupsListAllResult(groups = it as List) }, + onSuccess = callback.onSuccessHandler { PNChannelGroupsListAllResult(groups = it?.filterIsInstance() ?: emptyList()) }, onFailure = callback.onFailureHandler() ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt index e5d55f9aa..6620f1a14 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt @@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.files import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.downloadFileWithChannel -import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.files.PNDownloadFileResult import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt index a43767cb8..1137334ae 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt @@ -31,10 +31,10 @@ class AddMessageActionImpl( actionType = actionType, actionValue = actionValue, messageTimetoken = messageTimetoken.toULong(), - onSuccess = callback.onSuccessHandler { PNAddMessageActionResult( + onSuccess = callback.onSuccessHandler { PNAddMessageActionResult( action = PNMessageAction( - type = it?.type() ?: "", - value = it?.value() ?: "", + type = it?.actionType().orEmpty(), + value = it?.actionValue().orEmpty(), messageTimetoken = it?.messageTimetoken()?.toLong() ?: 0 ) )}, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt index 8f838a663..a9b03b77e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt @@ -1,15 +1,20 @@ package com.pubnub.api.endpoints.message_actions import cocoapods.PubNubSwift.PubNubBoundedPageObjC +import cocoapods.PubNubSwift.PubNubMessageActionObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getMessageActionsFrom import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult +import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PubNub +import com.pubnub.kmp.filterAndMap +import com.pubnub.kmp.onSuccessHandler2 import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSNumber @@ -33,17 +38,26 @@ class GetMessageActionsImpl( end = page.end?.let { NSNumber(long = it) }, limit = page.limit?.let { NSNumber(it) } ), - onSuccess = callback.onSuccessHandler { + onSuccess = callback.onSuccessHandler2 { messageActions, next -> PNGetMessageActionsResult( - actions = emptyList(), + actions = messageActions.filterAndMap { rawValue: PubNubMessageActionObjC -> createMessageAction(rawValue) }.toList(), page = PNBoundedPage( - start = it?.next()?.start()?.longValue(), - end = it?.next()?.end()?.longValue(), - limit = it?.next()?.limit()?.intValue() + start = next?.start()?.longValue(), + end = next?.end()?.longValue(), + limit = next?.limit()?.intValue() ) ) + }, onFailure = callback.onFailureHandler() ) } + + private fun createMessageAction(rawValue: PubNubMessageActionObjC): PNMessageAction { + return PNMessageAction( + type = rawValue.actionType(), + value = rawValue.actionValue(), + messageTimetoken = rawValue.messageTimetoken().toLong() + ) + } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt index 766c563d3..9ccff6b33 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt @@ -42,7 +42,7 @@ class HereNowImpl( PNHereNowChannelData( channelName = entry.value.channelName(), occupancy = entry.value.occupancy().toInt(), - occupants = (entry.value.occupants() as? List)?.map { occupant -> + occupants = (entry.value.occupants().filterIsInstance()).map { occupant -> PNHereNowOccupantData( uuid = occupant.uuid(), state = occupant.state() as JsonElement diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt index caeb30e85..45fe0484b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt @@ -24,7 +24,7 @@ class WhereNowImpl( override fun async(callback: Consumer>) { pubnub.whereNowWithUuid( uuid = uuid, - onSuccess = callback.onSuccessHandler { PNWhereNowResult(it as? List ?: emptyList()) }, + onSuccess = callback.onSuccessHandler { PNWhereNowResult(it?.filterIsInstance() ?: emptyList()) }, onFailure = callback.onFailureHandler() ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt index 08f41f9c8..299402c2a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.v2.callbacks -import cocoapods.PubNubSwift.EventListenerObjC +import cocoapods.PubNubSwift.PubNubEventListenerObjC import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult @@ -17,7 +17,7 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) actual interface EventListener : BaseEventListener { - val underlying: EventListenerObjC + val underlying: PubNubEventListenerObjC val onMessage: (PubNub, PNMessageResult) -> Unit val onPresence: (PubNub, PNPresenceEventResult) -> Unit val onSignal: (PubNub, PNSignalResult) -> Unit @@ -27,11 +27,11 @@ actual interface EventListener : BaseEventListener { } @OptIn(ExperimentalForeignApi::class) class EventListenerImpl( - override val underlying: EventListenerObjC, + override val underlying: PubNubEventListenerObjC, override val onMessage: (PubNub, PNMessageResult) -> Unit, override val onPresence: (PubNub, PNPresenceEventResult) -> Unit, override val onSignal: (PubNub, PNSignalResult) -> Unit, override val onMessageAction: (PubNub, PNMessageActionResult) -> Unit, override val onObjects: (PubNub, PNObjectEventResult) -> Unit, override val onFile: (PubNub, PNFileEventResult) -> Unit -): EventListener {} \ No newline at end of file +): EventListener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt index a89ff7120..078e52fcf 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.v2.callbacks -import cocoapods.PubNubSwift.StatusListenerObjC +import cocoapods.PubNubSwift.PubNubStatusListenerObjC import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.PNStatus import com.pubnub.kmp.PubNub @@ -12,12 +12,12 @@ import kotlinx.cinterop.ExperimentalForeignApi */ @OptIn(ExperimentalForeignApi::class) actual interface StatusListener : Listener { - val underlying: StatusListenerObjC + val underlying: PubNubStatusListenerObjC val onStatusChange: (PubNub, PNStatus) -> Unit } @OptIn(ExperimentalForeignApi::class) class StatusListenerImpl( - override val underlying: StatusListenerObjC, + override val underlying: PubNubStatusListenerObjC, override val onStatusChange: (PubNub, PNStatus) -> Unit ): StatusListener {} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt new file mode 100644 index 000000000..bdcf897b1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt @@ -0,0 +1,22 @@ +package com.pubnub.internal.entities + +import cocoapods.PubNubSwift.PubNubChannelGroupEntityObjC +import cocoapods.PubNubSwift.PubNubSubscriptionObjC +import com.pubnub.api.v2.entities.ChannelGroup +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.subscription.SubscriptionImpl +import kotlinx.cinterop.ExperimentalForeignApi + +@OptIn(ExperimentalForeignApi::class) +class ChannelGroupImpl( + private val channelGroup: PubNubChannelGroupEntityObjC +): ChannelGroup { + override val name: String + get() = channelGroup.name() + + override fun subscription(options: SubscriptionOptions): Subscription { + // TODO: Add support for handling SubscriptionOptions + return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = channelGroup)) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt new file mode 100644 index 000000000..031cda664 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt @@ -0,0 +1,62 @@ +package com.pubnub.internal.entities + +import cocoapods.PubNubSwift.PubNubChannelEntityObjC +import cocoapods.PubNubSwift.PubNubSubscriptionObjC +import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.SendFile +import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.v2.entities.Channel +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.subscription.SubscriptionImpl +import com.pubnub.kmp.Uploadable +import kotlinx.cinterop.ExperimentalForeignApi + +@OptIn(ExperimentalForeignApi::class) +class ChannelImpl( + private val channel: PubNubChannelEntityObjC +): Channel { + override fun publish( + message: Any, + meta: Any?, + shouldStore: Boolean?, + usePost: Boolean, + replicate: Boolean, + ttl: Int? + ): Publish { + TODO("Not yet implemented") + } + + override fun signal(message: Any): Signal { + TODO("Not yet implemented") + } + + override fun fire(message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { + TODO("Not yet implemented") + } + + override fun sendFile( + fileName: String, + inputStream: Uploadable, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, + cipherKey: String? + ): SendFile { + TODO("Not yet implemented") + } + + override fun deleteFile(fileName: String, fileId: String): DeleteFile { + TODO("Not yet implemented") + } + + override val name: String + get() = channel.name() + + override fun subscription(options: SubscriptionOptions): Subscription { + // TODO: Add support for handling SubscriptionOptions + return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = channel)) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt new file mode 100644 index 000000000..650e01adc --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt @@ -0,0 +1,23 @@ +package com.pubnub.internal.entities + +import cocoapods.PubNubSwift.PubNubChannelMetadataEntityObjC +import cocoapods.PubNubSwift.PubNubChannelMetadataObjC +import cocoapods.PubNubSwift.PubNubSubscriptionObjC +import com.pubnub.api.v2.entities.ChannelMetadata +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.subscription.SubscriptionImpl +import kotlinx.cinterop.ExperimentalForeignApi + +@OptIn(ExperimentalForeignApi::class) +class ChannelMetadataImpl( + private val channelMetadata: PubNubChannelMetadataEntityObjC +): ChannelMetadata { + override val id: String + get() = channelMetadata.name() + + override fun subscription(options: SubscriptionOptions): Subscription { + // TODO: Add support for handling SubscriptionOptions + return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = channelMetadata)) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt new file mode 100644 index 000000000..7851408be --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt @@ -0,0 +1,22 @@ +package com.pubnub.internal.entities + +import cocoapods.PubNubSwift.PubNubSubscriptionObjC +import cocoapods.PubNubSwift.PubNubUserMetadataEntityObjC +import com.pubnub.api.v2.entities.UserMetadata +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.subscription.SubscriptionImpl +import kotlinx.cinterop.ExperimentalForeignApi + +@OptIn(ExperimentalForeignApi::class) +class UserMetadataImpl( + private val userMetadata: PubNubUserMetadataEntityObjC +): UserMetadata { + override val id: String + get() = userMetadata.name() + + override fun subscription(options: SubscriptionOptions): Subscription { + // TODO: Add support for handling SubscriptionOptions + return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = userMetadata)) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt new file mode 100644 index 000000000..878065f78 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt @@ -0,0 +1,69 @@ +package com.pubnub.internal.subscription + +import cocoapods.PubNubSwift.PubNubSubscriptionObjC +import com.pubnub.api.PubNubException +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionCursor +import com.pubnub.api.v2.subscriptions.SubscriptionSet +import kotlinx.cinterop.ExperimentalForeignApi + +@OptIn(ExperimentalForeignApi::class) +class SubscriptionImpl( + val objCSubscription: PubNubSubscriptionObjC +) : Subscription { + + override fun close() { + objCSubscription.dispose() + } + + override fun addListener(listener: EventListener) { + objCSubscription.addListener(listener = listener.underlying) + } + + override fun removeListener(listener: Listener) { + (listener as? EventListener)?.let { objCSubscription.removeListener(it.underlying) } + } + + override fun removeAllListeners() { + objCSubscription.removeAllListeners() + } + + override fun subscribe(cursor: SubscriptionCursor) { + objCSubscription.subscribeWith(timetoken = cursor.timetoken.toULong()) + } + + override fun unsubscribe() { + objCSubscription.unsubscribe() + } + + override var onMessage: ((PNMessageResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + override var onPresence: ((PNPresenceEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + override var onSignal: ((PNSignalResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + override var onMessageAction: ((PNMessageActionResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + override var onObjects: ((PNObjectEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + override var onFile: ((PNFileEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + + override fun plus(subscription: Subscription): SubscriptionSet { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt new file mode 100644 index 000000000..db0bfa5a1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt @@ -0,0 +1,86 @@ +package com.pubnub.internal.subscription + +import cocoapods.PubNubSwift.PubNubSubscriptionSetObjC +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionCursor +import com.pubnub.api.v2.subscriptions.SubscriptionSet +import kotlinx.cinterop.ExperimentalForeignApi + +@OptIn(ExperimentalForeignApi::class) +class SubscriptionSetImpl( + private val objCSubscriptionSet: PubNubSubscriptionSetObjC +): SubscriptionSet { + override fun close() { + objCSubscriptionSet.dispose() + } + + override fun addListener(listener: EventListener) { + objCSubscriptionSet.addListener(listener = listener.underlying) + } + + override fun removeListener(listener: Listener) { + (listener as? EventListener)?.let { objCSubscriptionSet.removeListener(it.underlying) } + } + + override fun removeAllListeners() { + objCSubscriptionSet.removeAllListeners() + } + + override fun add(subscription: Subscription) { + TODO("Not yet implemented") + } + + override fun remove(subscription: Subscription) { + TODO("Not yet implemented") + } + + override val subscriptions: Set + get() = TODO("Not yet implemented") + + override fun subscribe(cursor: SubscriptionCursor) { + TODO("Not yet implemented") + } + + override fun unsubscribe() { + TODO("Not yet implemented") + } + + override var onMessage: ((PNMessageResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + + override var onPresence: ((PNPresenceEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + + override var onSignal: ((PNSignalResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + override var onMessageAction: ((PNMessageActionResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + + override var onObjects: ((PNObjectEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + + override var onFile: ((PNFileEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + + override fun plusAssign(subscription: Subscription) { + TODO("Not yet implemented") + } + + override fun minusAssign(subscription: Subscription) { + TODO("Not yet implemented") + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt index 3226617e8..9c7242298 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt @@ -3,7 +3,7 @@ package com.pubnub.kmp import cocoapods.PubNubSwift.PubNubChannelMetadataObjC import cocoapods.PubNubSwift.PubNubHashedPageObjC import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC -import cocoapods.PubNubSwift.PubNubSortPropertyObjC +import cocoapods.PubNubSwift.PubNubObjectSortPropertyObjC import cocoapods.PubNubSwift.PubNubUUIDMetadataObjC import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNPage @@ -62,9 +62,9 @@ internal fun createPNChannelMetadata(from: PubNubChannelMetadataObjC): PNChannel } @OptIn(ExperimentalForeignApi::class) -internal fun createObjectSortProperties(from: Collection>) : List { +internal fun createObjectSortProperties(from: Collection>) : List { return from.map { - PubNubSortPropertyObjC( + PubNubObjectSortPropertyObjC( key = it.key.fieldName, direction = it.dir ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 640a26401..eaf51233a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -1,7 +1,6 @@ package com.pubnub.kmp -import cocoapods.PubNubSwift.EventListenerObjC -import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjC +import cocoapods.PubNubSwift.PubNubAppContextEventObjC import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCConnected import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCConnectionError import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCDisconnected @@ -10,19 +9,18 @@ import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCHeartbeatFailed import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCHeartbeatSuccess import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCMalformedResponseCategory import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCSubscriptionChanged -import cocoapods.PubNubSwift.PubNubDeleteChannelMetadataEventMessageObjC -import cocoapods.PubNubSwift.PubNubDeleteMembershipEventMessageObjC -import cocoapods.PubNubSwift.PubNubDeleteUUIDMetadataEventMessageObjC -import cocoapods.PubNubSwift.PubNubFileEventResultObjC +import cocoapods.PubNubSwift.PubNubEventListenerObjC +import cocoapods.PubNubSwift.PubNubFileChangeEventObjC import cocoapods.PubNubSwift.PubNubMessageActionObjC import cocoapods.PubNubSwift.PubNubMessageObjC -import cocoapods.PubNubSwift.PubNubObjectEventMessageObjC -import cocoapods.PubNubSwift.PubNubObjectEventResultObjC -import cocoapods.PubNubSwift.PubNubPresenceEventResultObjC -import cocoapods.PubNubSwift.PubNubSetChannelMetadataEventMessageObjC -import cocoapods.PubNubSwift.PubNubSetMembershipEventMessageObjC -import cocoapods.PubNubSwift.PubNubSetUUIDMetadataEventMessageObjC -import cocoapods.PubNubSwift.StatusListenerObjC +import cocoapods.PubNubSwift.PubNubPresenceChangeObjC +import cocoapods.PubNubSwift.PubNubRemoveChannelMetadataResultObjC +import cocoapods.PubNubSwift.PubNubRemoveMembershipResultObjC +import cocoapods.PubNubSwift.PubNubRemoveUUIDMetadataResultObjC +import cocoapods.PubNubSwift.PubNubSetChannelMetadataResultObjC +import cocoapods.PubNubSwift.PubNubSetMembershipResultObjC +import cocoapods.PubNubSwift.PubNubSetUUIDMetadataResultObjC +import cocoapods.PubNubSwift.PubNubStatusListenerObjC import com.pubnub.api.JsonElementImpl import com.pubnub.api.PubNubException import com.pubnub.api.PubNubImpl @@ -70,7 +68,7 @@ actual fun createEventListener( onFile: (PubNub, PNFileEventResult) -> Unit ): EventListener { return EventListenerImpl( - underlying = EventListenerObjC( + underlying = PubNubEventListenerObjC( onMessage = { onMessage(pubnub, createMessageResult(it)) }, onPresence = { presenceEvents -> createPresenceEventResults(presenceEvents).forEach { onPresence(pubnub, it) } }, onSignal = { onSignal(pubnub, createSignalResult(it)) }, @@ -137,29 +135,27 @@ private fun createMessageActionResult(from: PubNubMessageActionObjC?): PNMessage @OptIn(ExperimentalForeignApi::class) private fun createPresenceEventResults(from: List<*>?): List { - return (from as List).let { - it.map { item: PubNubPresenceEventResultObjC -> - PNPresenceEventResult( - event = item.event(), - uuid = item.uuid(), - timestamp = item.timetoken()?.longValue, - occupancy = item.occupancy()?.intValue, - state = JsonElementImpl(item.state()), - channel = item.channel() ?: "", - subscription = item.subscription(), - timetoken = item.timetoken()?.longValue, - join = item.join() as? List, - leave = item.leave() as? List, - timeout = item.timeout() as? List, - hereNowRefresh = item.refreshHereNow()?.boolValue, - userMetadata = JsonElementImpl(item.userMetadata()) - ) - } - } + return from.filterAndMap { rawValue: PubNubPresenceChangeObjC -> + PNPresenceEventResult( + event = rawValue.event(), + uuid = rawValue.uuid(), + timestamp = rawValue.timetoken()?.longValue, + occupancy = rawValue.occupancy()?.intValue, + state = JsonElementImpl(rawValue.state()), + channel = rawValue.channel().orEmpty(), + subscription = rawValue.subscription(), + timetoken = rawValue.timetoken()?.longValue, + join = rawValue.join()?.filterIsInstance(), + leave = rawValue.leave()?.filterIsInstance(), + timeout = rawValue.timeout()?.filterIsInstance(), + hereNowRefresh = rawValue.refreshHereNow()?.boolValue, + userMetadata = JsonElementImpl(rawValue.userMetadata()) + ) + }.toList() } @OptIn(ExperimentalForeignApi::class) -private fun createFileEventResult(from: PubNubFileEventResultObjC?): PNFileEventResult { +private fun createFileEventResult(from: PubNubFileChangeEventObjC?): PNFileEventResult { return PNFileEventResult( channel = from!!.channel(), timetoken = from.timetoken()?.longValue, @@ -175,8 +171,8 @@ private fun createFileEventResult(from: PubNubFileEventResultObjC?): PNFileEvent } @OptIn(ExperimentalForeignApi::class) -private fun createObjectEvent(from: PubNubObjectEventResultObjC?): PNObjectEventResult? { - return mapObjectMessage(from?.message())?.let { +private fun createObjectEvent(from: PubNubAppContextEventObjC?): PNObjectEventResult? { + return mapAppContextEvent(from)?.let { PNObjectEventResult( result = BasePubSubResult( channel = from!!.channel(), @@ -190,28 +186,28 @@ private fun createObjectEvent(from: PubNubObjectEventResultObjC?): PNObjectEvent } @OptIn(ExperimentalForeignApi::class) -private fun mapObjectMessage(from: PubNubObjectEventMessageObjC?): PNObjectEventMessage? { +private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventMessage? { when (from) { - is PubNubSetUUIDMetadataEventMessageObjC -> + is PubNubSetUUIDMetadataResultObjC -> return PNSetUUIDMetadataEventMessage( source = from.source(), version = from.version(), event = from.event(), type = from.type(), data = PNUUIDMetadata( - id = from.data().id(), - name = from.data().name(), - externalId = from.data().externalId(), - profileUrl = from.data().profileUrl(), - email = from.data().email(), - custom = from.data().custom() as? Map, // TODO: Verify - updated = from.data().updated(), - eTag = from.data().eTag(), - type = from.data().type(), - status = from.data().status() + id = from.metadata().id(), + name = from.metadata().name(), + externalId = from.metadata().externalId(), + profileUrl = from.metadata().profileUrl(), + email = from.metadata().email(), + custom = from.metadata().custom() as? Map, // TODO: Verify + updated = from.metadata().updated(), + eTag = from.metadata().eTag(), + type = from.metadata().type(), + status = from.metadata().status() ) ) - is PubNubDeleteUUIDMetadataEventMessageObjC -> + is PubNubRemoveUUIDMetadataResultObjC -> return PNDeleteUUIDMetadataEventMessage( source = from.source(), version = from.version(), @@ -219,24 +215,24 @@ private fun mapObjectMessage(from: PubNubObjectEventMessageObjC?): PNObjectEvent type = from.type(), uuid = from.uuid() ) - is PubNubSetChannelMetadataEventMessageObjC -> + is PubNubSetChannelMetadataResultObjC -> return PNSetChannelMetadataEventMessage( source = from.source(), version = from.version(), event = from.event(), type = from.type(), data = PNChannelMetadata( - id = from.data().id(), - name = from.data().name(), - description = from.data().descr(), - custom = from.data().custom() as? Map, // TODO: Verify - updated = from.data().updated(), - eTag = from.data().eTag(), - type = from.data().type(), - status = from.data().status() + id = from.metadata().id(), + name = from.metadata().name(), + description = from.metadata().descr(), + custom = from.metadata().custom() as? Map, // TODO: Verify + updated = from.metadata().updated(), + eTag = from.metadata().eTag(), + type = from.metadata().type(), + status = from.metadata().status() ) ) - is PubNubDeleteChannelMetadataEventMessageObjC -> + is PubNubRemoveChannelMetadataResultObjC -> return PNDeleteChannelMetadataEventMessage( source = from.source(), version = from.version(), @@ -244,30 +240,30 @@ private fun mapObjectMessage(from: PubNubObjectEventMessageObjC?): PNObjectEvent type = from.type(), channel = from.channel() ) - is PubNubSetMembershipEventMessageObjC -> + is PubNubSetMembershipResultObjC -> return PNSetMembershipEventMessage( source = from.source(), version = from.version(), event = from.event(), type = from.type(), data = PNSetMembershipEvent( - channel = from.data().channel(), - uuid = from.data().uuid(), - custom = from.data().custom() as? Map, // TODO: Verify, - eTag = from.data().eTag(), - updated = from.data().updated(), - status = from.data().status() + channel = from.metadata().channel()?.name().orEmpty(), + uuid = from.metadata().uuid()?.id().orEmpty(), + custom = from.metadata().custom() as? Map, // TODO: Verify, + eTag = from.metadata().eTag().orEmpty(), + updated = from.metadata().updated().orEmpty(), + status = from.metadata().status().orEmpty() ) ) - is PubNubDeleteMembershipEventMessageObjC -> + is PubNubRemoveMembershipResultObjC -> return PNDeleteMembershipEventMessage( source = from.source(), version = from.version(), event = from.event(), type = from.type(), data = PNDeleteMembershipEvent( - channelId = from.data().channelId(), - uuid = from.data().uuid() + channelId = from.channelId(), + uuid = from.uuid() ) ) else -> return null @@ -280,7 +276,7 @@ actual fun createStatusListener( onStatus: (PubNub, PNStatus) -> Unit ): StatusListener { return StatusListenerImpl( - underlying = StatusListenerObjC(onStatusChange = { status -> + underlying = PubNubStatusListenerObjC(onStatusChange = { status -> when (status?.category()) { PubNubConnectionStatusCategoryObjCConnected -> PNStatusCategory.PNConnectedCategory @@ -305,8 +301,8 @@ actual fun createStatusListener( category = category, exception = status?.error()?.let { error -> PubNubException(errorMessage = error.localizedDescription) }, currentTimetoken = status?.currentTimetoken()?.longValue(), - affectedChannels = status?.affectedChannels() as Set, - affectedChannelGroups = status?.affectedChannelGroups() as Set + affectedChannels = status?.affectedChannels()?.filterIsInstance()?.toSet() ?: emptySet(), + affectedChannelGroups = status?.affectedChannelGroups()?.filterIsInstance()?.toSet() ?: emptySet() ) ) } diff --git a/swift b/swift index 2e9fd11ef..4a9eebda3 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit 2e9fd11ef7f045398e365593abedbcf1bbab2472 +Subproject commit 4a9eebda3f3796b18ce712f839952176b4c688e4 From 539be2141090bcda53969df21a70e99c0fdf87ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:32:55 +0000 Subject: [PATCH 27/62] Add IncludeType, fix futures.awaitAll and listener classcastexception on JS (#240) * Changes for integration tests, add includeType * Add includeType and fix PNFuture * Listener fixes --- .../kotlin/com/pubnub/kmp/futures.kt | 58 +++++++++---------- .../kotlin/com/pubnub/kmp/PNFutureTest.kt | 6 +- .../kotlin/com/pubnub/internal/PubNubCore.kt | 20 +++++-- .../objects/internal/IncludeQueryParam.kt | 8 +++ .../members/GetChannelMembersImpl.java | 4 +- .../members/ManageChannelMembersImpl.java | 4 +- .../members/RemoveChannelMembersImpl.java | 4 +- .../members/SetChannelMembersImpl.java | 3 +- .../memberships/GetMembershipsImpl.java | 4 +- .../memberships/ManageMembershipsImpl.java | 4 +- .../memberships/RemoveMembershipsImpl.java | 4 +- .../memberships/SetMembershipsImpl.java | 4 +- .../kotlin/com/pubnub/kmp/PubNub.kt | 6 ++ .../com/pubnub/api/ChannelMetadataTest.kt | 3 - .../kotlin/com/pubnub/api/MembersTest.kt | 12 ---- .../kotlin/com/pubnub/api/MembershipsTest.kt | 6 -- .../kotlin/com/pubnub/api/UserMetadataTest.kt | 1 - .../kotlin/com/pubnub/api/PubNubImpl.kt | 18 ++++-- .../kotlin/com/pubnub/api/PubNubImpl.kt | 54 +++++++++-------- .../kotlin/com/pubnub/kmp/factories.js.kt | 8 +-- .../jvmMain/kotlin/com/pubnub/api/PubNub.kt | 7 +++ .../api/integration/ObjectsIntegrationTest.kt | 4 +- .../kotlin/com/pubnub/internal/PubNubImpl.kt | 13 +++++ .../pubnub-kotlin-test/build.gradle.kts | 29 +++++----- .../com.pubnub.test}/BaseIntegrationTest.kt | 8 ++- 25 files changed, 172 insertions(+), 120 deletions(-) rename pubnub-kotlin/{pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test => pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test}/BaseIntegrationTest.kt (97%) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt index 8aee3db64..ddd80df96 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt @@ -62,40 +62,36 @@ fun PNFuture.alsoAsync(action: (T) -> PNFuture<*>): PNFuture = } -fun PNFuture.catch(action: (Exception) -> Result): PNFuture = object : PNFuture { - override fun async(callback: Consumer>) { - this@catch.async { result: Result -> - result.onSuccess { - callback.accept(result) - }.onFailure { - try { - callback.accept(action(it)) - } catch (e: Exception) { - callback.accept(Result.failure(e)) - } +fun PNFuture.catch(action: (Exception) -> Result): PNFuture = PNFuture { callback -> + this@catch.async { result: Result -> + result.onSuccess { + callback.accept(result) + }.onFailure { + try { + callback.accept(action(it)) + } catch (e: Exception) { + callback.accept(Result.failure(e)) } } } } -fun Collection>.awaitAll(): PNFuture> = object : PNFuture> { - override fun async(callback: Consumer>>) { - val counter = atomic(0) - val failed = atomic(false) - val array = Array(size) { null } - forEachIndexed { index, future -> - future.async { res -> - res.onSuccess { value -> - array[index] = value - val counterIncremented = counter.incrementAndGet() - if (counterIncremented == size) { - callback.accept(Result.success(array as Array)) - } - }.onFailure { exception -> - val failedWasSetPreviously = failed.getAndSet(true) - if (!failedWasSetPreviously) { - callback.accept(Result.failure(exception)) - } +fun Collection>.awaitAll(): PNFuture> = PNFuture { callback -> + val counter = atomic(0) + val failed = atomic(false) + val array = Array(size) { null } + forEachIndexed { index, future -> + future.async { res -> + res.onSuccess { value -> + array[index] = value + val counterIncremented = counter.incrementAndGet() + if (counterIncremented == size) { + callback.accept(Result.success(array.toList() as List)) + } + }.onFailure { exception -> + val failedWasSetPreviously = failed.getAndSet(true) + if (!failedWasSetPreviously) { + callback.accept(Result.failure(exception)) } } } @@ -103,11 +99,11 @@ fun Collection>.awaitAll(): PNFuture> = object : PNFut } @Suppress("UNCHECKED_CAST") -fun awaitAll(future1: PNFuture, future2: PNFuture): PNFuture> = listOf(future1 as PNFuture, future2 as PNFuture).awaitAll().then { it: Array -> +fun awaitAll(future1: PNFuture, future2: PNFuture): PNFuture> = listOf(future1 as PNFuture, future2 as PNFuture).awaitAll().then { it: List -> Pair(it[0] as T, it[1] as U) } @Suppress("UNCHECKED_CAST") -fun awaitAll(future1: PNFuture, future2: PNFuture, future3: PNFuture): PNFuture> = listOf(future1 as PNFuture, future2 as PNFuture, future3 as PNFuture).awaitAll().then { it: Array -> +fun awaitAll(future1: PNFuture, future2: PNFuture, future3: PNFuture): PNFuture> = listOf(future1 as PNFuture, future2 as PNFuture, future3 as PNFuture).awaitAll().then { it: List -> Triple(it[0] as T, it[1] as U, it[2] as X) } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt index 8cae29657..975087aab 100644 --- a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt +++ b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt @@ -52,13 +52,13 @@ class PNFutureTest { val value1 = true val value2 = 1 val value3: Any? = null - var set: Array? = null - listOf>(value1.asFuture(), value2.asFuture(), value3.asFuture()).awaitAll().async { result: Result> -> + var set: List? = null + listOf>(value1.asFuture(), value2.asFuture(), value3.asFuture()).awaitAll().async { result: Result> -> assertTrue { result.isSuccess } result.onSuccess { set = it } } - assertContentEquals(arrayOf(value1, value2, value3), set) + assertContentEquals(listOf(value1, value2, value3), set) } } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt index 9040bd819..142783209 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt @@ -1315,6 +1315,7 @@ class PubNubCore internal constructor( includeCount: Boolean = false, includeCustom: Boolean = false, includeChannelDetails: PNChannelDetailsLevel? = null, + includeType: Boolean = false, ) = GetMembershipsEndpoint( pubnub = this, uuid = uuid ?: configuration.userId.value, @@ -1330,7 +1331,7 @@ class PubNubCore internal constructor( IncludeQueryParam( includeCustom = includeCustom, includeChannelDetails = includeChannelDetails, - includeType = false, + includeChannelType = includeType, ), ) @@ -1401,6 +1402,7 @@ class PubNubCore internal constructor( includeCount: Boolean = false, includeCustom: Boolean = false, includeChannelDetails: PNChannelDetailsLevel? = null, + includeType: Boolean = false ) = manageMemberships( channelsToSet = channels, channelsToRemove = listOf(), @@ -1412,6 +1414,7 @@ class PubNubCore internal constructor( includeCount = includeCount, includeCustom = includeCustom, includeChannelDetails = includeChannelDetails, + includeType = includeType ) /** @@ -1445,6 +1448,7 @@ class PubNubCore internal constructor( includeCount: Boolean = false, includeCustom: Boolean = false, includeChannelDetails: PNChannelDetailsLevel? = null, + includeType: Boolean = false, ) = manageMemberships( channelsToSet = listOf(), channelsToRemove = channels, @@ -1456,6 +1460,7 @@ class PubNubCore internal constructor( includeCount = includeCount, includeCustom = includeCustom, includeChannelDetails = includeChannelDetails, + includeType = includeType, ) /** @@ -1491,6 +1496,7 @@ class PubNubCore internal constructor( includeCount: Boolean = false, includeCustom: Boolean = false, includeChannelDetails: PNChannelDetailsLevel? = null, + includeType: Boolean = false, ) = ManageMembershipsEndpoint( pubnub = this, channelsToSet = channelsToSet, @@ -1508,7 +1514,7 @@ class PubNubCore internal constructor( IncludeQueryParam( includeCustom = includeCustom, includeChannelDetails = includeChannelDetails, - includeType = false, + includeChannelType = includeType, ), ) @@ -1575,6 +1581,7 @@ class PubNubCore internal constructor( includeCount: Boolean = false, includeCustom: Boolean = false, includeUUIDDetails: PNUUIDDetailsLevel? = null, + includeType: Boolean = false, ) = GetChannelMembersEndpoint( pubnub = this, channel = channel, @@ -1590,7 +1597,7 @@ class PubNubCore internal constructor( IncludeQueryParam( includeCustom = includeCustom, includeUUIDDetails = includeUUIDDetails, - includeType = false, + includeUuidType = includeType, ), ) @@ -1661,6 +1668,7 @@ class PubNubCore internal constructor( includeCount: Boolean = false, includeCustom: Boolean = false, includeUUIDDetails: PNUUIDDetailsLevel? = null, + includeType: Boolean = false, ) = manageChannelMembers( channel = channel, uuidsToSet = uuids, @@ -1672,6 +1680,7 @@ class PubNubCore internal constructor( includeCount = includeCount, includeCustom = includeCustom, includeUUIDDetails = includeUUIDDetails, + includeType = includeType ) /** @@ -1740,6 +1749,7 @@ class PubNubCore internal constructor( includeCount: Boolean = false, includeCustom: Boolean = false, includeUUIDDetails: PNUUIDDetailsLevel? = null, + includeType: Boolean = false, ) = manageChannelMembers( channel = channel, uuidsToSet = listOf(), @@ -1751,6 +1761,7 @@ class PubNubCore internal constructor( includeCount = includeCount, includeCustom = includeCustom, includeUUIDDetails = includeUUIDDetails, + includeType = includeType, ) /** @@ -1786,6 +1797,7 @@ class PubNubCore internal constructor( includeCount: Boolean = false, includeCustom: Boolean = false, includeUUIDDetails: PNUUIDDetailsLevel? = null, + includeType: Boolean = false, ) = ManageChannelMembersEndpoint( pubnub = this, channel = channel, @@ -1803,7 +1815,7 @@ class PubNubCore internal constructor( IncludeQueryParam( includeCustom = includeCustom, includeUUIDDetails = includeUUIDDetails, - includeType = false, + includeUuidType = includeType, ), ) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/IncludeQueryParam.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/IncludeQueryParam.kt index b8ef56390..0e2c07575 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/IncludeQueryParam.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/IncludeQueryParam.kt @@ -9,6 +9,8 @@ data class IncludeQueryParam( private val includeUUIDDetails: PNUUIDDetailsLevel? = null, private val includeType: Boolean = true, private val includeStatus: Boolean = true, + private val includeChannelType: Boolean = false, + private val includeUuidType: Boolean = false ) { internal fun createIncludeQueryParams(): Map { val includeList = mutableListOf() @@ -28,6 +30,12 @@ data class IncludeQueryParam( if (includeType) { includeList.add("type") } + if (includeChannelType) { + includeList.add("channel.type") + } + if (includeUuidType) { + includeList.add("uuid.type") + } if (includeStatus) { includeList.add("status") } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/GetChannelMembersImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/GetChannelMembersImpl.java index 270f77973..80891a154 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/GetChannelMembersImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/GetChannelMembersImpl.java @@ -30,6 +30,7 @@ public class GetChannelMembersImpl extends DelegatingEndpoint sort = Collections.emptyList(); private boolean includeTotalCount; private boolean includeCustom; + private boolean includeType; private Include.PNUUIDDetailsLevel includeUUID; public GetChannelMembersImpl(String channel, final PubNubCore pubnubInstance) { @@ -53,7 +54,8 @@ protected EndpointInterface createAction() { SetChannelMembersImpl.toInternal(sort), includeTotalCount, includeCustom, - SetChannelMembersImpl.toInternal(includeUUID) + SetChannelMembersImpl.toInternal(includeUUID), + includeType ); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/ManageChannelMembersImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/ManageChannelMembersImpl.java index e5abb3616..31205ade6 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/ManageChannelMembersImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/ManageChannelMembersImpl.java @@ -35,6 +35,7 @@ public class ManageChannelMembersImpl extends DelegatingEndpoint sort = Collections.emptyList(); private boolean includeTotalCount; private boolean includeCustom; + private boolean includeType; private final String channel; private Include.PNUUIDDetailsLevel includeUUID; private final Collection uuidsToSet; @@ -79,7 +80,8 @@ protected EndpointInterface createAction() { SetChannelMembersImpl.toInternal(sort), includeTotalCount, includeCustom, - SetChannelMembersImpl.toInternal(includeUUID) + SetChannelMembersImpl.toInternal(includeUUID), + includeType ); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/RemoveChannelMembersImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/RemoveChannelMembersImpl.java index a4c8306d1..e6afc5ea9 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/RemoveChannelMembersImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/RemoveChannelMembersImpl.java @@ -33,6 +33,7 @@ public class RemoveChannelMembersImpl extends DelegatingEndpoint sort = Collections.emptyList(); private boolean includeTotalCount; private boolean includeCustom; + private boolean includeType; private final String channel; private final List uuids; private Include.PNUUIDDetailsLevel includeUUID; @@ -64,7 +65,8 @@ protected EndpointInterface createAction() { SetChannelMembersImpl.toInternal(sort), includeTotalCount, includeCustom, - SetChannelMembersImpl.toInternal(includeUUID) + SetChannelMembersImpl.toInternal(includeUUID), + includeType ); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/SetChannelMembersImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/SetChannelMembersImpl.java index bce77ddc6..5893e6c62 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/SetChannelMembersImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/SetChannelMembersImpl.java @@ -38,6 +38,7 @@ public class SetChannelMembersImpl extends DelegatingEndpoint sort = Collections.emptyList(); private boolean includeTotalCount; private boolean includeCustom; + private boolean includeType; private Include.PNUUIDDetailsLevel includeUUID; private final String channel; private final Collection uuids; @@ -61,7 +62,7 @@ protected EndpointInterface createAction() { for (PNUUID uuid : uuids) { memberInputs.add(new PNMember.Partial(uuid.getUuid().getId(), (uuid instanceof PNUUID.UUIDWithCustom) ? ((PNUUID.UUIDWithCustom) uuid).getCustom() : null, uuid.getStatus())); } - return pubnub.setChannelMembers(channel, memberInputs, limit, page, filter, toInternal(sort), includeTotalCount, includeCustom, toInternal(includeUUID)); + return pubnub.setChannelMembers(channel, memberInputs, limit, page, filter, toInternal(sort), includeTotalCount, includeCustom, toInternal(includeUUID), includeType); } static Collection> toInternal(Collection sort) { diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/GetMembershipsImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/GetMembershipsImpl.java index 5b6116ede..be76749dc 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/GetMembershipsImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/GetMembershipsImpl.java @@ -29,6 +29,7 @@ public class GetMembershipsImpl extends DelegatingEndpoint sort = Collections.emptyList(); private boolean includeTotalCount; private boolean includeCustom; + private boolean includeType; private Include.PNChannelDetailsLevel includeChannel; public GetMembershipsImpl(PubNubCore pubnub) { @@ -51,7 +52,8 @@ protected EndpointInterface createAction() { SetMembershipsImpl.toInternal(sort), includeTotalCount, includeCustom, - SetMembershipsImpl.toInternal(includeChannel)); + SetMembershipsImpl.toInternal(includeChannel), + includeType); } } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/ManageMembershipsImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/ManageMembershipsImpl.java index d28539b7f..a3c24e499 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/ManageMembershipsImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/ManageMembershipsImpl.java @@ -34,6 +34,7 @@ public class ManageMembershipsImpl extends DelegatingEndpoint sort = Collections.emptyList(); private boolean includeTotalCount; private boolean includeCustom; + private boolean includeType; private Include.PNChannelDetailsLevel includeChannel; public ManageMembershipsImpl(Collection channelsToSet, Collection channelsToRemove, final PubNubCore pubnubInstance) { @@ -77,7 +78,8 @@ protected EndpointInterface createAction() { SetMembershipsImpl.toInternal(sort), includeTotalCount, includeCustom, - SetMembershipsImpl.toInternal(includeChannel) + SetMembershipsImpl.toInternal(includeChannel), + includeType ); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/RemoveMembershipsImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/RemoveMembershipsImpl.java index d3b2b52b1..b6e4d18cb 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/RemoveMembershipsImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/RemoveMembershipsImpl.java @@ -32,6 +32,7 @@ public class RemoveMembershipsImpl extends DelegatingEndpoint sort = Collections.emptyList(); private boolean includeTotalCount; private boolean includeCustom; + private boolean includeType; private Include.PNChannelDetailsLevel includeChannel; public RemoveMembershipsImpl(@NotNull Collection channelMemberships, final PubNubCore pubnubInstance) { @@ -61,7 +62,8 @@ protected EndpointInterface createAction() { SetMembershipsImpl.toInternal(sort), includeTotalCount, includeCustom, - SetMembershipsImpl.toInternal(includeChannel) + SetMembershipsImpl.toInternal(includeChannel), + includeType ); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/SetMembershipsImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/SetMembershipsImpl.java index 4639bf945..bdcea9834 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/SetMembershipsImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/SetMembershipsImpl.java @@ -37,6 +37,7 @@ public class SetMembershipsImpl extends DelegatingEndpoint sort = Collections.emptyList(); private boolean includeTotalCount; private boolean includeCustom; + private boolean includeType; private Include.PNChannelDetailsLevel includeChannel; public SetMembershipsImpl(@NotNull Collection channelMemberships, final PubNubCore pubnubInstance) { @@ -66,7 +67,8 @@ protected EndpointInterface createAction() { toInternal(sort), includeTotalCount, includeCustom, - toInternal(includeChannel) + toInternal(includeChannel), + includeType ); } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt index 5fc7919cb..36894fd51 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt @@ -290,6 +290,7 @@ interface PubNub { includeCount: Boolean = false, includeCustom: Boolean = false, includeChannelDetails: PNChannelDetailsLevel? = null, + includeType: Boolean = false, ): GetMemberships fun setMemberships( @@ -302,6 +303,7 @@ interface PubNub { includeCount: Boolean = false, includeCustom: Boolean = false, includeChannelDetails: PNChannelDetailsLevel? = null, + includeType: Boolean = false, ): ManageMemberships fun removeMemberships( @@ -314,6 +316,7 @@ interface PubNub { includeCount: Boolean = false, includeCustom: Boolean = false, includeChannelDetails: PNChannelDetailsLevel? = null, + includeType: Boolean = false, ): ManageMemberships // fun manageMemberships( @@ -338,6 +341,7 @@ interface PubNub { includeCount: Boolean = false, includeCustom: Boolean = false, includeUUIDDetails: PNUUIDDetailsLevel? = null, + includeType: Boolean = false, ): GetChannelMembers fun setChannelMembers( @@ -350,6 +354,7 @@ interface PubNub { includeCount: Boolean = false, includeCustom: Boolean = false, includeUUIDDetails: PNUUIDDetailsLevel? = null, + includeType: Boolean = false, ): ManageChannelMembers fun removeChannelMembers( @@ -362,6 +367,7 @@ interface PubNub { includeCount: Boolean = false, includeCustom: Boolean = false, includeUUIDDetails: PNUUIDDetailsLevel? = null, + includeType: Boolean = false, ): ManageChannelMembers // fun manageChannelMembers( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt index f7242c3d5..19bc3c75c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt @@ -1,17 +1,14 @@ package com.pubnub.api import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage -import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage -import com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage import com.pubnub.kmp.createCustomObject import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await import com.pubnub.test.randomString import com.pubnub.test.test import kotlinx.coroutines.test.runTest -import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt index fe8110519..ec356d879 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt @@ -3,25 +3,13 @@ package com.pubnub.api import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.member.PNMember import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel -import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult -import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage -import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage -import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage -import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent -import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage import com.pubnub.kmp.createCustomObject import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await import com.pubnub.test.randomString -import com.pubnub.test.test import kotlinx.coroutines.test.runTest -import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals -import kotlin.test.assertFailsWith import kotlin.test.assertFalse import kotlin.time.Duration.Companion.seconds diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt index 18432d95a..fa4ba479b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt @@ -3,12 +3,8 @@ package com.pubnub.api import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult -import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage -import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage import com.pubnub.kmp.createCustomObject import com.pubnub.test.BaseIntegrationTest @@ -16,10 +12,8 @@ import com.pubnub.test.await import com.pubnub.test.randomString import com.pubnub.test.test import kotlinx.coroutines.test.runTest -import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals -import kotlin.test.assertFailsWith import kotlin.test.assertFalse import kotlin.time.Duration.Companion.seconds diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt index 65533e088..6920ef755 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt @@ -3,7 +3,6 @@ package com.pubnub.api import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 7656dbf5c..aa49deb80 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -555,7 +555,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): GetMemberships { return GetMembershipsImpl( pubnub = pubNubObjC, @@ -579,7 +580,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): ManageMemberships { return AddMembershipsImpl( pubnub = pubNubObjC, @@ -604,7 +606,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): ManageMemberships { return RemoveMembershipsImpl( pubnub = pubNubObjC, @@ -628,7 +631,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, ): GetChannelMembers { return GetChannelMembersImpl( pubnub = pubNubObjC, @@ -652,7 +656,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, ): ManageChannelMembers { return SetChannelMembersImpl( pubnub = pubNubObjC, @@ -677,7 +682,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean ): ManageChannelMembers { return RemoveChannelMembersImpl( pubnub = pubNubObjC, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 4a9b9a46a..0ebef3fcd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -562,7 +562,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): GetMemberships { return GetMembershipsImpl(jsPubNub, createJsObject { this.sort = sort.toJsMap() @@ -574,7 +575,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { this.channelFields = true this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM } - this.channelTypeField = false + this.channelTypeField = includeType this.channelStatusField = true //todo we don't have parameters for all fields here? } @@ -590,7 +591,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): ManageMemberships { return SetMembershipsImpl(jsPubNub, createJsObject { this.sort = sort.toJsMap() @@ -603,14 +605,14 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { this.channelFields = true this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM } - this.channelTypeField = false + this.channelTypeField = includeType this.channelStatusField = true //todo we don't have parameters for all fields here? } this.uuid = uuid this.channels = channels.map { createJsObject { this.id = it.channel - this.custom = it.custom?.toJsObject() + this.custom = it.custom?.adjustCollectionTypes()?.unsafeCast() this.status = status //todo this doesn't seem to get to the server with JS, or cannot read it back } }.toTypedArray() this.limit = limit @@ -626,7 +628,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel? + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): ManageMemberships { return RemoveMembershipsImpl(jsPubNub, createJsObject { this.sort = sort.toJsMap() @@ -639,7 +642,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { this.channelFields = true this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM } - this.channelTypeField = false + this.channelTypeField = includeType this.channelStatusField = true //todo we don't have parameters for all fields here? } @@ -673,7 +676,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, ): GetChannelMembers { return GetChannelMembersImpl(jsPubNub, createJsObject { this.channel = channel @@ -685,7 +689,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.customUUIDFields = true this.customFields = includeCustom this.totalCount = includeCount - this.UUIDTypeField = false + this.UUIDTypeField = includeType //todo we don't have parameters for all fields here } this.sort = sort.toJsMap() @@ -701,13 +705,14 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, ): ManageChannelMembers { return SetChannelMembersImpl(jsPubNub, createJsObject { this.channel = channel this.uuids = uuids.map { createJsObject { this.id = it.uuid - this.custom = it.custom?.toJsObject() + this.custom = it.custom?.adjustCollectionTypes()?.unsafeCast() this.status = status } }.toTypedArray() this.limit = limit @@ -721,6 +726,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.UUIDFields = true if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.customUUIDFields = true // this.UUIDStatusField = true + this.UUIDTypeField = includeType //todo we don't have parameters for all fields here } }) @@ -735,7 +741,8 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { sort: Collection>, includeCount: Boolean, includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel? + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean ): ManageChannelMembers { return RemoveChannelMembersImpl(jsPubNub, createJsObject { this.channel = channel @@ -750,6 +757,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { this.statusField = true if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.UUIDFields = true if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.customUUIDFields = true + this.UUIDTypeField = includeType //todo we don't have parameters for all fields here } }) @@ -946,7 +954,7 @@ fun UUIDMetadata( email.onValue { result.email = it } status.onValue { result.status = it } type.onValue { result.type = it } - custom.onValue { result.custom = it?.toJsObject() } + custom.onValue { result.custom = it?.adjustCollectionTypes()?.unsafeCast() } return result } @@ -962,18 +970,18 @@ fun ChannelMetadata( description.onValue { result.description = it } status.onValue { result.status = it } type.onValue { result.type = it } - custom.onValue { result.custom = it?.toJsObject() } + custom.onValue { result.custom = it?.adjustCollectionTypes()?.unsafeCast() } return result } - -fun Map.toJsObject(): PubNubJs.CustomObject { - val custom = createJsObject { } - entries.forEach { - custom[it.key] = it.value - } - @Suppress("UnsafeCastFromDynamic") - return custom -} +// +//fun Map.toJsObject(): PubNubJs.CustomObject { +// val custom = createJsObject { } +// entries.forEach { +// custom[it.key] = it.value +// } +// @Suppress("UnsafeCastFromDynamic") +// return custom +//} fun PNConfiguration.toJs(): PubNubJs.PNConfiguration { val config: PubNubJs.PNConfiguration = createJsObject() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt index 89ec315d2..b4bf331e3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt @@ -38,7 +38,7 @@ actual fun createEventListener( onObjects: (PubNub, PNObjectEventResult) -> Unit, onFile: (PubNub, PNFileEventResult) -> Unit ): EventListener { - val listener = object : PubNubJs.ListenerParameters { + val listener = object : PubNubJs.ListenerParameters, EventListener { override val message: (PubNubJs.MessageEvent) -> Unit = { messageEvent -> onMessage( pubnub, PNMessageResult( @@ -196,14 +196,14 @@ actual fun createEventListener( )) } } - return listener.asDynamic() + return listener } actual fun createStatusListener( pubnub: PubNub, onStatus: (PubNub, PNStatus) -> Unit ): StatusListener { - val listener = object : PubNubJs.StatusListenerParameters { + val listener = object : PubNubJs.StatusListenerParameters, StatusListener { override val status: ((statusEvent: PubNubJs.StatusEvent) -> Unit) = { statusEvent -> onStatus( pubnub, PNStatus( @@ -216,7 +216,7 @@ actual fun createStatusListener( ) } } - return listener.asDynamic() + return listener } actual fun createCustomObject(map: Map): CustomObject { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index 1b51bf96b..e53791e34 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -1025,6 +1025,7 @@ interface PubNub : includeCount: Boolean, includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): GetMemberships /** @@ -1084,6 +1085,7 @@ interface PubNub : includeCount: Boolean, includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): ManageMemberships /** @@ -1117,6 +1119,7 @@ interface PubNub : includeCount: Boolean, includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): ManageMemberships /** @@ -1152,6 +1155,7 @@ interface PubNub : includeCount: Boolean = false, includeCustom: Boolean = false, includeChannelDetails: PNChannelDetailsLevel? = null, + includeType: Boolean = false, ): ManageMemberships /** @@ -1208,6 +1212,7 @@ interface PubNub : includeCount: Boolean, includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, ): GetChannelMembers /** @@ -1267,6 +1272,7 @@ interface PubNub : includeCount: Boolean, includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, ): ManageChannelMembers /** @@ -1325,6 +1331,7 @@ interface PubNub : includeCount: Boolean, includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, ): ManageChannelMembers /** diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt index 3ff2954c1..5f292ef73 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt @@ -329,9 +329,9 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { ).sync() pubnub.manageMemberships( - uuid = testUuid, channelsToSet = listOf(PNChannelMembership.Partial(channelId = otherChannel, status = status)), channelsToRemove = listOf(), + uuid = testUuid, ).sync() val getAllResult = @@ -361,9 +361,9 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { val removeResult = pubnub.manageMemberships( - uuid = testUuid, channelsToSet = listOf(), channelsToRemove = listOf(channel, otherChannel), + uuid = testUuid, ).sync().data assertThat( diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt index f8eea5267..5adbe8c01 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt @@ -846,6 +846,7 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): GetMemberships { return com.pubnub.internal.endpoints.objects.membership.GetMembershipsImpl( pubNubCore.getMemberships( @@ -857,6 +858,7 @@ class PubNubImpl( includeCount, includeCustom, includeChannelDetails.toInternal(), + includeType ), ) } @@ -871,6 +873,7 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): ManageMemberships { return com.pubnub.internal.endpoints.objects.membership.ManageMembershipsImpl( pubNubCore.setMemberships( @@ -883,6 +886,7 @@ class PubNubImpl( includeCount, includeCustom, includeChannelDetails.toInternal(), + includeType ), ) } @@ -897,6 +901,7 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): ManageMemberships { return com.pubnub.internal.endpoints.objects.membership.ManageMembershipsImpl( pubNubCore.removeMemberships( @@ -909,6 +914,7 @@ class PubNubImpl( includeCount, includeCustom, includeChannelDetails.toInternal(), + includeType ), ) } @@ -924,6 +930,7 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, ): ManageMemberships { return com.pubnub.internal.endpoints.objects.membership.ManageMembershipsImpl( pubNubCore.manageMemberships( @@ -937,6 +944,7 @@ class PubNubImpl( includeCount, includeCustom, includeChannelDetails.toInternal(), + includeType ), ) } @@ -950,6 +958,7 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, ): GetChannelMembers { return com.pubnub.internal.endpoints.objects.member.GetChannelMembersImpl( pubNubCore.getChannelMembers( @@ -961,6 +970,7 @@ class PubNubImpl( includeCount, includeCustom, includeUUIDDetails.toInternal(), + includeType ), ) } @@ -1134,6 +1144,7 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, ): ManageChannelMembers { return com.pubnub.internal.endpoints.objects.member.ManageChannelMembersImpl( pubNubCore.setChannelMembers( @@ -1146,6 +1157,7 @@ class PubNubImpl( includeCount, includeCustom, includeUUIDDetails.toInternal(), + includeType ), ) } @@ -1196,6 +1208,7 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, ): ManageChannelMembers { return com.pubnub.internal.endpoints.objects.member.ManageChannelMembersImpl( pubNubCore.removeChannelMembers( diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts index b9c06bed9..4f59d5965 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -1,7 +1,5 @@ + import com.codingfeline.buildkonfig.compiler.FieldSpec.Type -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget -import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType -import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable import java.util.Properties plugins { @@ -27,14 +25,15 @@ kotlin { iosSimulatorArm64() sourceSets { -// val commonMain by getting { -// dependencies { -// api(project(":pubnub-kotlin:pubnub-kotlin-api")) -// api(project(":pubnub-core:pubnub-core-api")) -// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") + val commonMain by getting { + dependencies { + api(project(":pubnub-kotlin:pubnub-kotlin-api")) + api(project(":pubnub-core:pubnub-core-api")) + api(kotlin("test")) + api(libs.coroutines.test) // implementation(libs.datetime) -// } -// } + } + } // // val commonTest by getting { // dependencies { @@ -44,11 +43,11 @@ kotlin { // } // } // -// val jvmMain by getting { -// dependencies { -// implementation(project(":pubnub-core:pubnub-core-impl")) -// } -// } + val jvmMain by getting { + dependencies { + api(kotlin("test-junit")) + } + } // // val jvmTest by getting { // dependencies { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt similarity index 97% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt rename to pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt index 5e1a248ca..024b1002a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt @@ -5,6 +5,7 @@ import com.pubnub.api.enums.PNStatusCategory import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNEvent import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.createPNConfiguration import com.pubnub.kmp.PNFuture import com.pubnub.kmp.PubNub @@ -23,11 +24,14 @@ import kotlin.test.assertTrue abstract class BaseIntegrationTest { + lateinit var config: PNConfiguration lateinit var pubnub: PubNub + @BeforeTest - fun before() { - pubnub = createPubNub(createPNConfiguration(UserId("demo_user"), Keys.subKey, Keys.pubKey)) + open fun before() { + config = createPNConfiguration(UserId(randomString()), Keys.subKey, Keys.pubKey) + pubnub = createPubNub(config) } @AfterTest From 52e27116965f3089fb1836e0ee7f8251de89f1c1 Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Tue, 25 Jun 2024 15:49:45 +0200 Subject: [PATCH 28/62] Minor improvements for iosMain (#242) * Getting rid of warnings related to Maps * Ensuring that JsonImpl is used as expected * Added some missing implementations in PubNubImpl.kt * Updated submodule --- .../kotlin/com/pubnub/api/PubNubImpl.kt | 8 +++-- .../pubnub/api/endpoints/FetchMessages.ios.kt | 10 ++++--- .../pubnub/api/endpoints/MessageCounts.ios.kt | 3 +- .../api/endpoints/files/DownloadFile.ios.kt | 2 +- .../api/endpoints/files/GetFileUrl.ios.kt | 2 +- .../api/endpoints/files/ListFiles.ios.kt | 2 +- .../api/endpoints/presence/GetState.ios.kt | 3 +- .../api/endpoints/presence/HereNow.ios.kt | 8 +++-- .../com/pubnub/api/v2/PNConfiguration.ios.kt | 1 - .../api/v2/callbacks/StatusListener.ios.kt | 2 +- .../kotlin/com/pubnub/kmp/Converters.kt | 29 +++++++++++-------- .../kotlin/com/pubnub/kmp/factories.ios.kt | 6 ++-- swift | 2 +- 13 files changed, 45 insertions(+), 33 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index aa49deb80..24c264021 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -6,12 +6,14 @@ import cocoapods.PubNubSwift.channelGroupWith import cocoapods.PubNubSwift.channelMetadataWith import cocoapods.PubNubSwift.channelWith import cocoapods.PubNubSwift.disconnect +import cocoapods.PubNubSwift.removeAllListeners import cocoapods.PubNubSwift.setWithToken import cocoapods.PubNubSwift.subscribeWithChannels import cocoapods.PubNubSwift.subscribedChannelGroups import cocoapods.PubNubSwift.subscribedChannels import cocoapods.PubNubSwift.unsubscribeAll import cocoapods.PubNubSwift.unsubscribeFrom +import cocoapods.PubNubSwift.userMetadataWith import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages import com.pubnub.api.endpoints.DeleteMessagesImpl @@ -126,6 +128,7 @@ import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.internal.entities.ChannelGroupImpl import com.pubnub.internal.entities.ChannelImpl import com.pubnub.internal.entities.ChannelMetadataImpl +import com.pubnub.internal.entities.UserMetadataImpl import com.pubnub.kmp.CustomObject import com.pubnub.kmp.PubNub import com.pubnub.kmp.Uploadable @@ -152,7 +155,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun removeAllListeners() { - TODO("Not yet implemented") + pubNubObjC.removeAllListeners() } // TODO: replicate and usePost parameters are not present in Swift SDK @@ -792,13 +795,12 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun userMetadata(id: String): UserMetadata { - TODO("Not yet implemented") + return UserMetadataImpl(userMetadata = pubNubObjC.userMetadataWith(id = id)) } override fun subscriptionSetOf(subscriptions: Set): SubscriptionSet { TODO("Not yet implemented") } - override fun subscriptionSetOf( channels: Set, channelGroups: Set, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt index 07e24a5e0..4d6d312aa 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt @@ -7,6 +7,7 @@ import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.fetchMessagesFrom import com.pubnub.kmp.PNFuture import com.pubnub.api.JsonElement +import com.pubnub.api.JsonElementImpl import com.pubnub.api.PubNubError import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.HistoryMessageType @@ -16,6 +17,7 @@ import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.safeCast import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSNumber @@ -60,12 +62,12 @@ open class FetchMessagesImpl( } private fun mapMessages(rawValue: Map?): Map> { - return (rawValue as? Map>)?.mapValues { entry -> + return (rawValue?.safeCast>())?.mapValues { entry -> entry.value.map { PNFetchMessageItem( uuid = it.publisher(), - message = it.payload() as JsonElement, - meta = it.metadata() as? JsonElement, + message = JsonElementImpl(it.payload()), + meta = it.metadata()?.let { obj -> JsonElementImpl(obj) }, timetoken = it.published().toLong(), actions = mapMessageActions(rawValue = it.actions()), messageType = HistoryMessageType.of(it.messageType().toInt()), @@ -78,7 +80,7 @@ open class FetchMessagesImpl( private fun mapMessageActions(rawValue: List<*>): Map>> { return rawValue.filterIsInstance().groupBy { messageAction -> messageAction.actionType() - }?.mapValues { entry -> + }.mapValues { entry -> entry.value.groupBy { groupedMessageAction -> groupedMessageAction.actionValue() }.mapValues { groupedEntry -> diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt index 228c0933a..69cf2df88 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt @@ -8,6 +8,7 @@ import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.safeCast import kotlinx.cinterop.ExperimentalForeignApi /** @@ -25,7 +26,7 @@ class MessageCountsImpl( pubnub.messageCountsFor( channels = channels, channelsTimetokens = channelsTimetoken, - onSuccess = callback.onSuccessHandler { PNMessageCountResult(it as Map) }, + onSuccess = callback.onSuccessHandler { PNMessageCountResult(it?.safeCast() ?: emptyMap()) }, onFailure = callback.onFailureHandler() ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt index 6620f1a14..2e9e676f4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt @@ -31,7 +31,7 @@ class DownloadFileImpl( fileId = fileId, onSuccess = callback.onSuccessHandler { PNDownloadFileResult( - fileName = it?.name() ?: "", + fileName = it?.name().orEmpty(), byteStream = it?.url()?.let { url -> DownloadableImpl(inputStream = NSInputStream(uRL = url)) } )}, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt index 393f2de3d..a99648b76 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt @@ -27,7 +27,7 @@ class GetFileUrlImpl( channel = channel, fileName = fileName, fileId = fileId, - onSuccess = callback.onSuccessHandler { PNFileUrlResult(url = it ?: "") }, + onSuccess = callback.onSuccessHandler { PNFileUrlResult(url = it.orEmpty()) }, onFailure = callback.onFailureHandler() ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt index ae257b171..d9d0c99a1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt @@ -43,7 +43,7 @@ class ListFilesImpl( id = rawValue.id(), name = rawValue.name(), size = rawValue.size().toInt(), - created = rawValue.createdDate().toString() // TODO: Map to expected date format + created = rawValue.createdDateStringValue().orEmpty() ) } ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt index b137a875c..6d2ebe1ba 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt @@ -9,6 +9,7 @@ import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.safeCast import kotlinx.cinterop.ExperimentalForeignApi /** @@ -29,7 +30,7 @@ class GetStateImpl( channels = channels, channelGroups = channelGroups, uuid = uuid, - onSuccess = callback.onSuccessHandler { PNGetStateResult(stateByUUID = it as Map) }, + onSuccess = callback.onSuccessHandler { PNGetStateResult(stateByUUID = it?.safeCast() ?: emptyMap()) }, onFailure = callback.onFailureHandler() ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt index 9ccff6b33..63a0c81b8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt @@ -6,6 +6,7 @@ import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.hereNowWithChannels import com.pubnub.kmp.PNFuture import com.pubnub.api.JsonElement +import com.pubnub.api.JsonElementImpl import com.pubnub.api.models.consumer.presence.PNHereNowChannelData import com.pubnub.api.models.consumer.presence.PNHereNowOccupantData import com.pubnub.api.models.consumer.presence.PNHereNowResult @@ -13,6 +14,7 @@ import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.safeCast import kotlinx.cinterop.ExperimentalForeignApi /** @@ -38,16 +40,16 @@ class HereNowImpl( onSuccess = callback.onSuccessHandler { PNHereNowResult( totalChannels = it?.totalChannels()?.toInt() ?: 0, totalOccupancy = it?.totalOccupancy()?.toInt() ?: 0, - channels = (it?.channels() as? Map)?.mapValues { entry -> + channels = (it?.channels()?.safeCast())?.mapValues { entry -> PNHereNowChannelData( channelName = entry.value.channelName(), occupancy = entry.value.occupancy().toInt(), occupants = (entry.value.occupants().filterIsInstance()).map { occupant -> PNHereNowOccupantData( uuid = occupant.uuid(), - state = occupant.state() as JsonElement + state = JsonElementImpl(occupant.state()) ) - } ?: emptyList() + } ) }?.toMutableMap() ?: emptyMap().toMutableMap() )}, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt index 3a3c1e10c..84329343c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt @@ -9,7 +9,6 @@ actual interface PNConfiguration { actual val secretKey: String actual val authKey: String actual val cryptoModule: CryptoModule? - } actual interface CryptoModule diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt index 078e52fcf..51d971cc3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt @@ -20,4 +20,4 @@ actual interface StatusListener : Listener { class StatusListenerImpl( override val underlying: PubNubStatusListenerObjC, override val onStatusChange: (PubNub, PNStatus) -> Unit -): StatusListener {} \ No newline at end of file +): StatusListener \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt index 9c7242298..4f498438d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt @@ -39,7 +39,7 @@ internal fun createPNUUIDMetadata(from: PubNubUUIDMetadataObjC): PNUUIDMetadata externalId = from.externalId(), profileUrl = from.profileUrl(), email = from.email(), - custom = from.custom()?.asMap() as? Map, // TODO: Verify + custom = from.custom()?.asMap()?.safeCast(), updated = from.updated(), eTag = from.eTag(), type = from.type(), @@ -53,7 +53,7 @@ internal fun createPNChannelMetadata(from: PubNubChannelMetadataObjC): PNChannel id = from.id(), name = from.name(), description = from.descr(), - custom = from.custom()?.asMap() as? Map, // TODO: Verify + custom = from.custom()?.asMap()?.safeCast(), updated = from.updated(), eTag = from.eTag(), type = from.type(), @@ -75,18 +75,18 @@ internal fun createObjectSortProperties(from: Collection>) : Li internal fun createPNChannelMembership(from: PubNubMembershipMetadataObjC): PNChannelMembership { return PNChannelMembership( channel = PNChannelMetadata( - id = from.channel()?.id() ?: "", - name = from.channel()?.name() ?: "", - description = from.channel()?.descr() ?: "", - custom = from.channel()?.custom()?.asMap() as? Map, // TODO: Verify + id = from.channel()?.id().orEmpty(), + name = from.channel()?.name().orEmpty(), + description = from.channel()?.descr().orEmpty(), + custom = from.channel()?.custom()?.asMap()?.safeCast(), updated = from.channel()?.updated(), eTag = from.channel()?.eTag(), type = from.channel()?.type(), status = from.channel()?.status() ), - custom = from.custom() as? Map, // TODO: Verify - updated = from.updated() ?: "", - eTag = from.eTag() ?: "", + custom = from.custom()?.safeCast(), + updated = from.updated().orEmpty(), + eTag = from.eTag().orEmpty(), status = from.status() ) } @@ -95,13 +95,18 @@ internal fun createPNChannelMembership(from: PubNubMembershipMetadataObjC): PNCh internal fun createPNMember(from: PubNubMembershipMetadataObjC): PNMember { return PNMember( uuid = from.uuid()?.let { createPNUUIDMetadata(from = it) }, - custom = from.custom() as? Map, // TODO: Verify - updated = from.updated() ?: "", - eTag = from.eTag() ?: "", + custom = from.custom()?.safeCast(), // TODO: Verify + updated = from.updated().orEmpty(), + eTag = from.eTag().orEmpty(), status = from.status() ) } internal inline fun List<*>?.filterAndMap(mapper: (T) -> U): Collection { return this?.filterIsInstance()?.map(mapper) ?: emptyList() +} + +@Suppress("UNCHECKED_CAST") +inline fun Map<*, *>.safeCast(): Map { + return this as? Map ?: error("Cannot make the cast") } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index eaf51233a..38cd34219 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -200,7 +200,7 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM externalId = from.metadata().externalId(), profileUrl = from.metadata().profileUrl(), email = from.metadata().email(), - custom = from.metadata().custom() as? Map, // TODO: Verify + custom = from.metadata().custom()?.asMap()?.safeCast(), updated = from.metadata().updated(), eTag = from.metadata().eTag(), type = from.metadata().type(), @@ -225,7 +225,7 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM id = from.metadata().id(), name = from.metadata().name(), description = from.metadata().descr(), - custom = from.metadata().custom() as? Map, // TODO: Verify + custom = from.metadata().custom()?.asMap()?.safeCast(), updated = from.metadata().updated(), eTag = from.metadata().eTag(), type = from.metadata().type(), @@ -249,7 +249,7 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM data = PNSetMembershipEvent( channel = from.metadata().channel()?.name().orEmpty(), uuid = from.metadata().uuid()?.id().orEmpty(), - custom = from.metadata().custom() as? Map, // TODO: Verify, + custom = from.metadata().custom()?.safeCast(), eTag = from.metadata().eTag().orEmpty(), updated = from.metadata().updated().orEmpty(), status = from.metadata().status().orEmpty() diff --git a/swift b/swift index 4a9eebda3..9c1b9a198 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit 4a9eebda3f3796b18ce712f839952176b4c688e4 +Subproject commit 9c1b9a19863b6cee24faf6302f223e06930366e7 From 85fdec89a6093183d838df43439808c1f0b1e1e0 Mon Sep 17 00:00:00 2001 From: marcin-cebo <102806110+marcin-cebo@users.noreply.github.com> Date: Wed, 26 Jun 2024 10:07:35 +0200 Subject: [PATCH 29/62] Added secret key to configuration (#243) --- .../commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt | 2 +- .../iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt | 5 +++-- .../jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt | 5 +++-- .../jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt | 4 +++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt index 0411fdd82..09396b05d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt @@ -16,4 +16,4 @@ expect interface PNConfiguration { expect interface CryptoModule -expect fun createPNConfiguration(userId: UserId, subscribeKey: String, publishKey: String): PNConfiguration \ No newline at end of file +expect fun createPNConfiguration(userId: UserId, subscribeKey: String, publishKey: String, secretKey: String? = null): PNConfiguration \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt index 84329343c..6ec166c7d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt @@ -16,14 +16,15 @@ actual interface CryptoModule actual fun createPNConfiguration( userId: UserId, subscribeKey: String, - publishKey: String + publishKey: String, + secretKey: String? ): PNConfiguration { return object : PNConfiguration { override val userId: UserId = userId override val subscribeKey: String = subscribeKey override val publishKey: String = publishKey override val secretKey: String - get() = TODO("Not yet implemented") + get() = secretKey.orEmpty() override val authKey: String get() = TODO("Not yet implemented") override val cryptoModule: CryptoModule? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt index 0bc47c56a..5037877ce 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt @@ -15,7 +15,8 @@ actual interface PNConfiguration { actual fun createPNConfiguration( userId: UserId, subscribeKey: String, - publishKey: String + publishKey: String, + secretKey: String? ): PNConfiguration { return object : PNConfiguration { override val userId: UserId @@ -25,7 +26,7 @@ actual fun createPNConfiguration( override val publishKey: String get() = publishKey override val secretKey: String - get() = TODO("Not yet implemented") + get() = secretKey.orEmpty() override val authKey: String get() = TODO("Not yet implemented") override val cryptoModule: CryptoModule? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt index 120a2d100..bfb57896a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt @@ -6,10 +6,12 @@ import com.pubnub.api.crypto.CryptoModule actual fun createPNConfiguration( userId: UserId, subscribeKey: String, - publishKey: String + publishKey: String, + secretKey: String? ): PNConfiguration { return PNConfiguration.builder(userId, subscribeKey) { this.publishKey = publishKey + this.secretKey = secretKey.orEmpty() }.build() } From 17cf9a0b801fe217bda2fa436d74895046d38deb Mon Sep 17 00:00:00 2001 From: marcin-cebo <102806110+marcin-cebo@users.noreply.github.com> Date: Wed, 26 Jun 2024 13:55:33 +0200 Subject: [PATCH 30/62] Added secret key for tests (#244) --- .../kotlin/com.pubnub.test/BaseIntegrationTest.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt index 024b1002a..c4f4a1008 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt @@ -25,19 +25,25 @@ import kotlin.test.assertTrue abstract class BaseIntegrationTest { lateinit var config: PNConfiguration + lateinit var configPam: PNConfiguration lateinit var pubnub: PubNub + lateinit var pubnubPam: PubNub @BeforeTest open fun before() { config = createPNConfiguration(UserId(randomString()), Keys.subKey, Keys.pubKey) pubnub = createPubNub(config) + configPam = createPNConfiguration(UserId(randomString()), Keys.pamSubKey, Keys.pamPubKey, Keys.pamSecKey) + pubnubPam = createPubNub(configPam) } @AfterTest fun after() { pubnub.unsubscribeAll() pubnub.destroy() + pubnubPam.unsubscribeAll() + pubnubPam.destroy() } } From 0ded656088da7024821691dc61ae5d9f39c0325a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Wed, 26 Jun 2024 11:59:13 +0000 Subject: [PATCH 31/62] PNFuture variance fix (#245) --- .../src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt index 4c0944f49..77d9b8f2e 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt @@ -3,6 +3,6 @@ package com.pubnub.kmp import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result -fun interface PNFuture { - fun async(callback: Consumer>) +fun interface PNFuture { + fun async(callback: Consumer>) } \ No newline at end of file From dc79c264a15cf26bf52e03308875f562a8569bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Fri, 28 Jun 2024 09:37:04 +0000 Subject: [PATCH 32/62] SubscriptionSetImpl in JS and PNFuture.remember() (#246) --- .../kotlin/com/pubnub/kmp/futures.kt | 79 +++++++++++++------ .../kotlin/com/pubnub/api/PubNubImpl.kt | 9 ++- .../v2/subscriptions/SubscriptionImpl.kt | 1 - .../v2/subscriptions/SubscriptionSetImpl.kt | 77 ++++++++++++++++++ 4 files changed, 141 insertions(+), 25 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionSetImpl.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt index ddd80df96..7710a18d4 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt @@ -7,44 +7,73 @@ import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.api.v2.callbacks.mapCatching import kotlinx.atomicfu.atomic +import kotlinx.atomicfu.locks.ReentrantLock +import kotlinx.atomicfu.locks.reentrantLock +import kotlinx.atomicfu.locks.withLock import kotlin.jvm.JvmName -fun PubNubException.asFuture(): PNFuture = object : PNFuture { - override fun async(callback: Consumer>) { - callback.accept(Result.failure(this@asFuture)) +private class CompletablePNFuture : PNFuture { + private val reentrantLock: ReentrantLock = reentrantLock() + private lateinit var result: Result + private var callback: Consumer>? = null + + fun complete(result: Result) { + reentrantLock.withLock { + if (!this::result.isInitialized) { + this.result = result + callback?.accept(result) + } else { + error("This CompletablePNFuture has already completed with result $result") + } + } } -} -fun T.asFuture(): PNFuture = object : PNFuture { override fun async(callback: Consumer>) { - callback.accept(Result.success(this@asFuture)) + reentrantLock.withLock { + if (this.callback != null) { + error("Only one callback is supported for CompletablePNFuture.") + } + if (!this::result.isInitialized) { + this.callback = callback + } else { + callback.accept(result) + } + } } } -fun Result.asFuture(): PNFuture = object : PNFuture { - override fun async(callback: Consumer>) { - callback.accept(this@asFuture) +fun PubNubException.asFuture(): PNFuture = PNFuture { callback -> + callback.accept(Result.failure(this@asFuture)) +} + +fun T.asFuture(): PNFuture = PNFuture { callback -> + callback.accept(Result.success(this@asFuture)) +} + +fun Result.asFuture(): PNFuture = PNFuture { callback -> + callback.accept(this@asFuture) +} + +fun PNFuture.then(action: (T) -> U): PNFuture = PNFuture { callback -> + this@then.async { it: Result -> + callback.accept(it.mapCatching(action)) } } -fun PNFuture.then(action: (T) -> U): PNFuture = object : PNFuture { - override fun async(callback: Consumer>) { - this@then.async { it: Result -> - callback.accept(it.mapCatching(action)) +fun PNFuture.thenAsync(action: (T) -> PNFuture): PNFuture = PNFuture { callback -> + this@thenAsync.async { firstFutureResult: Result -> + val intermediateResult: Result> = firstFutureResult.mapCatching(action) + intermediateResult.onFailure { + callback.accept(Result.failure(it)) + }.onSuccess { secondFuture: PNFuture -> + secondFuture.async(callback) } } } -fun PNFuture.thenAsync(action: (T) -> PNFuture): PNFuture = object : PNFuture { - override fun async(callback: Consumer>) { - this@thenAsync.async { firstFutureResult: Result -> - val intermediateResult: Result> = firstFutureResult.mapCatching(action) - intermediateResult.onFailure { - callback.accept(Result.failure(it)) - }.onSuccess { secondFuture: PNFuture -> - secondFuture.async(callback) - } - } +fun PNFuture.remember() : PNFuture = CompletablePNFuture().also { completableFuture -> + this@remember.async { + completableFuture.complete(it) } } @@ -77,6 +106,10 @@ fun PNFuture.catch(action: (Exception) -> Result): PNFuture = PNFut } fun Collection>.awaitAll(): PNFuture> = PNFuture { callback -> + if (isEmpty()) { + callback.accept(Result.success(emptyList())) + return@PNFuture + } val counter = atomic(0) val failed = atomic(false) val array = Array(size) { null } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 0ebef3fcd..29f71121f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -120,6 +120,8 @@ import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.internal.v2.entities.ChannelImpl +import com.pubnub.internal.v2.subscriptions.SubscriptionImpl +import com.pubnub.internal.v2.subscriptions.SubscriptionSetImpl import com.pubnub.kmp.CustomObject import com.pubnub.kmp.Optional import com.pubnub.kmp.PubNub @@ -882,7 +884,12 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { channelGroups: Set, options: SubscriptionOptions ): SubscriptionSet { - TODO("Not yet implemented") + val params = mapOf( + "channels" to channels.toTypedArray(), + "channelGroups" to channelGroups.toTypedArray(), + //todo use options // "options" to + ).toJsMap() + return SubscriptionSetImpl(jsPubNub.asDynamic().subscriptionSet(params)) } override fun sendFile( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt index 4e7e38611..55130f422 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt @@ -26,7 +26,6 @@ class SubscriptionImpl(private val jsSubscription: dynamic) : Subscription { jsSubscription.addListener(listener) } - override fun removeListener(listener: Listener) { jsSubscription.removeListener(listener) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionSetImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionSetImpl.kt new file mode 100644 index 000000000..a5a5f2ef8 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionSetImpl.kt @@ -0,0 +1,77 @@ +package com.pubnub.internal.v2.subscriptions + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionCursor +import com.pubnub.api.v2.subscriptions.SubscriptionSet + +class SubscriptionSetImpl(private val jsSubscriptionSet: dynamic) : SubscriptionSet { + override fun close() { + unsubscribe() + } + + override fun plusAssign(subscription: Subscription) { + TODO("Not yet implemented") + } + + override fun minusAssign(subscription: Subscription) { + TODO("Not yet implemented") + } + + override fun add(subscription: Subscription) { + TODO("Not yet implemented") + } + + override fun remove(subscription: Subscription) { + TODO("Not yet implemented") + } + + override val subscriptions: Set + get() = TODO("Not yet implemented") + + override fun addListener(listener: EventListener) { + jsSubscriptionSet.addListener(listener) + } + + override fun removeListener(listener: Listener) { + jsSubscriptionSet.removeListener(listener) + } + + override fun removeAllListeners() { + TODO("Not yet implemented") + } + + override fun subscribe(cursor: SubscriptionCursor) { + jsSubscriptionSet.subscribe() + } + + override fun unsubscribe() { + jsSubscriptionSet.unsubscribe() + } + + override var onMessage: ((PNMessageResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + override var onPresence: ((PNPresenceEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + override var onSignal: ((PNSignalResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + override var onMessageAction: ((PNMessageActionResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + override var onObjects: ((PNObjectEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} + override var onFile: ((PNFileEventResult) -> Unit)? + get() = TODO("Not yet implemented") + set(value) {} +} \ No newline at end of file From a5d7525414155b7a7ac291ce112c6bf8a54105f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Mon, 1 Jul 2024 12:20:13 +0000 Subject: [PATCH 33/62] Tests, fixes (#247) * Various JS test fixes * More JS tests * More tests --- .../gradle/PubNubIosSimulatorTestPlugin.kt | 12 +-- kotlin-js-store/yarn.lock | 8 +- .../pubnub/api/models/consumer/PNStatus.kt | 4 + .../kotlin/com/pubnub/api/JsonElement.js.kt | 15 +++- .../pubnub-kotlin-api/build.gradle.kts | 5 +- .../pubnub-kotlin-api/karma.config.d/conf.js | 11 +++ .../com/pubnub/api/ChannelMetadataTest.kt | 8 +- .../kotlin/com/pubnub/api/EntitiesTest.kt | 77 +++++++++++++++++++ .../kotlin/com/pubnub/api/MembersTest.kt | 4 +- .../kotlin/com/pubnub/api/MembershipsTest.kt | 11 ++- .../kotlin/com/pubnub/api/PublishTest.kt | 19 ++--- .../kotlin/com/pubnub/api/UserMetadataTest.kt | 29 +++---- .../src/jsMain/kotlin/Pubnub.d.kt | 23 ++++-- .../kotlin/com/pubnub/api/EndpointImpl.kt | 24 ++++-- .../kotlin/com/pubnub/api/PubNubImpl.kt | 23 ++++-- .../com/pubnub/api/v2/PNConfiguration.js.kt | 6 ++ .../internal/v2/entities/ChannelImpl.kt | 8 +- .../kotlin/com/pubnub/kmp/factories.js.kt | 24 ++++-- .../com.pubnub.test/BaseIntegrationTest.kt | 34 +++++++- 19 files changed, 265 insertions(+), 80 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/karma.config.d/conf.js create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/EntitiesTest.kt diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt index 2c69993a8..b233a2483 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt @@ -30,18 +30,18 @@ class PubNubIosSimulatorTestPlugin : Plugin { } } - val shutdownTask = tasks.register("shutdownIOSSimulator") { - onlyIf { isMacOs.get() } - commandLine("xcrun", "simctl", "shutdown", deviceName) - dependsOn(tasks.withType()) - } +// val shutdownTask = tasks.register("shutdownIOSSimulator") { +// onlyIf { isMacOs.get() } +// commandLine("xcrun", "simctl", "shutdown", deviceName) +// dependsOn(tasks.withType()) +// } tasks.withType().configureEach { it.onlyIf { isMacOs.get() } it.standalone.set(false) it.device.set(deviceName) it.dependsOn(bootTask) - it.finalizedBy(shutdownTask) +// it.finalizedBy(shutdownTask) } } } diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 022f3c998..b0526fa29 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -2411,10 +2411,10 @@ proxy-from-env@^1.1.0: resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== -pubnub@8.1.0: - version "8.1.0" - resolved "https://registry.yarnpkg.com/pubnub/-/pubnub-8.1.0.tgz#d17e2925ce4a66e1b52b73bdeaee53f44237316e" - integrity sha512-f8T+vh414WayMNokKueOZykn3tosxF1ruu3KAM/4uLy1GzLWsL5/k46lGaxqVljkMtplM/8nJlbzA+/k8kkQ3A== +pubnub@8.2.4: + version "8.2.4" + resolved "https://registry.yarnpkg.com/pubnub/-/pubnub-8.2.4.tgz#5461d5fc11df4a35dcaf0332a7967c182baedc6a" + integrity sha512-NlA1Kk6f1CfI5n1yNB5hICwDSIWXaOyjHwEm0jmxPbAS+Mj8+WVeUZBomDIrTS870r37ynT9BUkr71gHWUq7Xg== dependencies: agentkeepalive "^3.5.2" buffer "^6.0.3" diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt index 8153d4501..f5e7b32dc 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt @@ -49,4 +49,8 @@ class PNStatus( result = 31 * result + affectedChannelGroups.hashCode() return result } + + override fun toString(): String { + return "PNStatus(error=$error, affectedChannelGroups=$affectedChannelGroups, affectedChannels=$affectedChannels, currentTimetoken=$currentTimetoken, exception=$exception, category=$category)" + } } diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt index 549cdcb4f..9280073c6 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt @@ -6,7 +6,20 @@ import com.pubnub.kmp.JsMap import com.pubnub.kmp.toMap import kotlin.js.json -actual abstract class JsonElement(val value: Any?) +actual abstract class JsonElement(val value: Any?) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is JsonElement) return false + + if (value != other.value) return false + + return true + } + + override fun hashCode(): Int { + return value?.hashCode() ?: 0 + } +} class JsonElementImpl(value: Any?) : JsonElement(value) { override fun toString(): String { diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index d86e61367..daceb1f60 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -17,6 +17,9 @@ kotlin { useMocha { timeout = "30s" } +// useKarma { +// useChrome() +// } } } } @@ -36,7 +39,7 @@ kotlin { val jsMain by getting { dependencies { - implementation(npm("pubnub", "8.1.0")) + implementation(npm("pubnub", "8.2.4")) } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/karma.config.d/conf.js b/pubnub-kotlin/pubnub-kotlin-api/karma.config.d/conf.js new file mode 100644 index 000000000..c852be1b8 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/karma.config.d/conf.js @@ -0,0 +1,11 @@ + config.set({ +// "singleRun": false, +// "autoWatch": true, + client: { + mocha: { + timeout : 15000 // 6 seconds - upped from 2 seconds + } + } + }); +//config.loggers.push({type: 'console'}) +config.logLevel = config.LOG_DEBUG \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt index 19bc3c75c..a74554a67 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt @@ -25,7 +25,7 @@ class ChannelMetadataTest : BaseIntegrationTest() { private val type = randomString() @Test - fun can_set_metadata() = runTest(timeout = 10.seconds) { + fun can_set_metadata() = runTest(timeout = defaultTimeout) { // when val result = pubnub.setChannelMetadata( channel, @@ -49,7 +49,7 @@ class ChannelMetadataTest : BaseIntegrationTest() { } @Test - fun can_receive_set_metadata_event() = runTest(timeout = 10.seconds) { + fun can_receive_set_metadata_event() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { // given pubnub.awaitSubscribe(listOf(channel)) @@ -79,7 +79,7 @@ class ChannelMetadataTest : BaseIntegrationTest() { } @Test - fun can_delete_metadata() = runTest(timeout = 10.seconds) { + fun can_delete_metadata() = runTest(timeout = defaultTimeout) { // given pubnub.setChannelMetadata( channel, @@ -102,7 +102,7 @@ class ChannelMetadataTest : BaseIntegrationTest() { } @Test - fun can_receive_delete_metadata_event() = runTest(timeout = 10.seconds) { + fun can_receive_delete_metadata_event() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { pubnub.setChannelMetadata( channel, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/EntitiesTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/EntitiesTest.kt new file mode 100644 index 000000000..c8eabe345 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/EntitiesTest.kt @@ -0,0 +1,77 @@ +package com.pubnub.api + +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.kmp.createEventListener +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import com.pubnub.test.test +import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.yield +import kotlin.test.Test +import kotlin.test.assertEquals + +class EntitiesTest : BaseIntegrationTest() { + private val channelName = "myChannel" + + @Test + fun can_subscribe_channel_subscription() = runTest(timeout = defaultTimeout) { + pubnub.test(backgroundScope) { + val channel = pubnub.channel(channelName) + val subscription = channel.awaitSubscribe() + assertEquals(listOf(channelName), pubnub.getSubscribedChannels()) + } + } + + @Test + fun can_get_events_from_channel_subscription() = runTest(timeout = defaultTimeout) { + pubnub.test(backgroundScope) { + val channel = pubnub.channel(channelName) + val subscription = channel.awaitSubscribe() + + var message: PNMessageResult? = null + subscription.addListener(createEventListener(pubnub, onMessage = { pubNub, pnMessageResult -> + message = pnMessageResult + })) + + pubnub.publish(channelName, "some message", shouldStore = false).await() + yield() + + assertEquals(nextMessage(), message) + } + } + + @Test + fun can_subscribe_channel_subscriptionSet() = runTest(timeout = defaultTimeout) { + pubnub.test(backgroundScope) { + val channelSet = setOf(channelName, "abc") + val set = pubnub.subscriptionSetOf(channelSet) + pubnub.awaitSubscribe(channelSet) { + set.subscribe() + } + assertEquals(channelSet, pubnub.getSubscribedChannels().toSet()) + } + } + + @Test + fun can_get_events_from_channel_subscriptionSet() = runTest(timeout = defaultTimeout) { + pubnub.test(backgroundScope) { + val channelSet = setOf(channelName, "abc") + val set = pubnub.subscriptionSetOf(channelSet) + pubnub.awaitSubscribe(channelSet) { + set.subscribe() + } + assertEquals(channelSet, pubnub.getSubscribedChannels().toSet()) + + var messageFromSetSubscription: PNMessageResult? = null + set.addListener(createEventListener(pubnub, onMessage = { pubNub, pnMessageResult -> + messageFromSetSubscription = pnMessageResult + })) + + pubnub.publish(channelName, "some message", shouldStore = false).await() + val receivedMessage = nextMessage() + yield() + + assertEquals(receivedMessage, messageFromSetSubscription) + } + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt index ec356d879..e2ff7a666 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt @@ -24,7 +24,7 @@ class MembersTest : BaseIntegrationTest() { private val type = randomString() @Test - fun can_set_members() = runTest(timeout = 10.seconds) { + fun can_set_members() = runTest(timeout = defaultTimeout) { // when val result = pubnub.setChannelMembers( channel, @@ -40,7 +40,7 @@ class MembersTest : BaseIntegrationTest() { } @Test - fun can_delete_members() = runTest(timeout = 10.seconds) { + fun can_delete_members() = runTest(timeout = defaultTimeout) { // given pubnub.setChannelMembers( channel, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt index fa4ba479b..1f67a6cf7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt @@ -28,7 +28,7 @@ class MembershipsTest : BaseIntegrationTest() { private val type = randomString() @Test - fun can_set_memberships() = runTest(timeout = 10.seconds) { + fun can_set_memberships() = runTest(timeout = defaultTimeout) { // when val result = pubnub.setMemberships( listOf(PNChannelMembership.Partial(channel, custom, status)), @@ -43,7 +43,7 @@ class MembershipsTest : BaseIntegrationTest() { } @Test - fun can_receive_set_membership_event() = runTest(timeout = 10.seconds) { + fun can_receive_set_membership_event() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { // given pubnub.awaitSubscribe(listOf(channel)) @@ -66,7 +66,7 @@ class MembershipsTest : BaseIntegrationTest() { } @Test - fun can_delete_membership() = runTest(timeout = 10.seconds) { + fun can_delete_membership() = runTest(timeout = defaultTimeout) { // given pubnub.setMemberships( listOf(PNChannelMembership.Partial(channel, custom, status)) @@ -88,7 +88,7 @@ class MembershipsTest : BaseIntegrationTest() { } @Test - fun can_receive_delete_membership_event() = runTest(timeout = 10.seconds) { + fun can_receive_delete_membership_event() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { // given pubnub.setMemberships( @@ -102,8 +102,7 @@ class MembershipsTest : BaseIntegrationTest() { // then val result = nextEvent() - val message = result.extractedMessage - message as PNDeleteMembershipEventMessage + val message = result.extractedMessage as PNDeleteMembershipEventMessage assertEquals(pubnub.configuration.userId.value, message.data.uuid) assertEquals(channel, message.data.channelId) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt index 938ac3f12..4db2653d5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt @@ -25,28 +25,29 @@ class PublishTest : BaseIntegrationTest() { @Test fun can_publish_message_string() = - runTest(timeout = 10.seconds) { + runTest(timeout = defaultTimeout) { val result = pubnub.publish(channel, "some message").await() assertTrue { result.timetoken > 0 } } @Test fun can_publish_message_map() = - runTest(timeout = 10.seconds) { + runTest(timeout = defaultTimeout) { val result = pubnub.publish(channel, mapOf("platform" to PLATFORM, "otherKey" to 123, "another" to true)).await() assertTrue { result.timetoken > 0 } } @Test + @Ignore // only JVM supports custom classes fun can_publish_message_object() = - runTest(timeout = 10.seconds) { + runTest(timeout = defaultTimeout) { val result = pubnub.publish(channel, ABC()).await() assertTrue { result.timetoken > 0 } } @Test - fun can_receive_message_with_object_metadata() = runTest(timeout = 10.seconds) { + fun can_receive_message_with_object_metadata() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) val mapData = mapOf( @@ -67,7 +68,7 @@ class PublishTest : BaseIntegrationTest() { } @Test - fun can_receive_message_with_primitive_payload() = runTest(timeout = 10.seconds) { + fun can_receive_message_with_primitive_payload() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) pubnub.publish( @@ -87,7 +88,7 @@ class PublishTest : BaseIntegrationTest() { } @Test - fun can_receive_message_with_map_payload() = runTest(timeout = 10.seconds) { + fun can_receive_message_with_map_payload() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) val mapData = mapOf( @@ -108,7 +109,7 @@ class PublishTest : BaseIntegrationTest() { } @Test - fun can_receive_message_with_payload_with_floats() = runTest(timeout = 10.seconds) { + fun can_receive_message_with_payload_with_floats() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) val mapData = mapOf( @@ -130,8 +131,8 @@ class PublishTest : BaseIntegrationTest() { } @Test - @Ignore - fun can_receive_message_with_primitive_metadata() = runTest(timeout = 10.seconds) { + @Ignore //todo js doesn't support primitive metadata? + fun can_receive_message_with_primitive_metadata() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) pubnub.publish(channel, "some message", "some meta").await() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt index 6920ef755..b9ffc72e5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt @@ -33,7 +33,7 @@ class UserMetadataTest : BaseIntegrationTest() { private val type = randomString() @Test - fun can_set_metadata() = runTest(timeout = 10.seconds) { + fun can_set_metadata() = runTest(timeout = defaultTimeout) { // when val result = pubnub.setUUIDMetadata( uuid, @@ -61,7 +61,7 @@ class UserMetadataTest : BaseIntegrationTest() { } @Test - fun can_receive_set_metadata_event() = runTest(timeout = 10.seconds) { + fun can_receive_set_metadata_event() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { // given pubnub.awaitSubscribe(listOf(uuid)) @@ -95,7 +95,7 @@ class UserMetadataTest : BaseIntegrationTest() { } @Test - fun can_delete_metadata() = runTest(timeout = 10.seconds) { + fun can_delete_metadata() = runTest(timeout = defaultTimeout) { // given pubnub.setUUIDMetadata( uuid, @@ -119,7 +119,7 @@ class UserMetadataTest : BaseIntegrationTest() { } @Test - fun can_receive_delete_metadata_event() = runTest(timeout = 10.seconds) { + fun can_receive_delete_metadata_event() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { // given pubnub.setUUIDMetadata( @@ -140,14 +140,13 @@ class UserMetadataTest : BaseIntegrationTest() { // then val result = nextEvent() - val message = result.extractedMessage - message as PNDeleteUUIDMetadataEventMessage + val message = result.extractedMessage as PNDeleteUUIDMetadataEventMessage assertEquals(uuid, message.uuid) } } @Test - fun can_get_metadata() = runTest(timeout = 10.seconds) { + fun can_get_metadata() = runTest(timeout = defaultTimeout) { // given pubnub.setUUIDMetadata( uuid, @@ -178,10 +177,9 @@ class UserMetadataTest : BaseIntegrationTest() { } @Test - @Ignore // very slow, use to test once fun can_get_all_metadata_with_paging() = runTest(timeout = 30.seconds) { // given - repeat(10) { + repeat(6) { pubnub.setUUIDMetadata( uuid + it, name = name, @@ -199,7 +197,12 @@ class UserMetadataTest : BaseIntegrationTest() { val allUsers = mutableListOf() var next: PNPage.PNNext? = null while(true) { - val result: PNUUIDMetadataArrayResult = pubnub.getAllUUIDMetadata(limit = 4, page = next, includeCustom = true).await() + val result: PNUUIDMetadataArrayResult = pubnub.getAllUUIDMetadata( + limit = 2, + page = next, + includeCustom = true, + filter = "id LIKE \"$uuid*\"" + ).await() allUsers.addAll(result.data) next = result.next if (next == null || result.data.isEmpty()) { @@ -208,13 +211,13 @@ class UserMetadataTest : BaseIntegrationTest() { } // clean up before asserting - repeat(10) { + repeat(6) { pubnub.removeUUIDMetadata(uuid + it) } // then - assertTrue { allUsers.size >= 10 } - repeat(10) { + assertTrue { allUsers.size == 6 } + repeat(6) { val pnuuidMetadata = allUsers.firstOrNull { user -> user.id == uuid + it } assertNotNull(pnuuidMetadata) assertEquals(name, pnuuidMetadata.name) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt index 30c4383b9..a82048c58 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt @@ -252,11 +252,11 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface StatusEvent { var category: String var operation: String - var affectedChannels: Array - var subscribedChannels: Array - var affectedChannelGroups: Array + var affectedChannels: Array? + var subscribedChannels: Array? + var affectedChannelGroups: Array? var lastTimetoken: String - var currentTimetoken: String + var currentTimetoken: String? var statusCode: Number? } @@ -391,7 +391,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { } interface PublishResponse { - var timetoken: Number + var timetoken: String } interface SignalParameters { @@ -548,7 +548,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { var withPresence: Boolean? - var timetoken: Number? + var timetoken: String? } @@ -1292,6 +1292,16 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface LegacyCryptor + interface SubscriptionOptions { + var receivePresenceEvents: Boolean + } + + interface SubscriptionSetParams { + var channels: Array + var channelGroups: Array + var subscriptionOptions: SubscriptionOptions + } + companion object { var CATEGORIES: Any var OPERATIONS: Any @@ -1379,3 +1389,4 @@ external interface ExponentialRetryPolicyConfiguration { var maximumDelay: Number var maximumRetry: Number } + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt index 914ff7df9..62d143bbe 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt @@ -9,13 +9,23 @@ open class EndpointImpl(private val promiseFactory: () -> Promise, priva PNFuture { override fun async(callback: Consumer>) { - promiseFactory().then( - onFulfilled = { response: T -> - callback.accept(Result.success(responseMapping(response))) - }, - onRejected = { throwable -> - callback.accept(Result.failure(throwable)) + try { + promiseFactory().then( + onFulfilled = { response: T -> + try { + callback.accept(Result.success(responseMapping(response))) + } catch (e: Exception) { + callback.accept(Result.failure(e)) + } + }, + onRejected = { throwable -> + callback.accept(Result.failure(throwable)) + } + ).catch { + callback.accept(Result.failure(it)) } - ) + } catch (e: Exception) { + callback.accept(Result.failure(e)) + } } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 29f71121f..1de44262e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -116,6 +116,7 @@ import com.pubnub.api.v2.entities.Channel import com.pubnub.api.v2.entities.ChannelGroup import com.pubnub.api.v2.entities.ChannelMetadata import com.pubnub.api.v2.entities.UserMetadata +import com.pubnub.api.v2.subscriptions.ReceivePresenceEventsImpl import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet @@ -715,7 +716,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { this.uuids = uuids.map { createJsObject { this.id = it.uuid this.custom = it.custom?.adjustCollectionTypes()?.unsafeCast() - this.status = status + this.status = it.status } }.toTypedArray() this.limit = limit this.page = page.toMetadataPage() @@ -836,7 +837,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { this.channels = channels.toTypedArray() this.channelGroups = channelGroups.toTypedArray() this.withPresence = withPresence - this.timetoken = withTimetoken + this.timetoken = withTimetoken.adjustCollectionTypes() as? String }) } @@ -884,11 +885,15 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { channelGroups: Set, options: SubscriptionOptions ): SubscriptionSet { - val params = mapOf( - "channels" to channels.toTypedArray(), - "channelGroups" to channelGroups.toTypedArray(), - //todo use options // "options" to - ).toJsMap() + val params = createJsObject { + this.channels = channels.toTypedArray() + this.channelGroups = channelGroups.toTypedArray() + this.subscriptionOptions = createJsObject { + if (options.allOptions.filterIsInstance().isNotEmpty()) { + receivePresenceEvents = true + } + } + } return SubscriptionSetImpl(jsPubNub.asDynamic().subscriptionSet(params)) } @@ -995,8 +1000,10 @@ fun PNConfiguration.toJs(): PubNubJs.PNConfiguration { config.userId = userId.value config.subscribeKey = subscribeKey config.publishKey = publishKey + // config.authKeys: String? -// config.logVerbosity: Boolean? + config.logVerbosity = logVerbosity + config.enableEventEngine = enableEventEngine // config.ssl: Boolean? // config.origin: dynamic /* String? | Array? */ // config.presenceTimeout: Number? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt index 5037877ce..6100ce8df 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt @@ -10,6 +10,8 @@ actual interface PNConfiguration { actual val secretKey: String actual val authKey: String actual val cryptoModule: CryptoModule? + val enableEventEngine: Boolean + val logVerbosity: Boolean } actual fun createPNConfiguration( @@ -31,6 +33,10 @@ actual fun createPNConfiguration( get() = TODO("Not yet implemented") override val cryptoModule: CryptoModule? get() = TODO("Not yet implemented") + override val enableEventEngine: Boolean + get() = false + override val logVerbosity: Boolean + get() = true } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt index e7b71317b..ed3a5238c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt @@ -6,10 +6,12 @@ import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.pubsub.Publish import com.pubnub.api.endpoints.pubsub.Signal import com.pubnub.api.v2.entities.Channel +import com.pubnub.api.v2.subscriptions.ReceivePresenceEventsImpl import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.internal.v2.subscriptions.SubscriptionImpl import com.pubnub.kmp.Uploadable +import com.pubnub.kmp.createJsObject class ChannelImpl( private val jsChannel: dynamic): Channel { @@ -53,7 +55,11 @@ class ChannelImpl( private val jsChannel: dynamic): Channel { get() = jsChannel.name override fun subscription(options: SubscriptionOptions): Subscription { //todo use options - return SubscriptionImpl(jsChannel.subscription()) + return SubscriptionImpl(jsChannel.subscription(createJsObject { + if (options.allOptions.filterIsInstance().isNotEmpty()) { + receivePresenceEvents = true + } + })) } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt index b4bf331e3..fbc309196 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt @@ -2,6 +2,7 @@ package com.pubnub.kmp import com.pubnub.api.JsonElementImpl import com.pubnub.api.PubNubImpl +import com.pubnub.api.enums.PNStatusCategory import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.files.PNDownloadableFile import com.pubnub.api.models.consumer.message_actions.PNMessageAction @@ -205,15 +206,22 @@ actual fun createStatusListener( ): StatusListener { val listener = object : PubNubJs.StatusListenerParameters, StatusListener { override val status: ((statusEvent: PubNubJs.StatusEvent) -> Unit) = { statusEvent -> - onStatus( - pubnub, PNStatus( - enumValueOf(statusEvent.category), //TODO parse category - null, - statusEvent.currentTimetoken.toString().toLong(), - statusEvent.affectedChannels.toList(), - statusEvent.affectedChannelGroups.toList() + val category = try { + enumValueOf(statusEvent.category) //TODO parse category + } catch (e: Exception) { + null + } + if (category != null) { + onStatus( + pubnub, PNStatus( + category, + null, + statusEvent.currentTimetoken.toString().toLongOrNull(), + statusEvent.affectedChannels?.toList() ?: emptyList(), + statusEvent.affectedChannelGroups?.toList() ?: emptyList() + ) ) - ) + } } } return listener diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt index c4f4a1008..b62f2d581 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt @@ -7,6 +7,10 @@ import com.pubnub.api.models.consumer.pubsub.PNEvent import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.createPNConfiguration +import com.pubnub.api.v2.entities.Subscribable +import com.pubnub.api.v2.subscriptions.EmptyOptions +import com.pubnub.api.v2.subscriptions.SubscribeCapable +import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.kmp.PNFuture import com.pubnub.kmp.PubNub import com.pubnub.kmp.createEventListener @@ -21,9 +25,12 @@ import kotlin.coroutines.resumeWithException import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.assertTrue +import kotlin.time.Duration.Companion.seconds abstract class BaseIntegrationTest { + val defaultTimeout = 10.seconds + lateinit var config: PNConfiguration lateinit var configPam: PNConfiguration lateinit var pubnub: PubNub @@ -105,16 +112,36 @@ class PubNubTest( }, ) - init { pubNub.addListener(eventVerificationListener) pubNub.addListener(statusVerificationListener) } + suspend fun com.pubnub.api.v2.entities.Channel.awaitSubscribe(options: SubscriptionOptions = EmptyOptions) = suspendCancellableCoroutine { cont -> + val subscription = subscription(options) + val statusListener = createStatusListener(pubNub) { _, pnStatus -> + if ((pnStatus.category == PNStatusCategory.PNConnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged) + && pnStatus.affectedChannels.contains(name)) { + cont.resume(subscription) + } + if (pnStatus.category == PNStatusCategory.PNUnexpectedDisconnectCategory || pnStatus.category == PNStatusCategory.PNConnectionError) { + cont.resumeWithException(pnStatus.exception ?: RuntimeException(pnStatus.category.toString())) + } + } + pubNub.addListener(statusListener) + cont.invokeOnCancellation { + pubNub.removeListener(statusListener) + } + subscription.subscribe() + } + suspend fun PubNub.awaitSubscribe( channels: Collection = setOf(), channelGroups: Collection = setOf(), - withPresence: Boolean = false + withPresence: Boolean = false, + customSubscriptionBlock: () -> Unit = { + subscribe(channels.toList(), channelGroups.toList(), withPresence) + } ) = suspendCancellableCoroutine { cont -> val statusListener = createStatusListener(pubNub) { _, pnStatus -> if ((pnStatus.category == PNStatusCategory.PNConnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged) @@ -132,7 +159,7 @@ class PubNubTest( cont.invokeOnCancellation { pubNub.removeListener(statusListener) } - subscribe(channels.toList(), channelGroups.toList(), withPresence) + customSubscriptionBlock() } // fun subscribe( @@ -196,7 +223,6 @@ class PubNubTest( // } // } - @Suppress("UNCHECKED_CAST") suspend fun nextEvent(): T { return messageQueue.receive() as T } From adac6f03bdceef41cafbeb822f7f7a2e82b3156f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 2 Jul 2024 16:33:15 +0000 Subject: [PATCH 34/62] More KMP tests (#248) * More tests and fixing equality checks in JSONElement --- kotlin-js-store/yarn.lock | 2 +- .../kotlin/com/pubnub/api/enums/PNPushType.kt | 4 +- .../consumer/history/HistoryMessageType.kt | 2 +- .../kotlin/com/pubnub/api/JsonElement.ios.kt | 33 +++- .../kotlin/com/pubnub/api/JsonElement.js.kt | 12 +- .../pubnub-kotlin-api/build.gradle.kts | 10 +- .../com/pubnub/api/v2/PNConfiguration.kt | 8 +- .../com/pubnub/api/DeleteMessagesTest.kt | 47 ++++++ .../com/pubnub/api/FetchMessagesTest.kt | 95 +++++++++++ .../kotlin/com/pubnub/api/HereWhereNowTest.kt | 48 ++++++ .../com/pubnub/api/MessageActionsTest.kt | 55 +++++++ .../com/pubnub/api/MessageCountsTest.kt | 46 ++++++ .../kotlin/com/pubnub/api/PublishTest.kt | 31 ++++ .../kotlin/com/pubnub/api/PushTest.kt | 153 ++++++++++++++++++ .../pubnub/api/endpoints/FetchMessages.ios.kt | 8 +- .../message_actions/AddMessageAction.ios.kt | 27 ++-- .../message_actions/GetMessageActions.ios.kt | 5 +- .../com/pubnub/api/v2/PNConfiguration.ios.kt | 3 +- .../src/jsMain/kotlin/Pubnub.d.kt | 2 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 10 +- .../pubnub/api/endpoints/FetchMessagesImpl.kt | 13 +- .../com/pubnub/api/v2/PNConfiguration.js.kt | 5 +- .../com/pubnub/api/v2/PNConfiguration.jvm.kt | 5 +- .../com.pubnub.test/BaseIntegrationTest.kt | 6 +- 24 files changed, 579 insertions(+), 51 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/DeleteMessagesTest.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/FetchMessagesTest.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/HereWhereNowTest.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageActionsTest.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageCountsTest.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PushTest.kt diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index b0526fa29..2a8e0ff3c 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -2823,7 +2823,7 @@ source-map-loader@5.0.0: iconv-lite "^0.6.3" source-map-js "^1.0.2" -source-map-support@0.5.21, source-map-support@~0.5.20: +source-map-support@~0.5.20: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt index db2126477..644f5d214 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt @@ -1,6 +1,6 @@ package com.pubnub.api.enums -enum class PNPushType(s: String) { +enum class PNPushType(private val value: String) { APNS("apns"), MPNS("mpns"), GCM("gcm"), @@ -8,8 +8,6 @@ enum class PNPushType(s: String) { APNS2("apns2"), ; - private val value: String = s - fun toParamString(): String { return value.lowercase() } diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt index 9071a9ffa..b17073be1 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt @@ -10,7 +10,7 @@ enum class HistoryMessageType(val value: Int) { companion object { fun of(value: Int?): HistoryMessageType = when (value) { - null, 0 -> Message + null, 0, -1, 999 -> Message 4 -> File else -> throw PubNubException("Unknown message type value $value") } diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt index f66f23ff0..2ed75a4dd 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt @@ -5,7 +5,31 @@ package com.pubnub.api import cocoapods.PubNubSwift.AnyJSONObjC import kotlinx.cinterop.ExperimentalForeignApi -actual abstract class JsonElement(val value: Any?) +actual abstract class JsonElement(val value: Any?) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is JsonElement) return false + + if (asMap() != null && other.asMap() != null) { + return asMap() == other.asMap() + } else if (asList() != null && other.asList() != null) { + return asList() == other.asList() + } else if (asString() != null && other.asString() != null) { + return asString() == other.asString() + } else if (asNumber() != null && other.asNumber() != null) { + return asNumber() == other.asNumber() + } + if (value != other.value) { + return false + } + + return true + } + + override fun hashCode(): Int { + return value?.hashCode() ?: 0 + } +} class JsonElementImpl(value: Any?) : JsonElement(value) @@ -19,10 +43,10 @@ actual fun JsonElement.asString(): String? { actual fun JsonElement.asMap(): Map? { return when (value) { - is AnyJSONObjC -> (value.asMap() as Map).mapValues { + is AnyJSONObjC -> (value.asMap() as? Map)?.mapValues { JsonElementImpl(it.value) } - is Map<*, *> -> (value as Map).mapValues { JsonElementImpl(it.value) } + is Map<*, *> -> (value as Map)?.mapValues { JsonElementImpl(it.value) } else -> null } } @@ -69,9 +93,8 @@ actual fun JsonElement.asDouble(): Double? { } actual fun JsonElement.asNumber(): Number? { - println(value.toString() + " " + value!!::class) return when (value) { - is AnyJSONObjC -> value.asNumber() as Number + is AnyJSONObjC -> value.asNumber() as? Number is Number -> value is Boolean -> if (value) 1 else 0 else -> null diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt index 9280073c6..61cc2c8de 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt @@ -11,6 +11,11 @@ actual abstract class JsonElement(val value: Any?) { if (this === other) return true if (other !is JsonElement) return false + if (asMap() != null && other.asMap() != null) { + return asMap() == other.asMap() + } else if (asList() != null && other.asList() != null) { + return asList() == other.asList() + } if (value != other.value) return false return true @@ -32,6 +37,7 @@ actual fun JsonElement.asString(): String? { } actual fun JsonElement.asMap(): Map? { + if (value?.isJsObject() != true) return null return value.unsafeCast>().toMap().mapValues { JsonElementImpl(it.value) } } @@ -40,7 +46,7 @@ actual fun JsonElement.isNull(): Boolean { } actual fun JsonElement.asList(): List? { - return (value as Array<*>).map { JsonElementImpl(it) } + return (value as? Array<*>)?.map { JsonElementImpl(it) } } actual fun JsonElement.asLong(): Long? { @@ -63,6 +69,10 @@ actual fun createJsonElement(any: Any?): JsonElement { return JsonElementImpl(any.adjustCollectionTypes()) } +private fun Any.isJsObject(): Boolean { + return this !is Array<*> && jsTypeOf(this) == "object" +} + internal fun Any?.adjustCollectionTypes(): Any? { return when (this) { is Map<*, *> -> { diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index daceb1f60..b23eced93 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -14,12 +14,12 @@ kotlin { js { browser { testTask { - useMocha { - timeout = "30s" - } -// useKarma { -// useChrome() +// useMocha { +// timeout = "30s" // } + useKarma { + useChrome() + } } } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt index 09396b05d..bf14d3467 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt @@ -16,4 +16,10 @@ expect interface PNConfiguration { expect interface CryptoModule -expect fun createPNConfiguration(userId: UserId, subscribeKey: String, publishKey: String, secretKey: String? = null): PNConfiguration \ No newline at end of file +expect fun createPNConfiguration( + userId: UserId, + subscribeKey: String, + publishKey: String, + secretKey: String? = null, + logVerbosity: Boolean = false, +): PNConfiguration \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/DeleteMessagesTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/DeleteMessagesTest.kt new file mode 100644 index 000000000..bc90399c1 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/DeleteMessagesTest.kt @@ -0,0 +1,47 @@ +package com.pubnub.api + +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import com.pubnub.test.randomString +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class DeleteMessagesTest : BaseIntegrationTest() { + private val channel = randomString() + + @Test + fun deleteMessages() = runTest { + val expectedMeta = mapOf(randomString() to randomString()) + val expectedMessage = randomString() + + val result = pubnub.publish( + channel = channel, + message = expectedMessage, + meta = expectedMeta, + shouldStore = true, + ttl = 60, + ).await() + + pubnub.deleteMessages( + channels = listOf(channel), + start = result.timetoken + 1, + end = result.timetoken + ).await() + + val messages = pubnub.fetchMessages( + channels = listOf(channel), + page = PNBoundedPage( + start = result.timetoken + 1, + end = result.timetoken + ) + ).await() + + if (messages.channels.isNotEmpty()) { + assertEquals(channel, messages.channels.entries.single().key) + assertTrue { messages.channels.entries.single().value.isEmpty() } + } + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/FetchMessagesTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/FetchMessagesTest.kt new file mode 100644 index 000000000..fb10a848f --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/FetchMessagesTest.kt @@ -0,0 +1,95 @@ +package com.pubnub.api + +import com.pubnub.api.models.consumer.history.HistoryMessageType +import com.pubnub.api.models.consumer.history.PNFetchMessageItem +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import com.pubnub.test.randomString +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class FetchMessagesTest : BaseIntegrationTest() { + private val channel = randomString() + + @Test + fun fetchMessages() = runTest { + val expectedMeta = mapOf(randomString() to randomString()) + val expectedMessage = randomString() + val expectedAction = randomString() + val expectedActionValue = randomString() + + val result = pubnub.publish( + channel = channel, + message = expectedMessage, + meta = expectedMeta, + shouldStore = true, + ttl = 60, + ).await() + + val actionResult = pubnub.addMessageAction( + channel = channel, + messageAction = PNMessageAction( + type = expectedAction, + value = expectedActionValue, + messageTimetoken = result.timetoken, + ), + ).await() + + val fetchResult = pubnub.fetchMessages( + includeMeta = true, + includeMessageActions = true, + includeMessageType = true, + includeUUID = true, + channels = listOf(channel), + ).await() + assertTrue { fetchResult.channels.isNotEmpty() } + + + val expectedItem = PNFetchMessageItem( + uuid = pubnub.configuration.userId.value, + message = createJsonElement(expectedMessage), + timetoken = result.timetoken, + meta = createJsonElement(expectedMeta), + messageType = HistoryMessageType.Message, + actions = mapOf( + expectedAction to mapOf( + expectedActionValue to listOf( + PNFetchMessageItem.Action( + actionTimetoken = actionResult.actionTimetoken.toString(), + uuid = pubnub.configuration.userId.value, + ), + ), + ), + ), + ) + + val expectedChannelsResponse: Map> = mapOf( + channel to listOf( + expectedItem, + ), + ) + + assertEquals(expectedChannelsResponse, fetchResult.channels) + + val fetchResultWithoutActions = pubnub.fetchMessages( + includeMeta = true, + includeMessageActions = false, + includeMessageType = true, + includeUUID = true, + channels = listOf(channel), + ).await() + + assertEquals( + mapOf( + channel to listOf( + expectedItem.copy(actions = null), + ), + ), + fetchResultWithoutActions.channels, + ) + } + +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/HereWhereNowTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/HereWhereNowTest.kt new file mode 100644 index 000000000..2e63df2a3 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/HereWhereNowTest.kt @@ -0,0 +1,48 @@ +package com.pubnub.api + +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import com.pubnub.test.randomString +import com.pubnub.test.test +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay +import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.withContext +import kotlin.test.Test +import kotlin.test.assertEquals + +class HereWhereNowTest : BaseIntegrationTest() { + private val channel = randomString() + + @Test + fun hereNow() = runTest(timeout = defaultTimeout) { + pubnub.test(backgroundScope) { + pubnub.awaitSubscribe(listOf(channel)) + withContext(Dispatchers.Default) { + delay(400) + } + + val result = pubnub.hereNow(listOf(channel)).await() + assertEquals(config.userId.value, result.channels[channel]?.occupants?.single()?.uuid) + assertEquals(1, result.channels[channel]?.occupancy) + assertEquals(1, result.totalChannels) + assertEquals(1, result.totalOccupancy) + assertEquals(channel, result.channels[channel]?.channelName) + } + } + + @Test + fun whereNow() = runTest(timeout = defaultTimeout) { + pubnub.test(backgroundScope) { + pubnub.awaitSubscribe(listOf(channel)) + withContext(Dispatchers.Default) { + delay(400) + } + + val result = pubnub.whereNow().await() + assertEquals(listOf(channel), result.channels) + } + } + + +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageActionsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageActionsTest.kt new file mode 100644 index 000000000..d52a4a027 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageActionsTest.kt @@ -0,0 +1,55 @@ +package com.pubnub.api + +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.history.HistoryMessageType +import com.pubnub.api.models.consumer.history.PNFetchMessageItem +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import com.pubnub.test.randomString +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class MessageActionsTest : BaseIntegrationTest() { + private val channel = randomString() + + @Test + fun add_getMessageAction() = runTest { + val expectedMeta = mapOf(randomString() to randomString()) + val expectedMessage = randomString() + val expectedAction = randomString() + val expectedActionValue = randomString() + + val result = pubnub.publish( + channel = channel, + message = expectedMessage, + meta = expectedMeta, + shouldStore = true, + ttl = 60, + ).await() + + val actionResult = pubnub.addMessageAction( + channel = channel, + messageAction = PNMessageAction( + type = expectedAction, + value = expectedActionValue, + messageTimetoken = result.timetoken, + ), + ).await() + + val actions = pubnub.getMessageActions(channel, PNBoundedPage( + start = actionResult.actionTimetoken!! + 1, + end = actionResult.actionTimetoken!! + )).await() + + assertTrue { actions.actions.isNotEmpty() } + val foundAction = actions.actions.single { it.actionTimetoken == actionResult.actionTimetoken } + assertEquals(expectedActionValue, foundAction.value) + assertEquals(actionResult.messageTimetoken, foundAction.messageTimetoken) + assertEquals(expectedAction, foundAction.type) + assertEquals(config.userId.value, foundAction.uuid) + } + +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageCountsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageCountsTest.kt new file mode 100644 index 000000000..76b28629c --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageCountsTest.kt @@ -0,0 +1,46 @@ +package com.pubnub.api + +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import com.pubnub.test.randomString +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertEquals + +class MessageCountsTest : BaseIntegrationTest() { + private val channel = randomString() + + @Test + fun messageCounts() = runTest { + val expectedMeta = mapOf(randomString() to randomString()) + val expectedMessage = randomString() + val expectedCount = 3L + val otherChannel = randomString() + val timetokens = (0 until expectedCount).map { + pubnub.publish( + channel = channel, + message = expectedMessage, + meta = expectedMeta, + shouldStore = true, + ttl = 60, + ).await().timetoken + } + val timetokensOther = (0 until expectedCount).map { + pubnub.publish( + channel = otherChannel, + message = expectedMessage, + meta = expectedMeta, + shouldStore = true, + ttl = 60, + ).await().timetoken + } + + val counts = pubnub.messageCounts( + listOf(channel, otherChannel), + listOf(timetokens.first() - 1, timetokensOther.first() - 1) + ).await() + + assertEquals(expectedCount, counts.channels[channel]) + assertEquals(expectedCount, counts.channels[otherChannel]) + } +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt index 4db2653d5..a07150a55 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt @@ -1,5 +1,6 @@ package com.pubnub.api +import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.kmp.PLATFORM import com.pubnub.kmp.createCustomObject import com.pubnub.test.BaseIntegrationTest @@ -30,6 +31,13 @@ class PublishTest : BaseIntegrationTest() { assertTrue { result.timetoken > 0 } } + @Test + fun can_signal() = + runTest(timeout = defaultTimeout) { + val result = pubnub.signal(channel, "some message").await() + assertTrue { result.timetoken > 0 } + } + @Test fun can_publish_message_map() = runTest(timeout = defaultTimeout) { @@ -37,6 +45,12 @@ class PublishTest : BaseIntegrationTest() { assertTrue { result.timetoken > 0 } } + @Test + fun can_signal_map() = + runTest(timeout = defaultTimeout) { + val result = pubnub.signal(channel, mapOf("platform" to PLATFORM, "otherKey" to 123, "another" to true)).await() + assertTrue { result.timetoken > 0 } + } @Test @Ignore // only JVM supports custom classes @@ -108,6 +122,23 @@ class PublishTest : BaseIntegrationTest() { } } + @Test + fun can_receive_signal_with_map_payload() = runTest(timeout = defaultTimeout) { + pubnub.test(backgroundScope) { + pubnub.awaitSubscribe(listOf(channel)) + val mapData = mapOf( + "stringValue" to "bbb", + "mapValue" to mapOf("innerKey" to false) + ) + pubnub.signal( + channel, + mapData, + ).await() + val result = nextEvent().message + deepCompare(mapData, result) + } + } + @Test fun can_receive_message_with_payload_with_floats() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PushTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PushTest.kt new file mode 100644 index 000000000..33bd3db27 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PushTest.kt @@ -0,0 +1,153 @@ +package com.pubnub.api + +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import com.pubnub.test.randomString +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock +import kotlinx.coroutines.test.runTest +import kotlin.test.AfterTest +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class PushTest : BaseIntegrationTest() { + private val channels = listOf(randomString(), randomString()) + + private val deviceId = + generateSequence { (0..9).random() }.take(70).toList().shuffled().joinToString(separator = "") + private val topic = randomString() + private val mutex = Mutex() //for some reason without this on JS tests run concurrently with before/after and fail + + @BeforeTest + override fun before() { + super.before() + runTest { + mutex.withLock { + pubnub.removePushNotificationsFromChannels(PNPushType.FCM, channels, deviceId).await() + pubnub.removePushNotificationsFromChannels( + PNPushType.APNS2, + channels, + deviceId, + topic, + PNPushEnvironment.PRODUCTION + ).await() + } + } + } + + @AfterTest + override fun after() { + runTest { + mutex.withLock { + pubnub.removePushNotificationsFromChannels(PNPushType.FCM, channels, deviceId).await() + pubnub.removePushNotificationsFromChannels( + PNPushType.APNS2, + channels, + deviceId, + topic, + PNPushEnvironment.PRODUCTION + ).await() + } + } + super.after() + } + + @Test + fun add_audit_removePushNotificationsOnChannels_fcm() = runTest { + mutex.withLock { + pubnub.addPushNotificationsOnChannels(PNPushType.FCM, channels, deviceId).await() + + val result = pubnub.auditPushChannelProvisions(PNPushType.FCM, deviceId).await() + assertEquals(channels.toSet(), result.channels.toSet()) + + pubnub.removePushNotificationsFromChannels( + PNPushType.FCM, + channels, + deviceId, + ).await() + + assertTrue { pubnub.auditPushChannelProvisions(PNPushType.FCM, deviceId) + .await().channels.isEmpty() } + } + } + + @Test + fun add_audit_removePushNotificationsOnChannels_apns() = runTest { + mutex.withLock { + pubnub.addPushNotificationsOnChannels( + PNPushType.APNS2, + channels, + deviceId, + topic, + PNPushEnvironment.PRODUCTION + ).await() + + val result = + pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) + .await() + assertEquals(channels.toSet(), result.channels.toSet()) + + pubnub.removePushNotificationsFromChannels( + PNPushType.APNS2, + channels, + deviceId, + topic, + PNPushEnvironment.PRODUCTION + ).await() + + assertTrue { pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) + .await().channels.isEmpty() } + } + } + + @Test + fun add_audit_removeAllPushNotifications_fcm() = runTest { + mutex.withLock { + pubnub.addPushNotificationsOnChannels(PNPushType.FCM, channels, deviceId).await() + + val result = pubnub.auditPushChannelProvisions(PNPushType.FCM, deviceId).await() + assertEquals(channels.toSet(), result.channels.toSet()) + + pubnub.removeAllPushNotificationsFromDeviceWithPushToken( + PNPushType.FCM, + deviceId, + ).await() + + assertTrue { pubnub.auditPushChannelProvisions(PNPushType.FCM, deviceId) + .await().channels.isEmpty() } + } + } + + @Test + fun add_audit_removeAllPushNotifications_apns() = runTest { + mutex.withLock { + pubnub.addPushNotificationsOnChannels( + PNPushType.APNS2, + channels, + deviceId, + topic, + PNPushEnvironment.PRODUCTION + ).await() + + val result = + pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) + .await() + assertEquals(channels.toSet(), result.channels.toSet()) + + pubnub.removeAllPushNotificationsFromDeviceWithPushToken( + PNPushType.APNS2, + deviceId, + topic, + PNPushEnvironment.PRODUCTION + ).await() + + assertTrue { pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) + .await().channels.isEmpty() } + } + } + +} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt index 4d6d312aa..061bcce11 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt @@ -71,13 +71,13 @@ open class FetchMessagesImpl( timetoken = it.published().toLong(), actions = mapMessageActions(rawValue = it.actions()), messageType = HistoryMessageType.of(it.messageType().toInt()), - error = PubNubError.CRYPTO_ERROR + error = null //todo translate crypto errors ) } } ?: emptyMap() } - private fun mapMessageActions(rawValue: List<*>): Map>> { + private fun mapMessageActions(rawValue: List<*>): Map>>? { return rawValue.filterIsInstance().groupBy { messageAction -> messageAction.actionType() }.mapValues { entry -> @@ -91,6 +91,8 @@ open class FetchMessagesImpl( ) } } - } ?: emptyMap() + }.ifEmpty { + null + } } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt index 1137334ae..5a841494b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt @@ -2,13 +2,13 @@ package com.pubnub.api.endpoints.message_actions import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.addMessageActionWithChannel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** @@ -23,21 +23,26 @@ class AddMessageActionImpl( private val channel: String, private val actionType: String, private val actionValue: String, - private val messageTimetoken: Long -): AddMessageAction { + private val messageTimetoken: Long, +) : AddMessageAction { override fun async(callback: Consumer>) { pubnub.addMessageActionWithChannel( channel = channel, actionType = actionType, actionValue = actionValue, messageTimetoken = messageTimetoken.toULong(), - onSuccess = callback.onSuccessHandler { PNAddMessageActionResult( - action = PNMessageAction( - type = it?.actionType().orEmpty(), - value = it?.actionValue().orEmpty(), - messageTimetoken = it?.messageTimetoken()?.toLong() ?: 0 + onSuccess = callback.onSuccessHandler { messageActionObjC -> + PNAddMessageActionResult( + action = PNMessageAction( + type = messageActionObjC?.actionType().orEmpty(), + value = messageActionObjC?.actionValue().orEmpty(), + messageTimetoken = messageActionObjC?.messageTimetoken()?.toLong() ?: 0, + ).apply { + uuid = messageActionObjC?.publisher() + actionTimetoken = messageActionObjC?.actionTimetoken()?.toLong() + } ) - )}, onFailure = callback.onFailureHandler() + }, onFailure = callback.onFailureHandler() ) } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt index a9b03b77e..d46560dbb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt @@ -58,6 +58,9 @@ class GetMessageActionsImpl( type = rawValue.actionType(), value = rawValue.actionValue(), messageTimetoken = rawValue.messageTimetoken().toLong() - ) + ).apply { + actionTimetoken = rawValue.actionTimetoken().toLong() + uuid = rawValue.publisher() + } } } \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt index 6ec166c7d..bfb785c7f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt @@ -17,7 +17,8 @@ actual fun createPNConfiguration( userId: UserId, subscribeKey: String, publishKey: String, - secretKey: String? + secretKey: String?, + logVerbosity: Boolean ): PNConfiguration { return object : PNConfiguration { override val userId: UserId = userId diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt index a82048c58..68afe5850 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt @@ -451,7 +451,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface FetchMessageItem { var channel: String - var message: JsonElement + var message: Any var timetoken: String var messageType: String? var uuid: String diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 1de44262e..29e112a33 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -174,16 +174,16 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { return FireImpl(jsPubNub, createJsObject { - this.message = message + this.message = message.adjustCollectionTypes() this.channel = channel - this.meta = meta + this.meta = meta?.adjustCollectionTypes() this.sendByPost = usePost }) } override fun signal(channel: String, message: Any): Signal { return SignalImpl(jsPubNub, createJsObject { - this.message = message + this.message = message.adjustCollectionTypes() this.channel = channel }) } @@ -204,7 +204,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { this.channels = channels.toTypedArray() this.device = deviceId this.topic = topic - this.environment = environment.name.lowercase() + this.environment = environment.toParamString() }) } @@ -218,7 +218,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { this.pushGateway = pushType.toParamString() this.device = deviceId this.topic = topic - this.topic = topic + this.environment = environment.toParamString() }) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt index eb296f42b..121f2f53f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt @@ -3,6 +3,7 @@ package com.pubnub.api.endpoints import PubNub import com.pubnub.api.EndpointImpl import com.pubnub.api.JsonElementImpl +import com.pubnub.api.createJsonElement import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.HistoryMessageType import com.pubnub.api.models.consumer.history.PNFetchMessageItem @@ -10,14 +11,15 @@ import com.pubnub.api.models.consumer.history.PNFetchMessagesResult import com.pubnub.kmp.toMap class FetchMessagesImpl(pubnub: PubNub, params: PubNub.FetchMessagesParameters) : FetchMessages, - EndpointImpl(promiseFactory = { pubnub.fetchMessages(params) }, + EndpointImpl( + promiseFactory = { pubnub.fetchMessages(params) }, responseMapping = { response -> PNFetchMessagesResult(response.channels.toMap().mapValues { it.value.map { item -> PNFetchMessageItem( item.uuid, - item.message, - JsonElementImpl(item.meta), + createJsonElement(item.message), + createJsonElement(item.meta), item.timetoken.toString().toLong(), item.actions?.toMap()?.mapValues { entry: Map.Entry -> entry.value.toMap().mapValues { entry2: Map.Entry> -> @@ -26,9 +28,10 @@ class FetchMessagesImpl(pubnub: PubNub, params: PubNub.FetchMessagesParameters) } } }, - HistoryMessageType.of(item.messageType?.toInt()), + HistoryMessageType.of(item.messageType?.toString()?.toInt()), null, //TODO item.error ) } }, response.more?.let { PNBoundedPage(it.start.toLong(), null, it.max.toInt()) }) - }) \ No newline at end of file + } + ) \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt index 6100ce8df..164ec5d98 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt @@ -18,7 +18,8 @@ actual fun createPNConfiguration( userId: UserId, subscribeKey: String, publishKey: String, - secretKey: String? + secretKey: String?, + logVerbosity: Boolean ): PNConfiguration { return object : PNConfiguration { override val userId: UserId @@ -36,7 +37,7 @@ actual fun createPNConfiguration( override val enableEventEngine: Boolean get() = false override val logVerbosity: Boolean - get() = true + get() = logVerbosity } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt index bfb57896a..d53235e0d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt @@ -2,16 +2,19 @@ package com.pubnub.api.v2 import com.pubnub.api.UserId import com.pubnub.api.crypto.CryptoModule +import com.pubnub.api.enums.PNLogVerbosity actual fun createPNConfiguration( userId: UserId, subscribeKey: String, publishKey: String, - secretKey: String? + secretKey: String?, + logVerbosity: Boolean ): PNConfiguration { return PNConfiguration.builder(userId, subscribeKey) { this.publishKey = publishKey this.secretKey = secretKey.orEmpty() + this.logVerbosity = if (logVerbosity) PNLogVerbosity.BODY else PNLogVerbosity.NONE }.build() } diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt index b62f2d581..ee23a7fce 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt @@ -7,9 +7,7 @@ import com.pubnub.api.models.consumer.pubsub.PNEvent import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.createPNConfiguration -import com.pubnub.api.v2.entities.Subscribable import com.pubnub.api.v2.subscriptions.EmptyOptions -import com.pubnub.api.v2.subscriptions.SubscribeCapable import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.kmp.PNFuture import com.pubnub.kmp.PubNub @@ -39,14 +37,14 @@ abstract class BaseIntegrationTest { @BeforeTest open fun before() { - config = createPNConfiguration(UserId(randomString()), Keys.subKey, Keys.pubKey) + config = createPNConfiguration(UserId(randomString()), Keys.subKey, Keys.pubKey, logVerbosity = true) pubnub = createPubNub(config) configPam = createPNConfiguration(UserId(randomString()), Keys.pamSubKey, Keys.pamPubKey, Keys.pamSecKey) pubnubPam = createPubNub(configPam) } @AfterTest - fun after() { + open fun after() { pubnub.unsubscribeAll() pubnub.destroy() pubnubPam.unsubscribeAll() From 4656ca429984d7ae75742a249d46c7bd52f30c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Thu, 4 Jul 2024 08:26:46 +0000 Subject: [PATCH 35/62] Change GSON number strategy to lazily parsed (#250) All custom objects will contain Number in place of integers or doubles that need to be changed to desired concrete types with toLong etc. This is a breaking change. --- .../pubnub/internal/managers/MapperManager.kt | 2 + .../internal/managers/MapperManagerTest.kt | 41 +++++++++++++++++++ .../AbstractReconnectionProblemIT.java | 3 ++ .../api/integration/ObjectsIntegrationTest.kt | 8 ++-- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt index 14c674376..0b917e2fb 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt @@ -10,6 +10,7 @@ import com.google.gson.JsonObject import com.google.gson.JsonParseException import com.google.gson.JsonSerializationContext import com.google.gson.JsonSerializer +import com.google.gson.ToNumberPolicy import com.google.gson.TypeAdapter import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonToken @@ -60,6 +61,7 @@ class MapperManager { .registerTypeAdapter(JSONObject::class.java, JSONObjectAdapter()) .registerTypeAdapter(JSONArray::class.java, JSONArrayAdapter()) .disableHtmlEscaping() + .setObjectToNumberStrategy(ToNumberPolicy.LAZILY_PARSED_NUMBER) .create() converterFactory = GsonConverterFactory.create(objectMapper) } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt index ef2b728b0..251d61854 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt @@ -69,4 +69,45 @@ internal class MapperManagerTest { assertEquals(expected, json1) assertEquals(expected, json2) } + + @Test + fun fromJson_numbers() { + val mapperManager = MapperManager() + val map = mapOf( + "a" to 12345678, + "b" to 1.2313, + "c" to 943809302493249023L, + "d" to 1, + "e" to 0, + "f" to "943809302493249023" + ) + val json = mapperManager.toJson(map) + val decodedMap = mapperManager.fromJson>(json, Map::class.java) + decodedMap.forEach { t, u -> + println("$t: $u (${u!!::class}") + } + assertEquals(map["a"], decodedMap["a"].tryLong()?.toInt()) + assertEquals(map["b"], decodedMap["b"].tryDouble()) + assertEquals(map["c"], decodedMap["c"].tryLong()) + assertEquals(map["d"], decodedMap["d"].tryLong()?.toInt()) + assertEquals(map["e"], decodedMap["e"].tryLong()?.toInt()) + assertEquals(map["f"], decodedMap["f"]) + assertEquals(map["f"].toString().toLong(), decodedMap["f"].tryLong()) + } +} + +private fun Any?.tryLong(): Long? { + return when (this) { + is Number -> toLong() + is String -> toLongOrNull() + else -> null + } +} + +private fun Any?.tryDouble(): Double? { + return when (this) { + is Number -> toDouble() + is String -> toDoubleOrNull() + else -> null + } } diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java index 0e207447e..ccc2f5792 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java @@ -13,6 +13,7 @@ import org.junit.AssumptionViolatedException; import org.junit.Before; import org.junit.ClassRule; +import org.junit.Ignore; import org.junit.Test; import org.junit.rules.TestRule; import org.junit.runner.Description; @@ -202,6 +203,7 @@ private PubNub adminPubNub() { } @Test + @Ignore public void alwaysContinueSubscriptionToChannelGroupIfNoActionTaken() throws PubNubException, InterruptedException { final String channelGroup = "chg-1-" + randomId(); @@ -222,6 +224,7 @@ public void alwaysContinueSubscriptionToChannelGroupIfNoActionTaken() throws Pub @Test + @Ignore public void alwaysContinueSubscriptionIfNoActionTaken() throws InterruptedException { final String channel = "ch-" + randomId(); diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt index 5f292ef73..f6a6e5b8c 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt @@ -41,14 +41,14 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { type = type, ).sync() - val getAllResult = pubnub.getAllChannelMetadata().sync() + val getAllResult = pubnub.getAllChannelMetadata(filter = "id == \"$channel\"").sync() val getSingleResult = pubnub.getChannelMetadata(channel = channel).sync() pubnub.removeChannelMetadata(channel = channel).sync() assertTrue(getAllResult.data.any { it.id == channel }) assertEquals(setResult, getSingleResult) - val getAllAfterRemovalResult = pubnub.getAllChannelMetadata().sync() + val getAllAfterRemovalResult = pubnub.getAllChannelMetadata(filter = "id == \"$channel\"").sync() assertTrue(getAllAfterRemovalResult.data.none { it.id == channel }) } @@ -66,14 +66,14 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { assertEquals(status, setResult.data?.status) assertEquals(type, setResult.data?.type) - val getAllResult = pubnub.getAllUUIDMetadata().sync() + val getAllResult = pubnub.getAllUUIDMetadata(filter = "id == \"$testUuid\"").sync() val getSingleResult = pubnub.getUUIDMetadata(uuid = testUuid).sync() pubnub.removeUUIDMetadata(uuid = testUuid).sync() assertTrue(getAllResult.data.any { it.id == testUuid }) assertEquals(setResult, getSingleResult) - val getAllAfterRemovalResult = pubnub.getAllUUIDMetadata().sync() + val getAllAfterRemovalResult = pubnub.getAllUUIDMetadata(filter = "id == \"$testUuid\"").sync() assertTrue(getAllAfterRemovalResult.data.none { it.id == testUuid }) } From 20d8ecc522f6168f5960b06f08c43f38f0f7788b Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Mon, 8 Jul 2024 20:47:29 +0200 Subject: [PATCH 36/62] Fixes for custom fields (AppContext) and push methods (#252) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixes for custom fields (AppContext) and push methods * Fix for SetChannelMembersImpl * Added missing changes from swift repository * Fix for factories.ios.kt * Some test fixes --------- Co-authored-by: Wojciech Kaliciński --- .../kotlin/com/pubnub/api/MembersTest.kt | 21 +++++++++++++++++-- .../kotlin/com/pubnub/api/PublishTest.kt | 8 +++---- .../kotlin/com/pubnub/api/UserMetadataTest.kt | 2 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 19 ++++++++++------- .../member/ManageChannelMembers.ios.kt | 3 ++- .../membership/ManageMemberships.ios.kt | 4 +++- .../endpoints/push/AddChannelsToPush.ios.kt | 7 ++++++- .../endpoints/push/ListPushProvisions.ios.kt | 7 ++++++- .../RemoveAllPushChannelsForDevice.ios.kt | 7 ++++++- .../push/RemoveChannelsFromPush.ios.kt | 7 ++++++- .../kmp/{Converters.kt => converters.kt} | 10 ++++----- .../kotlin/com/pubnub/kmp/factories.ios.kt | 6 +++--- swift | 2 +- 13 files changed, 74 insertions(+), 29 deletions(-) rename pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/{Converters.kt => converters.kt} (93%) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt index e2ff7a666..b50772a0a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt @@ -8,6 +8,7 @@ import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await import com.pubnub.test.randomString import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.yield import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse @@ -28,14 +29,29 @@ class MembersTest : BaseIntegrationTest() { // when val result = pubnub.setChannelMembers( channel, - listOf(PNMember.Partial(pubnub.configuration.userId.value, custom, status)), + listOf(PNMember.Partial(pubnub.configuration.userId.value, custom, null)), includeCustom = includeCustom, - includeUUIDDetails = PNUUIDDetailsLevel.UUID_WITH_CUSTOM + includeUUIDDetails = PNUUIDDetailsLevel.UUID_WITH_CUSTOM, ).await() // then val pnChannelDetails = result.data.single { it.uuid?.id == pubnub.configuration.userId.value } assertEquals(customData, pnChannelDetails.custom) +// assertEquals(status, pnChannelDetails.status) + } + + @Test + fun can_set_members_with_status() = runTest(timeout = 10.seconds) { + // when + val result = pubnub.setChannelMembers( + channel, + listOf(PNMember.Partial(pubnub.configuration.userId.value, null, status)), + includeCustom = includeCustom, + includeUUIDDetails = PNUUIDDetailsLevel.UUID_WITH_CUSTOM, + ).await() + + // then + val pnChannelDetails = result.data.single { it.uuid?.id == pubnub.configuration.userId.value } assertEquals(status, pnChannelDetails.status) } @@ -53,6 +69,7 @@ class MembersTest : BaseIntegrationTest() { // then var next: PNPage.PNNext? = null while(true) { + yield() val result = pubnub.getMemberships(pubnub.configuration.userId.value, page = next).await() next = result.next assertFalse { result.data.any { it.channel?.id == channel } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt index a07150a55..070392d7f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt @@ -2,7 +2,6 @@ package com.pubnub.api import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.kmp.PLATFORM -import com.pubnub.kmp.createCustomObject import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await import com.pubnub.test.test @@ -12,7 +11,6 @@ import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue -import kotlin.time.Duration.Companion.seconds @JsExport data class ABC ( @@ -61,7 +59,7 @@ class PublishTest : BaseIntegrationTest() { } @Test - fun can_receive_message_with_object_metadata() = runTest(timeout = defaultTimeout) { + fun can_receive_message_with_map_metadata() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) val mapData = mapOf( @@ -74,13 +72,15 @@ class PublishTest : BaseIntegrationTest() { "longValue" to 1000L, "listValue" to listOf(123, "aaa", mapOf("innerK" to "innerV")) ) - pubnub.publish(channel, "some message", createCustomObject(mapData)).await() + pubnub.publish(channel, "some message", mapData).await() val result = nextMessage() assertEquals("some message", result.message.asString()) deepCompare(mapData, result.userMetadata!!) } } + private fun isIOS() = PLATFORM == "iOS" + @Test fun can_receive_message_with_primitive_payload() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt index b9ffc72e5..ecafa075f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt @@ -216,7 +216,7 @@ class UserMetadataTest : BaseIntegrationTest() { } // then - assertTrue { allUsers.size == 6 } + assertEquals(6, allUsers.size) repeat(6) { val pnuuidMetadata = allUsers.firstOrNull { user -> user.id == uuid + it } assertNotNull(pnuuidMetadata) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 24c264021..e8721e9bb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -206,7 +206,6 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { return pubNubObjC.subscribedChannelGroups().filterIsInstance() } - // TODO: Why do we need topic parameter here? override fun addPushNotificationsOnChannels( pushType: PNPushType, channels: List, @@ -215,14 +214,15 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { environment: PNPushEnvironment ): AddChannelsToPush { return AddChannelsToPushImpl( + pushType = pushType, pubnub = pubNubObjC, channels = channels, deviceId = deviceId, - pushType = pushType + topic = topic, + environment = environment ) } - // TODO: Why do we need topic and environment parameters here? override fun auditPushChannelProvisions( pushType: PNPushType, deviceId: String, @@ -232,11 +232,12 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { return ListPushProvisionsImpl( pubnub = pubNubObjC, deviceId = deviceId, - pushType = pushType + pushType = pushType, + topic = topic, + environment = environment ) } - // TODO: Why do we need topic and environment parameters here? override fun removePushNotificationsFromChannels( pushType: PNPushType, channels: List, @@ -248,7 +249,9 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { pubnub = pubNubObjC, channels = channels, deviceId = deviceId, - pushType = pushType + pushType = pushType, + topic = topic, + environment = environment ) } @@ -261,7 +264,9 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { return RemoveAllPushChannelsForDeviceImpl( pubnub = pubNubObjC, deviceId = deviceId, - pushType = pushType + pushType = pushType, + topic = topic, + environment = environment ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt index e4fd75a77..9230a0e4a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt @@ -1,5 +1,6 @@ package com.pubnub.api.endpoints.objects.member +import cocoapods.PubNubSwift.AnyJSONObjC import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.PubNubUUIDMetadataObjC @@ -43,7 +44,7 @@ class SetChannelMembersImpl( override fun async(callback: Consumer>) { pubnub.setChannelMembersWithChannel( channel = channel, - uuids = uuids.map { PubNubUUIDMetadataObjC(id = it.uuid, custom = it.custom?.value, status = it.status) }, + uuids = uuids.map { PubNubUUIDMetadataObjC(id = it.uuid, custom = AnyJSONObjC(it.custom?.value), status = it.status) }, limit = limit?.let { NSNumber(it) }, page = createPubNubHashedPage(from = page), filter = filter, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt index b866373ca..dece4a5c0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt @@ -1,5 +1,7 @@ package com.pubnub.api.endpoints.objects.membership +import cocoapods.PubNubSwift.AnyJSONObjC +import cocoapods.PubNubSwift.PubNubChannelMetadataObjC import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeMembershipsWithChannels @@ -41,7 +43,7 @@ class AddMembershipsImpl( ): ManageMemberships { override fun async(callback: Consumer>) { pubnub.setMembershipsWithChannels( - channels = channels, + channels = channels.map { PubNubChannelMetadataObjC(it.channel, AnyJSONObjC(it.custom?.value), it.status)}, uuid = uuid, limit = limit?.let { NSNumber(it) }, page = createPubNubHashedPage(from = page), diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt index 991f5a680..a770abd24 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt @@ -4,6 +4,7 @@ import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.addChannelsToPushNotificationsWithChannels import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException +import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushAddChannelResult import com.pubnub.kmp.onFailureHandler @@ -20,10 +21,12 @@ actual interface AddChannelsToPush : PNFuture @OptIn(ExperimentalForeignApi::class) class AddChannelsToPushImpl( + private val pushType: PNPushType, private val pubnub: PubNubObjC, private val channels: List, private val deviceId: String, - private val pushType: PNPushType + private val topic: String?, + private val environment: PNPushEnvironment ): AddChannelsToPush { override fun async(callback: Consumer>) { deviceId.toNSData()?.let { data: NSData -> @@ -31,6 +34,8 @@ class AddChannelsToPushImpl( channels = channels, deviceId = data, pushType = pushType.toParamString(), + topic = topic.orEmpty(), + environment = environment.toParamString(), onSuccess = callback.onSuccessHandler { PNPushAddChannelResult() }, onFailure = callback.onFailureHandler() ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt index 59a0c6cd9..075253d6e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt @@ -4,6 +4,7 @@ import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.listPushChannelsWithDeviceId import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException +import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult import com.pubnub.kmp.onFailureHandler @@ -23,13 +24,17 @@ actual interface ListPushProvisions : PNFuture class ListPushProvisionsImpl( private val pubnub: PubNubObjC, private val deviceId: String, - private val pushType: PNPushType + private val pushType: PNPushType, + private val topic: String?, + private val environment: PNPushEnvironment ): ListPushProvisions { override fun async(callback: Consumer>) { deviceId.toNSData()?.let { data: NSData -> pubnub.listPushChannelsWithDeviceId( deviceId = data, pushType = pushType.toParamString(), + topic = topic.orEmpty(), + environment = environment.toParamString(), onSuccess = callback.onSuccessHandler { PNPushListProvisionsResult(channels = it?.filterIsInstance() ?: emptyList()) }, onFailure = callback.onFailureHandler() ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt index 8e81b6753..6f85d7079 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt @@ -4,6 +4,7 @@ import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeAllChannelsFromPushWithPushType import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException +import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult import com.pubnub.kmp.onFailureHandler @@ -23,13 +24,17 @@ actual interface RemoveAllPushChannelsForDevice : PNFuture>) { deviceId.toNSData()?.let { data: NSData -> pubnub.removeAllChannelsFromPushWithPushType( pushType = pushType.toParamString(), deviceId = data, + topic = topic.orEmpty(), + environment = environment.toParamString(), onSuccess = callback.onSuccessReturnValue(PNPushRemoveAllChannelsResult()), onFailure = callback.onFailureHandler() ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt index b792d4f8e..c5f71f6a4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt @@ -4,6 +4,7 @@ import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeChannelsFromPushWithChannels import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException +import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult import com.pubnub.kmp.onFailureHandler @@ -23,7 +24,9 @@ class RemoveChannelsFromPushImpl( private val pubnub: PubNubObjC, private val channels: List, private val deviceId: String, - private val pushType: PNPushType + private val pushType: PNPushType, + private val topic: String?, + private val environment: PNPushEnvironment, ): RemoveChannelsFromPush { override fun async(callback: Consumer>) { deviceId.toNSData()?.let { data: NSData -> @@ -31,6 +34,8 @@ class RemoveChannelsFromPushImpl( channels = channels, deviceId = data, pushType = pushType.toParamString(), + topic = topic.orEmpty(), + environment = environment.toParamString(), onSuccess = callback.onSuccessHandler { PNPushRemoveChannelResult() }, onFailure = callback.onFailureHandler() ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt similarity index 93% rename from pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt index 4f498438d..dbf8335c2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Converters.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt @@ -39,7 +39,7 @@ internal fun createPNUUIDMetadata(from: PubNubUUIDMetadataObjC): PNUUIDMetadata externalId = from.externalId(), profileUrl = from.profileUrl(), email = from.email(), - custom = from.custom()?.asMap()?.safeCast(), + custom = from.custom()?.safeCast(), updated = from.updated(), eTag = from.eTag(), type = from.type(), @@ -53,7 +53,7 @@ internal fun createPNChannelMetadata(from: PubNubChannelMetadataObjC): PNChannel id = from.id(), name = from.name(), description = from.descr(), - custom = from.custom()?.asMap()?.safeCast(), + custom = from.custom()?.safeCast(), updated = from.updated(), eTag = from.eTag(), type = from.type(), @@ -78,7 +78,7 @@ internal fun createPNChannelMembership(from: PubNubMembershipMetadataObjC): PNCh id = from.channel()?.id().orEmpty(), name = from.channel()?.name().orEmpty(), description = from.channel()?.descr().orEmpty(), - custom = from.channel()?.custom()?.asMap()?.safeCast(), + custom = from.channel()?.custom()?.safeCast(), updated = from.channel()?.updated(), eTag = from.channel()?.eTag(), type = from.channel()?.type(), @@ -95,7 +95,7 @@ internal fun createPNChannelMembership(from: PubNubMembershipMetadataObjC): PNCh internal fun createPNMember(from: PubNubMembershipMetadataObjC): PNMember { return PNMember( uuid = from.uuid()?.let { createPNUUIDMetadata(from = it) }, - custom = from.custom()?.safeCast(), // TODO: Verify + custom = from.custom()?.safeCast(), updated = from.updated().orEmpty(), eTag = from.eTag().orEmpty(), status = from.status() @@ -109,4 +109,4 @@ internal inline fun List<*>?.filterAndMap(mapper: (T) -> U): Coll @Suppress("UNCHECKED_CAST") inline fun Map<*, *>.safeCast(): Map { return this as? Map ?: error("Cannot make the cast") -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 38cd34219..394bc4fd8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -165,7 +165,7 @@ private fun createFileEventResult(from: PubNubFileChangeEventObjC?): PNFileEvent file = PNDownloadableFile( id = from.file().id(), name = from.file().name(), - url = from.file().url()?.absoluteString ?: "" + url = from.file().url()?.absoluteString.orEmpty() ) ) } @@ -200,7 +200,7 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM externalId = from.metadata().externalId(), profileUrl = from.metadata().profileUrl(), email = from.metadata().email(), - custom = from.metadata().custom()?.asMap()?.safeCast(), + custom = from.metadata().custom()?.safeCast(), updated = from.metadata().updated(), eTag = from.metadata().eTag(), type = from.metadata().type(), @@ -225,7 +225,7 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM id = from.metadata().id(), name = from.metadata().name(), description = from.metadata().descr(), - custom = from.metadata().custom()?.asMap()?.safeCast(), + custom = from.metadata().custom()?.safeCast(), updated = from.metadata().updated(), eTag = from.metadata().eTag(), type = from.metadata().type(), diff --git a/swift b/swift index 9c1b9a198..cde54b05f 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit 9c1b9a19863b6cee24faf6302f223e06930366e7 +Subproject commit cde54b05f0c7aa546aefc0e050185b96ef31cb16 From 365be720cfaa3a85e3bafc7592db457d2464677c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 9 Jul 2024 08:48:34 +0000 Subject: [PATCH 37/62] Change actionTimetoken to Long, ktlint, tests (#253) * More tests * Change timetokens to long * Re-add ktLint --- .../gradle/PubNubKotlinLibraryPlugin.kt | 24 - .../com/pubnub/gradle/PubNubSharedPlugin.kt | 32 + pubnub-core/pubnub-core-api/build.gradle.kts | 3 - .../kotlin/com/pubnub/api/JsonElement.kt | 13 +- .../kotlin/com/pubnub/api/PubNubException.kt | 4 +- .../consumer/files/PNDownloadFileResult.kt | 2 +- .../models/consumer/history/PNFetchMessage.kt | 4 +- .../objects/channel/PNChannelMetadata.kt | 2 +- .../push/payload/PushPayloadHelper.kt | 2 +- .../pubnub/api/retry/RetryConfiguration.kt | 4 +- .../com/pubnub/api/v2/callbacks/Consumer.kt | 2 +- .../com/pubnub/api/v2/callbacks/Result.kt | 185 +- .../kotlin/com/pubnub/kmp/Downloadable.kt | 2 +- .../kotlin/com/pubnub/kmp/PNFuture.kt | 2 +- .../kotlin/com/pubnub/kmp/futures.kt | 19 +- .../kotlin/com/pubnub/kmp/PNFutureTest.kt | 3 +- .../kotlin/com/pubnub/api/JsonElement.ios.kt | 36 +- .../com/pubnub/api/PubNubException.ios.kt | 5 +- .../pubnub/api/v2/callbacks/Consumer.ios.kt | 2 +- .../kotlin/com/pubnub/kmp/Downloadable.ios.kt | 2 +- .../kotlin/com/pubnub/api/JsonElement.js.kt | 32 +- .../com/pubnub/api/PubNubException.js.kt | 3 +- .../pubnub/api/v2/callbacks/Consumer.js.kt | 2 +- .../kotlin/com/pubnub/kmp/Downloadable.js.kt | 2 +- .../src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt | 1 - .../kotlin/com/pubnub/api/BasePubNub.kt | 1 - .../kotlin/com/pubnub/api/JsonElement.jvm.kt | 46 +- .../kotlin/com/pubnub/api/PubNubException.kt | 2 +- .../pubnub/api/v2/callbacks/Consumer.jvm.kt | 2 +- .../kotlin/com/pubnub/kmp/Downloadable.jvm.kt | 2 +- .../v3/FetchMessagesMetaActionsTestSuite.kt | 2 +- .../pubnub-kotlin-api/build.gradle.kts | 3 +- .../pubnub/api/endpoints/DeleteMessages.kt | 4 +- .../com/pubnub/api/endpoints/FetchMessages.kt | 2 +- .../com/pubnub/api/endpoints/MessageCounts.kt | 4 +- .../kotlin/com/pubnub/api/endpoints/Time.kt | 4 +- .../pubnub/api/endpoints/access/GrantToken.kt | 5 +- .../api/endpoints/access/RevokeToken.kt | 2 +- .../channel_groups/AddChannelChannelGroup.kt | 4 +- .../channel_groups/AllChannelsChannelGroup.kt | 4 +- .../channel_groups/DeleteChannelGroup.kt | 4 +- .../channel_groups/ListAllChannelGroup.kt | 4 +- .../RemoveChannelChannelGroup.kt | 5 +- .../pubnub/api/endpoints/files/DeleteFile.kt | 4 +- .../api/endpoints/files/DownloadFile.kt | 2 - .../pubnub/api/endpoints/files/GetFileUrl.kt | 4 +- .../pubnub/api/endpoints/files/ListFiles.kt | 4 +- .../api/endpoints/files/PublishFileMessage.kt | 4 +- .../pubnub/api/endpoints/files/SendFile.kt | 1 - .../message_actions/AddMessageAction.kt | 5 +- .../message_actions/GetMessageActions.kt | 5 +- .../message_actions/RemoveMessageAction.kt | 5 +- .../objects/channel/GetAllChannelMetadata.kt | 4 +- .../objects/channel/GetChannelMetadata.kt | 4 +- .../objects/channel/RemoveChannelMetadata.kt | 4 +- .../objects/channel/SetChannelMetadata.kt | 4 +- .../objects/member/GetChannelMembers.kt | 4 +- .../objects/member/ManageChannelMembers.kt | 4 +- .../objects/membership/GetMemberships.kt | 4 +- .../objects/membership/ManageMemberships.kt | 4 +- .../objects/uuid/GetAllUUIDMetadata.kt | 4 +- .../endpoints/objects/uuid/GetUUIDMetadata.kt | 5 +- .../objects/uuid/RemoveUUIDMetadata.kt | 5 +- .../endpoints/objects/uuid/SetUUIDMetadata.kt | 4 +- .../pubnub/api/endpoints/presence/GetState.kt | 5 +- .../pubnub/api/endpoints/presence/HereNow.kt | 5 +- .../pubnub/api/endpoints/presence/SetState.kt | 5 +- .../pubnub/api/endpoints/presence/WhereNow.kt | 5 +- .../pubnub/api/endpoints/pubsub/Publish.kt | 4 +- .../com/pubnub/api/endpoints/pubsub/Signal.kt | 4 +- .../api/endpoints/push/AddChannelsToPush.kt | 4 +- .../api/endpoints/push/ListPushProvisions.kt | 4 +- .../push/RemoveAllPushChannelsForDevice.kt | 4 +- .../endpoints/push/RemoveChannelsFromPush.kt | 4 +- .../objects/PNRemoveMetadataResult.kt | 2 +- .../consumer/objects/member/PNMember.kt | 2 +- .../objects/membership/PNChannelMembership.kt | 4 +- .../pubsub/objects/PNObjectEventResult.kt | 2 +- .../com/pubnub/api/v2/PNConfiguration.kt | 3 +- .../pubnub/api/v2/callbacks/EventListener.kt | 4 +- .../pubnub/api/v2/callbacks/StatusListener.kt | 2 +- .../com/pubnub/api/v2/entities/Channel.kt | 8 +- .../kotlin/com/pubnub/kmp/Optional.kt | 11 +- .../kotlin/com/pubnub/kmp/PubNub.kt | 19 +- .../kotlin/com/pubnub/kmp/abstractions.kt | 2 +- .../kotlin/com/pubnub/kmp/factories.kt | 3 +- .../com/pubnub/api/ChannelMetadataTest.kt | 60 +- .../com/pubnub/api/DeleteMessagesTest.kt | 7 +- .../kotlin/com/pubnub/api/EntitiesTest.kt | 22 +- .../com/pubnub/api/FetchMessagesTest.kt | 38 +- .../kotlin/com/pubnub/api/HereWhereNowTest.kt | 13 +- .../kotlin/com/pubnub/api/MembersTest.kt | 2 +- .../kotlin/com/pubnub/api/MembershipsTest.kt | 3 +- .../com/pubnub/api/MessageActionsTest.kt | 30 +- .../com/pubnub/api/MessageCountsTest.kt | 2 +- .../kotlin/com/pubnub/api/PublishTest.kt | 9 +- .../kotlin/com/pubnub/api/PushTest.kt | 42 +- .../kotlin/com/pubnub/api/TimeTest.kt | 15 + .../kotlin/com/pubnub/api/UserMetadataTest.kt | 6 +- .../kotlin/com/pubnub/kmp/platform.kt | 2 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 8 +- .../api/endpoints/DeleteMessages.ios.kt | 12 +- .../pubnub/api/endpoints/FetchMessages.ios.kt | 23 +- .../pubnub/api/endpoints/MessageCounts.ios.kt | 10 +- .../com/pubnub/api/endpoints/Time.ios.kt | 10 +- .../api/endpoints/access/GrantToken.ios.kt | 5 +- .../api/endpoints/access/RevokeToken.ios.kt | 2 +- .../AddChannelChannelGroup.ios.kt | 10 +- .../AllChannelsChannelGroup.ios.kt | 19 +- .../channel_groups/DeleteChannelGroup.ios.kt | 10 +- .../channel_groups/ListAllChannelGroup.ios.kt | 10 +- .../RemoveChannelChannelGroup.ios.kt | 13 +- .../api/endpoints/files/DeleteFile.ios.kt | 4 +- .../api/endpoints/files/DownloadFile.ios.kt | 7 +- .../api/endpoints/files/GetFileUrl.ios.kt | 4 +- .../api/endpoints/files/ListFiles.ios.kt | 4 +- .../endpoints/files/PublishFileMessage.ios.kt | 8 +- .../api/endpoints/files/SendFile.ios.kt | 14 +- .../message_actions/AddMessageAction.ios.kt | 8 +- .../message_actions/GetMessageActions.ios.kt | 14 +- .../RemoveMessageAction.ios.kt | 13 +- .../channel/GetAllChannelMetadata.ios.kt | 6 +- .../objects/channel/GetChannelMetadata.ios.kt | 11 +- .../channel/RemoveChannelMetadata.ios.kt | 10 +- .../objects/channel/SetChannelMetadata.ios.kt | 12 +- .../objects/member/GetChannelMembers.ios.kt | 2 +- .../member/ManageChannelMembers.ios.kt | 6 +- .../objects/membership/GetMemberships.ios.kt | 6 +- .../membership/ManageMemberships.ios.kt | 8 +- .../objects/uuid/GetAllUUIDMetadata.ios.kt | 2 +- .../objects/uuid/GetUUIDMetadata.ios.kt | 13 +- .../objects/uuid/RemoveUUIDMetadata.ios.kt | 13 +- .../objects/uuid/SetUUIDMetadata.ios.kt | 10 +- .../api/endpoints/presence/GetState.ios.kt | 14 +- .../api/endpoints/presence/HereNow.ios.kt | 48 +- .../api/endpoints/presence/SetState.ios.kt | 10 +- .../api/endpoints/presence/WhereNow.ios.kt | 13 +- .../api/endpoints/pubsub/Publish.ios.kt | 22 +- .../pubnub/api/endpoints/pubsub/Signal.ios.kt | 10 +- .../endpoints/push/AddChannelsToPush.ios.kt | 11 +- .../endpoints/push/ListPushProvisions.ios.kt | 8 +- .../RemoveAllPushChannelsForDevice.ios.kt | 10 +- .../push/RemoveChannelsFromPush.ios.kt | 11 +- .../com/pubnub/api/v2/PNConfiguration.ios.kt | 2 +- .../api/v2/callbacks/EventListener.ios.kt | 3 +- .../api/v2/callbacks/StatusListener.ios.kt | 2 +- .../internal/entities/ChannelGroupImpl.kt | 4 +- .../pubnub/internal/entities/ChannelImpl.kt | 6 +- .../internal/entities/ChannelMetadataImpl.kt | 5 +- .../internal/entities/UserMetadataImpl.kt | 4 +- .../internal/subscription/SubscriptionImpl.kt | 4 +- .../subscription/SubscriptionSetImpl.kt | 4 +- .../kotlin/com/pubnub/kmp/abstractions.ios.kt | 2 +- .../kotlin/com/pubnub/kmp/converters.kt | 16 +- .../kotlin/com/pubnub/kmp/factories.ios.kt | 16 +- .../kotlin/com/pubnub/kmp/results.ios.kt | 16 +- .../kotlin/com/pubnub/kmp/platform.ios.kt | 2 +- .../src/iosTest/kotlin/testlauncher.kt | 12 +- .../src/jsMain/kotlin/Pubnub.d.kt | 280 ++- .../kotlin/com/pubnub/api/Endpoint.js.kt | 8 - .../kotlin/com/pubnub/api/EndpointImpl.kt | 5 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 869 +++++---- .../pubnub/api/endpoints/DeleteMessages.js.kt | 4 +- .../api/endpoints/DeleteMessagesImpl.kt | 12 +- .../pubnub/api/endpoints/FetchMessages.js.kt | 4 +- .../pubnub/api/endpoints/FetchMessagesImpl.kt | 42 +- .../pubnub/api/endpoints/MessageCounts.js.kt | 5 +- .../pubnub/api/endpoints/MessageCountsImpl.kt | 12 +- .../com/pubnub/api/endpoints/Time.js.kt | 5 +- .../com/pubnub/api/endpoints/TimeImpl.kt | 2 +- .../api/endpoints/access/GrantToken.js.kt | 4 +- .../api/endpoints/access/GrantTokenImpl.kt | 2 +- .../api/endpoints/access/RevokeToken.js.kt | 2 +- .../api/endpoints/access/RevokeTokenImpl.kt | 2 +- .../AddChannelChannelGroup.js.kt | 4 +- .../AddChannelChannelGroupImpl.kt | 2 +- .../AllChannelsChannelGroup.js.kt | 4 +- .../AllChannelsChannelGroupImpl.kt | 2 +- .../channel_groups/DeleteChannelGroup.js.kt | 5 +- .../channel_groups/DeleteChannelGroupImpl.kt | 2 +- .../channel_groups/ListAllChannelGroup.js.kt | 4 +- .../channel_groups/ListAllChannelGroupImpl.kt | 2 +- .../RemoveChannelChannelGroup.js.kt | 3 +- .../RemoveChannelChannelGroupImpl.kt | 2 +- .../api/endpoints/files/DeleteFile.js.kt | 5 +- .../api/endpoints/files/DeleteFileImpl.kt | 4 +- .../api/endpoints/files/DownloadFile.js.kt | 2 +- .../api/endpoints/files/DownloadFileImpl.kt | 5 +- .../api/endpoints/files/GetFileUrl.js.kt | 5 +- .../api/endpoints/files/GetFileUrlImpl.kt | 2 +- .../api/endpoints/files/ListFiles.js.kt | 5 +- .../api/endpoints/files/ListFilesImpl.kt | 2 +- .../endpoints/files/PublishFileMessage.js.kt | 5 +- .../endpoints/files/PublishFileMessageImpl.kt | 2 +- .../pubnub/api/endpoints/files/SendFile.js.kt | 2 +- .../api/endpoints/files/SendFileImpl.kt | 4 +- .../message_actions/AddMessageAction.js.kt | 4 +- .../message_actions/AddMessageActionImpl.kt | 2 +- .../message_actions/GetMessageActionImpl.kt | 5 +- .../message_actions/GetMessageActions.js.kt | 3 +- .../message_actions/RemoveMessageAction.js.kt | 4 +- .../RemoveMessageActionImpl.kt | 2 +- .../channel/GetAllChannelMetadata.js.kt | 5 +- .../channel/GetAllChannelMetadataImpl.kt | 3 +- .../objects/channel/GetChannelMetadata.js.kt | 5 +- .../objects/channel/GetChannelMetadataImpl.kt | 3 +- .../channel/RemoveChannelMetadata.js.kt | 4 +- .../channel/RemoveChannelMetadataImpl.kt | 6 +- .../objects/channel/SetChannelMetadata.js.kt | 5 +- .../objects/channel/SetChannelMetadataImpl.kt | 3 +- .../objects/member/GetChannelMembers.js.kt | 3 +- .../objects/member/GetChannelMembersImpl.kt | 3 - .../objects/member/ManageChannelMembers.js.kt | 5 +- .../member/RemoveChannelMembersImpl.kt | 1 - .../objects/member/SetChannelMembersImpl.kt | 7 +- .../objects/membership/GetMemberships.js.kt | 5 +- .../objects/membership/GetMembershipsImpl.kt | 3 +- .../membership/ManageMemberships.js.kt | 5 +- .../membership/RemoveMembershipsImpl.kt | 7 +- .../objects/membership/SetMembershipsImpl.kt | 7 +- .../objects/uuid/GetAllUUIDMetadata.js.kt | 5 +- .../objects/uuid/GetAllUUIDMetadataImpl.kt | 3 +- .../objects/uuid/GetUUIDMetadata.js.kt | 3 +- .../objects/uuid/GetUUIDMetadataImpl.kt | 3 +- .../objects/uuid/RemoveUUIDMetadata.js.kt | 2 +- .../objects/uuid/RemoveUUIDMetadataImpl.kt | 6 +- .../objects/uuid/SetUUIDMetadata.js.kt | 4 +- .../objects/uuid/SetUUIDMetadataImpl.kt | 5 +- .../api/endpoints/presence/GetState.js.kt | 6 +- .../api/endpoints/presence/GetStateImpl.kt | 2 +- .../api/endpoints/presence/HereNow.js.kt | 4 +- .../api/endpoints/presence/HereNowImpl.kt | 2 +- .../api/endpoints/presence/SetState.js.kt | 5 +- .../api/endpoints/presence/SetStateImpl.kt | 2 +- .../api/endpoints/presence/WhereNow.js.kt | 4 +- .../api/endpoints/presence/WhereNowImpl.kt | 2 +- .../pubnub/api/endpoints/pubsub/FireImpl.kt | 2 +- .../pubnub/api/endpoints/pubsub/Publish.js.kt | 3 +- .../api/endpoints/pubsub/PublishImpl.kt | 2 +- .../pubnub/api/endpoints/pubsub/Signal.js.kt | 4 +- .../pubnub/api/endpoints/pubsub/SignalImpl.kt | 2 +- .../endpoints/push/AddChannelsToPush.js.kt | 5 +- .../endpoints/push/AddChannelsToPushImpl.kt | 2 +- .../endpoints/push/ListPushProvisions.js.kt | 5 +- .../endpoints/push/ListPushProvisionsImpl.kt | 3 +- .../push/RemoveAllPushChannelsForDevice.js.kt | 5 +- .../RemoveAllPushChannelsForDeviceImpl.kt | 4 +- .../push/RemoveChannelsFromPush.js.kt | 5 +- .../push/RemoveChannelsFromPushImpl.kt | 2 +- .../com/pubnub/api/v2/PNConfiguration.js.kt | 2 +- .../api/v2/callbacks/EventListener.js.kt | 4 +- .../api/v2/callbacks/StatusListener.js.kt | 2 +- .../internal/v2/entities/ChannelImpl.kt | 25 +- .../v2/subscriptions/SubscriptionImpl.kt | 4 +- .../v2/subscriptions/SubscriptionSetImpl.kt | 2 +- .../kotlin/com/pubnub/kmp/abstractions.js.kt | 4 +- .../kotlin/com/pubnub/kmp/converters.js.kt | 3 +- .../kotlin/com/pubnub/kmp/factories.js.kt | 192 +- .../kotlin/com/pubnub/kmp/platform.js.kt | 2 +- .../jvmMain/kotlin/com/pubnub/api/Endpoint.kt | 1 - .../jvmMain/kotlin/com/pubnub/api/PubNub.kt | 6 +- .../pubnub/api/callbacks/SubscribeCallback.kt | 2 +- .../message_actions/RemoveMessageAction.kt | 3 +- .../objects/channel/GetAllChannelMetadata.kt | 3 +- .../com/pubnub/api/v2/PNConfiguration.jvm.kt | 8 +- .../pubnub/api/v2/callbacks/EventListener.kt | 2 +- .../pubnub/api/v2/callbacks/StatusListener.kt | 2 +- .../kotlin/com/pubnub/kmp/abstractions.jvm.kt | 2 +- .../kotlin/com/pubnub/kmp/factories.jvm.kt | 4 +- .../kotlin/com/pubnub/kmp/platform.jvm.kt | 2 +- .../kotlin/com/pubnub/internal/PubNubImpl.kt | 2 +- .../internal/v2/entities/ChannelImpl.kt | 2 +- .../pubnub-kotlin-test/build.gradle.kts | 4 +- .../com.pubnub.test/BaseIntegrationTest.kt | 41 +- .../kotlin/com.pubnub.test/FakePubNub.kt | 1686 +++++------------ .../kotlin/com.pubnub.test/FakePubNub.ios.kt | 39 - .../kotlin/com.pubnub.test/FakePubNub.js.kt | 27 - .../kotlin/com.pubnub.test/FakePubNub.jvm.kt | 42 - 278 files changed, 2382 insertions(+), 2760 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/TimeTest.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt index 280d86506..c24ed6b89 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt @@ -17,7 +17,6 @@ class PubNubKotlinLibraryPlugin : Plugin { with(target) { apply() apply() - apply() // Kotlin extensions.configure { @@ -30,29 +29,6 @@ class PubNubKotlinLibraryPlugin : Plugin { } } - // Ktlint - extensions.configure { - outputToConsole.set(true) - verbose.set(true) - additionalEditorconfig.set( - mapOf( - "ij_kotlin_imports_layout" to "*,java.**,javax.**,kotlin.**,^", - "indent_size" to "4", - "ktlint_standard_multiline-expression-wrapping" to "disabled", - "ktlint_standard_string-template-indent" to "disabled", - "ktlint_standard_max-line-length" to "disabled", - "ktlint_standard_if-else-wrapping" to "disabled", - "ktlint_standard_discouraged-comment-location" to "disabled", - "ktlint_standard_trailing-comma-on-declaration-site" to "disabled", - "ktlint_standard_trailing-comma-on-call-site" to "disabled", - "ktlint_standard_function-signature" to "disabled", - ) - ) - } - - dependencies { - "ktlintRuleset"(project(":build-logic:ktlint-custom-rules")) - } } } } \ No newline at end of file diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt index 4f89ea109..7408aae61 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt @@ -4,14 +4,46 @@ import com.vanniktech.maven.publish.MavenPublishPlugin import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.project +import org.jlleitschuh.gradle.ktlint.KtlintExtension +import org.jlleitschuh.gradle.ktlint.KtlintPlugin class PubNubSharedPlugin : Plugin { override fun apply(target: Project) { with(target) { apply() + apply() group = providers.gradleProperty("GROUP").get() version = providers.gradleProperty("VERSION_NAME").get() + + // Ktlint + extensions.configure { + outputToConsole.set(true) + verbose.set(true) + additionalEditorconfig.set( + mapOf( + "ij_kotlin_imports_layout" to "*,java.**,javax.**,kotlin.**,^", + "indent_size" to "4", + "ktlint_standard_multiline-expression-wrapping" to "disabled", + "ktlint_standard_string-template-indent" to "disabled", + "ktlint_standard_max-line-length" to "disabled", + "ktlint_standard_if-else-wrapping" to "disabled", + "ktlint_standard_discouraged-comment-location" to "disabled", + "ktlint_standard_trailing-comma-on-declaration-site" to "disabled", + "ktlint_standard_trailing-comma-on-call-site" to "disabled", + "ktlint_standard_function-signature" to "disabled", + "ktlint_standard_filename" to "disabled", + "ktlint_standard_package-name" to "disabled", + ) + ) + } + + dependencies { + "ktlintRuleset"(project(":build-logic:ktlint-custom-rules")) + } } } } \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/build.gradle.kts b/pubnub-core/pubnub-core-api/build.gradle.kts index 4843098eb..a350ba89b 100644 --- a/pubnub-core/pubnub-core-api/build.gradle.kts +++ b/pubnub-core/pubnub-core-api/build.gradle.kts @@ -33,6 +33,3 @@ kotlin { } } -//atomicfu { -// dependenciesVersion = "0.24.0" -//} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt index 4d2bc56cb..c01cf621b 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt @@ -3,21 +3,30 @@ package com.pubnub.api expect abstract class JsonElement expect fun JsonElement.isNull(): Boolean + expect fun JsonElement.asList(): List? + expect fun JsonElement.asLong(): Long? + expect fun JsonElement.asDouble(): Double? + expect fun JsonElement.asNumber(): Number? + expect fun JsonElement.asBoolean(): Boolean? + expect fun JsonElement.asString(): String? + expect fun JsonElement.asMap(): Map? expect fun createJsonElement(any: Any?): JsonElement fun JsonElement.decode(): Any? { - if (isNull()) return null + if (isNull()) { + return null + } return asMap()?.mapValues { it.value.decode() } ?: asList()?.map { it.decode() } ?: asNumber() ?: asBoolean() ?: asString() -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt index f551d754a..67a693011 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt @@ -11,11 +11,13 @@ package com.pubnub.api */ expect class PubNubException(errorMessage: String?, cause: Throwable? = null) : Exception { constructor(pubnubError: PubNubError, cause: Throwable? = null) + // test only constructor(errorMessage: String?, statusCode: Int, cause: Throwable? = null) + val statusCode: Int companion object { fun from(e: Throwable): PubNubException } -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt index 235697bbe..ce136f96e 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt @@ -5,4 +5,4 @@ import com.pubnub.kmp.Downloadable data class PNDownloadFileResult( val fileName: String, val byteStream: Downloadable?, -) \ No newline at end of file +) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt index 531bfbad9..2874ba2f0 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt @@ -44,7 +44,7 @@ data class PNFetchMessageItem( val error: PubNubError? = null, ) { // for compatibility with legacy Java SDK - class Action(uuid: String, actionTimetoken: String) : + class Action(uuid: String, actionTimetoken: Long) : com.pubnub.api.models.consumer.history.Action(uuid, actionTimetoken) } @@ -56,7 +56,7 @@ data class PNFetchMessageItem( */ open class Action( val uuid: String, - val actionTimetoken: String, + val actionTimetoken: Long, ) { override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt index 764ab7424..ebb59c444 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt @@ -4,7 +4,7 @@ data class PNChannelMetadata( val id: String, val name: String?, val description: String?, - val custom: Map?, + val custom: Map?, val updated: String?, val eTag: String?, val type: String?, diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt index 8ca3d0018..69262d432 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt @@ -8,7 +8,7 @@ class PushPayloadHelper { @Deprecated( replaceWith = ReplaceWith("fcmPayloadV2"), message = "The legacy GCM/FCM payload is deprecated and will" + - "be removed in the next major release. Use `fcmPayloadV2` with the `FCMPayloadV2` message body instead." + "be removed in the next major release. Use `fcmPayloadV2` with the `FCMPayloadV2` message body instead." ) var fcmPayload: FCMPayload? = null var fcmPayloadV2: FCMPayloadV2? = null diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt index 0331277dc..a1d1c3621 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt @@ -1,7 +1,7 @@ package com.pubnub.api.retry -//import org.jetbrains.annotations.TestOnly -//import org.slf4j.LoggerFactory +// import org.jetbrains.annotations.TestOnly TODO +// import org.slf4j.LoggerFactory TODO import kotlin.jvm.JvmSynthetic import kotlin.time.Duration import kotlin.time.Duration.Companion.seconds diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt index d3288c08b..1a5a9ef89 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt @@ -2,4 +2,4 @@ package com.pubnub.api.v2.callbacks expect fun interface Consumer { fun accept(p: T) -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt index eeb4b3bb1..dda0799c0 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt @@ -20,112 +20,112 @@ import kotlin.jvm.JvmSynthetic * or a failure with a [PubNubException]. */ class Result -@PublishedApi -internal constructor( @PublishedApi - @get:JvmSynthetic - internal val value: Any?, -) { - // discovery - - /** - * Returns `true` if this instance represents a successful outcome. - * In this case [isFailure] returns `false`. - */ - public val isSuccess: Boolean get() = value !is Failure - - /** - * Returns `true` if this instance represents a failed outcome. - * In this case [isSuccess] returns `false`. - */ - public val isFailure: Boolean get() = value is Failure - - // value & exception retrieval - - /** - * Returns the encapsulated value if this instance represents [success][Result.isSuccess] or `null` - * if it is [failure][Result.isFailure]. - * - * This function is a shorthand for `getOrElse { null }` (see [getOrElse]) or - * `fold(onSuccess = { it }, onFailure = { null })` (see [fold]). - */ - @Suppress("UNCHECKED_CAST") - public inline fun getOrNull(): T? = - when { - isFailure -> null - else -> value as T - } - - /** - * Returns the encapsulated [PubNubException] exception if this instance represents [failure][isFailure] or `null` - * if it is [success][isSuccess]. - * - * This function is a shorthand for `fold(onSuccess = { null }, onFailure = { it })` (see [fold]). - */ - public fun exceptionOrNull(): PubNubException? = - when (value) { - is Failure -> value.exception - else -> null - } + internal constructor( + @PublishedApi + @get:JvmSynthetic + internal val value: Any?, + ) { + // discovery - /** - * Returns a string `Success(v)` if this instance represents [success][Result.isSuccess] - * where `v` is a string representation of the value or a string `Failure(x)` if - * it is [failure][isFailure] where `x` is a string representation of the exception. - */ - public override fun toString(): String = - when (value) { - is Failure -> value.toString() // "Failure($exception)" - else -> "Success($value)" - } + /** + * Returns `true` if this instance represents a successful outcome. + * In this case [isFailure] returns `false`. + */ + public val isSuccess: Boolean get() = value !is Failure - public inline fun onFailure(action: Consumer): Result { - exceptionOrNull()?.let { action.accept(it) } - return this - } + /** + * Returns `true` if this instance represents a failed outcome. + * In this case [isSuccess] returns `false`. + */ + public val isFailure: Boolean get() = value is Failure - @Suppress("UNCHECKED_CAST") - public inline fun onSuccess(action: Consumer): Result { - if (isSuccess) { - action.accept(value as T) - } - return this - } + // value & exception retrieval - // companion with constructors + /** + * Returns the encapsulated value if this instance represents [success][Result.isSuccess] or `null` + * if it is [failure][Result.isFailure]. + * + * This function is a shorthand for `getOrElse { null }` (see [getOrElse]) or + * `fold(onSuccess = { it }, onFailure = { null })` (see [fold]). + */ + @Suppress("UNCHECKED_CAST") + public inline fun getOrNull(): T? = + when { + isFailure -> null + else -> value as T + } - /** - * Companion object for [Result] class that contains its constructor functions - * [success] and [failure]. - */ - public companion object { /** - * Returns an instance that encapsulates the given [value] as successful value. + * Returns the encapsulated [PubNubException] exception if this instance represents [failure][isFailure] or `null` + * if it is [success][isSuccess]. + * + * This function is a shorthand for `fold(onSuccess = { null }, onFailure = { it })` (see [fold]). */ - @JvmStatic - public fun success(value: T): Result = Result(value) + public fun exceptionOrNull(): PubNubException? = + when (value) { + is Failure -> value.exception + else -> null + } /** - * Returns an instance that encapsulates the given [PubNubException] [exception] as failure. + * Returns a string `Success(v)` if this instance represents [success][Result.isSuccess] + * where `v` is a string representation of the value or a string `Failure(x)` if + * it is [failure][isFailure] where `x` is a string representation of the exception. */ - @JvmStatic - public fun failure(exception: PubNubException): Result = Result(createFailure(exception)) + public override fun toString(): String = + when (value) { + is Failure -> value.toString() // "Failure($exception)" + else -> "Success($value)" + } + + public inline fun onFailure(action: Consumer): Result { + exceptionOrNull()?.let { action.accept(it) } + return this + } - @JvmStatic - public fun failure(exception: Throwable): Result = Result(createFailure(PubNubException.from(exception))) - } + @Suppress("UNCHECKED_CAST") + public inline fun onSuccess(action: Consumer): Result { + if (isSuccess) { + action.accept(value as T) + } + return this + } - internal class Failure( - @JvmField - val exception: PubNubException, - ) { - override fun equals(other: Any?): Boolean = other is Failure && exception == other.exception + // companion with constructors - override fun hashCode(): Int = exception.hashCode() + /** + * Companion object for [Result] class that contains its constructor functions + * [success] and [failure]. + */ + public companion object { + /** + * Returns an instance that encapsulates the given [value] as successful value. + */ + @JvmStatic + public fun success(value: T): Result = Result(value) + + /** + * Returns an instance that encapsulates the given [PubNubException] [exception] as failure. + */ + @JvmStatic + public fun failure(exception: PubNubException): Result = Result(createFailure(exception)) + + @JvmStatic + public fun failure(exception: Throwable): Result = Result(createFailure(PubNubException.from(exception))) + } - override fun toString(): String = "Failure($exception)" + internal class Failure( + @JvmField + val exception: PubNubException, + ) { + override fun equals(other: Any?): Boolean = other is Failure && exception == other.exception + + override fun hashCode(): Int = exception.hashCode() + + override fun toString(): String = "Failure($exception)" + } } -} /** * Creates an instance of internal marker [Result.Failure] class to @@ -189,14 +189,12 @@ public inline fun Result.getOrDefault(defaultValue: R): R { return value as T } - /** * Returns the result of [onSuccess] for the encapsulated value if this instance represents [success][Result.isSuccess] * or the result of [onFailure] function for the encapsulated [Throwable] exception if it is [failure][Result.isFailure]. * * Note, that this function rethrows any [Throwable] exception thrown by [onSuccess] or by [onFailure] function. */ -//@InlineOnly public inline fun Result.fold( onSuccess: (value: T) -> R, onFailure: (exception: Throwable) -> R @@ -221,7 +219,6 @@ public inline fun Result.fold( * Note, that this function rethrows any [Throwable] exception thrown by [transform] function. * See [mapCatching] for an alternative that encapsulates exceptions. */ -//@InlineOnly public inline fun Result.map(transform: (value: T) -> R): Result { // contract { // callsInPlace(transform, InvocationKind.AT_MOST_ONCE) @@ -252,4 +249,4 @@ public inline fun Result.wrapException(block: (PubNubException) -> PubNub isSuccess -> this else -> Result.failure(block(exceptionOrNull()!!)) } -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt index 124c3d165..04cada04a 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt @@ -1,3 +1,3 @@ package com.pubnub.kmp -expect abstract class Downloadable \ No newline at end of file +expect abstract class Downloadable diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt index 77d9b8f2e..60dd9824c 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt @@ -5,4 +5,4 @@ import com.pubnub.api.v2.callbacks.Result fun interface PNFuture { fun async(callback: Consumer>) -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt index 7710a18d4..e0eb0ba1b 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt @@ -71,7 +71,7 @@ fun PNFuture.thenAsync(action: (T) -> PNFuture): PNFuture = PNFu } } -fun PNFuture.remember() : PNFuture = CompletablePNFuture().also { completableFuture -> +fun PNFuture.remember(): PNFuture = CompletablePNFuture().also { completableFuture -> this@remember.async { completableFuture.complete(it) } @@ -90,7 +90,6 @@ fun PNFuture.alsoAsync(action: (T) -> PNFuture<*>): PNFuture = } } - fun PNFuture.catch(action: (Exception) -> Result): PNFuture = PNFuture { callback -> this@catch.async { result: Result -> result.onSuccess { @@ -105,7 +104,7 @@ fun PNFuture.catch(action: (Exception) -> Result): PNFuture = PNFut } } -fun Collection>.awaitAll(): PNFuture> = PNFuture { callback -> +fun Collection>.awaitAll(): PNFuture> = PNFuture { callback -> if (isEmpty()) { callback.accept(Result.success(emptyList())) return@PNFuture @@ -132,11 +131,19 @@ fun Collection>.awaitAll(): PNFuture> = PNFuture { call } @Suppress("UNCHECKED_CAST") -fun awaitAll(future1: PNFuture, future2: PNFuture): PNFuture> = listOf(future1 as PNFuture, future2 as PNFuture).awaitAll().then { it: List -> +fun awaitAll( + future1: PNFuture, + future2: PNFuture +): PNFuture> = listOf(future1 as PNFuture, future2 as PNFuture).awaitAll().then { it: List -> Pair(it[0] as T, it[1] as U) } @Suppress("UNCHECKED_CAST") -fun awaitAll(future1: PNFuture, future2: PNFuture, future3: PNFuture): PNFuture> = listOf(future1 as PNFuture, future2 as PNFuture, future3 as PNFuture).awaitAll().then { it: List -> +fun awaitAll( + future1: PNFuture, + future2: PNFuture, + future3: PNFuture +): PNFuture> = listOf(future1 as PNFuture, future2 as PNFuture, future3 as PNFuture).awaitAll().then { + it: List -> Triple(it[0] as T, it[1] as U, it[2] as X) -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt index 975087aab..881743c82 100644 --- a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt +++ b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt @@ -7,7 +7,6 @@ import kotlin.test.assertEquals import kotlin.test.assertTrue class PNFutureTest { - @Test fun asFuture1() { val value = true @@ -61,4 +60,4 @@ class PNFutureTest { } assertContentEquals(listOf(value1, value2, value3), set) } -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt index 2ed75a4dd..6c966dab9 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt @@ -7,8 +7,12 @@ import kotlinx.cinterop.ExperimentalForeignApi actual abstract class JsonElement(val value: Any?) { override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is JsonElement) return false + if (this === other) { + return true + } + if (other !is JsonElement) { + return false + } if (asMap() != null && other.asMap() != null) { return asMap() == other.asMap() @@ -44,8 +48,8 @@ actual fun JsonElement.asString(): String? { actual fun JsonElement.asMap(): Map? { return when (value) { is AnyJSONObjC -> (value.asMap() as? Map)?.mapValues { - JsonElementImpl(it.value) - } + JsonElementImpl(it.value) + } is Map<*, *> -> (value as Map)?.mapValues { JsonElementImpl(it.value) } else -> null } @@ -58,8 +62,8 @@ actual fun JsonElement.isNull(): Boolean { actual fun JsonElement.asList(): List? { return when (value) { is AnyJSONObjC -> value.asList()?.map { - JsonElementImpl(it) - } + JsonElementImpl(it) + } is List<*> -> value.map { JsonElementImpl(it) } else -> null } @@ -70,7 +74,11 @@ actual fun JsonElement.asLong(): Long? { is AnyJSONObjC -> value.asInt()?.longValue is Long -> value is Int -> value.toLong() - is Boolean -> if (value) 1 else 0 + is Boolean -> if (value) { + 1 + } else { + 0 + } else -> null } } @@ -87,7 +95,11 @@ actual fun JsonElement.asDouble(): Double? { return when (value) { is AnyJSONObjC -> value.asDouble()?.doubleValue is Number -> value.toDouble() - is Boolean -> if (value) 1.0 else 0.0 + is Boolean -> if (value) { + 1.0 + } else { + 0.0 + } else -> null } } @@ -96,11 +108,15 @@ actual fun JsonElement.asNumber(): Number? { return when (value) { is AnyJSONObjC -> value.asNumber() as? Number is Number -> value - is Boolean -> if (value) 1 else 0 + is Boolean -> if (value) { + 1 + } else { + 0 + } else -> null } } actual fun createJsonElement(any: Any?): JsonElement { return JsonElementImpl(AnyJSONObjC(any)) -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt index 0b6e82bcb..36751a415 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt @@ -14,12 +14,11 @@ actual class PubNubException( errorMessage: String?, cause: Throwable? ) : Exception(errorMessage, cause) { - actual constructor(errorMessage: String?, cause: Throwable?) : this(statusCode = 0, errorMessage, cause) actual constructor(pubnubError: PubNubError, cause: Throwable?) : this(statusCode = 0, pubnubError.message, cause) // test only - actual constructor(errorMessage: String?, statusCode: Int, cause: Throwable?) : this(statusCode, errorMessage,cause) + actual constructor(errorMessage: String?, statusCode: Int, cause: Throwable?) : this(statusCode, errorMessage, cause) actual companion object { actual fun from(e: Throwable): PubNubException { @@ -30,4 +29,4 @@ actual class PubNubException( } } } -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt index 0c836d68c..69490ac96 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt @@ -2,4 +2,4 @@ package com.pubnub.api.v2.callbacks actual fun interface Consumer { actual fun accept(p: T) -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt index c5e183ff8..20df3d448 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt @@ -6,4 +6,4 @@ actual abstract class Downloadable class DownloadableImpl( private val inputStream: NSInputStream -): Downloadable() \ No newline at end of file +) : Downloadable() diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt index 61cc2c8de..1b7627d8f 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt @@ -8,15 +8,21 @@ import kotlin.js.json actual abstract class JsonElement(val value: Any?) { override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is JsonElement) return false + if (this === other) { + return true + } + if (other !is JsonElement) { + return false + } if (asMap() != null && other.asMap() != null) { return asMap() == other.asMap() } else if (asList() != null && other.asList() != null) { return asList() == other.asList() } - if (value != other.value) return false + if (value != other.value) { + return false + } return true } @@ -28,7 +34,7 @@ actual abstract class JsonElement(val value: Any?) { class JsonElementImpl(value: Any?) : JsonElement(value) { override fun toString(): String { - return "JsonElementImpl(${value.toString()} : ${value?.let { it::class }})" + return "JsonElementImpl($value : ${value?.let { it::class }})" } } @@ -37,7 +43,9 @@ actual fun JsonElement.asString(): String? { } actual fun JsonElement.asMap(): Map? { - if (value?.isJsObject() != true) return null + if (value?.isJsObject() != true) { + return null + } return value.unsafeCast>().toMap().mapValues { JsonElementImpl(it.value) } } @@ -90,12 +98,12 @@ internal fun Any?.adjustCollectionTypes(): Any? { is Collection<*> -> { this.map { it.adjustCollectionTypes() }.map { - if (it is JsonElementImpl) { - it.value - } else { - it - } - }.toTypedArray() + if (it is JsonElementImpl) { + it.value + } else { + it + } + }.toTypedArray() } is Array<*> -> { @@ -114,4 +122,4 @@ internal fun Any?.adjustCollectionTypes(): Any? { else -> this } -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt index fb8edd38a..771f88aa5 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt @@ -14,7 +14,6 @@ actual class PubNubException( errorMessage: String?, cause: Throwable? ) : Exception(errorMessage, cause) { - actual constructor(errorMessage: String?, cause: Throwable?) : this(statusCode = 0, errorMessage, cause) actual constructor(pubnubError: PubNubError, cause: Throwable?) : this(statusCode = 0, pubnubError.message, cause) @@ -31,4 +30,4 @@ actual class PubNubException( } } } -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt index 0c836d68c..69490ac96 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt @@ -2,4 +2,4 @@ package com.pubnub.api.v2.callbacks actual fun interface Consumer { actual fun accept(p: T) -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt index b61cb7571..b532a4fc9 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt @@ -2,4 +2,4 @@ package com.pubnub.kmp actual abstract class Downloadable(val pubnubFile: Any) -class DownloadableImpl(pubnubFile: Any) : Downloadable(pubnubFile) \ No newline at end of file +class DownloadableImpl(pubnubFile: Any) : Downloadable(pubnubFile) diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt index 957a1fea9..543f792d8 100644 --- a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt +++ b/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt @@ -16,5 +16,4 @@ fun Map.toJsMap(): JsMap = createJsObject { } }.unsafeCast>() - fun createJsObject(configure: T.() -> Unit = {}): T = (js("({})") as T).apply(configure) diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt index 20c9a0886..c40011758 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt @@ -11,7 +11,6 @@ import com.pubnub.api.v2.entities.BaseChannelMetadata import com.pubnub.api.v2.entities.BaseUserMetadata import com.pubnub.api.v2.subscriptions.BaseSubscription import com.pubnub.api.v2.subscriptions.BaseSubscriptionSet -import com.pubnub.api.v2.subscriptions.EmptyOptions import com.pubnub.api.v2.subscriptions.SubscriptionOptions import java.io.InputStream diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt index 43f9baf7a..8c75534e6 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt @@ -1,17 +1,23 @@ package com.pubnub.api -import com.google.gson.Gson import com.google.gson.GsonBuilder -import com.google.gson.JsonObject actual typealias JsonElement = com.google.gson.JsonElement actual fun JsonElement.asString(): String? { - return if (this.isJsonPrimitive && this.asJsonPrimitive.isString) this.asString else null + return if (this.isJsonPrimitive && this.asJsonPrimitive.isString) { + this.asString + } else { + null + } } actual fun JsonElement.asMap(): Map? { - return if (this.isJsonObject) this.asJsonObject.asMap() else null + return if (this.isJsonObject) { + this.asJsonObject.asMap() + } else { + null + } } actual fun JsonElement.isNull(): Boolean { @@ -19,25 +25,45 @@ actual fun JsonElement.isNull(): Boolean { } actual fun JsonElement.asList(): List? { - return if (this.isJsonArray) this.asJsonArray.asList() else null + return if (this.isJsonArray) { + this.asJsonArray.asList() + } else { + null + } } actual fun JsonElement.asLong(): Long? { - return if (this.isJsonPrimitive && this.asJsonPrimitive.isNumber) this.asLong else null + return if (this.isJsonPrimitive && this.asJsonPrimitive.isNumber) { + this.asLong + } else { + null + } } actual fun JsonElement.asBoolean(): Boolean? { - return if (this.isJsonPrimitive && this.asJsonPrimitive.isBoolean) this.asBoolean else null + return if (this.isJsonPrimitive && this.asJsonPrimitive.isBoolean) { + this.asBoolean + } else { + null + } } actual fun JsonElement.asDouble(): Double? { - return if (this.isJsonPrimitive && this.asJsonPrimitive.isNumber) this.asDouble else null + return if (this.isJsonPrimitive && this.asJsonPrimitive.isNumber) { + this.asDouble + } else { + null + } } actual fun JsonElement.asNumber(): Number? { - return if (this.isJsonPrimitive && this.asJsonPrimitive.isNumber) this.asNumber else null + return if (this.isJsonPrimitive && this.asJsonPrimitive.isNumber) { + this.asNumber + } else { + null + } } actual fun createJsonElement(any: Any?): JsonElement { return GsonBuilder().serializeNulls().create().toJsonTree(any) -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt index 8fe09f9bc..f082f907f 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt @@ -50,7 +50,7 @@ actual data class PubNubException( ) // test only - actual constructor( errorMessage: String?, statusCode: Int, cause: Throwable?) : this( + actual constructor(errorMessage: String?, statusCode: Int, cause: Throwable?) : this( statusCode = statusCode, errorMessage = errorMessage, cause = cause, diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt index bdcbd4ec7..00cf05076 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt @@ -2,4 +2,4 @@ package com.pubnub.api.v2.callbacks import java.util.function.Consumer -actual typealias Consumer = Consumer \ No newline at end of file +actual typealias Consumer = Consumer diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt index 510d69843..a87836fdf 100644 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt +++ b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt @@ -2,4 +2,4 @@ package com.pubnub.kmp import java.io.InputStream -actual typealias Downloadable = InputStream \ No newline at end of file +actual typealias Downloadable = InputStream diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesMetaActionsTestSuite.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesMetaActionsTestSuite.kt index 1a73635dc..7c3487b03 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesMetaActionsTestSuite.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesMetaActionsTestSuite.kt @@ -39,7 +39,7 @@ class FetchMessagesMetaActionsTestSuite : assertEquals(1, actions!!.keys.size) assertEquals(1, actions["reaction"]!!["smile"]!!.size) assertEquals("publishersUuid", actions["reaction"]!!["smile"]!![0].uuid) - assertEquals("200", actions["reaction"]!!["smile"]!![0].actionTimetoken) + assertEquals(200, actions["reaction"]!!["smile"]!![0].actionTimetoken) } override fun successfulResponseBody() = diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index b23eced93..825a22cfd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -7,7 +7,6 @@ plugins { id("pubnub.dokka") id("pubnub.multiplatform") id("pubnub.ios-simulator-test") - } kotlin { @@ -73,4 +72,4 @@ kotlin { export(project(":pubnub-core:pubnub-core-api")) } } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt index 54caa24ef..9ca67e435 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult +import com.pubnub.kmp.PNFuture /** * @see [com.pubnub.api.PubNub.deleteMessages] */ -expect interface DeleteMessages : PNFuture \ No newline at end of file +expect interface DeleteMessages : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt index 549c7444a..68cc41382 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/FetchMessages.kt @@ -6,4 +6,4 @@ import com.pubnub.kmp.PNFuture /** * @see [PubNub.fetchMessages] */ -expect interface FetchMessages : PNFuture \ No newline at end of file +expect interface FetchMessages : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt index 367f682d7..d83e3bb01 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/MessageCounts.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNMessageCountResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.messageCounts] */ -expect interface MessageCounts : PNFuture \ No newline at end of file +expect interface MessageCounts : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/Time.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/Time.kt index 464515963..8ebdc0013 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/Time.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/Time.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNTimeResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.time] */ -expect interface Time : PNFuture \ No newline at end of file +expect interface Time : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt index 8105bd07b..0d153aee6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.kt @@ -1,7 +1,6 @@ package com.pubnub.api.endpoints.access -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult +import com.pubnub.kmp.PNFuture -expect interface GrantToken : PNFuture { -} \ No newline at end of file +expect interface GrantToken : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt index 0d097c01f..2bf3d6c27 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.kt @@ -2,4 +2,4 @@ package com.pubnub.api.endpoints.access import com.pubnub.kmp.PNFuture -expect interface RevokeToken : PNFuture \ No newline at end of file +expect interface RevokeToken : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt index d27bda3c9..569bd8f86 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.addChannelsToChannelGroup] */ -expect interface AddChannelChannelGroup : PNFuture \ No newline at end of file +expect interface AddChannelChannelGroup : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt index 7cdadeda3..d7793a969 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.listChannelsForChannelGroup] */ -expect interface AllChannelsChannelGroup : PNFuture \ No newline at end of file +expect interface AllChannelsChannelGroup : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt index fc1b42955..7587391f2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.deleteChannelGroup] */ -expect interface DeleteChannelGroup : PNFuture \ No newline at end of file +expect interface DeleteChannelGroup : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt index c13159796..059480fe2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.listAllChannelGroups] */ -expect interface ListAllChannelGroup : PNFuture \ No newline at end of file +expect interface ListAllChannelGroup : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt index 95b1d847b..d94f6278a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.removeChannelsFromChannelGroup] */ -expect interface RemoveChannelChannelGroup : PNFuture { -} \ No newline at end of file +expect interface RemoveChannelChannelGroup : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt index 6664f6f9c..9fb0fe4ae 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNDeleteFileResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.deleteFile] */ -expect interface DeleteFile : PNFuture \ No newline at end of file +expect interface DeleteFile : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt index d0b90e3fe..4a5e6fab1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.kt @@ -1,8 +1,6 @@ package com.pubnub.api.endpoints.files -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.models.consumer.files.PNDownloadFileResult -import com.pubnub.api.models.consumer.files.PNFileUploadResult import com.pubnub.kmp.PNFuture /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt index 237b4d580..34b713099 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNFileUrlResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getFileUrl] */ -expect interface GetFileUrl : PNFuture \ No newline at end of file +expect interface GetFileUrl : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt index 0bf689162..c6d22e7ac 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNListFilesResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.listFiles] */ -expect interface ListFiles : PNFuture \ No newline at end of file +expect interface ListFiles : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt index 639090323..11a13866c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.files -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.publishFileMessage] */ -expect interface PublishFileMessage : PNFuture \ No newline at end of file +expect interface PublishFileMessage : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt index a026f925a..760467541 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/files/SendFile.kt @@ -1,6 +1,5 @@ package com.pubnub.api.endpoints.files -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.models.consumer.files.PNFileUploadResult import com.pubnub.kmp.PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt index 64e023bd5..b500bb2fb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.message_actions -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.addMessageAction] */ -expect interface AddMessageAction : PNFuture { -} \ No newline at end of file +expect interface AddMessageAction : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt index e94606f9e..a8f227a39 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.message_actions -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getMessageActions] */ -expect interface GetMessageActions : PNFuture { -} \ No newline at end of file +expect interface GetMessageActions : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt index 2cd7b3aa2..84087bac1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.message_actions -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.removeMessageAction] */ -expect interface RemoveMessageAction : PNFuture { -} \ No newline at end of file +expect interface RemoveMessageAction : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt index ec3adb74a..284d48747 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.objects.channel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getAllChannelMetadata] */ expect interface GetAllChannelMetadata : - PNFuture \ No newline at end of file + PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt index 33386e935..9f812a3df 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.channel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getChannelMetadata] */ -expect interface GetChannelMetadata : PNFuture \ No newline at end of file +expect interface GetChannelMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt index 6dc6a21da..c264bde82 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.objects.channel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult +import com.pubnub.kmp.PNFuture -expect interface RemoveChannelMetadata : PNFuture \ No newline at end of file +expect interface RemoveChannelMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt index cc88f24e6..b9fe05f98 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.channel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.setChannelMetadata] */ -expect interface SetChannelMetadata : PNFuture \ No newline at end of file +expect interface SetChannelMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt index 8a7685817..a219e6f25 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.member -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getChannelMembers] */ -expect interface GetChannelMembers : PNFuture \ No newline at end of file +expect interface GetChannelMembers : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt index de9973f0f..4707d6efd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.member -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.manageChannelMembers] */ -expect interface ManageChannelMembers : PNFuture \ No newline at end of file +expect interface ManageChannelMembers : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt index 632c177a1..ca30c6534 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.membership -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getMemberships] */ -expect interface GetMemberships : PNFuture \ No newline at end of file +expect interface GetMemberships : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt index 87e256ff0..b488c21b2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.membership -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.manageMemberships] */ -expect interface ManageMemberships : PNFuture \ No newline at end of file +expect interface ManageMemberships : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt index 033421de0..aed0fda3a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.uuid -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getAllUUIDMetadata] */ -expect interface GetAllUUIDMetadata : PNFuture \ No newline at end of file +expect interface GetAllUUIDMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt index 4bfd2e3e3..7c4dab26d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.objects.uuid -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getUUIDMetadata] */ -expect interface GetUUIDMetadata : PNFuture { -} \ No newline at end of file +expect interface GetUUIDMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt index c33a924f2..ae63beddd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.kt @@ -1,7 +1,6 @@ package com.pubnub.api.endpoints.objects.uuid -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult +import com.pubnub.kmp.PNFuture -expect interface RemoveUUIDMetadata : PNFuture { -} \ No newline at end of file +expect interface RemoveUUIDMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt index 2521b7659..695d8291e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.uuid -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.setUUIDMetadata] */ -expect interface SetUUIDMetadata : PNFuture \ No newline at end of file +expect interface SetUUIDMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt index c37e4ec74..94b1e826e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/GetState.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.presence -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNGetStateResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getPresenceState] */ -expect interface GetState : PNFuture { -} \ No newline at end of file +expect interface GetState : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt index 24f791e1f..5c1d07945 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.presence -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNHereNowResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.hereNow] */ -expect interface HereNow : PNFuture { -} \ No newline at end of file +expect interface HereNow : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt index 2dcd8165d..aac8479fc 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/SetState.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.presence -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNSetStateResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.setPresenceState] */ -expect interface SetState : PNFuture { -} \ No newline at end of file +expect interface SetState : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt index 65a38a200..84143cd29 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.presence -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNWhereNowResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.whereNow] */ -expect interface WhereNow : PNFuture { -} \ No newline at end of file +expect interface WhereNow : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt index 9c6ab41e7..3dc729521 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.pubsub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNPublishResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.publish] */ -expect interface Publish : PNFuture \ No newline at end of file +expect interface Publish : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt index 70ca99a25..e77864c96 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.pubsub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNPublishResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.signal] */ -expect interface Signal : PNFuture \ No newline at end of file +expect interface Signal : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt index b00bb0708..f2a25e906 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.push -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushAddChannelResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.addPushNotificationsOnChannels] */ -expect interface AddChannelsToPush : PNFuture \ No newline at end of file +expect interface AddChannelsToPush : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt index c872f3b15..f5432148d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.push -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.auditPushChannelProvisions] */ -expect interface ListPushProvisions : PNFuture \ No newline at end of file +expect interface ListPushProvisions : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt index 8b7aea173..1e99e9b62 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.push -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken] */ -expect interface RemoveAllPushChannelsForDevice : PNFuture \ No newline at end of file +expect interface RemoveAllPushChannelsForDevice : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt index a6af5e679..075e1981a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.push -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.removePushNotificationsFromChannels] */ -expect interface RemoveChannelsFromPush : PNFuture \ No newline at end of file +expect interface RemoveChannelsFromPush : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt index 5cea2920b..4c7516314 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNRemoveMetadataResult.kt @@ -1,3 +1,3 @@ package com.pubnub.api.models.consumer.objects -data class PNRemoveMetadataResult(val status: Int) \ No newline at end of file +data class PNRemoveMetadataResult(val status: Int) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt index cb4b20a58..bbbc6cf8c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt @@ -5,7 +5,7 @@ import com.pubnub.kmp.CustomObject data class PNMember( val uuid: PNUUIDMetadata?, - val custom: Map? = null, + val custom: Map? = null, val updated: String, val eTag: String, val status: String?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt index 5eb450e8b..e857e892c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt @@ -1,11 +1,11 @@ package com.pubnub.api.models.consumer.objects.membership -import com.pubnub.kmp.CustomObject import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.kmp.CustomObject data class PNChannelMembership( val channel: PNChannelMetadata?, - val custom: Map?, + val custom: Map?, val updated: String, val eTag: String, val status: String?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt index 720f6ecf5..dab9b4cc2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt @@ -68,7 +68,7 @@ data class PNDeleteUUIDMetadataEventMessage( data class PNSetMembershipEvent( val channel: String, val uuid: String, - val custom: Map?, + val custom: Map?, val eTag: String, val updated: String, val status: String?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt index bf14d3467..c35ad4ea6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt @@ -11,7 +11,6 @@ expect interface PNConfiguration { val secretKey: String val authKey: String val cryptoModule: CryptoModule? - } expect interface CryptoModule @@ -22,4 +21,4 @@ expect fun createPNConfiguration( publishKey: String, secretKey: String? = null, logVerbosity: Boolean = false, -): PNConfiguration \ No newline at end of file +): PNConfiguration diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt index 9867239d8..d751791b5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt @@ -1,9 +1,7 @@ package com.pubnub.api.v2.callbacks -import com.pubnub.api.callbacks.Listener - /** * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -expect interface EventListener : BaseEventListener \ No newline at end of file +expect interface EventListener : BaseEventListener diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt index c123cfee7..d076a5a23 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt @@ -6,4 +6,4 @@ import com.pubnub.api.callbacks.Listener * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for * PubNub connection status changes. */ -expect interface StatusListener : Listener \ No newline at end of file +expect interface StatusListener : Listener diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt index 27529c03e..2ed22defb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt @@ -62,7 +62,7 @@ interface Channel : BaseChannel { fun publish( message: Any, meta: Any? = null, - shouldStore: Boolean? = null, + shouldStore: Boolean = true, usePost: Boolean = false, replicate: Boolean = true, ttl: Int? = null @@ -110,9 +110,9 @@ interface Channel : BaseChannel { */ fun fire( message: Any, - meta: Any? = null, - usePost: Boolean = false, - ttl: Int? = null + meta: Any?, + usePost: Boolean, + ttl: Int? ): Publish /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt index 78d22393a..02d4476ff 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt @@ -2,9 +2,16 @@ package com.pubnub.kmp sealed interface Optional { class Value(val value: T) : Optional + class Absent : Optional - fun onValue(action: (T)->Unit) : Optional = this.apply { (this as? Value)?.let { action(it.value)} } - fun onAbsent(action: ()->Unit) : Optional = this.apply { if (this is Absent) { action() }} + + fun onValue(action: (T) -> Unit): Optional = this.apply { (this as? Value)?.let { action(it.value) } } + + fun onAbsent(action: () -> Unit): Optional = this.apply { + if (this is Absent) { + action() + } + } } fun T?.toOptional(): Optional = this?.let { Optional.Value(it) } ?: Optional.Absent() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt index 36894fd51..1ceaf38e9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt @@ -73,15 +73,20 @@ import com.pubnub.api.v2.subscriptions.SubscriptionSet interface PubNub { val configuration: PNConfiguration + fun addListener(listener: EventListener) + fun addListener(listener: StatusListener) + fun removeListener(listener: Listener) - fun removeAllListeners()//region api + + fun removeAllListeners() //region api + fun publish( channel: String, message: Any, meta: Any? = null, - shouldStore: Boolean? = null, + shouldStore: Boolean = true, usePost: Boolean = false, replicate: Boolean = true, ttl: Int? = null, @@ -101,7 +106,9 @@ interface PubNub { ): Signal fun getSubscribedChannels(): List + fun getSubscribedChannelGroups(): List + fun addPushNotificationsOnChannels( pushType: PNPushType, channels: List, @@ -161,7 +168,6 @@ interface PubNub { fun whereNow(uuid: String = configuration.userId.value): WhereNow - // TODO bring back when/if all SDKs accept a `uuid` parameter // fun setPresenceState( // channels: List = listOf(), @@ -210,12 +216,14 @@ interface PubNub { ): AddChannelChannelGroup fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup + fun removeChannelsFromChannelGroup( channels: List, channelGroup: String, ): RemoveChannelChannelGroup fun listAllChannelGroups(): ListAllChannelGroup + fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup fun grantToken( @@ -228,7 +236,9 @@ interface PubNub { ): GrantToken fun revokeToken(token: String): RevokeToken + fun time(): Time + fun getAllChannelMetadata( limit: Int? = null, page: PNPage? = null, @@ -254,6 +264,7 @@ interface PubNub { ): SetChannelMetadata fun removeChannelMetadata(channel: String): RemoveChannelMetadata + fun getAllUUIDMetadata( limit: Int? = null, page: PNPage? = null, @@ -281,6 +292,7 @@ interface PubNub { ): SetUUIDMetadata fun removeUUIDMetadata(uuid: String? = null): RemoveUUIDMetadata + fun getMemberships( uuid: String? = null, limit: Int? = null, @@ -463,5 +475,4 @@ interface PubNub { channelGroups: Set = emptySet(), options: SubscriptionOptions = EmptyOptions, ): SubscriptionSet - } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt index 09a27fe81..2e34bd87d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/abstractions.kt @@ -2,4 +2,4 @@ package com.pubnub.kmp expect class CustomObject -expect abstract class Uploadable \ No newline at end of file +expect abstract class Uploadable diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt index 560e7e26b..ca75391bd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt @@ -12,6 +12,7 @@ import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener expect fun createPubNub(config: PNConfiguration): PubNub + expect fun createEventListener( pubnub: PubNub, onMessage: (PubNub, PNMessageResult) -> Unit = { _, _ -> }, @@ -27,4 +28,4 @@ expect fun createStatusListener( onStatus: (PubNub, PNStatus) -> Unit = { _, _ -> }, ): StatusListener -expect fun createCustomObject(map: Map): CustomObject \ No newline at end of file +expect fun createCustomObject(map: Map): CustomObject diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt index a74554a67..af3140b3a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt @@ -1,5 +1,7 @@ package com.pubnub.api +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage @@ -12,6 +14,8 @@ import kotlinx.coroutines.test.runTest import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith +import kotlin.test.assertNotNull +import kotlin.test.assertTrue import kotlin.time.Duration.Companion.seconds class ChannelMetadataTest : BaseIntegrationTest() { @@ -119,10 +123,64 @@ class ChannelMetadataTest : BaseIntegrationTest() { pubnub.removeChannelMetadata(channel).await() // then - val result = nextEvent() + var result = nextEvent() + if (result.extractedMessage !is PNDeleteChannelMetadataEventMessage) { + result = nextEvent() + } val message = result.extractedMessage + assertTrue { message is PNDeleteChannelMetadataEventMessage } message as PNDeleteChannelMetadataEventMessage assertEquals(channel, message.channel) } } + + @Test + fun can_get_all_metadata_with_paging() = runTest(timeout = 30.seconds) { + // given + repeat(6) { + pubnub.setChannelMetadata( + channel + it, + name = name, + status = status, + custom = custom, + includeCustom = includeCustom, + type = type, + description = description + ).await() + } + + // when + val allChannels = mutableListOf() + var next: PNPage.PNNext? = null + while (true) { + val result = pubnub.getAllChannelMetadata( + limit = 2, + page = next, + includeCustom = true, + filter = "id LIKE \"$channel*\"" + ).await() + allChannels.addAll(result.data) + next = result.next + if (next == null || result.data.isEmpty()) { + break + } + } + + // clean up before asserting + repeat(6) { + pubnub.removeChannelMetadata(channel + it) + } + + // then + assertTrue { allChannels.size == 6 } + repeat(6) { index -> + val pnChannelMetadata = allChannels.firstOrNull { it.id == channel + index } + assertNotNull(pnChannelMetadata) + assertEquals(name, pnChannelMetadata.name) + assertEquals(description, pnChannelMetadata.description) + assertEquals(status, pnChannelMetadata.status) + assertEquals(customData, pnChannelMetadata.custom) + assertEquals(type, pnChannelMetadata.type) + } + } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/DeleteMessagesTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/DeleteMessagesTest.kt index bc90399c1..ffb90746c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/DeleteMessagesTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/DeleteMessagesTest.kt @@ -7,20 +7,17 @@ import com.pubnub.test.randomString import kotlinx.coroutines.test.runTest import kotlin.test.Test import kotlin.test.assertEquals -import kotlin.test.assertTrue class DeleteMessagesTest : BaseIntegrationTest() { private val channel = randomString() @Test fun deleteMessages() = runTest { - val expectedMeta = mapOf(randomString() to randomString()) val expectedMessage = randomString() val result = pubnub.publish( channel = channel, message = expectedMessage, - meta = expectedMeta, shouldStore = true, ttl = 60, ).await() @@ -41,7 +38,7 @@ class DeleteMessagesTest : BaseIntegrationTest() { if (messages.channels.isNotEmpty()) { assertEquals(channel, messages.channels.entries.single().key) - assertTrue { messages.channels.entries.single().value.isEmpty() } + assertEquals(emptyList(), messages.channels.entries.single().value) } } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/EntitiesTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/EntitiesTest.kt index c8eabe345..844cbaecf 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/EntitiesTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/EntitiesTest.kt @@ -29,9 +29,11 @@ class EntitiesTest : BaseIntegrationTest() { val subscription = channel.awaitSubscribe() var message: PNMessageResult? = null - subscription.addListener(createEventListener(pubnub, onMessage = { pubNub, pnMessageResult -> - message = pnMessageResult - })) + subscription.addListener( + createEventListener(pubnub, onMessage = { pubNub, pnMessageResult -> + message = pnMessageResult + }) + ) pubnub.publish(channelName, "some message", shouldStore = false).await() yield() @@ -45,7 +47,7 @@ class EntitiesTest : BaseIntegrationTest() { pubnub.test(backgroundScope) { val channelSet = setOf(channelName, "abc") val set = pubnub.subscriptionSetOf(channelSet) - pubnub.awaitSubscribe(channelSet) { + pubnub.awaitSubscribe(channelSet) { set.subscribe() } assertEquals(channelSet, pubnub.getSubscribedChannels().toSet()) @@ -57,15 +59,17 @@ class EntitiesTest : BaseIntegrationTest() { pubnub.test(backgroundScope) { val channelSet = setOf(channelName, "abc") val set = pubnub.subscriptionSetOf(channelSet) - pubnub.awaitSubscribe(channelSet) { + pubnub.awaitSubscribe(channelSet) { set.subscribe() } assertEquals(channelSet, pubnub.getSubscribedChannels().toSet()) var messageFromSetSubscription: PNMessageResult? = null - set.addListener(createEventListener(pubnub, onMessage = { pubNub, pnMessageResult -> - messageFromSetSubscription = pnMessageResult - })) + set.addListener( + createEventListener(pubnub, onMessage = { pubNub, pnMessageResult -> + messageFromSetSubscription = pnMessageResult + }) + ) pubnub.publish(channelName, "some message", shouldStore = false).await() val receivedMessage = nextMessage() @@ -74,4 +78,4 @@ class EntitiesTest : BaseIntegrationTest() { assertEquals(receivedMessage, messageFromSetSubscription) } } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/FetchMessagesTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/FetchMessagesTest.kt index fb10a848f..adcb3aa0d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/FetchMessagesTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/FetchMessagesTest.kt @@ -1,5 +1,6 @@ package com.pubnub.api +import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.HistoryMessageType import com.pubnub.api.models.consumer.history.PNFetchMessageItem import com.pubnub.api.models.consumer.message_actions.PNMessageAction @@ -47,7 +48,6 @@ class FetchMessagesTest : BaseIntegrationTest() { ).await() assertTrue { fetchResult.channels.isNotEmpty() } - val expectedItem = PNFetchMessageItem( uuid = pubnub.configuration.userId.value, message = createJsonElement(expectedMessage), @@ -58,7 +58,7 @@ class FetchMessagesTest : BaseIntegrationTest() { expectedAction to mapOf( expectedActionValue to listOf( PNFetchMessageItem.Action( - actionTimetoken = actionResult.actionTimetoken.toString(), + actionTimetoken = actionResult.actionTimetoken!!, uuid = pubnub.configuration.userId.value, ), ), @@ -92,4 +92,36 @@ class FetchMessagesTest : BaseIntegrationTest() { ) } -} \ No newline at end of file + @Test + fun fetchMessages_with_limit_1() = runTest { + val expectedMessage = randomString() + + val result = pubnub.publish( + channel = channel, + message = expectedMessage, + shouldStore = true, + ttl = 60, + ).await() + + val fetchResult = pubnub.fetchMessages( + channels = listOf(channel), + page = PNBoundedPage(limit = 1) + ).await() + + val expectedItem = PNFetchMessageItem( + uuid = pubnub.configuration.userId.value, + message = createJsonElement(expectedMessage), + timetoken = result.timetoken, + meta = null, + messageType = HistoryMessageType.Message, + ) + + val expectedChannelsResponse: Map> = mapOf( + channel to listOf( + expectedItem, + ), + ) + + assertEquals(expectedChannelsResponse, fetchResult.channels) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/HereWhereNowTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/HereWhereNowTest.kt index 2e63df2a3..89e1b9c66 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/HereWhereNowTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/HereWhereNowTest.kt @@ -12,16 +12,14 @@ import kotlin.test.Test import kotlin.test.assertEquals class HereWhereNowTest : BaseIntegrationTest() { - private val channel = randomString() - @Test fun hereNow() = runTest(timeout = defaultTimeout) { + val channel = randomString() pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) withContext(Dispatchers.Default) { - delay(400) + delay(3200) // herenow has a 3 second cache } - val result = pubnub.hereNow(listOf(channel)).await() assertEquals(config.userId.value, result.channels[channel]?.occupants?.single()?.uuid) assertEquals(1, result.channels[channel]?.occupancy) @@ -33,16 +31,15 @@ class HereWhereNowTest : BaseIntegrationTest() { @Test fun whereNow() = runTest(timeout = defaultTimeout) { + val channel = randomString() pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) withContext(Dispatchers.Default) { - delay(400) + delay(3200) } val result = pubnub.whereNow().await() assertEquals(listOf(channel), result.channels) } } - - -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt index b50772a0a..875fa8bc9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt @@ -68,7 +68,7 @@ class MembersTest : BaseIntegrationTest() { // then var next: PNPage.PNNext? = null - while(true) { + while (true) { yield() val result = pubnub.getMemberships(pubnub.configuration.userId.value, page = next).await() next = result.next diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt index 1f67a6cf7..9a1562184 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt @@ -15,7 +15,6 @@ import kotlinx.coroutines.test.runTest import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse -import kotlin.time.Duration.Companion.seconds class MembershipsTest : BaseIntegrationTest() { private val channel = "myChannel" + randomString() @@ -77,7 +76,7 @@ class MembershipsTest : BaseIntegrationTest() { // then var next: PNPage.PNNext? = null - while(true) { + while (true) { val result = pubnub.getChannelMembers(channel, page = next).await() next = result.next assertFalse { result.data.any { it.uuid?.id == pubnub.configuration.userId.value } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageActionsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageActionsTest.kt index d52a4a027..8df69e9e4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageActionsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageActionsTest.kt @@ -1,8 +1,6 @@ package com.pubnub.api import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.history.HistoryMessageType -import com.pubnub.api.models.consumer.history.PNFetchMessageItem import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await @@ -16,7 +14,7 @@ class MessageActionsTest : BaseIntegrationTest() { private val channel = randomString() @Test - fun add_getMessageAction() = runTest { + fun add_get_remove_MessageAction() = runTest { val expectedMeta = mapOf(randomString() to randomString()) val expectedMessage = randomString() val expectedAction = randomString() @@ -39,10 +37,13 @@ class MessageActionsTest : BaseIntegrationTest() { ), ).await() - val actions = pubnub.getMessageActions(channel, PNBoundedPage( - start = actionResult.actionTimetoken!! + 1, - end = actionResult.actionTimetoken!! - )).await() + val actions = pubnub.getMessageActions( + channel, + PNBoundedPage( + start = actionResult.actionTimetoken!! + 1, + end = actionResult.actionTimetoken!! + ) + ).await() assertTrue { actions.actions.isNotEmpty() } val foundAction = actions.actions.single { it.actionTimetoken == actionResult.actionTimetoken } @@ -50,6 +51,17 @@ class MessageActionsTest : BaseIntegrationTest() { assertEquals(actionResult.messageTimetoken, foundAction.messageTimetoken) assertEquals(expectedAction, foundAction.type) assertEquals(config.userId.value, foundAction.uuid) - } -} \ No newline at end of file + pubnub.removeMessageAction(channel, foundAction.messageTimetoken, foundAction.actionTimetoken!!).await() + + val actionsAfterDelete = pubnub.getMessageActions( + channel, + PNBoundedPage( + start = actionResult.actionTimetoken!! + 1, + end = actionResult.actionTimetoken!! + ) + ).await() + + assertEquals(emptyList(), actionsAfterDelete.actions) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageCountsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageCountsTest.kt index 76b28629c..4c41ccc5c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageCountsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageCountsTest.kt @@ -43,4 +43,4 @@ class MessageCountsTest : BaseIntegrationTest() { assertEquals(expectedCount, counts.channels[channel]) assertEquals(expectedCount, counts.channels[otherChannel]) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt index 070392d7f..9fe2c8e1b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt @@ -13,7 +13,7 @@ import kotlin.test.assertEquals import kotlin.test.assertTrue @JsExport -data class ABC ( +data class ABC( val aaa: Boolean = false, val bbb: Int = 123, val ccc: String = "platform: $PLATFORM" @@ -162,7 +162,7 @@ class PublishTest : BaseIntegrationTest() { } @Test - @Ignore //todo js doesn't support primitive metadata? + @Ignore // todo js doesn't support primitive metadata? fun can_receive_message_with_primitive_metadata() = runTest(timeout = defaultTimeout) { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) @@ -179,7 +179,6 @@ class PublishTest : BaseIntegrationTest() { } } - private fun deepCompare(expected: Any?, actual: JsonElement) { // println("e: " + expected.toString() + " " + expected!!::class) // println("a: " + actual.toString()) @@ -205,7 +204,7 @@ private fun deepCompare(expected: Any?, actual: JsonElement) { assertEquals(expected.toDouble(), actual.asDouble()!!, 0.01) } else if (expected is String) { assertEquals(expected, actual.asString()!!) - } else if (expected == null){ + } else if (expected == null) { assertTrue { actual.isNull() } } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PushTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PushTest.kt index 33bd3db27..d89688ed5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PushTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PushTest.kt @@ -5,9 +5,12 @@ import com.pubnub.api.enums.PNPushType import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await import com.pubnub.test.randomString +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import kotlinx.coroutines.test.runTest +import kotlinx.coroutines.withContext import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test @@ -20,17 +23,16 @@ class PushTest : BaseIntegrationTest() { private val deviceId = generateSequence { (0..9).random() }.take(70).toList().shuffled().joinToString(separator = "") private val topic = randomString() - private val mutex = Mutex() //for some reason without this on JS tests run concurrently with before/after and fail + private val mutex = Mutex() // for some reason without this on JS tests run concurrently with before/after and fail @BeforeTest override fun before() { super.before() runTest { mutex.withLock { - pubnub.removePushNotificationsFromChannels(PNPushType.FCM, channels, deviceId).await() - pubnub.removePushNotificationsFromChannels( + pubnub.removeAllPushNotificationsFromDeviceWithPushToken(PNPushType.FCM, deviceId).await() + pubnub.removeAllPushNotificationsFromDeviceWithPushToken( PNPushType.APNS2, - channels, deviceId, topic, PNPushEnvironment.PRODUCTION @@ -70,8 +72,14 @@ class PushTest : BaseIntegrationTest() { deviceId, ).await() - assertTrue { pubnub.auditPushChannelProvisions(PNPushType.FCM, deviceId) - .await().channels.isEmpty() } + withContext(Dispatchers.Default) { + delay(1000) + } + + assertEquals( + emptyList(), + pubnub.auditPushChannelProvisions(PNPushType.FCM, deviceId).await().channels + ) } } @@ -99,8 +107,10 @@ class PushTest : BaseIntegrationTest() { PNPushEnvironment.PRODUCTION ).await() - assertTrue { pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) - .await().channels.isEmpty() } + assertTrue { + pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) + .await().channels.isEmpty() + } } } @@ -117,8 +127,7 @@ class PushTest : BaseIntegrationTest() { deviceId, ).await() - assertTrue { pubnub.auditPushChannelProvisions(PNPushType.FCM, deviceId) - .await().channels.isEmpty() } + assertEquals(emptyList(), pubnub.auditPushChannelProvisions(PNPushType.FCM, deviceId).await().channels) } } @@ -145,9 +154,14 @@ class PushTest : BaseIntegrationTest() { PNPushEnvironment.PRODUCTION ).await() - assertTrue { pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) - .await().channels.isEmpty() } + withContext(Dispatchers.Default) { + delay(1000) + } + + assertTrue { + pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) + .await().channels.isEmpty() + } } } - -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/TimeTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/TimeTest.kt new file mode 100644 index 000000000..a96749b39 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/TimeTest.kt @@ -0,0 +1,15 @@ +package com.pubnub.api + +import com.pubnub.test.BaseIntegrationTest +import com.pubnub.test.await +import kotlinx.coroutines.test.runTest +import kotlin.test.Test +import kotlin.test.assertTrue + +class TimeTest : BaseIntegrationTest() { + @Test + fun time() = runTest { + val time = pubnub.time().await() + assertTrue { time.timetoken > 1000000 } + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt index ecafa075f..a61a7ac34 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt @@ -12,12 +12,10 @@ import com.pubnub.test.await import com.pubnub.test.randomString import com.pubnub.test.test import kotlinx.coroutines.test.runTest -import kotlin.test.Ignore import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertNotNull -import kotlin.test.assertTrue import kotlin.time.Duration.Companion.seconds class UserMetadataTest : BaseIntegrationTest() { @@ -160,7 +158,7 @@ class UserMetadataTest : BaseIntegrationTest() { type = type ).await() - //when + // when val result = pubnub.getUUIDMetadata(uuid, includeCustom = true).await() // then @@ -196,7 +194,7 @@ class UserMetadataTest : BaseIntegrationTest() { // when val allUsers = mutableListOf() var next: PNPage.PNNext? = null - while(true) { + while (true) { val result: PNUUIDMetadataArrayResult = pubnub.getAllUUIDMetadata( limit = 2, page = next, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/kmp/platform.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/kmp/platform.kt index 1f697c541..8f8ac21e3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/kmp/platform.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/kmp/platform.kt @@ -1,3 +1,3 @@ package com.pubnub.kmp -internal expect val PLATFORM: String \ No newline at end of file +internal expect val PLATFORM: String diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index e8721e9bb..475c3d072 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -16,7 +16,6 @@ import cocoapods.PubNubSwift.unsubscribeFrom import cocoapods.PubNubSwift.userMetadataWith import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages -import com.pubnub.api.endpoints.DeleteMessagesImpl import com.pubnub.api.endpoints.FetchMessages import com.pubnub.api.endpoints.FetchMessagesImpl import com.pubnub.api.endpoints.MessageCounts @@ -163,7 +162,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { channel: String, message: Any, meta: Any?, - shouldStore: Boolean?, + shouldStore: Boolean, usePost: Boolean, replicate: Boolean, ttl: Int? @@ -290,7 +289,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { - return DeleteMessagesImpl( + return com.pubnub.api.endpoints.DeleteMessagesImpl( pubnub = pubNubObjC, channels = channels, start = start, @@ -806,6 +805,7 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { override fun subscriptionSetOf(subscriptions: Set): SubscriptionSet { TODO("Not yet implemented") } + override fun subscriptionSetOf( channels: Set, channelGroups: Set, @@ -849,4 +849,4 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { fileId = fileId ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt index 27d9ead40..b39d52e6b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.deleteMessagesFrom -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessReturnValue import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessReturnValue import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSNumber @@ -17,12 +17,12 @@ import platform.Foundation.NSNumber actual interface DeleteMessages : PNFuture @OptIn(ExperimentalForeignApi::class) -class DeleteMessagesImpl ( +class DeleteMessagesImpl( private val pubnub: PubNubObjC, private val channels: List, private val start: Long?, private val end: Long? -): DeleteMessages { +) : DeleteMessages { override fun async(callback: Consumer>) { pubnub.deleteMessagesFrom( channels = channels, @@ -32,4 +32,4 @@ class DeleteMessagesImpl ( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt index 061bcce11..5db35d84f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt @@ -5,18 +5,16 @@ import cocoapods.PubNubSwift.PubNubMessageActionObjC import cocoapods.PubNubSwift.PubNubMessageObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.fetchMessagesFrom -import com.pubnub.kmp.PNFuture -import com.pubnub.api.JsonElement import com.pubnub.api.JsonElementImpl -import com.pubnub.api.PubNubError import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.HistoryMessageType import com.pubnub.api.models.consumer.history.PNFetchMessageItem import com.pubnub.api.models.consumer.history.PNFetchMessagesResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.kmp.safeCast import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSNumber @@ -24,7 +22,7 @@ import platform.Foundation.NSNumber /** * @see [PubNub.fetchMessages] */ -actual interface FetchMessages : PNFuture {} +actual interface FetchMessages : PNFuture @OptIn(ExperimentalForeignApi::class) open class FetchMessagesImpl( @@ -35,7 +33,7 @@ open class FetchMessagesImpl( private val includeMeta: Boolean, private val includeMessageActions: Boolean, private val includeMessageType: Boolean -): FetchMessages { +) : FetchMessages { override fun async(callback: Consumer>) { pubnub.fetchMessagesFrom( channels = channels, @@ -46,7 +44,7 @@ open class FetchMessagesImpl( page = PubNubBoundedPageObjC( start = page.start?.let { NSNumber(long = it) }, end = page.end?.let { NSNumber(long = it) }, - limit = page.limit?.let { NSNumber(int = it) } + limit = page.limit?.let { NSNumber(int = it) } ), onSuccess = callback.onSuccessHandler { PNFetchMessagesResult( @@ -56,7 +54,8 @@ open class FetchMessagesImpl( end = it?.page()?.end()?.longValue, limit = it?.page()?.limit()?.intValue ) - )}, + ) + }, onFailure = callback.onFailureHandler() ) } @@ -71,7 +70,7 @@ open class FetchMessagesImpl( timetoken = it.published().toLong(), actions = mapMessageActions(rawValue = it.actions()), messageType = HistoryMessageType.of(it.messageType().toInt()), - error = null //todo translate crypto errors + error = null // todo translate crypto errors ) } } ?: emptyMap() @@ -87,7 +86,7 @@ open class FetchMessagesImpl( groupedEntry.value.map { PNFetchMessageItem.Action( uuid = it.publisher(), - actionTimetoken = it.published()?.longValue.toString() + actionTimetoken = it.published()?.longValue!! ) } } @@ -95,4 +94,4 @@ open class FetchMessagesImpl( null } } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt index 69cf2df88..551634f11 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.messageCountsFor -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNMessageCountResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.kmp.safeCast import kotlinx.cinterop.ExperimentalForeignApi @@ -21,7 +21,7 @@ class MessageCountsImpl( private val pubnub: PubNubObjC, private val channels: List, private val channelsTimetoken: List -): MessageCounts { +) : MessageCounts { override fun async(callback: Consumer>) { pubnub.messageCountsFor( channels = channels, @@ -30,4 +30,4 @@ class MessageCountsImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt index 6b5c8d803..c0d053d80 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.timeOnSuccess -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNTimeResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** @@ -18,11 +18,11 @@ actual interface Time : PNFuture @OptIn(ExperimentalForeignApi::class) class TimeImpl( private val pubnub: PubNubObjC -): Time { +) : Time { override fun async(callback: Consumer>) { pubnub.timeOnSuccess( onSuccess = callback.onSuccessHandler { PNTimeResult(it.toLong()) }, onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt index 1b0b0f300..71713052e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.ios.kt @@ -1,7 +1,6 @@ package com.pubnub.api.endpoints.access -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult +import com.pubnub.kmp.PNFuture -actual interface GrantToken : PNFuture { -} \ No newline at end of file +actual interface GrantToken : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt index 6e58a2afb..e02277014 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.ios.kt @@ -2,4 +2,4 @@ package com.pubnub.api.endpoints.access import com.pubnub.kmp.PNFuture -actual interface RevokeToken : PNFuture \ No newline at end of file +actual interface RevokeToken : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt index b1154eea5..6a2498a67 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints.channel_groups import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.addChannelsTo -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** @@ -20,7 +20,7 @@ class AddChannelChannelGroupImpl( private val pubnub: PubNubObjC, private val channels: List, private val channelGroup: String -): AddChannelChannelGroup { +) : AddChannelChannelGroup { override fun async(callback: Consumer>) { pubnub.addChannelsTo( channelGroup = channelGroup, @@ -29,4 +29,4 @@ class AddChannelChannelGroupImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt index c80b19e74..38ec8d7eb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt @@ -2,30 +2,33 @@ package com.pubnub.api.endpoints.channel_groups import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.listChannelsFor -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.listChannelsForChannelGroup] */ -actual interface AllChannelsChannelGroup : PNFuture { -} +actual interface AllChannelsChannelGroup : PNFuture @OptIn(ExperimentalForeignApi::class) class AllChannelsChannelGroupImpl( private val pubnub: PubNubObjC, private val channelGroup: String -): AllChannelsChannelGroup { +) : AllChannelsChannelGroup { override fun async(callback: Consumer>) { pubnub.listChannelsFor( channelGroup = channelGroup, - onSuccess = callback.onSuccessHandler { PNChannelGroupsAllChannelsResult(channels = it?.filterIsInstance() ?: emptyList()) }, + onSuccess = callback.onSuccessHandler { + PNChannelGroupsAllChannelsResult( + channels = it?.filterIsInstance() ?: emptyList() + ) + }, onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt index f0570a6cf..da9f2b4f6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints.channel_groups import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.deleteWithChannelGroup -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** @@ -19,7 +19,7 @@ actual interface DeleteChannelGroup : PNFuture class DeleteChannelGroupImpl( private val pubnub: PubNubObjC, private val channelGroup: String -): DeleteChannelGroup { +) : DeleteChannelGroup { override fun async(callback: Consumer>) { pubnub.deleteWithChannelGroup( channelGroup = channelGroup, @@ -27,4 +27,4 @@ class DeleteChannelGroupImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt index 7582c178d..2b3b466f7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints.channel_groups import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.listChannelGroupsOnSuccess -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** @@ -18,11 +18,11 @@ actual interface ListAllChannelGroup : PNFuture @OptIn(ExperimentalForeignApi::class) class ListAllChannelGroupImpl( private val pubnub: PubNubObjC -): ListAllChannelGroup { +) : ListAllChannelGroup { override fun async(callback: Consumer>) { pubnub.listChannelGroupsOnSuccess( onSuccess = callback.onSuccessHandler { PNChannelGroupsListAllResult(groups = it?.filterIsInstance() ?: emptyList()) }, onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt index e32a93c98..c5fcec488 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt @@ -2,26 +2,25 @@ package com.pubnub.api.endpoints.channel_groups import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeWithChannels -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.removeChannelsFromChannelGroup] */ -actual interface RemoveChannelChannelGroup : PNFuture { -} +actual interface RemoveChannelChannelGroup : PNFuture @OptIn(ExperimentalForeignApi::class) class RemoveChannelChannelGroupImpl( private val pubnub: PubNubObjC, private val channels: List, private val channelGroup: String -): RemoveChannelChannelGroup { +) : RemoveChannelChannelGroup { override fun async(callback: Consumer>) { pubnub.removeWithChannels( channels = channels, @@ -30,4 +29,4 @@ class RemoveChannelChannelGroupImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt index 8e3d97271..61e764ae1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt @@ -2,10 +2,10 @@ package com.pubnub.api.endpoints.files import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.deleteFileWithChannel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNDeleteFileResult import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessReturnValue import kotlinx.cinterop.ExperimentalForeignApi @@ -21,7 +21,7 @@ class DeleteFileImpl( private val channel: String, private val fileName: String, private val fileId: String -): DeleteFile { +) : DeleteFile { override fun async(callback: Consumer>) { pubnub.deleteFileWithChannel( channel = channel, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt index 2e9e676f4..9068eb1aa 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt @@ -23,7 +23,7 @@ class DownloadFileImpl( private val channel: String, private val fileName: String, private val fileId: String -): DownloadFile { +) : DownloadFile { override fun async(callback: Consumer>) { pubnub.downloadFileWithChannel( channel = channel, @@ -33,8 +33,9 @@ class DownloadFileImpl( PNDownloadFileResult( fileName = it?.name().orEmpty(), byteStream = it?.url()?.let { url -> DownloadableImpl(inputStream = NSInputStream(uRL = url)) } - )}, + ) + }, onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt index a99648b76..0d56362d5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt @@ -2,10 +2,10 @@ package com.pubnub.api.endpoints.files import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getFileUrlWithChannel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNFileUrlResult import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi @@ -21,7 +21,7 @@ class GetFileUrlImpl( private val channel: String, private val fileName: String, private val fileId: String -): GetFileUrl { +) : GetFileUrl { override fun async(callback: Consumer>) { pubnub.getFileUrlWithChannel( channel = channel, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt index d9d0c99a1..b15e8aab1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt @@ -3,12 +3,12 @@ package com.pubnub.api.endpoints.files import cocoapods.PubNubSwift.PubNubFileObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.listFilesWithChannel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNListFilesResult import com.pubnub.api.models.consumer.files.PNUploadedFile import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.createPubNubHashedPage import com.pubnub.kmp.filterAndMap import com.pubnub.kmp.onFailureHandler @@ -27,7 +27,7 @@ class ListFilesImpl( private val channel: String, private val limit: Int?, private val next: PNPage.PNNext? -): ListFiles { +) : ListFiles { override fun async(callback: Consumer>) { pubnub.listFilesWithChannel( channel = channel, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt index 47556ab8c..c43045f68 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints.files import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.publishFileMessageWithChannel -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSNumber @@ -26,7 +26,7 @@ class PublishFileMessageImpl( private val meta: Any?, private val ttl: Int?, private val shouldStore: Boolean? -): PublishFileMessage { +) : PublishFileMessage { override fun async(callback: Consumer>) { pubnub.publishFileMessageWithChannel( channel = channel, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt index 683800292..5c33f33a4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt @@ -5,20 +5,20 @@ import cocoapods.PubNubSwift.PubNubFileContentObjC import cocoapods.PubNubSwift.PubNubInputStreamContentObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.PubNubUploadableObjC -import com.pubnub.api.models.consumer.files.PNFileUploadResult -import com.pubnub.api.v2.callbacks.Consumer -import com.pubnub.api.v2.callbacks.Result -import com.pubnub.kmp.PNFuture -import kotlinx.cinterop.ExperimentalForeignApi import cocoapods.PubNubSwift.sendFileWithChannel import com.pubnub.api.PubNubException import com.pubnub.api.models.consumer.files.PNBaseFile +import com.pubnub.api.models.consumer.files.PNFileUploadResult +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.DataUploadContent import com.pubnub.kmp.FileUploadContent +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.StreamUploadContent import com.pubnub.kmp.Uploadable import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler2 +import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSInputStream import platform.Foundation.NSNumber @@ -37,7 +37,7 @@ class SendFileImpl( private val meta: Any?, private val ttl: Int?, private val shouldStore: Boolean?, -): SendFile { +) : SendFile { override fun async(callback: Consumer>) { mapContent(inputStream)?.let { content -> pubnub.sendFileWithChannel( @@ -80,4 +80,4 @@ class SendFileImpl( else -> null } } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt index 5a841494b..5705704c3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt @@ -14,8 +14,7 @@ import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.addMessageAction] */ -actual interface AddMessageAction : PNFuture { -} +actual interface AddMessageAction : PNFuture @OptIn(ExperimentalForeignApi::class) class AddMessageActionImpl( @@ -42,7 +41,8 @@ class AddMessageActionImpl( actionTimetoken = messageActionObjC?.actionTimetoken()?.toLong() } ) - }, onFailure = callback.onFailureHandler() + }, + onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt index d46560dbb..a14395785 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt @@ -4,16 +4,14 @@ import cocoapods.PubNubSwift.PubNubBoundedPageObjC import cocoapods.PubNubSwift.PubNubMessageActionObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getMessageActionsFrom -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result -import com.pubnub.kmp.PubNub +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.filterAndMap +import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler2 import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSNumber @@ -21,15 +19,14 @@ import platform.Foundation.NSNumber /** * @see [PubNub.getMessageActions] */ -actual interface GetMessageActions : PNFuture { -} +actual interface GetMessageActions : PNFuture @OptIn(ExperimentalForeignApi::class) class GetMessageActionsImpl( private val channel: String, private val pubnub: PubNubObjC, private val page: PNBoundedPage -): GetMessageActions { +) : GetMessageActions { override fun async(callback: Consumer>) { pubnub.getMessageActionsFrom( channel = channel, @@ -47,7 +44,6 @@ class GetMessageActionsImpl( limit = next?.limit()?.intValue() ) ) - }, onFailure = callback.onFailureHandler() ) @@ -63,4 +59,4 @@ class GetMessageActionsImpl( uuid = rawValue.publisher() } } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt index 2c8d01881..0dd0bf2d9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt @@ -2,19 +2,18 @@ package com.pubnub.api.endpoints.message_actions import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeMessageActionWithChannel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessReturnValue import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessReturnValue import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.removeMessageAction] */ -actual interface RemoveMessageAction : PNFuture { -} +actual interface RemoveMessageAction : PNFuture @OptIn(ExperimentalForeignApi::class) class RemoveMessageActionImpl( @@ -22,7 +21,7 @@ class RemoveMessageActionImpl( private val channel: String, private val messageTimetoken: Long, private val actionTimetoken: Long -): RemoveMessageAction { +) : RemoveMessageAction { override fun async(callback: Consumer>) { pubnub.removeMessageActionWithChannel( channel = channel, @@ -32,4 +31,4 @@ class RemoveMessageActionImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt index f2a4c01c1..242b5afb9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt @@ -3,13 +3,13 @@ package com.pubnub.api.endpoints.objects.channel import cocoapods.PubNubSwift.PubNubChannelMetadataObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getAllChannelMetadataWithLimit -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.PNSortKey import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.createObjectSortProperties import com.pubnub.kmp.createPNChannelMetadata import com.pubnub.kmp.createPubNubHashedPage @@ -33,7 +33,7 @@ class GetAllChannelMetadataImpl( private val sort: Collection>, private val includeCount: Boolean, private val includeCustom: Boolean -): GetAllChannelMetadata { +) : GetAllChannelMetadata { override fun async(callback: Consumer>) { pubnub.getAllChannelMetadataWithLimit( limit = limit?.let { NSNumber(it) }, @@ -54,4 +54,4 @@ class GetAllChannelMetadataImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt index 4f6c25b6b..cd80a1b52 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt @@ -2,14 +2,13 @@ package com.pubnub.api.endpoints.objects.channel import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getChannelMetadataWithChannel -import com.pubnub.kmp.PNFuture -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.createPNChannelMetadata +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** @@ -22,7 +21,7 @@ class GetChannelMetadataImpl( private val pubnub: PubNubObjC, private val channel: String, private val includeCustom: Boolean -): GetChannelMetadata { +) : GetChannelMetadata { override fun async(callback: Consumer>) { pubnub.getChannelMetadataWithChannel( channel = channel, @@ -36,4 +35,4 @@ class GetChannelMetadataImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt index bc1679987..9900edc9b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints.objects.channel import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeChannelMetadataWithChannel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi actual interface RemoveChannelMetadata : PNFuture @@ -16,7 +16,7 @@ actual interface RemoveChannelMetadata : PNFuture class RemoveChannelMetadataImpl( private val pubnub: PubNubObjC, private val channel: String -): RemoveChannelMetadata { +) : RemoveChannelMetadata { override fun async(callback: Consumer>) { pubnub.removeChannelMetadataWithChannel( channel = channel, @@ -24,4 +24,4 @@ class RemoveChannelMetadataImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt index fd76c8424..6177d3515 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt @@ -3,17 +3,15 @@ package com.pubnub.api.endpoints.objects.channel import cocoapods.PubNubSwift.AnyJSONObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.setChannelMetadataWithChannel -import com.pubnub.kmp.PNFuture -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.createPNChannelMetadata +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi -import platform.posix.stat /** * @see [PubNub.setChannelMetadata] @@ -30,7 +28,7 @@ class SetChannelMetadataImpl( private val includeCustom: Boolean, private val type: String?, private val status: String? -): SetChannelMetadata { +) : SetChannelMetadata { override fun async(callback: Consumer>) { pubnub.setChannelMetadataWithChannel( channel = channel, @@ -49,4 +47,4 @@ class SetChannelMetadataImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt index aa810f6c9..e9b53108a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt @@ -6,11 +6,11 @@ import cocoapods.PubNubSwift.getChannelMembersWithChannel import com.pubnub.api.models.consumer.objects.PNMemberKey import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.PNSortKey -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.createPNMember import com.pubnub.kmp.createPubNubHashedPage import com.pubnub.kmp.filterAndMap diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt index 9230a0e4a..9b6b153d4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt @@ -10,11 +10,11 @@ import com.pubnub.api.models.consumer.objects.PNMemberKey import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.PNSortKey import com.pubnub.api.models.consumer.objects.member.MemberInput -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.createPNMember import com.pubnub.kmp.createPubNubHashedPage import com.pubnub.kmp.filterAndMap @@ -40,7 +40,7 @@ class SetChannelMembersImpl( private val includeCount: Boolean, private val includeCustom: Boolean, private val includeUUIDDetails: PNUUIDDetailsLevel? -): ManageChannelMembers { +) : ManageChannelMembers { override fun async(callback: Consumer>) { pubnub.setChannelMembersWithChannel( channel = channel, @@ -79,7 +79,7 @@ class RemoveChannelMembersImpl( private val includeCount: Boolean, private val includeCustom: Boolean, private val includeUUIDDetails: PNUUIDDetailsLevel? -): ManageChannelMembers { +) : ManageChannelMembers { override fun async(callback: Consumer>) { pubnub.removeChannelMembersWithChannel( channel = channel, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt index 92459a923..cee734364 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt @@ -7,10 +7,10 @@ import com.pubnub.api.models.consumer.objects.PNMembershipKey import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.PNSortKey import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.createPNChannelMembership import com.pubnub.kmp.createPubNubHashedPage import com.pubnub.kmp.filterAndMap @@ -35,11 +35,11 @@ class GetMembershipsImpl( private val includeCount: Boolean, private val includeCustom: Boolean, private val includeChannelDetails: PNChannelDetailsLevel? -): GetMemberships { +) : GetMemberships { override fun async(callback: Consumer>) { pubnub.getMembershipsWithUuid( uuid = uuid, - limit = limit?.let { NSNumber(it) }, + limit = limit?.let { NSNumber(it) }, page = createPubNubHashedPage(from = page), filter = filter, sort = sort.map { it.key.fieldName }, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt index dece4a5c0..007abc899 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt @@ -11,10 +11,10 @@ import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.PNSortKey import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.createPNChannelMembership import com.pubnub.kmp.createPubNubHashedPage import com.pubnub.kmp.filterAndMap @@ -40,10 +40,10 @@ class AddMembershipsImpl( private val includeCount: Boolean, private val includeCustom: Boolean, private val includeChannelDetails: PNChannelDetailsLevel? -): ManageMemberships { +) : ManageMemberships { override fun async(callback: Consumer>) { pubnub.setMembershipsWithChannels( - channels = channels.map { PubNubChannelMetadataObjC(it.channel, AnyJSONObjC(it.custom?.value), it.status)}, + channels = channels.map { PubNubChannelMetadataObjC(it.channel, AnyJSONObjC(it.custom?.value), it.status) }, uuid = uuid, limit = limit?.let { NSNumber(it) }, page = createPubNubHashedPage(from = page), @@ -79,7 +79,7 @@ class RemoveMembershipsImpl( private val includeCount: Boolean, private val includeCustom: Boolean, private val includeChannelDetails: PNChannelDetailsLevel? -): ManageMemberships { +) : ManageMemberships { override fun async(callback: Consumer>) { pubnub.removeMembershipsWithChannels( channels = channels, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt index d1b7e998a..f5140774f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt @@ -54,4 +54,4 @@ class GetAllUUIDMetadataImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt index c659dc548..b32946178 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt @@ -2,27 +2,26 @@ package com.pubnub.api.endpoints.objects.uuid import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getUUIDMetadataWithUuid -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.createPNUUIDMetadata +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.getUUIDMetadata] */ -actual interface GetUUIDMetadata : PNFuture { -} +actual interface GetUUIDMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class GetUUIDMetadataImpl( private val pubnub: PubNubObjC, private val uuid: String?, private val includeCustom: Boolean -): GetUUIDMetadata { +) : GetUUIDMetadata { override fun async(callback: Consumer>) { pubnub.getUUIDMetadataWithUuid( uuid = uuid, @@ -36,4 +35,4 @@ class GetUUIDMetadataImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt index 1535a8fa5..606c03108 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt @@ -2,22 +2,21 @@ package com.pubnub.api.endpoints.objects.uuid import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeUUIDMetadataWithUuid -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi -actual interface RemoveUUIDMetadata : PNFuture { -} +actual interface RemoveUUIDMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class RemoveUUIDMetadataImpl( private val pubnub: PubNubObjC, private val uuid: String? -): RemoveUUIDMetadata { +) : RemoveUUIDMetadata { override fun async(callback: Consumer>) { pubnub.removeUUIDMetadataWithUuid( uuid = uuid, @@ -25,4 +24,4 @@ class RemoveUUIDMetadataImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt index 497e4fb23..d61123679 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt @@ -3,14 +3,14 @@ package com.pubnub.api.endpoints.objects.uuid import cocoapods.PubNubSwift.AnyJSONObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.setUUIDMetadataWithUuid -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.PNFuture import com.pubnub.kmp.createPNUUIDMetadata +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** @@ -30,7 +30,7 @@ class SetUUIDMetadataImpl( private val includeCustom: Boolean, private val type: String?, private val status: String? -): SetUUIDMetadata { +) : SetUUIDMetadata { override fun async(callback: Consumer>) { pubnub.setUUIDMetadataWithUuid( uuid = uuid, @@ -51,4 +51,4 @@ class SetUUIDMetadataImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt index 6d2ebe1ba..b15846ffd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt @@ -2,21 +2,19 @@ package com.pubnub.api.endpoints.presence import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.getPresenceStateWithChannels -import com.pubnub.kmp.PNFuture -import com.pubnub.api.JsonElement import com.pubnub.api.models.consumer.presence.PNGetStateResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.kmp.safeCast import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.getPresenceState] */ -actual interface GetState : PNFuture { -} +actual interface GetState : PNFuture @OptIn(ExperimentalForeignApi::class) class GetStateImpl( @@ -24,7 +22,7 @@ class GetStateImpl( private val channels: List, private val channelGroups: List, private val uuid: String -): GetState { +) : GetState { override fun async(callback: Consumer>) { pubnub.getPresenceStateWithChannels( channels = channels, @@ -34,4 +32,4 @@ class GetStateImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt index 63a0c81b8..eece52b2e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt @@ -4,24 +4,22 @@ import cocoapods.PubNubSwift.PubNubHereNowChannelDataObjC import cocoapods.PubNubSwift.PubNubHereNowOccupantDataObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.hereNowWithChannels -import com.pubnub.kmp.PNFuture -import com.pubnub.api.JsonElement import com.pubnub.api.JsonElementImpl import com.pubnub.api.models.consumer.presence.PNHereNowChannelData import com.pubnub.api.models.consumer.presence.PNHereNowOccupantData import com.pubnub.api.models.consumer.presence.PNHereNowResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.kmp.safeCast import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.hereNow] */ -actual interface HereNow : PNFuture { -} +actual interface HereNow : PNFuture @OptIn(ExperimentalForeignApi::class) class HereNowImpl( @@ -30,30 +28,32 @@ class HereNowImpl( private val channelGroups: List, private val includeState: Boolean, private val includeUUIDs: Boolean -): HereNow { +) : HereNow { override fun async(callback: Consumer>) { pubnub.hereNowWithChannels( channels = channels, channelGroups = channelGroups, includeState = includeState, includeUUIDs = includeUUIDs, - onSuccess = callback.onSuccessHandler { PNHereNowResult( - totalChannels = it?.totalChannels()?.toInt() ?: 0, - totalOccupancy = it?.totalOccupancy()?.toInt() ?: 0, - channels = (it?.channels()?.safeCast())?.mapValues { entry -> - PNHereNowChannelData( - channelName = entry.value.channelName(), - occupancy = entry.value.occupancy().toInt(), - occupants = (entry.value.occupants().filterIsInstance()).map { occupant -> - PNHereNowOccupantData( - uuid = occupant.uuid(), - state = JsonElementImpl(occupant.state()) - ) - } - ) - }?.toMutableMap() ?: emptyMap().toMutableMap() - )}, + onSuccess = callback.onSuccessHandler { + PNHereNowResult( + totalChannels = it?.totalChannels()?.toInt() ?: 0, + totalOccupancy = it?.totalOccupancy()?.toInt() ?: 0, + channels = (it?.channels()?.safeCast())?.mapValues { entry -> + PNHereNowChannelData( + channelName = entry.value.channelName(), + occupancy = entry.value.occupancy().toInt(), + occupants = (entry.value.occupants().filterIsInstance()).map { occupant -> + PNHereNowOccupantData( + uuid = occupant.uuid(), + state = JsonElementImpl(occupant.state()) + ) + } + ) + }?.toMutableMap() ?: emptyMap().toMutableMap() + ) + }, onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt index 361efdeaf..caada0cf9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt @@ -4,12 +4,12 @@ import cocoapods.PubNubSwift.AnyJSONObjC import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.setPresenceStateWithChannels import com.pubnub.api.JsonElementImpl -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNSetStateResult import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** @@ -23,7 +23,7 @@ class SetStateImpl( private val channels: List, private val channelGroups: List, private val state: Any, -): SetState { +) : SetState { override fun async(callback: Consumer>) { pubnub.setPresenceStateWithChannels( channels = channels, @@ -33,4 +33,4 @@ class SetStateImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt index 45fe0484b..a567c636b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt @@ -2,25 +2,24 @@ package com.pubnub.api.endpoints.presence import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.whereNowWithUuid -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNWhereNowResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** * @see [PubNub.whereNow] */ -actual interface WhereNow : PNFuture { -} +actual interface WhereNow : PNFuture @OptIn(ExperimentalForeignApi::class) class WhereNowImpl( private val pubnub: PubNubObjC, private val uuid: String -): WhereNow { +) : WhereNow { override fun async(callback: Consumer>) { pubnub.whereNowWithUuid( uuid = uuid, @@ -28,4 +27,4 @@ class WhereNowImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt index 1bf6d81a4..08fe2ebf3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints.pubsub import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.publishWithChannel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSNumber @@ -24,16 +24,24 @@ class PublishImpl( private val meta: Any?, private val shouldStore: Boolean?, private val ttl: Int? -): Publish { +) : Publish { override fun async(callback: Consumer>) { pubnub.publishWithChannel( channel = channel, message = message, meta = meta, - shouldStore = if (shouldStore != null) NSNumber(bool = shouldStore) else null, - ttl = if (ttl != null) NSNumber(int = ttl) else null, + shouldStore = if (shouldStore != null) { + NSNumber(bool = shouldStore) + } else { + null + }, + ttl = if (ttl != null) { + NSNumber(int = ttl) + } else { + null + }, onSuccess = callback.onSuccessHandler { PNPublishResult(it.toLong()) }, onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt index f509ab37f..5ee9883ea 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt @@ -2,12 +2,12 @@ package com.pubnub.api.endpoints.pubsub import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.signalWithChannel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import kotlinx.cinterop.ExperimentalForeignApi /** @@ -20,7 +20,7 @@ class SignalImpl( private val pubnub: PubNubObjC, private val channel: String, private val message: Any -): Signal { +) : Signal { override fun async(callback: Consumer>) { pubnub.signalWithChannel( channel = channel, @@ -29,4 +29,4 @@ class SignalImpl( onFailure = callback.onFailureHandler() ) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt index a770abd24..520e31309 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt @@ -2,18 +2,19 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.addChannelsToPushNotificationsWithChannels -import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushAddChannelResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.kmp.toNSData import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSData + /** * @see [PubNub.addPushNotificationsOnChannels] */ @@ -27,7 +28,7 @@ class AddChannelsToPushImpl( private val deviceId: String, private val topic: String?, private val environment: PNPushEnvironment -): AddChannelsToPush { +) : AddChannelsToPush { override fun async(callback: Consumer>) { deviceId.toNSData()?.let { data: NSData -> pubnub.addChannelsToPushNotificationsWithChannels( @@ -41,4 +42,4 @@ class AddChannelsToPushImpl( ) } ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId"))) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt index 075253d6e..effb89c53 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt @@ -2,15 +2,15 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.listPushChannelsWithDeviceId -import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.kmp.toNSData import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSData @@ -27,7 +27,7 @@ class ListPushProvisionsImpl( private val pushType: PNPushType, private val topic: String?, private val environment: PNPushEnvironment -): ListPushProvisions { +) : ListPushProvisions { override fun async(callback: Consumer>) { deviceId.toNSData()?.let { data: NSData -> pubnub.listPushChannelsWithDeviceId( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt index 6f85d7079..89c42fdae 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt @@ -2,15 +2,15 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeAllChannelsFromPushWithPushType -import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessReturnValue import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessReturnValue import com.pubnub.kmp.toNSData import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSData @@ -27,7 +27,7 @@ class RemoveAllPushChannelsForDeviceImpl( private val pushType: PNPushType, private val topic: String?, private val environment: PNPushEnvironment -): RemoveAllPushChannelsForDevice { +) : RemoveAllPushChannelsForDevice { override fun async(callback: Consumer>) { deviceId.toNSData()?.let { data: NSData -> pubnub.removeAllChannelsFromPushWithPushType( @@ -40,4 +40,4 @@ class RemoveAllPushChannelsForDeviceImpl( ) } ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId"))) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt index c5f71f6a4..826a7f20c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.ios.kt @@ -2,15 +2,15 @@ package com.pubnub.api.endpoints.push import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.removeChannelsFromPushWithChannels -import com.pubnub.kmp.PNFuture import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult -import com.pubnub.kmp.onFailureHandler -import com.pubnub.kmp.onSuccessHandler import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import com.pubnub.kmp.PNFuture +import com.pubnub.kmp.onFailureHandler +import com.pubnub.kmp.onSuccessHandler import com.pubnub.kmp.toNSData import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSData @@ -19,6 +19,7 @@ import platform.Foundation.NSData * @see [PubNub.removePushNotificationsFromChannels] */ actual interface RemoveChannelsFromPush : PNFuture + @OptIn(ExperimentalForeignApi::class) class RemoveChannelsFromPushImpl( private val pubnub: PubNubObjC, @@ -27,7 +28,7 @@ class RemoveChannelsFromPushImpl( private val pushType: PNPushType, private val topic: String?, private val environment: PNPushEnvironment, -): RemoveChannelsFromPush { +) : RemoveChannelsFromPush { override fun async(callback: Consumer>) { deviceId.toNSData()?.let { data: NSData -> pubnub.removeChannelsFromPushWithChannels( @@ -41,4 +42,4 @@ class RemoveChannelsFromPushImpl( ) } ?: callback.accept(Result.failure(PubNubException("Cannot create NSData from $deviceId"))) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt index bfb785c7f..349803290 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt @@ -31,4 +31,4 @@ actual fun createPNConfiguration( override val cryptoModule: CryptoModule? get() = TODO("Not yet implemented") } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt index 299402c2a..183734c2d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -25,6 +25,7 @@ actual interface EventListener : BaseEventListener { val onObjects: (PubNub, PNObjectEventResult) -> Unit val onFile: (PubNub, PNFileEventResult) -> Unit } + @OptIn(ExperimentalForeignApi::class) class EventListenerImpl( override val underlying: PubNubEventListenerObjC, @@ -34,4 +35,4 @@ class EventListenerImpl( override val onMessageAction: (PubNub, PNMessageActionResult) -> Unit, override val onObjects: (PubNub, PNObjectEventResult) -> Unit, override val onFile: (PubNub, PNFileEventResult) -> Unit -): EventListener \ No newline at end of file +) : EventListener diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt index 51d971cc3..baf190dba 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt @@ -20,4 +20,4 @@ actual interface StatusListener : Listener { class StatusListenerImpl( override val underlying: PubNubStatusListenerObjC, override val onStatusChange: (PubNub, PNStatus) -> Unit -): StatusListener \ No newline at end of file +) : StatusListener diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt index bdcf897b1..c97695055 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt @@ -11,7 +11,7 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) class ChannelGroupImpl( private val channelGroup: PubNubChannelGroupEntityObjC -): ChannelGroup { +) : ChannelGroup { override val name: String get() = channelGroup.name() @@ -19,4 +19,4 @@ class ChannelGroupImpl( // TODO: Add support for handling SubscriptionOptions return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = channelGroup)) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt index 031cda664..6aa8b15cc 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt @@ -16,11 +16,11 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) class ChannelImpl( private val channel: PubNubChannelEntityObjC -): Channel { +) : Channel { override fun publish( message: Any, meta: Any?, - shouldStore: Boolean?, + shouldStore: Boolean, usePost: Boolean, replicate: Boolean, ttl: Int? @@ -59,4 +59,4 @@ class ChannelImpl( // TODO: Add support for handling SubscriptionOptions return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = channel)) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt index 650e01adc..0ea026c27 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt @@ -1,7 +1,6 @@ package com.pubnub.internal.entities import cocoapods.PubNubSwift.PubNubChannelMetadataEntityObjC -import cocoapods.PubNubSwift.PubNubChannelMetadataObjC import cocoapods.PubNubSwift.PubNubSubscriptionObjC import com.pubnub.api.v2.entities.ChannelMetadata import com.pubnub.api.v2.subscriptions.Subscription @@ -12,7 +11,7 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) class ChannelMetadataImpl( private val channelMetadata: PubNubChannelMetadataEntityObjC -): ChannelMetadata { +) : ChannelMetadata { override val id: String get() = channelMetadata.name() @@ -20,4 +19,4 @@ class ChannelMetadataImpl( // TODO: Add support for handling SubscriptionOptions return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = channelMetadata)) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt index 7851408be..429c39398 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt @@ -11,7 +11,7 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) class UserMetadataImpl( private val userMetadata: PubNubUserMetadataEntityObjC -): UserMetadata { +) : UserMetadata { override val id: String get() = userMetadata.name() @@ -19,4 +19,4 @@ class UserMetadataImpl( // TODO: Add support for handling SubscriptionOptions return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = userMetadata)) } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt index 878065f78..eb2496733 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt @@ -1,7 +1,6 @@ package com.pubnub.internal.subscription import cocoapods.PubNubSwift.PubNubSubscriptionObjC -import com.pubnub.api.PubNubException import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult @@ -19,7 +18,6 @@ import kotlinx.cinterop.ExperimentalForeignApi class SubscriptionImpl( val objCSubscription: PubNubSubscriptionObjC ) : Subscription { - override fun close() { objCSubscription.dispose() } @@ -66,4 +64,4 @@ class SubscriptionImpl( override fun plus(subscription: Subscription): SubscriptionSet { TODO("Not yet implemented") } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt index db0bfa5a1..e050d120e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt @@ -17,7 +17,7 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) class SubscriptionSetImpl( private val objCSubscriptionSet: PubNubSubscriptionSetObjC -): SubscriptionSet { +) : SubscriptionSet { override fun close() { objCSubscriptionSet.dispose() } @@ -83,4 +83,4 @@ class SubscriptionSetImpl( override fun minusAssign(subscription: Subscription) { TODO("Not yet implemented") } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt index 859a277a3..f740adc90 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt @@ -10,7 +10,7 @@ actual abstract class Uploadable data class DataUploadContent( val data: NSData, val contentType: String? -): Uploadable() +) : Uploadable() data class FileUploadContent( val url: NSURL diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt index dbf8335c2..00b27d3fa 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt @@ -25,8 +25,16 @@ internal fun String.toNSData(): NSData? { @OptIn(ExperimentalForeignApi::class) internal fun createPubNubHashedPage(from: PNPage?): PubNubHashedPageObjC { return PubNubHashedPageObjC( - start = if (from is PNPage.PNNext) { from.pageHash } else { null }, - end = if (from is PNPage.PNPrev) { from.pageHash } else { null }, + start = if (from is PNPage.PNNext) { + from.pageHash + } else { + null + }, + end = if (from is PNPage.PNPrev) { + from.pageHash + } else { + null + }, totalCount = null ) } @@ -62,7 +70,7 @@ internal fun createPNChannelMetadata(from: PubNubChannelMetadataObjC): PNChannel } @OptIn(ExperimentalForeignApi::class) -internal fun createObjectSortProperties(from: Collection>) : List { +internal fun createObjectSortProperties(from: Collection>): List { return from.map { PubNubObjectSortPropertyObjC( key = it.key.fieldName, @@ -108,5 +116,5 @@ internal inline fun List<*>?.filterAndMap(mapper: (T) -> U): Coll @Suppress("UNCHECKED_CAST") inline fun Map<*, *>.safeCast(): Map { - return this as? Map ?: error("Cannot make the cast") + return this as? Map ?: error("Cannot make the cast") } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 394bc4fd8..af747edf5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -73,7 +73,11 @@ actual fun createEventListener( onPresence = { presenceEvents -> createPresenceEventResults(presenceEvents).forEach { onPresence(pubnub, it) } }, onSignal = { onSignal(pubnub, createSignalResult(it)) }, onMessageAction = { onMessageAction(pubnub, createMessageActionResult(it)) }, - onAppContext = { if (createObjectEvent(it) != null) { createObjectEvent(it) } else {} }, + onAppContext = { + if (createObjectEvent(it) != null) { + createObjectEvent(it) + } else {} + }, onFile = { onFile(pubnub, createFileEventResult(it)) } ), onMessage = onMessage, @@ -176,11 +180,12 @@ private fun createObjectEvent(from: PubNubAppContextEventObjC?): PNObjectEventRe PNObjectEventResult( result = BasePubSubResult( channel = from!!.channel(), - subscription = from.subscription(), + subscription = from.subscription(), timetoken = from.timetoken()?.longValue, userMetadata = JsonElementImpl(from.userMetadata()), publisher = from.publisher(), - ), extractedMessage = it + ), + extractedMessage = it ) } } @@ -297,7 +302,8 @@ actual fun createStatusListener( else -> null }?.let { category -> onStatus( - pubnub, PNStatus( + pubnub, + PNStatus( category = category, exception = status?.error()?.let { error -> PubNubException(errorMessage = error.localizedDescription) }, currentTimetoken = status?.currentTimetoken()?.longValue(), @@ -313,4 +319,4 @@ actual fun createStatusListener( actual fun createCustomObject(map: Map): CustomObject { return CustomObject(map) -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt index 2ffed932d..0741f3db3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt @@ -5,7 +5,7 @@ import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result import platform.Foundation.NSError -fun Consumer>.onSuccessHandler(mapper: (T) -> U) : (T) -> Unit { +fun Consumer>.onSuccessHandler(mapper: (T) -> U): (T) -> Unit { return { input: T -> accept( try { @@ -17,7 +17,7 @@ fun Consumer>.onSuccessHandler(mapper: (T) -> U) : (T) -> Unit { } } -fun Consumer>.onSuccessHandler3(mapper: (T, X, Y) -> U) : (T, X, Y) -> Unit { +fun Consumer>.onSuccessHandler3(mapper: (T, X, Y) -> U): (T, X, Y) -> Unit { return { input: T, secondInput: X, thirdInput: Y -> accept( try { @@ -29,7 +29,7 @@ fun Consumer>.onSuccessHandler3(mapper: (T, X, Y) -> U) : } } -fun Consumer>.onSuccessHandler2(mapper: (T, X) -> Y) : (T, X) -> Unit { +fun Consumer>.onSuccessHandler2(mapper: (T, X) -> Y): (T, X) -> Unit { return { input: T, secondInput: X -> accept( try { @@ -41,15 +41,17 @@ fun Consumer>.onSuccessHandler2(mapper: (T, X) -> Y) : (T, X } } -fun Consumer>.onSuccessReturnValue(value: T) : () -> Unit { +fun Consumer>.onSuccessReturnValue(value: T): () -> Unit { return { accept(Result.success(value)) } } -fun Consumer>.onFailureHandler(mapper: (NSError?) -> Throwable = { error: NSError? -> - PubNubException(errorMessage = error?.localizedDescription) -} ): (NSError?) -> Unit { +fun Consumer>.onFailureHandler( + mapper: (NSError?) -> Throwable = { error: NSError? -> + PubNubException(errorMessage = error?.localizedDescription) + } +): (NSError?) -> Unit { return { error: NSError? -> accept(Result.failure(mapper(error))) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/com/pubnub/kmp/platform.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/com/pubnub/kmp/platform.ios.kt index 1a4c3d9b1..1dc123af3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/com/pubnub/kmp/platform.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/com/pubnub/kmp/platform.ios.kt @@ -1,3 +1,3 @@ package com.pubnub.kmp -internal actual val PLATFORM: String = "iOS" \ No newline at end of file +internal actual val PLATFORM: String = "iOS" diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/testlauncher.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/testlauncher.kt index 2812f05a2..b32fe1667 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/testlauncher.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/testlauncher.kt @@ -1,10 +1,12 @@ package testlauncher -import platform.CoreFoundation.* +import platform.CoreFoundation.CFRunLoopRun import kotlin.experimental.ExperimentalNativeApi -import kotlin.native.concurrent.* -import kotlin.native.internal.test.* -import kotlin.system.* +import kotlin.native.concurrent.TransferMode +import kotlin.native.concurrent.Worker +import kotlin.native.concurrent.freeze +import kotlin.native.internal.test.testLauncherEntryPoint +import kotlin.system.exitProcess @OptIn(ExperimentalNativeApi::class) fun mainBackground(args: Array) { @@ -15,4 +17,4 @@ fun mainBackground(args: Array) { } CFRunLoopRun() error("CFRunLoopRun should never return") -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt index 68afe5850..b72ef0e62 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/Pubnub.d.kt @@ -1,5 +1,8 @@ @file:Suppress( - "INTERFACE_WITH_SUPERCLASS", "OVERRIDING_FINAL_MEMBER", "RETURN_TYPE_MISMATCH_ON_OVERRIDE", "CONFLICTING_OVERLOADS" + "INTERFACE_WITH_SUPERCLASS", + "OVERRIDING_FINAL_MEMBER", + "RETURN_TYPE_MISMATCH_ON_OVERRIDE", + "CONFLICTING_OVERLOADS" ) import PubNub.GetAllMetadataParameters @@ -16,7 +19,6 @@ import PubNub.SetChannelMembersParameters import PubNub.SetChannelMetadataParameters import PubNub.SetMembershipsParameters import PubNub.SetUUIDMetadataParameters -import com.pubnub.api.JsonElement import com.pubnub.kmp.JsMap import com.pubnub.kmp.Optional import org.khronos.webgl.ArrayBuffer @@ -63,45 +65,82 @@ external interface PagedObjectsResponse : ObjectsResponse) + fun setUUIDMetadata(params: SetUUIDMetadataParameters): Promise + fun removeUUIDMetadata(callback: Callback) + fun removeUUIDMetadata(params: RemoveUUIDMetadataParameters): Promise + fun removeUUIDMetadata(): Promise + fun removeUUIDMetadata(params: RemoveUUIDMetadataParameters, callback: Callback) + fun getAllUUIDMetadata(callback: Callback) + fun getAllUUIDMetadata(params: GetAllMetadataParameters): Promise + fun getAllUUIDMetadata(): Promise + fun getAllUUIDMetadata(params: GetAllMetadataParameters, callback: Callback) + fun getUUIDMetadata(callback: Callback) + fun getUUIDMetadata(params: GetUUIDMetadataParameters): Promise + fun getUUIDMetadata(): Promise + fun getUUIDMetadata(params: GetUUIDMetadataParameters, callback: Callback) + fun setChannelMetadata(params: SetChannelMetadataParameters, callback: Callback) + fun setChannelMetadata(params: SetChannelMetadataParameters): Promise + fun removeChannelMetadata( - params: RemoveChannelMetadataParameters, callback: Callback + params: RemoveChannelMetadataParameters, + callback: Callback ) fun removeChannelMetadata(params: RemoveChannelMetadataParameters): Promise + fun getAllChannelMetadata(callback: Callback) + fun getAllChannelMetadata(params: GetAllMetadataParameters): Promise + fun getAllChannelMetadata(): Promise + fun getAllChannelMetadata(params: GetAllMetadataParameters, callback: Callback) + fun getChannelMetadata(params: GetChannelMetadataParameters, callback: Callback) + fun getChannelMetadata(params: GetChannelMetadataParameters): Promise + fun getMemberships(callback: Callback) + fun getMemberships(params: GetMembershipsParametersv2): Promise + fun getMemberships(): Promise + fun getMemberships(params: GetMembershipsParametersv2, callback: Callback) + fun setMemberships(params: SetMembershipsParameters, callback: Callback) + fun setMemberships(params: SetMembershipsParameters): Promise + fun removeMemberships(params: RemoveMembershipsParameters, callback: Callback) + fun removeMemberships(params: RemoveMembershipsParameters): Promise + fun getChannelMembers(params: GetChannelMembersParameters, callback: Callback) + fun getChannelMembers(params: GetChannelMembersParameters): Promise + fun setChannelMembers(params: SetChannelMembersParameters, callback: Callback) + fun setChannelMembers(params: SetChannelMembersParameters): Promise + fun removeChannelMembers(params: RemoveChannelMembersParameters, callback: Callback) + fun removeChannelMembers(params: RemoveChannelMembersParameters): Promise } @@ -118,88 +157,165 @@ external interface RemoveMessageActionResult { open external class PubNub(config: Any /* UUID | UserId */) { open var channelGroups: ChannelGroups open var push: Push + open fun setUUID(uuid: String) + open fun getUUID(): String + open fun setAuthKey(authKey: String) + open fun setFilterExpression(filterExpression: String) + open fun getFilterExpression(): String + open fun publish(params: PublishParameters, callback: Callback) + open fun publish(params: PublishParameters): Promise + open fun fire(params: FireParameters, callback: Callback) + open fun fire(params: FireParameters): Promise + open fun signal(params: SignalParameters, callback: Callback) + open fun signal(params: SignalParameters): Promise + open fun history(params: HistoryParameters, callback: Callback) + open fun history(params: HistoryParameters): Promise + open fun fetchMessages(params: FetchMessagesParameters, callback: Callback) + open fun fetchMessages(params: FetchMessagesParameters): Promise + open fun deleteMessages(params: DeleteMessagesParameters, callback: StatusCallback) + open fun deleteMessages(params: DeleteMessagesParameters): Promise + open fun messageCounts(params: MessageCountsParameters, callback: Callback) + open fun messageCounts(params: MessageCountsParameters): Promise + open fun subscribe(params: SubscribeParameters) + open fun unsubscribe(params: UnsubscribeParameters) + open fun unsubscribeAll() + open fun stop() + open fun reconnect() + open fun addListener(params: ListenerParameters) + open fun addListener(params: StatusListenerParameters) + open fun removeListener(params: Any) + open fun getSubscribedChannels(): Array + open fun getSubscribedChannelGroups(): Array + open fun hereNow(params: HereNowParameters, callback: Callback) + open fun hereNow(params: HereNowParameters): Promise + open fun whereNow(params: WhereNowParameters, callback: Callback) + open fun whereNow(params: WhereNowParameters): Promise + open fun getState(params: GetStateParameters, callback: Callback) + open fun getState(params: GetStateParameters): Promise + open fun setState(params: SetStateParameters, callback: Callback) + open fun setState(params: SetStateParameters): Promise + open fun grant(params: GrantParameters, callback: StatusCallback) + open fun grant(params: GrantParameters): Promise + open fun grantToken(params: GrantTokenParameters, callback: Callback) + open fun grantToken(params: GrantTokenParameters): Promise + open fun setToken(params: String?) + open fun getToken(): String? + open fun parseToken(params: String): ParsedGrantToken + open fun revokeToken(params: String, callback: Callback) + open fun revokeToken(params: String): Promise + open fun listFiles(params: ListFilesParameters, callback: Callback) + open fun listFiles(params: ListFilesParameters): Promise + open fun sendFile(params: SendFileParameters, callback: Callback) + open fun sendFile(params: SendFileParameters): Promise + open fun downloadFile(params: DownloadFileParameters, callback: Callback) + open fun downloadFile(params: DownloadFileParameters): Promise + open fun getFileUrl(params: FileInputParameters): String + open fun deleteFile(params: FileInputParameters, callback: StatusCallback) + open fun deleteFile(params: FileInputParameters): Promise + open fun publishFile(params: PublishFileParameters, callback: Callback) + open fun publishFile(params: PublishFileParameters): Promise + open var objects: ObjectsFunctions + open fun addMessageAction(params: AddMessageActionParameters, callback: Callback) + open fun addMessageAction(params: AddMessageActionParameters): Promise + open fun removeMessageAction(params: RemoveMessageActionParameters, callback: Callback) + open fun removeMessageAction(params: RemoveMessageActionParameters): Promise + open fun getMessageActions(params: GetMessageActionsParameters, callback: Callback) + open fun getMessageActions(params: GetMessageActionsParameters): Promise + open fun encrypt( - data: String, customCipherKey: String = definedExternally, options: CryptoParameters = definedExternally + data: String, + customCipherKey: String = definedExternally, + options: CryptoParameters = definedExternally ): String open fun decrypt( - data: String?, customCipherKey: String = definedExternally, options: CryptoParameters = definedExternally + data: String?, + customCipherKey: String = definedExternally, + options: CryptoParameters = definedExternally ): Any open fun decrypt(data: String?): Any + open fun decrypt(data: String?, customCipherKey: String = definedExternally): Any + open fun decrypt( - data: Any?, customCipherKey: String = definedExternally, options: CryptoParameters = definedExternally + data: Any?, + customCipherKey: String = definedExternally, + options: CryptoParameters = definedExternally ): Any open fun decrypt(data: Any?): Any + open fun decrypt(data: Any?, customCipherKey: String = definedExternally): Any + open fun time(): Promise + open fun time(callback: Callback) + interface KeepAliveSettings { var keepAliveMsecs: Number? var freeSocketKeepAliveTimeout: Number? @@ -216,7 +332,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { var authKey: String? var logVerbosity: Boolean? var ssl: Boolean? - var origin: dynamic /* String? | Array? */ + var origin: dynamic // String? | Array? var presenceTimeout: Number? var heartbeatInterval: Number? var restore: Boolean? @@ -231,7 +347,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { var useRandomIVs: Boolean? var dedupeOnSubscribe: Boolean? var cryptoModule: CryptoModule? - var retryConfiguration: dynamic /* LinearRetryPolicyConfiguration? | ExponentialRetryPolicyConfiguration? */ + var retryConfiguration: dynamic // LinearRetryPolicyConfiguration? | ExponentialRetryPolicyConfiguration? var enableEventEngine: Boolean? var maintainPresenceState: Boolean? } @@ -246,7 +362,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var actualChannel: String var subscribedChannel: String var userMetadata: Any? - } interface StatusEvent { @@ -261,7 +376,7 @@ open external class PubNub(config: Any /* UUID | UserId */) { } interface PresenceEvent { - var action: String /* "join" | "leave" | "state-change" | "timeout" */ + var action: String // "join" | "leave" | "state-change" | "timeout" var channel: String var occupancy: Number var state: Any? @@ -309,8 +424,8 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface `T$6` { var source: String var version: String - var event: String /* "set" | "delete" */ - var type: String /* "uuid" | "channel" | "membership" */ + var event: String // "set" | "delete" + var type: String // "uuid" | "channel" | "membership" var data: Any? } @@ -323,37 +438,41 @@ open external class PubNub(config: Any /* UUID | UserId */) { } interface `T$7` { - var event: String /* "set" */ - var type: String /* "uuid" */ + var event: String // "set" + var type: String // "uuid" var data: UUIDMetadataObject } interface SetUUIDMetadataEvent : BaseObjectsEvent + interface HasId { var id: String } interface `T$9` { - var event: String /* "delete" */ - var type: String /* "uuid" */ + var event: String // "delete" + var type: String // "uuid" var data: HasId } interface RemoveUUIDMetadataEvent : BaseObjectsEvent + interface `T$10` { - var event: String /* "set" */ - var type: String /* "channel" */ + var event: String // "set" + var type: String // "channel" var data: ChannelMetadataObject } interface SetChannelMetadataEvent : BaseObjectsEvent + interface `T$11` { - var event: String /* "delete" */ - var type: String /* "channel" */ + var event: String // "delete" + var type: String // "channel" var data: HasId } interface RemoveChannelMetadataEvent : BaseObjectsEvent + interface SetMembershipObject { var channel: HasId var uuid: HasId @@ -363,24 +482,26 @@ open external class PubNub(config: Any /* UUID | UserId */) { } interface `T$13` { - var event: String /* "set" */ - var type: String /* "membership" */ + var event: String // "set" + var type: String // "membership" var data: SetMembershipObject } interface SetMembershipEvent : BaseObjectsEvent + interface DeleteMembershipObject { var channel: HasId var uuid: HasId } interface `T$15` { - var event: String /* "delete" */ - var type: String /* "membership" */ + var event: String // "delete" + var type: String // "membership" var data: DeleteMembershipObject } interface RemoveMembershipEvent : BaseObjectsEvent + interface PublishParameters { var message: Any var channel: String @@ -412,7 +533,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var start: String? var end: String? var includeMeta: Boolean? - } interface HistoryMessage { @@ -443,10 +563,10 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface Action { var uuid: String var actionTimetoken: String - } interface ActionContentToAction : JsMap> + interface ActionTypeToActions : JsMap interface FetchMessageItem { @@ -490,12 +610,19 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface Push { fun addChannels(params: PushChannelParameters, callback: StatusCallback) + fun addChannels(params: PushChannelParameters): Promise + fun listChannels(params: PushDeviceParameters, callback: Callback) + fun listChannels(params: PushDeviceParameters): Promise + fun removeChannels(params: PushChannelParameters, callback: StatusCallback) + fun removeChannels(params: PushChannelParameters): Promise + fun deleteDevice(params: PushDeviceParameters, callback: StatusCallback) + fun deleteDevice(params: PushDeviceParameters): Promise } @@ -506,7 +633,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var environment: String? var topic: String? - } interface PushDeviceParameters { @@ -515,7 +641,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var environment: String? var topic: String? - } interface PushListChannelsResponse { @@ -529,7 +654,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var operation: String var statusCode: Number var errorData: Error? - } interface FireParameters { @@ -538,7 +662,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var sendByPost: Boolean? var meta: Any? - } interface SubscribeParameters { @@ -549,26 +672,33 @@ open external class PubNub(config: Any /* UUID | UserId */) { var withPresence: Boolean? var timetoken: String? - } interface UnsubscribeParameters { var channels: Array? var channelGroups: Array? - } interface ChannelGroups { fun addChannels(params: AddChannelParameters, callback: StatusCallback) + fun addChannels(params: AddChannelParameters): Promise + fun removeChannels(params: RemoveChannelParameters, callback: StatusCallback) + fun removeChannels(params: RemoveChannelParameters): Promise + fun listChannels(params: ListChannelsParameters, callback: Callback) + fun listChannels(params: ListChannelsParameters): Promise + fun listGroups(callback: Callback) + fun listGroups(): Promise + fun deleteGroup(params: DeleteGroupParameters, callback: StatusCallback) + fun deleteGroup(params: DeleteGroupParameters): Promise } @@ -619,13 +749,11 @@ open external class PubNub(config: Any /* UUID | UserId */) { var includeUUIDs: Boolean? var includeState: Boolean? - } interface HereNowOccupantData { var uuid: String var state: Any? - } interface HereNowChannelData { @@ -644,7 +772,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface WhereNowParameters { var uuid: String? - } interface WhereNowResponse { @@ -657,7 +784,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var channelGroups: Array? var state: Any? - } interface SetStateResponse { @@ -670,7 +796,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var channels: Array? var channelGroups: Array? - } interface GetStateResponse { @@ -701,7 +826,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var join: Boolean? var update: Boolean? - } interface PatternsOrResources { @@ -710,7 +834,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var groups: JsMap? var uuids: JsMap? - } interface GrantTokenParameters { @@ -722,7 +845,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var patterns: PatternsOrResources? var meta: Json? - } interface ParsedGrantToken : GrantTokenParameters { @@ -745,7 +867,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var join: Boolean? var update: Boolean? - } interface RevokeTokenResponse { @@ -785,7 +906,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var end: String? var limit: Number? - } interface GetMessageActionsResponse { @@ -793,7 +913,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var start: String? var end: String? - } interface ListFilesParameters { @@ -801,12 +920,11 @@ open external class PubNub(config: Any /* UUID | UserId */) { var limit: Number? var next: String? - } interface SendFileParameters { var channel: String - var file: dynamic /* StreamFileInput | BufferFileInput | UriFileInput */ + var file: dynamic // StreamFileInput | BufferFileInput | UriFileInput var message: Any? @@ -817,28 +935,24 @@ open external class PubNub(config: Any /* UUID | UserId */) { var ttl: Number? var meta: Any? - } interface StreamFileInput { var stream: Any var name: String var mimeType: String? - } interface BufferFileInput { var data: Any var name: String var mimeType: String? - } interface UriFileInput { var uri: String var name: String var mimeType: String? - } interface DownloadFileParameters { @@ -846,7 +960,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var id: String var name: String var cipherKey: String? - } interface FileInputParameters { @@ -866,7 +979,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var ttl: Number? var meta: Any? - } interface UploadedFile { @@ -913,7 +1025,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var eTag: String var updated: String var custom: CustomObject? - } interface v2ObjectData { @@ -921,12 +1032,10 @@ open external class PubNub(config: Any /* UUID | UserId */) { var eTag: String var updated: String var custom: CustomObject? - } interface ObjectParam { var custom: CustomObject? - } interface UUIDMetadataFieldsNullable { @@ -939,10 +1048,11 @@ open external class PubNub(config: Any /* UUID | UserId */) { } interface UUIDMetadata : ObjectParam, UUIDMetadataFieldsNullable, Partial + interface UUIDMetadataObject : v2ObjectData, UUIDMetadataFieldsNullable + interface UuidIncludeCustom { var customFields: Boolean? - } interface SetUUIDMetadataParameters { @@ -950,26 +1060,22 @@ open external class PubNub(config: Any /* UUID | UserId */) { var data: UUIDMetadata var include: UuidIncludeCustom? - } interface RemoveUUIDMetadataParameters { var uuid: String? - } interface MetadataIncludeOptions { var totalCount: Boolean? var customFields: Boolean? - } interface MetadataPage { var next: String? var prev: String? - } interface GetAllMetadataParameters { @@ -982,14 +1088,12 @@ open external class PubNub(config: Any /* UUID | UserId */) { var limit: Number? var page: MetadataPage? - } interface GetUUIDMetadataParameters { var uuid: String? var include: UuidIncludeCustom? - } interface ChannelMetadataFieldsPartial { @@ -1007,12 +1111,13 @@ open external class PubNub(config: Any /* UUID | UserId */) { } interface ChannelMetadata : ObjectParam, ChannelMetadataFieldsNullable + interface ChannelMetadataObject : v2ObjectData, ChannelMetadataFieldsNullable + interface SetChannelMetadataParameters { var channel: String var data: ChannelMetadata var include: UuidIncludeCustom? - } interface RemoveChannelMetadataParameters { @@ -1026,25 +1131,21 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface GetChannelMetadataParameters { var channel: String var include: IncludeCustomFields? - } interface HasStatus { var status: String? - } interface UUIDMembershipObject : v2ObjectDataOmitId { - var uuid: UUIDMetadataObject /* UUIDMetadataObject & HasStatus | HasId */ + var uuid: UUIDMetadataObject // UUIDMetadataObject & HasStatus | HasId var status: String? - } interface ChannelMembershipObject : v2ObjectDataOmitId { var channel: ChannelMetadataObject? var status: String? - } interface IncludeOptions { @@ -1061,7 +1162,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var UUIDStatusField: Boolean? var UUIDTypeField: Boolean? - } interface UUIDMembersParameters { @@ -1074,7 +1174,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var limit: Number? var page: MetadataPage? - } interface MembershipIncludeOptions { @@ -1091,7 +1190,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var channelStatusField: Boolean? var channelTypeField: Boolean? - } interface ChannelMembersParameters { @@ -1104,7 +1202,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var limit: Number? var page: MetadataPage? - } interface GetChannelMembersParameters : UUIDMembersParameters { @@ -1113,21 +1210,18 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface GetMembershipsParametersv2 : ChannelMembersParameters { var uuid: String? - } interface SetCustom { var id: String var custom: CustomObject? var status: String? - } interface SetMembershipsParameters : ChannelMembersParameters { var uuid: String? var channels: Array? - } interface RemoveMembershipsParameters : ChannelMembersParameters { @@ -1154,7 +1248,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var keyLength: Number? var mode: String? - } interface FetchTimeResponse { @@ -1171,10 +1264,9 @@ open external class PubNub(config: Any /* UUID | UserId */) { interface APNS2Target { var topic: String - var environment: String? /* "development" | "production" */ + var environment: String? // "development" | "production" var excludedDevices: Array? - } interface BaseNotificationPayload { @@ -1188,7 +1280,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var title: String? var body: String? - } interface APNSNotificationPayload : BaseNotificationPayload { @@ -1206,7 +1297,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var count: Number? var type: String? - } interface FCMNotificationPayload : BaseNotificationPayload { @@ -1214,7 +1304,6 @@ open external class PubNub(config: Any /* UUID | UserId */) { var icon: String? var tag: String? - } interface `T$37` { @@ -1239,50 +1328,63 @@ open external class PubNub(config: Any /* UUID | UserId */) { var apns: APNSNotificationPayload var mpns: MPNSNotificationPayload var fcm: FCMNotificationPayload + fun buildPayload(platforms: Array): Any? } open class CryptoModule(configuration: CryptoModuleConfiguration) { - open var defaultCryptor: dynamic /* Cryptor | LegacyCryptor */ + open var defaultCryptor: dynamic // Cryptor | LegacyCryptor open var cryptors: Array */> + open fun encrypt(data: ArrayBuffer): ArrayBuffer + open fun encrypt(data: String): ArrayBuffer - open fun decrypt(data: ArrayBuffer): dynamic /* ArrayBuffer | String */ - open fun decrypt(data: String): dynamic /* ArrayBuffer | String */ + + open fun decrypt(data: ArrayBuffer): dynamic // ArrayBuffer | String + + open fun decrypt(data: String): dynamic // ArrayBuffer | String + open fun encryptFile(file: PubNubFileType, fd: PubNubFileType): Promise + open fun decryptFile(file: PubNubFileType, fd: PubNubFileType): Promise companion object { fun legacyCryptoModule(configuration: CryptorConfiguration): CryptoModule + fun aesCbcCryptoModule(configuration: CryptorConfiguration): CryptoModule + fun withDefaultCryptor(defaultCryptor: Cryptor): CryptoModule + fun withDefaultCryptor(defaultCryptor: LegacyCryptor): CryptoModule } } interface PubNubFileType { - var data: dynamic /* File | Blob */ + var data: dynamic // File | Blob var name: String var mimeType: String + fun create(config: Any): PubNubFileType + fun toArrayBuffer(): ArrayBuffer + fun toBlob(): Blob + override fun toString(): String + fun toFile(): File } interface CryptorConfiguration { var cipherKey: String var useRandomIVs: Boolean? - } interface CryptoModuleConfiguration { - var default: dynamic /* Cryptor | LegacyCryptor */ + var default: dynamic // Cryptor | LegacyCryptor var cryptors: Array */>? - } interface EncryptedDataType { @@ -1305,9 +1407,12 @@ open external class PubNub(config: Any /* UUID | UserId */) { companion object { var CATEGORIES: Any var OPERATIONS: Any + fun generateUUID(): String + var LinearRetryPolicy: Any var ExponentialRetryPolicy: Any + fun notificationPayload(title: String, body: String): NotificationsPayload } } @@ -1389,4 +1494,3 @@ external interface ExponentialRetryPolicyConfiguration { var maximumDelay: Number var maximumRetry: Number } - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt deleted file mode 100644 index f5c56ca23..000000000 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/Endpoint.js.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.pubnub.api - -import com.pubnub.api.v2.callbacks.Consumer -import com.pubnub.api.v2.callbacks.Result - -//actual interface PNFuture { -// actual fun async(callback: Consumer>) -//} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt index 62d143bbe..d8e9d73b0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/EndpointImpl.kt @@ -5,9 +5,8 @@ import com.pubnub.api.v2.callbacks.Result import com.pubnub.kmp.PNFuture import kotlin.js.Promise -open class EndpointImpl(private val promiseFactory: () -> Promise, private val responseMapping: (T) -> U): +open class EndpointImpl(private val promiseFactory: () -> Promise, private val responseMapping: (T) -> U) : PNFuture { - override fun async(callback: Consumer>) { try { promiseFactory().then( @@ -28,4 +27,4 @@ open class EndpointImpl(private val promiseFactory: () -> Promise, priva callback.accept(Result.failure(e)) } } -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 29e112a33..a1592ad50 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -121,7 +121,6 @@ import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.internal.v2.entities.ChannelImpl -import com.pubnub.internal.v2.subscriptions.SubscriptionImpl import com.pubnub.internal.v2.subscriptions.SubscriptionSetImpl import com.pubnub.kmp.CustomObject import com.pubnub.kmp.Optional @@ -134,15 +133,18 @@ import kotlin.js.json import PubNub as PubNubJs class PubNubImpl(override val configuration: PNConfiguration) : PubNub { - private val jsPubNub: PubNubJs = PubNubJs(configuration.toJs()) override fun addListener(listener: EventListener) { - jsPubNub.addListener(listener.asDynamic().unsafeCast()) // todo figure out a better way (similar to DelegatingEventListener in JVM) + jsPubNub.addListener( + listener.asDynamic().unsafeCast() + ) // todo figure out a better way (similar to DelegatingEventListener in JVM) } override fun addListener(listener: StatusListener) { - jsPubNub.addListener(listener.asDynamic().unsafeCast()) // todo figure out a better way (similar to DelegatingEventListener in JVM) + jsPubNub.addListener( + listener.asDynamic().unsafeCast() + ) // todo figure out a better way (similar to DelegatingEventListener in JVM) } override fun removeListener(listener: Listener) { @@ -157,35 +159,44 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { channel: String, message: Any, meta: Any?, - shouldStore: Boolean?, + shouldStore: Boolean, usePost: Boolean, replicate: Boolean, ttl: Int? ): Publish { - return PublishImpl(jsPubNub, createJsObject { - this.message = message.adjustCollectionTypes() - this.channel = channel - this.storeInHistory = shouldStore - this.meta = meta?.adjustCollectionTypes() - this.sendByPost = usePost - this.ttl = ttl - }) + return PublishImpl( + jsPubNub, + createJsObject { + this.message = message.adjustCollectionTypes() + this.channel = channel + this.storeInHistory = shouldStore + this.meta = meta?.adjustCollectionTypes() + this.sendByPost = usePost + this.ttl = ttl + } + ) } override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { - return FireImpl(jsPubNub, createJsObject { - this.message = message.adjustCollectionTypes() - this.channel = channel - this.meta = meta?.adjustCollectionTypes() - this.sendByPost = usePost - }) + return FireImpl( + jsPubNub, + createJsObject { + this.message = message.adjustCollectionTypes() + this.channel = channel + this.meta = meta?.adjustCollectionTypes() + this.sendByPost = usePost + } + ) } override fun signal(channel: String, message: Any): Signal { - return SignalImpl(jsPubNub, createJsObject { - this.message = message.adjustCollectionTypes() - this.channel = channel - }) + return SignalImpl( + jsPubNub, + createJsObject { + this.message = message.adjustCollectionTypes() + this.channel = channel + } + ) } override fun getSubscribedChannels(): List = jsPubNub.getSubscribedChannels().toList() @@ -199,13 +210,16 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { topic: String?, environment: PNPushEnvironment ): AddChannelsToPush { - return AddChannelsToPushImpl(jsPubNub, createJsObject { - this.pushGateway = pushType.toParamString() - this.channels = channels.toTypedArray() - this.device = deviceId - this.topic = topic - this.environment = environment.toParamString() - }) + return AddChannelsToPushImpl( + jsPubNub, + createJsObject { + this.pushGateway = pushType.toParamString() + this.channels = channels.toTypedArray() + this.device = deviceId + this.topic = topic + this.environment = environment.toParamString() + } + ) } override fun auditPushChannelProvisions( @@ -214,12 +228,15 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { topic: String?, environment: PNPushEnvironment ): ListPushProvisions { - return ListPushProvisionsImpl(jsPubNub, createJsObject { - this.pushGateway = pushType.toParamString() - this.device = deviceId - this.topic = topic - this.environment = environment.toParamString() - }) + return ListPushProvisionsImpl( + jsPubNub, + createJsObject { + this.pushGateway = pushType.toParamString() + this.device = deviceId + this.topic = topic + this.environment = environment.toParamString() + } + ) } override fun removePushNotificationsFromChannels( @@ -229,13 +246,16 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { topic: String?, environment: PNPushEnvironment ): RemoveChannelsFromPush { - return RemoveChannelsFromPushImpl(jsPubNub, createJsObject { - this.pushGateway = pushType.toParamString() - this.channels = channels.toTypedArray() - this.device = deviceId - this.topic = topic - this.environment = environment.toParamString() - }) + return RemoveChannelsFromPushImpl( + jsPubNub, + createJsObject { + this.pushGateway = pushType.toParamString() + this.channels = channels.toTypedArray() + this.device = deviceId + this.topic = topic + this.environment = environment.toParamString() + } + ) } override fun removeAllPushNotificationsFromDeviceWithPushToken( @@ -244,12 +264,15 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { topic: String?, environment: PNPushEnvironment ): RemoveAllPushChannelsForDevice { - return RemoveAllPushChannelsForDeviceImpl(jsPubNub, createJsObject { - this.pushGateway = pushType.toParamString() - this.device = deviceId - this.topic = topic - this.environment = environment.toParamString() - }) + return RemoveAllPushChannelsForDeviceImpl( + jsPubNub, + createJsObject { + this.pushGateway = pushType.toParamString() + this.device = deviceId + this.topic = topic + this.environment = environment.toParamString() + } + ) } override fun fetchMessages( @@ -260,33 +283,42 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeMessageActions: Boolean, includeMessageType: Boolean ): FetchMessages { - return FetchMessagesImpl(jsPubNub, createJsObject { - this.channels = channels.toTypedArray() - this.start = page.start?.toString() - this.end = page.end?.toString() - this.count = page.limit - this.includeUUID = includeUUID - this.includeMeta = includeMeta - this.withMessageActions = includeMessageActions - this.includeMessageActions = includeMessageActions - this.includeMessageType = includeMessageType - this.stringifiedTimeToken = true - }) + return FetchMessagesImpl( + jsPubNub, + createJsObject { + this.channels = channels.toTypedArray() + this.start = page.start?.toString() + this.end = page.end?.toString() + this.count = page.limit + this.includeUUID = includeUUID + this.includeMeta = includeMeta + this.withMessageActions = includeMessageActions + this.includeMessageActions = includeMessageActions + this.includeMessageType = includeMessageType + this.stringifiedTimeToken = true + } + ) } override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { - return DeleteMessagesImpl(jsPubNub, createJsObject { - this.channel = channels.first()// channels.toTypedArray() todo JS doesn't accept multiple channels here! - this.start = start?.toString() - this.end = end?.toString() - }) + return DeleteMessagesImpl( + jsPubNub, + createJsObject { + this.channel = channels.first() // channels.toTypedArray() todo JS doesn't accept multiple channels here! + this.start = start?.toString() + this.end = end?.toString() + } + ) } override fun messageCounts(channels: List, channelsTimetoken: List): MessageCounts { - return MessageCountsImpl(jsPubNub, createJsObject { - this.channels = channels.toTypedArray() - this.channelTimetokens = channelsTimetoken.map { it.toString() }.toTypedArray() - }) + return MessageCountsImpl( + jsPubNub, + createJsObject { + this.channels = channels.toTypedArray() + this.channelTimetokens = channelsTimetoken.map { it.toString() }.toTypedArray() + } + ) } override fun hereNow( @@ -295,18 +327,24 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeState: Boolean, includeUUIDs: Boolean ): HereNow { - return HereNowImpl(jsPubNub, createJsObject { - this.channels = channels.toTypedArray() - this.channelGroups = channelGroups.toTypedArray() - this.includeState = includeState - this.includeUUIDs = includeUUIDs - }) + return HereNowImpl( + jsPubNub, + createJsObject { + this.channels = channels.toTypedArray() + this.channelGroups = channelGroups.toTypedArray() + this.includeState = includeState + this.includeUUIDs = includeUUIDs + } + ) } override fun whereNow(uuid: String): WhereNow { - return WhereNowImpl(jsPubNub, createJsObject { - this.uuid = uuid - }) + return WhereNowImpl( + jsPubNub, + createJsObject { + this.uuid = uuid + } + ) } override fun setPresenceState( @@ -314,19 +352,25 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { channelGroups: List, state: Any, ): SetState { - return SetStateImpl(jsPubNub, createJsObject { - this.state = state - this.channels = channels.toTypedArray() - this.channelGroups = channelGroups.toTypedArray() - }) + return SetStateImpl( + jsPubNub, + createJsObject { + this.state = state + this.channels = channels.toTypedArray() + this.channelGroups = channelGroups.toTypedArray() + } + ) } override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { - return GetStateImpl(jsPubNub, createJsObject { - this.channels = channels.toTypedArray() - this.channelGroups = channelGroups.toTypedArray() - this.uuid = uuid - }) + return GetStateImpl( + jsPubNub, + createJsObject { + this.channels = channels.toTypedArray() + this.channelGroups = channelGroups.toTypedArray() + this.uuid = uuid + } + ) } override fun presence(channels: List, channelGroups: List, connected: Boolean) { @@ -334,14 +378,17 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun addMessageAction(channel: String, messageAction: PNMessageAction): AddMessageAction { - return AddMessageActionImpl(jsPubNub, createJsObject { - this.channel = channel - this.messageTimetoken = messageAction.messageTimetoken.toString() - this.action = createJsObject { - this.type = messageAction.type - this.value = messageAction.value + return AddMessageActionImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.messageTimetoken = messageAction.messageTimetoken.toString() + this.action = createJsObject { + this.type = messageAction.type + this.value = messageAction.value + } } - }) + ) } override fun removeMessageAction( @@ -349,43 +396,58 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { messageTimetoken: Long, actionTimetoken: Long ): RemoveMessageAction { - return RemoveMessageActionImpl(jsPubNub, createJsObject { - this.channel = channel - this.messageTimetoken = messageTimetoken.toString() - this.actionTimetoken = actionTimetoken.toString() - }) + return RemoveMessageActionImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.messageTimetoken = messageTimetoken.toString() + this.actionTimetoken = actionTimetoken.toString() + } + ) } override fun getMessageActions(channel: String, page: PNBoundedPage): GetMessageActions { - return GetMessageActionImpl(jsPubNub, createJsObject { - this.channel = channel - this.start = page.start?.toString() - this.end = page.end?.toString() - this.limit = page.limit - }) + return GetMessageActionImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.start = page.start?.toString() + this.end = page.end?.toString() + this.limit = page.limit + } + ) } override fun addChannelsToChannelGroup(channels: List, channelGroup: String): AddChannelChannelGroup { - return AddChannelChannelGroupImpl(jsPubNub, createJsObject { - this.channels = channels.toTypedArray() - this.channelGroup = channelGroup - }) + return AddChannelChannelGroupImpl( + jsPubNub, + createJsObject { + this.channels = channels.toTypedArray() + this.channelGroup = channelGroup + } + ) } override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { - return AllChannelsChannelGroupImpl(jsPubNub, createJsObject { - this.channelGroup = channelGroup - }) + return AllChannelsChannelGroupImpl( + jsPubNub, + createJsObject { + this.channelGroup = channelGroup + } + ) } override fun removeChannelsFromChannelGroup( channels: List, channelGroup: String ): RemoveChannelChannelGroup { - return RemoveChannelChannelGroupImpl(jsPubNub, createJsObject { - this.channels = channels.toTypedArray() - this.channelGroup = channelGroup - }) + return RemoveChannelChannelGroupImpl( + jsPubNub, + createJsObject { + this.channels = channels.toTypedArray() + this.channelGroup = channelGroup + } + ) } override fun listAllChannelGroups(): ListAllChannelGroup { @@ -393,9 +455,12 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { - return DeleteChannelGroupImpl(jsPubNub, createJsObject { - this.channelGroup = channelGroup - }) + return DeleteChannelGroupImpl( + jsPubNub, + createJsObject { + this.channelGroup = channelGroup + } + ) } override fun grantToken( @@ -406,23 +471,26 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { channelGroups: List, uuids: List ): GrantToken { - return GrantTokenImpl(jsPubNub, createJsObject { - this.meta = meta?.let { metaNotNull -> - json(*metaNotNull.entries.map { Pair(it.key, it.value) }.toTypedArray()) - } - this.ttl = ttl - this.authorized_uuid = authorizedUUID - this.resources = createJsObject { - this.channels = getGrantTokenPermissions(channels) - this.groups = getGrantTokenPermissions(channelGroups) - this.uuids = getGrantTokenPermissions(uuids) - } - this.patterns = createJsObject { - this.channels = getGrantTokenPermissions(channels) - this.groups = getGrantTokenPermissions(channelGroups) - this.uuids = getGrantTokenPermissions(uuids) + return GrantTokenImpl( + jsPubNub, + createJsObject { + this.meta = meta?.let { metaNotNull -> + json(*metaNotNull.entries.map { Pair(it.key, it.value) }.toTypedArray()) + } + this.ttl = ttl + this.authorized_uuid = authorizedUUID + this.resources = createJsObject { + this.channels = getGrantTokenPermissions(channels) + this.groups = getGrantTokenPermissions(channelGroups) + this.uuids = getGrantTokenPermissions(uuids) + } + this.patterns = createJsObject { + this.channels = getGrantTokenPermissions(channels) + this.groups = getGrantTokenPermissions(channelGroups) + this.uuids = getGrantTokenPermissions(uuids) + } } - }) + ) } override fun revokeToken(token: String): RevokeToken { @@ -441,25 +509,31 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCount: Boolean, includeCustom: Boolean ): GetAllChannelMetadata { - return GetAllChannelMetadataImpl(jsPubNub, createJsObject { - this.page = page.toMetadataPage() - this.filter = filter - this.limit = limit - this.sort = sort.toJsMap() - this.include = createJsObject { - this.customFields = includeCustom - this.totalCount = includeCount + return GetAllChannelMetadataImpl( + jsPubNub, + createJsObject { + this.page = page.toMetadataPage() + this.filter = filter + this.limit = limit + this.sort = sort.toJsMap() + this.include = createJsObject { + this.customFields = includeCustom + this.totalCount = includeCount + } } - }) + ) } override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { - return GetChannelMetadataImpl(jsPubNub, createJsObject { - this.channel = channel - this.include = createJsObject { - this.customFields = includeCustom + return GetChannelMetadataImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.include = createJsObject { + this.customFields = includeCustom + } } - }) + ) } override fun setChannelMetadata( @@ -471,26 +545,32 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { type: String?, status: String? ): SetChannelMetadata { - return SetChannelMetadataImpl(jsPubNub, createJsObject { - this.channel = channel - this.data = ChannelMetadata( - name.toOptional(), - description.toOptional(), - status.toOptional(), - type.toOptional(), - custom.toOptional() - ) - - this.include = createJsObject { - this.customFields = includeCustom + return SetChannelMetadataImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.data = ChannelMetadata( + name.toOptional(), + description.toOptional(), + status.toOptional(), + type.toOptional(), + custom.toOptional() + ) + + this.include = createJsObject { + this.customFields = includeCustom + } } - }) + ) } override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { - return RemoveChannelMetadataImpl(jsPubNub, createJsObject { - this.channel = channel - }) + return RemoveChannelMetadataImpl( + jsPubNub, + createJsObject { + this.channel = channel + } + ) } override fun getAllUUIDMetadata( @@ -501,25 +581,31 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeCount: Boolean, includeCustom: Boolean ): GetAllUUIDMetadata { - return GetAllUUIDMetadataImpl(jsPubNub, createJsObject { - this.limit = limit - this.page = page.toMetadataPage() - this.filter = filter - this.include = createJsObject { - this.customFields = includeCustom - this.totalCount = includeCount + return GetAllUUIDMetadataImpl( + jsPubNub, + createJsObject { + this.limit = limit + this.page = page.toMetadataPage() + this.filter = filter + this.include = createJsObject { + this.customFields = includeCustom + this.totalCount = includeCount + } + this.sort = sort.toJsMap() } - this.sort = sort.toJsMap() - }) + ) } override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { - return GetUUIDMetadataImpl(jsPubNub, createJsObject { - this.uuid = uuid - this.include = createJsObject { - this.customFields = customFields + return GetUUIDMetadataImpl( + jsPubNub, + createJsObject { + this.uuid = uuid + this.include = createJsObject { + this.customFields = customFields + } } - }) + ) } override fun setUUIDMetadata( @@ -533,28 +619,34 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { type: String?, status: String? ): SetUUIDMetadata { - return SetUUIDMetadataImpl(jsPubNub, createJsObject { - data = UUIDMetadata( - name.toOptional(), - externalId.toOptional(), - profileUrl.toOptional(), - email.toOptional(), - status.toOptional(), - type.toOptional(), - custom.toOptional() - ) - this.uuid = uuid - - include = createJsObject { - this.customFields = includeCustom + return SetUUIDMetadataImpl( + jsPubNub, + createJsObject { + data = UUIDMetadata( + name.toOptional(), + externalId.toOptional(), + profileUrl.toOptional(), + email.toOptional(), + status.toOptional(), + type.toOptional(), + custom.toOptional() + ) + this.uuid = uuid + + include = createJsObject { + this.customFields = includeCustom + } } - }) + ) } override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { - return RemoveUUIDMetadataImpl(jsPubNub, createJsObject { - this.uuid = uuid - }) + return RemoveUUIDMetadataImpl( + jsPubNub, + createJsObject { + this.uuid = uuid + } + ) } override fun getMemberships( @@ -568,21 +660,24 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeChannelDetails: PNChannelDetailsLevel?, includeType: Boolean, ): GetMemberships { - return GetMembershipsImpl(jsPubNub, createJsObject { - this.sort = sort.toJsMap() - this.filter = filter - this.include = createJsObject { - this.customFields = includeCustom - this.totalCount = includeCount - if (includeChannelDetails != null) { - this.channelFields = true - this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM + return GetMembershipsImpl( + jsPubNub, + createJsObject { + this.sort = sort.toJsMap() + this.filter = filter + this.include = createJsObject { + this.customFields = includeCustom + this.totalCount = includeCount + if (includeChannelDetails != null) { + this.channelFields = true + this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM + } + this.channelTypeField = includeType + this.channelStatusField = true + // todo we don't have parameters for all fields here? } - this.channelTypeField = includeType - this.channelStatusField = true - //todo we don't have parameters for all fields here? } - }) + ) } override fun setMemberships( @@ -597,29 +692,34 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeChannelDetails: PNChannelDetailsLevel?, includeType: Boolean, ): ManageMemberships { - return SetMembershipsImpl(jsPubNub, createJsObject { - this.sort = sort.toJsMap() - this.page = page.toMetadataPage() - this.filter = filter - this.include = createJsObject { - this.customFields = includeCustom - this.totalCount = includeCount - if (includeChannelDetails != null) { - this.channelFields = true - this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM + return SetMembershipsImpl( + jsPubNub, + createJsObject { + this.sort = sort.toJsMap() + this.page = page.toMetadataPage() + this.filter = filter + this.include = createJsObject { + this.customFields = includeCustom + this.totalCount = includeCount + if (includeChannelDetails != null) { + this.channelFields = true + this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM + } + this.channelTypeField = includeType + this.channelStatusField = true + // todo we don't have parameters for all fields here? } - this.channelTypeField = includeType - this.channelStatusField = true - //todo we don't have parameters for all fields here? + this.uuid = uuid + this.channels = channels.map { + createJsObject { + this.id = it.channel + this.custom = it.custom?.adjustCollectionTypes()?.unsafeCast() + this.status = status // todo this doesn't seem to get to the server with JS, or cannot read it back + } + }.toTypedArray() + this.limit = limit } - this.uuid = uuid - this.channels = channels.map { createJsObject { - this.id = it.channel - this.custom = it.custom?.adjustCollectionTypes()?.unsafeCast() - this.status = status //todo this doesn't seem to get to the server with JS, or cannot read it back - } }.toTypedArray() - this.limit = limit - }) + ) } override fun removeMemberships( @@ -634,25 +734,28 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeChannelDetails: PNChannelDetailsLevel?, includeType: Boolean, ): ManageMemberships { - return RemoveMembershipsImpl(jsPubNub, createJsObject { - this.sort = sort.toJsMap() - this.page = page.toMetadataPage() - this.filter = filter - this.include = createJsObject { - this.customFields = includeCustom - this.totalCount = includeCount - if (includeChannelDetails != null) { - this.channelFields = true - this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM + return RemoveMembershipsImpl( + jsPubNub, + createJsObject { + this.sort = sort.toJsMap() + this.page = page.toMetadataPage() + this.filter = filter + this.include = createJsObject { + this.customFields = includeCustom + this.totalCount = includeCount + if (includeChannelDetails != null) { + this.channelFields = true + this.customChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM + } + this.channelTypeField = includeType + this.channelStatusField = true + // todo we don't have parameters for all fields here? } - this.channelTypeField = includeType - this.channelStatusField = true - //todo we don't have parameters for all fields here? + this.uuid = uuid + this.channels = channels.toTypedArray() + this.limit = limit } - this.uuid = uuid - this.channels = channels.toTypedArray() - this.limit = limit - }) + ) } // TODO doesn't exist in JS @@ -682,21 +785,28 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeUUIDDetails: PNUUIDDetailsLevel?, includeType: Boolean, ): GetChannelMembers { - return GetChannelMembersImpl(jsPubNub, createJsObject { - this.channel = channel - this.limit = limit - this.page = page.toMetadataPage() - this.filter = filter - this.include = createJsObject { - if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.UUIDFields = true - if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.customUUIDFields = true - this.customFields = includeCustom - this.totalCount = includeCount - this.UUIDTypeField = includeType - //todo we don't have parameters for all fields here + return GetChannelMembersImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.limit = limit + this.page = page.toMetadataPage() + this.filter = filter + this.include = createJsObject { + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) { + this.UUIDFields = true + } + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) { + this.customUUIDFields = true + } + this.customFields = includeCustom + this.totalCount = includeCount + this.UUIDTypeField = includeType + // todo we don't have parameters for all fields here + } + this.sort = sort.toJsMap() } - this.sort = sort.toJsMap() - }) + ) } override fun setChannelMembers( @@ -711,28 +821,37 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeUUIDDetails: PNUUIDDetailsLevel?, includeType: Boolean, ): ManageChannelMembers { - return SetChannelMembersImpl(jsPubNub, createJsObject { - this.channel = channel - this.uuids = uuids.map { createJsObject { - this.id = it.uuid - this.custom = it.custom?.adjustCollectionTypes()?.unsafeCast() - this.status = it.status - } }.toTypedArray() - this.limit = limit - this.page = page.toMetadataPage() - this.filter = filter - this.sort = sort.toJsMap() - this.include = createJsObject { - this.totalCount = includeCount - this.customFields = includeCustom - this.statusField = true - if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.UUIDFields = true - if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.customUUIDFields = true + return SetChannelMembersImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.uuids = uuids.map { + createJsObject { + this.id = it.uuid + this.custom = it.custom?.adjustCollectionTypes()?.unsafeCast() + this.status = it.status + } + }.toTypedArray() + this.limit = limit + this.page = page.toMetadataPage() + this.filter = filter + this.sort = sort.toJsMap() + this.include = createJsObject { + this.totalCount = includeCount + this.customFields = includeCustom + this.statusField = true + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) { + this.UUIDFields = true + } + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) { + this.customUUIDFields = true + } // this.UUIDStatusField = true - this.UUIDTypeField = includeType - //todo we don't have parameters for all fields here + this.UUIDTypeField = includeType + // todo we don't have parameters for all fields here + } } - }) + ) } override fun removeChannelMembers( @@ -747,23 +866,30 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { includeUUIDDetails: PNUUIDDetailsLevel?, includeType: Boolean ): ManageChannelMembers { - return RemoveChannelMembersImpl(jsPubNub, createJsObject { - this.channel = channel - this.uuids = uuids.toTypedArray() - this.limit = limit - this.page = page.toMetadataPage() - this.filter = filter - this.sort = sort.toJsMap() - this.include = createJsObject { - this.totalCount = includeCount - this.customFields = includeCustom - this.statusField = true - if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.UUIDFields = true - if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) this.customUUIDFields = true - this.UUIDTypeField = includeType - //todo we don't have parameters for all fields here + return RemoveChannelMembersImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.uuids = uuids.toTypedArray() + this.limit = limit + this.page = page.toMetadataPage() + this.filter = filter + this.sort = sort.toJsMap() + this.include = createJsObject { + this.totalCount = includeCount + this.customFields = includeCustom + this.statusField = true + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) { + this.UUIDFields = true + } + if (includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM) { + this.customUUIDFields = true + } + this.UUIDTypeField = includeType + // todo we don't have parameters for all fields here + } } - }) + ) } // override fun manageChannelMembers( @@ -782,29 +908,38 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { // } override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { - return ListFilesImpl(jsPubNub, createJsObject { - this.channel = channel - this.limit = limit - if (next != null) { - this.next = next.pageHash + return ListFilesImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.limit = limit + if (next != null) { + this.next = next.pageHash + } } - }) + ) } override fun getFileUrl(channel: String, fileName: String, fileId: String): GetFileUrl { - return GetFileUrlImpl(jsPubNub, createJsObject { - this.channel = channel - this.name = fileName - this.id = fileId - }) + return GetFileUrlImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.name = fileName + this.id = fileId + } + ) } override fun deleteFile(channel: String, fileName: String, fileId: String): DeleteFile { - return DeleteFileImpl(jsPubNub, createJsObject { - this.channel = channel - this.name = fileName - this.id = fileId - }) + return DeleteFileImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.name = fileName + this.id = fileId + } + ) } override fun publishFileMessage( @@ -816,15 +951,18 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { ttl: Int?, shouldStore: Boolean? ): PublishFileMessage { - return PublishFileMessageImpl(jsPubNub, createJsObject { - this.channel = channel - this.fileName = fileName - this.fileId = fileId - this.message = message?.adjustCollectionTypes() - this.meta = meta?.adjustCollectionTypes() - this.ttl = ttl - this.storeInHistory = shouldStore - }) + return PublishFileMessageImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.fileName = fileName + this.fileId = fileId + this.message = message?.adjustCollectionTypes() + this.meta = meta?.adjustCollectionTypes() + this.ttl = ttl + this.storeInHistory = shouldStore + } + ) } override fun subscribe( @@ -833,19 +971,23 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { withPresence: Boolean, withTimetoken: Long ) { - jsPubNub.subscribe(createJsObject { - this.channels = channels.toTypedArray() - this.channelGroups = channelGroups.toTypedArray() - this.withPresence = withPresence - this.timetoken = withTimetoken.adjustCollectionTypes() as? String - }) + jsPubNub.subscribe( + createJsObject { + this.channels = channels.toTypedArray() + this.channelGroups = channelGroups.toTypedArray() + this.withPresence = withPresence + this.timetoken = withTimetoken.adjustCollectionTypes() as? String + } + ) } override fun unsubscribe(channels: List, channelGroups: List) { - jsPubNub.unsubscribe(createJsObject { - this.channels = channels.toTypedArray() - this.channelGroups = channelGroups.toTypedArray() - }) + jsPubNub.unsubscribe( + createJsObject { + this.channels = channels.toTypedArray() + this.channelGroups = channelGroups.toTypedArray() + } + ) } override fun unsubscribeAll() { @@ -857,7 +999,6 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun destroy() { - } override fun channel(name: String): Channel { @@ -907,24 +1048,30 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { shouldStore: Boolean?, cipherKey: String? ): SendFile { - return SendFileImpl(jsPubNub, createJsObject { - this.channel = channel - this.file = inputStream.fileInput - this.message = message - this.meta = meta - this.ttl = ttl - this.storeInHistory = shouldStore - this.cipherKey = cipherKey - }) + return SendFileImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.file = inputStream.fileInput + this.message = message + this.meta = meta + this.ttl = ttl + this.storeInHistory = shouldStore + this.cipherKey = cipherKey + } + ) } override fun downloadFile(channel: String, fileName: String, fileId: String, cipherKey: String?): DownloadFile { - return DownloadFileImpl(jsPubNub, createJsObject { - this.channel = channel - this.name = fileName - this.id = fileId - this.cipherKey = cipherKey - }) + return DownloadFileImpl( + jsPubNub, + createJsObject { + this.channel = channel + this.name = fileName + this.id = fileId + this.cipherKey = cipherKey + } + ) } } @@ -986,24 +1133,24 @@ fun ChannelMetadata( return result } // -//fun Map.toJsObject(): PubNubJs.CustomObject { +// fun Map.toJsObject(): PubNubJs.CustomObject { // val custom = createJsObject { } // entries.forEach { // custom[it.key] = it.value // } // @Suppress("UnsafeCastFromDynamic") // return custom -//} +// } fun PNConfiguration.toJs(): PubNubJs.PNConfiguration { val config: PubNubJs.PNConfiguration = createJsObject() config.userId = userId.value config.subscribeKey = subscribeKey config.publishKey = publishKey - -// config.authKeys: String? + config.secretKey = secretKey config.logVerbosity = logVerbosity config.enableEventEngine = enableEventEngine +// config.authKey // config.ssl: Boolean? // config.origin: dynamic /* String? | Array? */ // config.presenceTimeout: Number? @@ -1026,8 +1173,7 @@ fun PNConfiguration.toJs(): PubNubJs.PNConfiguration { return config } - -private inline fun getGrantTokenPermissions(grants: List) = +private inline fun getGrantTokenPermissions(grants: List) = grants.filterIsInstance().associate { it.id to createJsObject { this.get = it.get @@ -1037,11 +1183,14 @@ private inline fun getGrantTokenPermissions(grants: this.write = it.write this.manage = it.manage this.read = it.read - //todo what about create? any other? + // todo what about create? any other? } }.toJsMap() -private fun Collection>.toJsMap() = associateBy(keySelector = { pnSortKey -> pnSortKey.key.fieldName }, valueTransform = { pnSortKey -> pnSortKey.dir }).toJsMap() +private fun Collection>.toJsMap() = associateBy( + keySelector = { pnSortKey -> pnSortKey.key.fieldName }, + valueTransform = { pnSortKey -> pnSortKey.dir } +).toJsMap() private fun PNPage?.toMetadataPage(): PubNubJs.MetadataPage? = this?.let { pageNotNull -> @@ -1052,4 +1201,4 @@ private fun PNPage?.toMetadataPage(): PubNubJs.MetadataPage? = this.prev = pageNotNull.pageHash } } - } \ No newline at end of file + } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt index bc1e75326..7a7b2505d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.js.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult +import com.pubnub.kmp.PNFuture /** * @see [com.pubnub.api.PubNub.deleteMessages] */ -actual interface DeleteMessages : PNFuture \ No newline at end of file +actual interface DeleteMessages : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessagesImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessagesImpl.kt index c7b48ad69..b4ca94c50 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessagesImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/DeleteMessagesImpl.kt @@ -2,16 +2,12 @@ package com.pubnub.api.endpoints import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.JsonElementImpl -import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.history.HistoryMessageType import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult -import com.pubnub.api.models.consumer.history.PNFetchMessageItem -import com.pubnub.api.models.consumer.history.PNFetchMessagesResult -import com.pubnub.kmp.toMap class DeleteMessagesImpl(pubnub: PubNub, params: PubNub.DeleteMessagesParameters) : DeleteMessages, - EndpointImpl(promiseFactory = { pubnub.deleteMessages(params) }, + EndpointImpl( + promiseFactory = { pubnub.deleteMessages(params) }, responseMapping = { PNDeleteMessagesResult() - }) \ No newline at end of file + } + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt index 9e58c4e17..771566b7c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessages.js.kt @@ -1,11 +1,9 @@ package com.pubnub.api.endpoints -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNFetchMessagesResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.fetchMessages] */ actual interface FetchMessages : PNFuture - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt index 121f2f53f..35394b559 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/FetchMessagesImpl.kt @@ -2,7 +2,6 @@ package com.pubnub.api.endpoints import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.JsonElementImpl import com.pubnub.api.createJsonElement import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.HistoryMessageType @@ -14,24 +13,27 @@ class FetchMessagesImpl(pubnub: PubNub, params: PubNub.FetchMessagesParameters) EndpointImpl( promiseFactory = { pubnub.fetchMessages(params) }, responseMapping = { response -> - PNFetchMessagesResult(response.channels.toMap().mapValues { - it.value.map { item -> - PNFetchMessageItem( - item.uuid, - createJsonElement(item.message), - createJsonElement(item.meta), - item.timetoken.toString().toLong(), - item.actions?.toMap()?.mapValues { entry: Map.Entry -> - entry.value.toMap().mapValues { entry2: Map.Entry> -> - entry2.value.map { action -> - PNFetchMessageItem.Action(action.uuid, action.actionTimetoken) + PNFetchMessagesResult( + response.channels.toMap().mapValues { entry -> + entry.value.map { item -> + PNFetchMessageItem( + item.uuid, + createJsonElement(item.message), + item.meta?.let { createJsonElement(it) }, + item.timetoken.toString().toLong(), + item.actions?.toMap()?.mapValues { entry: Map.Entry -> + entry.value.toMap().mapValues { entry2: Map.Entry> -> + entry2.value.map { action -> + PNFetchMessageItem.Action(action.uuid, action.actionTimetoken.toLong()) + } } - } - }, - HistoryMessageType.of(item.messageType?.toString()?.toInt()), - null, //TODO item.error - ) - } - }, response.more?.let { PNBoundedPage(it.start.toLong(), null, it.max.toInt()) }) + }, + HistoryMessageType.of(item.messageType?.toString()?.toInt()), + null, // TODO item.error + ) + } + }, + response.more?.let { PNBoundedPage(it.start.toLong(), null, it.max.toInt()) } + ) } - ) \ No newline at end of file + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt index a813a7067..963f54379 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCounts.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.history.PNMessageCountResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.messageCounts] */ -actual interface MessageCounts : PNFuture \ No newline at end of file +actual interface MessageCounts : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCountsImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCountsImpl.kt index a61d45a66..9684ed21f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCountsImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/MessageCountsImpl.kt @@ -2,17 +2,13 @@ package com.pubnub.api.endpoints import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.JsonElementImpl -import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.history.HistoryMessageType -import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult -import com.pubnub.api.models.consumer.history.PNFetchMessageItem -import com.pubnub.api.models.consumer.history.PNFetchMessagesResult import com.pubnub.api.models.consumer.history.PNMessageCountResult import com.pubnub.kmp.toMap class MessageCountsImpl(pubnub: PubNub, params: PubNub.MessageCountsParameters) : MessageCounts, - EndpointImpl(promiseFactory = { pubnub.messageCounts(params) }, + EndpointImpl( + promiseFactory = { pubnub.messageCounts(params) }, responseMapping = { PNMessageCountResult(it.channels.toMap().mapValues { entry -> entry.value.toLong() }) - }) \ No newline at end of file + } + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt index 507888d85..a7e369500 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/Time.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNTimeResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.time] */ -actual interface Time : PNFuture \ No newline at end of file +actual interface Time : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/TimeImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/TimeImpl.kt index f86f01642..a618293d0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/TimeImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/TimeImpl.kt @@ -7,4 +7,4 @@ import com.pubnub.api.models.consumer.PNTimeResult class TimeImpl(pubnub: PubNub) : Time, EndpointImpl( promiseFactory = { pubnub.time() }, responseMapping = { PNTimeResult(it.timetoken.toLong()) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt index 74512c8be..71713052e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantToken.js.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.access -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult +import com.pubnub.kmp.PNFuture -actual interface GrantToken : PNFuture \ No newline at end of file +actual interface GrantToken : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt index 9df06ce48..4a74ce314 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/GrantTokenImpl.kt @@ -9,4 +9,4 @@ class GrantTokenImpl(pubnub: PubNub, params: PubNub.GrantTokenParameters) : Gran responseMapping = { PNGrantTokenResult(it) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt index 6e58a2afb..e02277014 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeToken.js.kt @@ -2,4 +2,4 @@ package com.pubnub.api.endpoints.access import com.pubnub.kmp.PNFuture -actual interface RevokeToken : PNFuture \ No newline at end of file +actual interface RevokeToken : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeTokenImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeTokenImpl.kt index d9ed2cf2e..79aec7752 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeTokenImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/access/RevokeTokenImpl.kt @@ -6,4 +6,4 @@ import com.pubnub.api.EndpointImpl class RevokeTokenImpl(pubnub: PubNub, params: String) : RevokeToken, EndpointImpl( promiseFactory = { pubnub.revokeToken(params) }, responseMapping = { } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt index e2749d194..8862f151d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.js.kt @@ -1,11 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.addChannelsToChannelGroup] */ actual interface AddChannelChannelGroup : PNFuture - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroupImpl.kt index 34a72c9f2..ce02d5869 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroupImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroupImpl.kt @@ -9,4 +9,4 @@ class AddChannelChannelGroupImpl(pubnub: PubNub, params: PubNub.AddChannelParame responseMapping = { PNChannelGroupsAddChannelResult() } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt index f4fc6dcbf..32bdbd525 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.js.kt @@ -1,11 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.listChannelsForChannelGroup] */ actual interface AllChannelsChannelGroup : PNFuture - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt index 8d8f292c9..c992dc1bc 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt @@ -11,4 +11,4 @@ class AllChannelsChannelGroupImpl(pubnub: PubNub, params: PubNub.ListChannelsPar it.channels.toList() ) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt index bbf6014c9..964232485 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.deleteChannelGroup] */ -actual interface DeleteChannelGroup : PNFuture \ No newline at end of file +actual interface DeleteChannelGroup : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt index 2257f9aca..9e9b6073b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroupImpl.kt @@ -9,4 +9,4 @@ class DeleteChannelGroupImpl(pubnub: PubNub, params: PubNub.DeleteGroupParameter responseMapping = { PNChannelGroupsDeleteGroupResult() } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt index 06460bfe7..92a180491 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.js.kt @@ -1,11 +1,9 @@ package com.pubnub.api.endpoints.channel_groups -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.listAllChannelGroups] */ actual interface ListAllChannelGroup : PNFuture - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroupImpl.kt index e3221b0e1..7b46ae5c6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroupImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroupImpl.kt @@ -12,4 +12,4 @@ class ListAllChannelGroupImpl(pubnub: PubNub) : ListAllChannelGroup, it.groups.toList() ) } - ) \ No newline at end of file + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt index d5f54e8ed..7a1ed4cef 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.js.kt @@ -1,8 +1,7 @@ package com.pubnub.api.endpoints.channel_groups -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.removeChannelsFromChannelGroup] diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt index 96aa269ac..73fd4048e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt @@ -10,4 +10,4 @@ class RemoveChannelChannelGroupImpl(pubnub: PubNub, params: PubNub.RemoveChannel responseMapping = { PNChannelGroupsRemoveChannelResult() } - ) \ No newline at end of file + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt index 3b3953e91..825559886 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.files -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNDeleteFileResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.deleteFile] */ -actual interface DeleteFile : PNFuture \ No newline at end of file +actual interface DeleteFile : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFileImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFileImpl.kt index 0f497bbec..7593a29db 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFileImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DeleteFileImpl.kt @@ -3,8 +3,6 @@ package com.pubnub.api.endpoints.files import PubNub import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.files.PNDeleteFileResult -import com.pubnub.api.models.consumer.files.PNFileUrlResult -import kotlin.js.Promise class DeleteFileImpl(pubnub: PubNub, params: PubNub.FileInputParameters) : DeleteFile, EndpointImpl( @@ -12,4 +10,4 @@ class DeleteFileImpl(pubnub: PubNub, params: PubNub.FileInputParameters) : Delet responseMapping = { result -> PNDeleteFileResult(result.status.toInt()) } - ) \ No newline at end of file + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.js.kt index 5dd93aa8c..9727b2674 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.js.kt @@ -6,4 +6,4 @@ import com.pubnub.kmp.PNFuture /** * @see [PubNub.sendFile] */ -actual interface DownloadFile : PNFuture \ No newline at end of file +actual interface DownloadFile : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFileImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFileImpl.kt index 71ce14712..811559076 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFileImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/DownloadFileImpl.kt @@ -2,10 +2,7 @@ package com.pubnub.api.endpoints.files import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.models.consumer.files.PNBaseFile import com.pubnub.api.models.consumer.files.PNDownloadFileResult -import com.pubnub.api.models.consumer.files.PNFileUploadResult -import com.pubnub.kmp.Downloadable import com.pubnub.kmp.DownloadableImpl class DownloadFileImpl(pubnub: PubNub, params: PubNub.DownloadFileParameters) : DownloadFile, EndpointImpl( @@ -16,4 +13,4 @@ class DownloadFileImpl(pubnub: PubNub, params: PubNub.DownloadFileParameters) : DownloadableImpl(it) ) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt index 4f590feea..7d967fb4a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.files -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNFileUrlResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getFileUrl] */ -actual interface GetFileUrl : PNFuture \ No newline at end of file +actual interface GetFileUrl : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrlImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrlImpl.kt index cdd316af9..81104319b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrlImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrlImpl.kt @@ -19,4 +19,4 @@ class GetFileUrlImpl(pubnub: PubNub, params: PubNub.FileInputParameters) : GetFi responseMapping = { result -> PNFileUrlResult(result) } - ) \ No newline at end of file + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt index eeefac15e..5039caa45 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.files -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNListFilesResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.listFiles] */ -actual interface ListFiles : PNFuture \ No newline at end of file +actual interface ListFiles : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFilesImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFilesImpl.kt index 8d8616762..172d4cf05 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFilesImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/ListFilesImpl.kt @@ -24,4 +24,4 @@ class ListFilesImpl(pubnub: PubNub, params: PubNub.ListFilesParameters) : ListFi } ) } - ) \ No newline at end of file + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt index f4610da0b..0fad16a32 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.files -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.publishFileMessage] */ -actual interface PublishFileMessage : PNFuture \ No newline at end of file +actual interface PublishFileMessage : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessageImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessageImpl.kt index b8abf02dc..cd939cb5d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessageImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessageImpl.kt @@ -9,4 +9,4 @@ class PublishFileMessageImpl(pubnub: PubNub, params: PubNub.PublishFileParameter responseMapping = { PNPublishFileMessageResult(it.timetoken.toLong()) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFile.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFile.js.kt index 333925128..482d22f11 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFile.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFile.js.kt @@ -6,4 +6,4 @@ import com.pubnub.kmp.PNFuture /** * @see [PubNub.sendFile] */ -actual interface SendFile : PNFuture \ No newline at end of file +actual interface SendFile : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFileImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFileImpl.kt index a2bf93722..97463bc38 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFileImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/files/SendFileImpl.kt @@ -10,11 +10,11 @@ class SendFileImpl(pubnub: PubNub, params: PubNub.SendFileParameters) : SendFile responseMapping = { PNFileUploadResult( it.timetoken.toLong(), - 200, //TODO anything else possible here? + 200, // TODO anything else possible here? PNBaseFile( it.id, it.name ) ) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt index 1b49af2fa..c214c0a04 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.js.kt @@ -1,11 +1,9 @@ package com.pubnub.api.endpoints.message_actions -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.addMessageAction] */ actual interface AddMessageAction : PNFuture - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt index faa1be288..7ee7f8370 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageActionImpl.kt @@ -13,4 +13,4 @@ class AddMessageActionImpl(pubnub: PubNub, params: PubNub.AddMessageActionParame it.data.toMessageAction() ) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt index 1b81c3597..1b8096696 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActionImpl.kt @@ -4,7 +4,6 @@ import PubNub import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult -import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.kmp.toMessageAction class GetMessageActionImpl(pubnub: PubNub, params: PubNub.GetMessageActionsParameters) : GetMessageActions, EndpointImpl( @@ -15,8 +14,8 @@ class GetMessageActionImpl(pubnub: PubNub, params: PubNub.GetMessageActionsParam action.toMessageAction() }, it.start?.let { startNotNull -> - PNBoundedPage(startNotNull.toLong(), it.end?.toLong(), null) //TODO kmp does js not return limit? + PNBoundedPage(startNotNull.toLong(), it.end?.toLong(), null) // TODO kmp does js not return limit? } ) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt index 79d93685a..61fcd54c5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.js.kt @@ -1,8 +1,7 @@ package com.pubnub.api.endpoints.message_actions -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getMessageActions] diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt index 9210f4df0..c623139a0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.js.kt @@ -1,11 +1,9 @@ package com.pubnub.api.endpoints.message_actions -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.removeMessageAction] */ actual interface RemoveMessageAction : PNFuture - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageActionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageActionImpl.kt index b2c212744..c954689c4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageActionImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageActionImpl.kt @@ -10,4 +10,4 @@ class RemoveMessageActionImpl(pubnub: PubNub, params: PubNub.RemoveMessageAction responseMapping = { PNRemoveMessageActionResult() } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt index 68f6dd76c..e0709f922 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.js.kt @@ -1,11 +1,10 @@ package com.pubnub.api.endpoints.objects.channel -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getAllChannelMetadata] */ actual interface GetAllChannelMetadata : - PNFuture \ No newline at end of file + PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadataImpl.kt index bdd2e45e2..26133283c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadataImpl.kt @@ -8,7 +8,8 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResu import com.pubnub.kmp.toChannelMetadata class GetAllChannelMetadataImpl(pubnub: PubNub, params: PubNub.GetAllMetadataParameters) : GetAllChannelMetadata, - EndpointImpl(promiseFactory = { pubnub.objects.getAllChannelMetadata(params) }, + EndpointImpl( + promiseFactory = { pubnub.objects.getAllChannelMetadata(params) }, responseMapping = { pagedObjectsResponse: GetAllChannelMetadataResponse -> PNChannelMetadataArrayResult( pagedObjectsResponse.status.toInt(), diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt index bc6402e5e..7438fbab2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.objects.channel -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getChannelMetadata] */ -actual interface GetChannelMetadata : PNFuture \ No newline at end of file +actual interface GetChannelMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt index 1988fcfeb..17f9a43ca 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadataImpl.kt @@ -8,6 +8,7 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult import com.pubnub.kmp.toChannelMetadataResult class GetChannelMetadataImpl(pubnub: PubNub, params: PubNub.GetChannelMetadataParameters) : GetChannelMetadata, - EndpointImpl(promiseFactory = { pubnub.objects.getChannelMetadata(params) }, + EndpointImpl( + promiseFactory = { pubnub.objects.getChannelMetadata(params) }, responseMapping = SetChannelMetadataResponse::toChannelMetadataResult ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt index ea0645459..327aeef92 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.js.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.objects.channel -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult +import com.pubnub.kmp.PNFuture -actual interface RemoveChannelMetadata : PNFuture \ No newline at end of file +actual interface RemoveChannelMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadataImpl.kt index 2ca403544..75c947da2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadataImpl.kt @@ -6,7 +6,9 @@ import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult class RemoveChannelMetadataImpl(pubnub: PubNub, params: PubNub.RemoveChannelMetadataParameters) : RemoveChannelMetadata, - EndpointImpl(promiseFactory = { pubnub.objects.removeChannelMetadata(params) }, + EndpointImpl( + promiseFactory = { pubnub.objects.removeChannelMetadata(params) }, responseMapping = { PNRemoveMetadataResult(it.status.toInt()) - }) \ No newline at end of file + } + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt index 3c7b96b16..2fc5780ff 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.objects.channel -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.setChannelMetadata] */ -actual interface SetChannelMetadata : PNFuture \ No newline at end of file +actual interface SetChannelMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt index f7716680a..6058ccaf4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadataImpl.kt @@ -7,6 +7,7 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult import com.pubnub.kmp.toChannelMetadataResult class SetChannelMetadataImpl(pubnub: PubNub, params: PubNub.SetChannelMetadataParameters) : SetChannelMetadata, - EndpointImpl(promiseFactory = { pubnub.objects.setChannelMetadata(params) }, + EndpointImpl( + promiseFactory = { pubnub.objects.setChannelMetadata(params) }, responseMapping = SetChannelMetadataResponse::toChannelMetadataResult ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt index 885783c31..d1cdbf595 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.js.kt @@ -1,8 +1,7 @@ package com.pubnub.api.endpoints.objects.member -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getChannelMembers] diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt index 313fe7e52..4bd68666c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembersImpl.kt @@ -3,13 +3,10 @@ package com.pubnub.api.endpoints.objects.member import ManageChannelMembersResponse import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult -import com.pubnub.kmp.toPNMember import com.pubnub.kmp.toPNMemberArrayResult class GetChannelMembersImpl(pubnub: PubNub, params: PubNub.GetChannelMembersParameters) : GetChannelMembers, EndpointImpl( promiseFactory = { pubnub.objects.getChannelMembers(params) }, responseMapping = ManageChannelMembersResponse::toPNMemberArrayResult ) - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt index 80faa4b9e..093cf5da3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.objects.member -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.manageChannelMembers] */ -actual interface ManageChannelMembers : PNFuture \ No newline at end of file +actual interface ManageChannelMembers : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/RemoveChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/RemoveChannelMembersImpl.kt index 194b225fe..90da64607 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/RemoveChannelMembersImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/RemoveChannelMembersImpl.kt @@ -10,4 +10,3 @@ class RemoveChannelMembersImpl(pubnub: PubNub, params: PubNub.RemoveChannelMembe promiseFactory = { pubnub.objects.removeChannelMembers(params) }, responseMapping = ManageChannelMembersResponse::toPNMemberArrayResult ) - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/SetChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/SetChannelMembersImpl.kt index 65bb59ea1..899643dcc 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/SetChannelMembersImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/member/SetChannelMembersImpl.kt @@ -3,15 +3,10 @@ package com.pubnub.api.endpoints.objects.member import ManageChannelMembersResponse import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.models.consumer.objects.member.PNMember import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -import com.pubnub.kmp.toMap -import com.pubnub.kmp.toPNMember import com.pubnub.kmp.toPNMemberArrayResult class SetChannelMembersImpl(pubnub: PubNub, params: PubNub.SetChannelMembersParameters) : ManageChannelMembers, EndpointImpl( promiseFactory = { pubnub.objects.setChannelMembers(params) }, responseMapping = ManageChannelMembersResponse::toPNMemberArrayResult -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt index 15d5c253b..a3d6f2855 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.objects.membership -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getMemberships] */ -actual interface GetMemberships : PNFuture \ No newline at end of file +actual interface GetMemberships : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMembershipsImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMembershipsImpl.kt index b6d7543f1..a1a328d70 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMembershipsImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMembershipsImpl.kt @@ -7,6 +7,7 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArra import com.pubnub.kmp.toPNChannelMembershipArrayResult class GetMembershipsImpl(pubnub: PubNub, params: PubNub.GetMembershipsParametersv2) : GetMemberships, - EndpointImpl(promiseFactory = { pubnub.objects.getMemberships(params) }, + EndpointImpl( + promiseFactory = { pubnub.objects.getMemberships(params) }, responseMapping = ManageMembershipsResponse::toPNChannelMembershipArrayResult ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt index e6ca955a8..d94303c05 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.objects.membership -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.manageMemberships] */ -actual interface ManageMemberships : PNFuture \ No newline at end of file +actual interface ManageMemberships : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/RemoveMembershipsImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/RemoveMembershipsImpl.kt index 970aaaf08..92119cdde 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/RemoveMembershipsImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/RemoveMembershipsImpl.kt @@ -3,14 +3,11 @@ package com.pubnub.api.endpoints.objects.membership import ManageMembershipsResponse import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.kmp.toChannelMetadata -import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult -import com.pubnub.kmp.toMap import com.pubnub.kmp.toPNChannelMembershipArrayResult class RemoveMembershipsImpl(pubnub: PubNub, params: PubNub.RemoveMembershipsParameters) : ManageMemberships, - EndpointImpl(promiseFactory = { pubnub.objects.removeMemberships(params) }, + EndpointImpl( + promiseFactory = { pubnub.objects.removeMemberships(params) }, responseMapping = ManageMembershipsResponse::toPNChannelMembershipArrayResult ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/SetMembershipsImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/SetMembershipsImpl.kt index 00e42e85c..bc071e05f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/SetMembershipsImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/membership/SetMembershipsImpl.kt @@ -3,14 +3,11 @@ package com.pubnub.api.endpoints.objects.membership import ManageMembershipsResponse import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.kmp.toChannelMetadata -import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult -import com.pubnub.kmp.toMap import com.pubnub.kmp.toPNChannelMembershipArrayResult class SetMembershipsImpl(pubnub: PubNub, params: PubNub.SetMembershipsParameters) : ManageMemberships, - EndpointImpl(promiseFactory = { pubnub.objects.setMemberships(params) }, + EndpointImpl( + promiseFactory = { pubnub.objects.setMemberships(params) }, responseMapping = ManageMembershipsResponse::toPNChannelMembershipArrayResult ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt index 499762daa..f4cee7937 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.objects.uuid -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getAllUUIDMetadata] */ -actual interface GetAllUUIDMetadata : PNFuture \ No newline at end of file +actual interface GetAllUUIDMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt index 64c5abb95..3e0e6db58 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt @@ -8,7 +8,8 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult import com.pubnub.kmp.toPNUUIDMetadata class GetAllUUIDMetadataImpl(pubnub: PubNub, params: PubNub.GetAllMetadataParameters) : GetAllUUIDMetadata, - EndpointImpl(promiseFactory = { pubnub.objects.getAllUUIDMetadata(params) }, + EndpointImpl( + promiseFactory = { pubnub.objects.getAllUUIDMetadata(params) }, responseMapping = { pagedObjectsResponse: GetAllUUIDMetadataResponse -> PNUUIDMetadataArrayResult( pagedObjectsResponse.status.toInt(), diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt index ba1818f1f..8d24a7507 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.js.kt @@ -1,8 +1,7 @@ package com.pubnub.api.endpoints.objects.uuid -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getUUIDMetadata] diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt index 3820e6c15..0bf0fc297 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadataImpl.kt @@ -7,6 +7,7 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.kmp.toPNUUIDMetadataResult class GetUUIDMetadataImpl(pubnub: PubNub, params: PubNub.GetUUIDMetadataParameters) : GetUUIDMetadata, - EndpointImpl(promiseFactory = { pubnub.objects.getUUIDMetadata(params) }, + EndpointImpl( + promiseFactory = { pubnub.objects.getUUIDMetadata(params) }, responseMapping = GetUUIDMetadataResponse::toPNUUIDMetadataResult ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt index 777ed0926..22a190cab 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.js.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.objects.uuid -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult +import com.pubnub.kmp.PNFuture actual interface RemoveUUIDMetadata : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt index c9ca55ae7..65727cf62 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt @@ -6,7 +6,9 @@ import com.pubnub.api.EndpointImpl import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult class RemoveUUIDMetadataImpl(pubnub: PubNub, params: PubNub.RemoveUUIDMetadataParameters) : RemoveUUIDMetadata, - EndpointImpl(promiseFactory = { pubnub.objects.removeUUIDMetadata(params) }, + EndpointImpl( + promiseFactory = { pubnub.objects.removeUUIDMetadata(params) }, responseMapping = { PNRemoveMetadataResult(it.status.toInt()) - }) \ No newline at end of file + } + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt index a45e71561..42421c4ba 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.js.kt @@ -1,11 +1,9 @@ package com.pubnub.api.endpoints.objects.uuid -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.setUUIDMetadata] */ actual interface SetUUIDMetadata : PNFuture - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt index 4b7ea2950..28ead38e7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadataImpl.kt @@ -8,6 +8,7 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.kmp.toPNUUIDMetadataResult class SetUUIDMetadataImpl(pubnub: PubNub, params: PubNub.SetUUIDMetadataParameters) : SetUUIDMetadata, - EndpointImpl(promiseFactory = { pubnub.objects.setUUIDMetadata(params) }, + EndpointImpl( + promiseFactory = { pubnub.objects.setUUIDMetadata(params) }, responseMapping = GetUUIDMetadataResponse::toPNUUIDMetadataResult - ) \ No newline at end of file + ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt index 2ad4df8d3..ab86c972a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetState.js.kt @@ -1,11 +1,9 @@ package com.pubnub.api.endpoints.presence -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNGetStateResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.getPresenceState] */ -actual interface GetState : PNFuture { -} \ No newline at end of file +actual interface GetState : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt index 696491f05..c0ac210b3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/GetStateImpl.kt @@ -16,4 +16,4 @@ class GetStateImpl(pubnub: PubNub, params: PubNub.GetStateParameters) : GetState } ) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt index 33243e23f..41c9d57a6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.js.kt @@ -1,11 +1,9 @@ package com.pubnub.api.endpoints.presence -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNHereNowResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.hereNow] */ actual interface HereNow : PNFuture - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt index 8e700700e..79d12e644 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/HereNowImpl.kt @@ -29,4 +29,4 @@ class HereNowImpl(pubnub: PubNub, params: PubNub.HereNowParameters) : HereNow, E }.toMutableMap() ) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt index ebac124cb..e7449b94b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetState.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.presence -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNSetStateResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.setPresenceState] */ -actual interface SetState : PNFuture \ No newline at end of file +actual interface SetState : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetStateImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetStateImpl.kt index ca009ab01..090504078 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetStateImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/SetStateImpl.kt @@ -12,4 +12,4 @@ class SetStateImpl(pubnub: PubNub, params: PubNub.SetStateParameters) : SetState JsonElementImpl(response.state) ) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt index dd0faff39..f83400e59 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.js.kt @@ -1,11 +1,9 @@ package com.pubnub.api.endpoints.presence -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.presence.PNWhereNowResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.whereNow] */ actual interface WhereNow : PNFuture - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNowImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNowImpl.kt index 7cb36d77e..ec660eb30 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNowImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/presence/WhereNowImpl.kt @@ -11,4 +11,4 @@ class WhereNowImpl(pubnub: PubNub, params: PubNub.WhereNowParameters) : WhereNow whereNowResponse.channels.toList() ) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/FireImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/FireImpl.kt index 65591fd60..1d80dea18 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/FireImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/FireImpl.kt @@ -9,4 +9,4 @@ class FireImpl(pubnub: PubNub, params: PubNub.FireParameters) : Publish, Endpoin responseMapping = { PNPublishResult(it.timetoken.toLong()) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt index 3f170518e..67f9f590e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.js.kt @@ -1,8 +1,7 @@ package com.pubnub.api.endpoints.pubsub -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNPublishResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.publish] diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/PublishImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/PublishImpl.kt index 82733b2dd..c8872dd7d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/PublishImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/PublishImpl.kt @@ -9,4 +9,4 @@ class PublishImpl(pubnub: PubNub, params: PubNub.PublishParameters) : Publish, E responseMapping = { PNPublishResult(it.timetoken.toLong()) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt index 69fe1b035..682c677c2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.js.kt @@ -1,11 +1,9 @@ package com.pubnub.api.endpoints.pubsub -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.PNPublishResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.signal] */ actual interface Signal : PNFuture - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/SignalImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/SignalImpl.kt index 1c2a665cc..604674182 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/SignalImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/pubsub/SignalImpl.kt @@ -9,4 +9,4 @@ class SignalImpl(pubnub: PubNub, params: PubNub.SignalParameters) : Signal, Endp responseMapping = { PNPublishResult(it.timetoken.toLong()) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt index 0fda98573..278eaca36 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.push -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushAddChannelResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.addPushNotificationsOnChannels] */ -actual interface AddChannelsToPush : PNFuture \ No newline at end of file +actual interface AddChannelsToPush : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPushImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPushImpl.kt index bce980c63..96fc28997 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPushImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPushImpl.kt @@ -9,4 +9,4 @@ class AddChannelsToPushImpl(pubnub: PubNub, params: PubNub.PushChannelParameters responseMapping = { PNPushAddChannelResult() } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt index 60d031572..e21ce4a16 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.push -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.auditPushChannelProvisions] */ -actual interface ListPushProvisions : PNFuture \ No newline at end of file +actual interface ListPushProvisions : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisionsImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisionsImpl.kt index 0b0c76e17..ad78ba696 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisionsImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisionsImpl.kt @@ -2,7 +2,6 @@ package com.pubnub.api.endpoints.push import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.models.consumer.push.PNPushAddChannelResult import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult class ListPushProvisionsImpl(pubnub: PubNub, params: PubNub.PushDeviceParameters) : ListPushProvisions, EndpointImpl( @@ -10,4 +9,4 @@ class ListPushProvisionsImpl(pubnub: PubNub, params: PubNub.PushDeviceParameters responseMapping = { PNPushListProvisionsResult(it.channels.toList()) } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt index 0646d3f39..6f92c7d52 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.push -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken] */ -actual interface RemoveAllPushChannelsForDevice : PNFuture \ No newline at end of file +actual interface RemoveAllPushChannelsForDevice : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt index dd74c06a0..60b054d6b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt @@ -2,8 +2,6 @@ package com.pubnub.api.endpoints.push import PubNub import com.pubnub.api.EndpointImpl -import com.pubnub.api.models.consumer.push.PNPushAddChannelResult -import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult class RemoveAllPushChannelsForDeviceImpl(pubnub: PubNub, params: PubNub.PushDeviceParameters) : RemoveAllPushChannelsForDevice, EndpointImpl( @@ -11,4 +9,4 @@ class RemoveAllPushChannelsForDeviceImpl(pubnub: PubNub, params: PubNub.PushDevi responseMapping = { PNPushRemoveAllChannelsResult() } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt index a99c6e8fe..9bff1e618 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.js.kt @@ -1,10 +1,9 @@ package com.pubnub.api.endpoints.push -import PubNub -import com.pubnub.kmp.PNFuture import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult +import com.pubnub.kmp.PNFuture /** * @see [PubNub.removePushNotificationsFromChannels] */ -actual interface RemoveChannelsFromPush : PNFuture \ No newline at end of file +actual interface RemoveChannelsFromPush : PNFuture diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPushImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPushImpl.kt index 94402ee3b..db66b1646 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPushImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPushImpl.kt @@ -9,4 +9,4 @@ class RemoveChannelsFromPushImpl(pubnub: PubNub, params: PubNub.PushChannelParam responseMapping = { PNPushRemoveChannelResult() } -) \ No newline at end of file +) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt index 164ec5d98..7156d2279 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt @@ -41,4 +41,4 @@ actual fun createPNConfiguration( } } -actual interface CryptoModule \ No newline at end of file +actual interface CryptoModule diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt index 4b6776b2f..e304b8d57 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.js.kt @@ -1,9 +1,7 @@ package com.pubnub.api.v2.callbacks -import com.pubnub.api.callbacks.Listener - /** * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -actual interface EventListener : BaseEventListener \ No newline at end of file +actual interface EventListener : BaseEventListener diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt index feb40c8cc..7194d85f3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.js.kt @@ -6,4 +6,4 @@ import com.pubnub.api.callbacks.Listener * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for * PubNub connection status changes. */ -actual interface StatusListener : Listener \ No newline at end of file +actual interface StatusListener : Listener diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt index ed3a5238c..689c958bf 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt @@ -13,12 +13,11 @@ import com.pubnub.internal.v2.subscriptions.SubscriptionImpl import com.pubnub.kmp.Uploadable import com.pubnub.kmp.createJsObject -class ChannelImpl( private val jsChannel: dynamic): Channel { - +class ChannelImpl(private val jsChannel: dynamic) : Channel { override fun publish( message: Any, meta: Any?, - shouldStore: Boolean?, + shouldStore: Boolean, usePost: Boolean, replicate: Boolean, ttl: Int? @@ -34,7 +33,6 @@ class ChannelImpl( private val jsChannel: dynamic): Channel { TODO("Not yet implemented") } - override fun sendFile( fileName: String, inputStream: Uploadable, @@ -54,12 +52,15 @@ class ChannelImpl( private val jsChannel: dynamic): Channel { override val name: String get() = jsChannel.name - override fun subscription(options: SubscriptionOptions): Subscription { //todo use options - return SubscriptionImpl(jsChannel.subscription(createJsObject { - if (options.allOptions.filterIsInstance().isNotEmpty()) { - receivePresenceEvents = true - } - })) + override fun subscription(options: SubscriptionOptions): Subscription { // todo use options + return SubscriptionImpl( + jsChannel.subscription( + createJsObject { + if (options.allOptions.filterIsInstance().isNotEmpty()) { + receivePresenceEvents = true + } + } + ) + ) } - -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt index 55130f422..c9f5a5ea0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionImpl.kt @@ -13,7 +13,6 @@ import com.pubnub.api.v2.subscriptions.SubscriptionCursor import com.pubnub.api.v2.subscriptions.SubscriptionSet class SubscriptionImpl(private val jsSubscription: dynamic) : Subscription { - override fun close() { unsubscribe() } @@ -31,7 +30,7 @@ class SubscriptionImpl(private val jsSubscription: dynamic) : Subscription { } override fun removeAllListeners() { - TODO("Not yet implemented") //todo js doesn't support this? + TODO("Not yet implemented") // todo js doesn't support this? } override fun subscribe(cursor: SubscriptionCursor) { // todo use cursor @@ -65,5 +64,4 @@ class SubscriptionImpl(private val jsSubscription: dynamic) : Subscription { override var onFile: ((PNFileEventResult) -> Unit)? get() = TODO("Not yet implemented") set(value) {} - } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionSetImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionSetImpl.kt index a5a5f2ef8..a04f71935 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionSetImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/internal/v2/subscriptions/SubscriptionSetImpl.kt @@ -74,4 +74,4 @@ class SubscriptionSetImpl(private val jsSubscriptionSet: dynamic) : Subscription override var onFile: ((PNFileEventResult) -> Unit)? get() = TODO("Not yet implemented") set(value) {} -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt index 793464383..a0f6d766d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/abstractions.js.kt @@ -2,8 +2,8 @@ package com.pubnub.kmp actual typealias CustomObject = CustomObjectImpl -class CustomObjectImpl(map: Map = emptyMap()) : Map by map +class CustomObjectImpl(map: Map = emptyMap()) : Map by map actual abstract class Uploadable(val fileInput: Any) -class UploadableImpl(fileInput: Any): Uploadable(fileInput) \ No newline at end of file +class UploadableImpl(fileInput: Any) : Uploadable(fileInput) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/converters.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/converters.js.kt index 68d3b5645..5f2a6c5c5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/converters.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/converters.js.kt @@ -81,6 +81,7 @@ internal fun ManageMembershipsResponse.toPNChannelMembershipArrayResult() = PNCh internal fun ObjectsResponse.toPNUUIDMetadataResult() = PNUUIDMetadataResult(status.toInt(), data.toPNUUIDMetadata()) + internal fun PubNub.UUIDMetadataObject.toPNUUIDMetadata() = PNUUIDMetadata( id, name, externalId, profileUrl, email, custom?.toMap(), updated, eTag, type, status ) @@ -93,4 +94,4 @@ internal fun PubNub.MessageAction.toMessageAction() = ).apply { this.actionTimetoken = this@toMessageAction.actionTimetoken.toLong() this.uuid = this@toMessageAction.uuid - } \ No newline at end of file + } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt index fbc309196..dcd6d45cd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt @@ -42,22 +42,24 @@ actual fun createEventListener( val listener = object : PubNubJs.ListenerParameters, EventListener { override val message: (PubNubJs.MessageEvent) -> Unit = { messageEvent -> onMessage( - pubnub, PNMessageResult( + pubnub, + PNMessageResult( BasePubSubResult( messageEvent.channel, messageEvent.subscription, messageEvent.timetoken.toLong(), - JsonElementImpl(messageEvent.userMetadata), + messageEvent.userMetadata?.let { JsonElementImpl(it) }, messageEvent.publisher ), JsonElementImpl(messageEvent.message), - null //TODO kmp error + null // TODO kmp error ) ) } override val presence: ((presenceEvent: PubNubJs.PresenceEvent) -> Unit) = { presenceEvent -> onPresence( - pubnub, PNPresenceEventResult( + pubnub, + PNPresenceEventResult( presenceEvent.action, presenceEvent.uuid, presenceEvent.timestamp.toLong(), @@ -68,11 +70,11 @@ actual fun createEventListener( presenceEvent.timetoken.toLong(), ) ) - } override val signal: ((signalEvent: PubNubJs.SignalEvent) -> Unit) = { signalEvent -> onSignal( - pubnub, PNSignalResult( + pubnub, + PNSignalResult( BasePubSubResult( signalEvent.channel, signalEvent.subscription, @@ -87,27 +89,31 @@ actual fun createEventListener( override val messageAction: ((messageActionEvent: PubNubJs.MessageActionEvent) -> Unit) = { messageActionEvent -> - onMessageAction(pubnub, PNMessageActionResult( - BasePubSubResult( - messageActionEvent.channel, - messageActionEvent.subscription, - messageActionEvent.timetoken.toLong(), - null, - messageActionEvent.publisher - ), - messageActionEvent.event, - PNMessageAction( - messageActionEvent.data.type, - messageActionEvent.data.value, - messageActionEvent.data.messageTimetoken.toLong() - ).apply { - actionTimetoken = messageActionEvent.data.messageTimetoken.toLong() - } - )) + onMessageAction( + pubnub, + PNMessageActionResult( + BasePubSubResult( + messageActionEvent.channel, + messageActionEvent.subscription, + messageActionEvent.timetoken.toLong(), + null, + messageActionEvent.publisher + ), + messageActionEvent.event, + PNMessageAction( + messageActionEvent.data.type, + messageActionEvent.data.value, + messageActionEvent.data.messageTimetoken.toLong() + ).apply { + actionTimetoken = messageActionEvent.data.messageTimetoken.toLong() + } + ) + ) } override val file: ((fileEvent: PubNubJs.FileEvent) -> Unit) = { fileEvent -> onFile( - pubnub, PNFileEventResult( + pubnub, + PNFileEventResult( fileEvent.channel, fileEvent.timetoken.toLong(), fileEvent.publisher, @@ -121,80 +127,83 @@ actual fun createEventListener( } override val objects = { event: PubNubJs.BaseObjectsEvent -> val eventAndType = event.message.event to event.message.type - onObjects(pubnub, PNObjectEventResult( - BasePubSubResult( - event.channel, - event.subscription, - event.timetoken.toLong(), - null, - event.publisher - ), - when (eventAndType) { - "set" to "channel" -> PNSetChannelMetadataEventMessage( - event.message.source, - event.message.version, - event.message.event, - event.message.type, - event.message.data.unsafeCast().toChannelMetadata() - ) - - "set" to "uuid" -> PNSetUUIDMetadataEventMessage( - event.message.source, - event.message.version, - event.message.event, - event.message.type, - event.message.data.unsafeCast().toPNUUIDMetadata() - ) - - "set" to "membership" -> event.message.data.unsafeCast().let { - PNSetMembershipEventMessage( + onObjects( + pubnub, + PNObjectEventResult( + BasePubSubResult( + event.channel, + event.subscription, + event.timetoken.toLong(), + null, + event.publisher + ), + when (eventAndType) { + "set" to "channel" -> PNSetChannelMetadataEventMessage( event.message.source, event.message.version, event.message.event, event.message.type, - PNSetMembershipEvent( - it.channel.id, - it.uuid.id, - it.custom?.toMap(), - it.eTag, - it.updated, - null //todo missing - ) + event.message.data.unsafeCast().toChannelMetadata() ) - } - - "delete" to "channel" -> PNDeleteChannelMetadataEventMessage( - event.message.source, - event.message.version, - event.message.event, - event.message.type, - event.message.data.asDynamic().id - ) - "delete" to "uuid" -> PNDeleteUUIDMetadataEventMessage( - event.message.source, - event.message.version, - event.message.event, - event.message.type, - event.message.data.asDynamic().id - ) + "set" to "uuid" -> PNSetUUIDMetadataEventMessage( + event.message.source, + event.message.version, + event.message.event, + event.message.type, + event.message.data.unsafeCast().toPNUUIDMetadata() + ) - "delete" to "membership" -> PNDeleteMembershipEventMessage( - event.message.source, - event.message.version, - event.message.event, - event.message.type, - event.message.data.unsafeCast().let { - PNDeleteMembershipEvent( - it.channel.id, - it.uuid.id + "set" to "membership" -> event.message.data.unsafeCast().let { + PNSetMembershipEventMessage( + event.message.source, + event.message.version, + event.message.event, + event.message.type, + PNSetMembershipEvent( + it.channel.id, + it.uuid.id, + it.custom?.toMap(), + it.eTag, + it.updated, + null // todo missing + ) ) } - ) - else -> throw IllegalStateException("Bad object event") - } - )) + "delete" to "channel" -> PNDeleteChannelMetadataEventMessage( + event.message.source, + event.message.version, + event.message.event, + event.message.type, + event.message.data.asDynamic().id + ) + + "delete" to "uuid" -> PNDeleteUUIDMetadataEventMessage( + event.message.source, + event.message.version, + event.message.event, + event.message.type, + event.message.data.asDynamic().id + ) + + "delete" to "membership" -> PNDeleteMembershipEventMessage( + event.message.source, + event.message.version, + event.message.event, + event.message.type, + event.message.data.unsafeCast().let { + PNDeleteMembershipEvent( + it.channel.id, + it.uuid.id + ) + } + ) + + else -> throw IllegalStateException("Bad object event") + } + ) + ) } } return listener @@ -207,13 +216,14 @@ actual fun createStatusListener( val listener = object : PubNubJs.StatusListenerParameters, StatusListener { override val status: ((statusEvent: PubNubJs.StatusEvent) -> Unit) = { statusEvent -> val category = try { - enumValueOf(statusEvent.category) //TODO parse category + enumValueOf(statusEvent.category) // TODO parse category } catch (e: Exception) { null } if (category != null) { onStatus( - pubnub, PNStatus( + pubnub, + PNStatus( category, null, statusEvent.currentTimetoken.toString().toLongOrNull(), @@ -229,4 +239,4 @@ actual fun createStatusListener( actual fun createCustomObject(map: Map): CustomObject { return CustomObjectImpl(map) -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsTest/kotlin/com/pubnub/kmp/platform.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsTest/kotlin/com/pubnub/kmp/platform.js.kt index b36e00b7b..090049c8a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsTest/kotlin/com/pubnub/kmp/platform.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsTest/kotlin/com/pubnub/kmp/platform.js.kt @@ -1,3 +1,3 @@ package com.pubnub.kmp -internal actual val PLATFORM: String = "JS" \ No newline at end of file +internal actual val PLATFORM: String = "JS" diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/Endpoint.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/Endpoint.kt index dc0945516..d2a562856 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/Endpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/Endpoint.kt @@ -31,4 +31,3 @@ interface Endpoint : ExtendedRemoteAction { */ fun overrideConfiguration(configuration: PNConfiguration): Endpoint } - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index e53791e34..b751c202a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -93,7 +93,8 @@ interface PubNub : ).getConstructor(com.pubnub.api.v2.PNConfiguration::class.java).newInstance(configuration) as PubNub } - @Deprecated(message = "Use `create` with the new PNConfiguration.Builder instead", + @Deprecated( + message = "Use `create` with the new PNConfiguration.Builder instead", replaceWith = ReplaceWith("create(userId, subscribeKey, builder)") ) fun create( @@ -118,7 +119,6 @@ interface PubNub : ) as PubNub } - /** * Generates random UUID to use. You should set a unique UUID to identify the user or the device * that connects to PubNub. @@ -191,7 +191,7 @@ interface PubNub : channel: String, message: Any, meta: Any?, - shouldStore: Boolean?, + shouldStore: Boolean, usePost: Boolean, replicate: Boolean, ttl: Int?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/callbacks/SubscribeCallback.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/callbacks/SubscribeCallback.kt index 8c52c47b4..1278683ea 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/callbacks/SubscribeCallback.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/callbacks/SubscribeCallback.kt @@ -9,4 +9,4 @@ import com.pubnub.api.v2.callbacks.StatusListener * * Setting explicit [StatusListener] and/or [EventListener] should be preferred. */ -abstract class SubscribeCallback : StatusListener, EventListener \ No newline at end of file +abstract class SubscribeCallback : StatusListener, EventListener diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt index 779ed51de..1244acdb8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.kt @@ -6,8 +6,7 @@ import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResul /** * @see [PubNub.removeMessageAction] */ -actual interface RemoveMessageAction : - Endpoint { +actual interface RemoveMessageAction : Endpoint { val channel: String val messageTimetoken: Long val actionTimetoken: Long diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt index 232f243c8..17b9ba60b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.kt @@ -6,5 +6,4 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResu /** * @see [PubNub.getAllChannelMetadata] */ -actual interface GetAllChannelMetadata : - Endpoint +actual interface GetAllChannelMetadata : Endpoint diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt index d53235e0d..f378ed295 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt @@ -14,8 +14,12 @@ actual fun createPNConfiguration( return PNConfiguration.builder(userId, subscribeKey) { this.publishKey = publishKey this.secretKey = secretKey.orEmpty() - this.logVerbosity = if (logVerbosity) PNLogVerbosity.BODY else PNLogVerbosity.NONE + this.logVerbosity = if (logVerbosity) { + PNLogVerbosity.BODY + } else { + PNLogVerbosity.NONE + } }.build() } -actual typealias CryptoModule = CryptoModule \ No newline at end of file +actual typealias CryptoModule = CryptoModule diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt index ef5cd4a5d..edcf25483 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt @@ -85,4 +85,4 @@ actual interface EventListener : BaseEventListener, Listener { pubnub: PubNub, result: PNFileEventResult, ) {} -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt index 03733307d..519f561f0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt @@ -27,4 +27,4 @@ actual interface StatusListener : BaseStatusListener, Listener { pubnub: PubNub, status: PNStatus, ) -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt index 75382b86b..6cf253074 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/abstractions.jvm.kt @@ -4,4 +4,4 @@ import java.io.InputStream actual typealias CustomObject = Any -actual typealias Uploadable = InputStream \ No newline at end of file +actual typealias Uploadable = InputStream diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt index d0fa7244d..b0daa24f0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt @@ -1,5 +1,6 @@ package com.pubnub.kmp +import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult @@ -10,7 +11,6 @@ import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.api.PubNub import com.pubnub.kmp.PubNub as PubNubKmp actual fun createPubNub(config: PNConfiguration): PubNubKmp { @@ -66,4 +66,4 @@ actual fun createStatusListener( actual fun createCustomObject(map: Map): CustomObject { return map -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmTest/kotlin/com/pubnub/kmp/platform.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmTest/kotlin/com/pubnub/kmp/platform.jvm.kt index cf80b6fd7..61613c8f8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmTest/kotlin/com/pubnub/kmp/platform.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmTest/kotlin/com/pubnub/kmp/platform.jvm.kt @@ -1,3 +1,3 @@ package com.pubnub.kmp -internal actual val PLATFORM: String = "JVM" \ No newline at end of file +internal actual val PLATFORM: String = "JVM" diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt index 5adbe8c01..05ce4e890 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt @@ -265,7 +265,7 @@ class PubNubImpl( channel: String, message: Any, meta: Any?, - shouldStore: Boolean?, + shouldStore: Boolean, usePost: Boolean, replicate: Boolean, ttl: Int?, diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt index a409a0ad3..56df3191c 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt @@ -23,7 +23,7 @@ class ChannelImpl(pubnub: PubNubImpl, channelName: ChannelName) : override fun publish( message: Any, meta: Any?, - shouldStore: Boolean?, + shouldStore: Boolean, usePost: Boolean, replicate: Boolean, ttl: Int? diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts index 4f59d5965..2d4e701ec 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -56,7 +56,6 @@ kotlin { // } } - // targets.withType { // if (konanTarget.family.isAppleFamily) { // binaries.withType { @@ -90,5 +89,4 @@ kotlin { buildConfigField(Type.STRING, "pamSecKey", testProps.getProperty("pamSecKey")) } } - -} \ No newline at end of file +} diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt index ee23a7fce..eb78b2a58 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt @@ -15,9 +15,12 @@ import com.pubnub.kmp.createEventListener import com.pubnub.kmp.createPubNub import com.pubnub.kmp.createStatusListener import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.channels.Channel +import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.suspendCancellableCoroutine +import kotlinx.coroutines.withContext import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.test.AfterTest @@ -26,7 +29,6 @@ import kotlin.test.assertTrue import kotlin.time.Duration.Companion.seconds abstract class BaseIntegrationTest { - val defaultTimeout = 10.seconds lateinit var config: PNConfiguration @@ -34,12 +36,11 @@ abstract class BaseIntegrationTest { lateinit var pubnub: PubNub lateinit var pubnubPam: PubNub - @BeforeTest open fun before() { config = createPNConfiguration(UserId(randomString()), Keys.subKey, Keys.pubKey, logVerbosity = true) pubnub = createPubNub(config) - configPam = createPNConfiguration(UserId(randomString()), Keys.pamSubKey, Keys.pamPubKey, Keys.pamSecKey) + configPam = createPNConfiguration(UserId(randomString()), Keys.pamSubKey, Keys.pamPubKey, Keys.pamSecKey, logVerbosity = true) pubnubPam = createPubNub(configPam) } @@ -52,17 +53,22 @@ abstract class BaseIntegrationTest { } } -suspend fun PNFuture.await() = suspendCancellableCoroutine { cont -> - async { result -> - result.onSuccess { - cont.resume(it) - }.onFailure { - cont.resumeWithException(it) +suspend fun PNFuture.await(): T { + val t = suspendCancellableCoroutine { cont -> + async { result -> + result.onSuccess { + cont.resume(it) + }.onFailure { + cont.resumeWithException(it) + } } } + withContext(Dispatchers.Default) { + delay(100) + } + return t } - class PubNubTest( private val pubNub: PubNub, private val withPresenceOverride: Boolean, @@ -118,8 +124,9 @@ class PubNubTest( suspend fun com.pubnub.api.v2.entities.Channel.awaitSubscribe(options: SubscriptionOptions = EmptyOptions) = suspendCancellableCoroutine { cont -> val subscription = subscription(options) val statusListener = createStatusListener(pubNub) { _, pnStatus -> - if ((pnStatus.category == PNStatusCategory.PNConnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged) - && pnStatus.affectedChannels.contains(name)) { + if ((pnStatus.category == PNStatusCategory.PNConnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged) && + pnStatus.affectedChannels.contains(name) + ) { cont.resume(subscription) } if (pnStatus.category == PNStatusCategory.PNUnexpectedDisconnectCategory || pnStatus.category == PNStatusCategory.PNConnectionError) { @@ -142,8 +149,8 @@ class PubNubTest( } ) = suspendCancellableCoroutine { cont -> val statusListener = createStatusListener(pubNub) { _, pnStatus -> - if ((pnStatus.category == PNStatusCategory.PNConnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged) - && pnStatus.affectedChannels.containsAll(channels) && pnStatus.affectedChannelGroups.containsAll( + if ((pnStatus.category == PNStatusCategory.PNConnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged) && + pnStatus.affectedChannels.containsAll(channels) && pnStatus.affectedChannelGroups.containsAll( channelGroups ) ) { @@ -185,8 +192,8 @@ class PubNubTest( withPresence: Boolean = false ) = suspendCancellableCoroutine { cont -> val statusListener = createStatusListener(pubNub) { _, pnStatus -> - if (pnStatus.category == PNStatusCategory.PNDisconnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged - && pnStatus.affectedChannels.containsAll(channels) && pnStatus.affectedChannelGroups.containsAll( + if (pnStatus.category == PNStatusCategory.PNDisconnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged && + pnStatus.affectedChannels.containsAll(channels) && pnStatus.affectedChannelGroups.containsAll( channelGroups ) ) { @@ -261,4 +268,4 @@ suspend fun PubNub.test( } } -fun randomString() = (0..6).map { "abcdefghijklmnopqrstuvw".random() }.joinToString("") \ No newline at end of file +fun randomString() = (0..6).map { "abcdefghijklmnopqrstuvw".random() }.joinToString("") diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt index 4a317db8c..94b0b93bd 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt @@ -1,1177 +1,509 @@ -//package com.pubnub.test -// -//import com.pubnub.api.JsonElement -//import com.pubnub.api.PubNub -//import com.pubnub.api.asMap -//import com.pubnub.api.callbacks.Listener -//import com.pubnub.api.endpoints.DeleteMessages -//import com.pubnub.api.endpoints.FetchMessages -//import com.pubnub.api.endpoints.MessageCounts -//import com.pubnub.api.endpoints.Time -//import com.pubnub.api.endpoints.access.GrantToken -//import com.pubnub.api.endpoints.access.RevokeToken -//import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup -//import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup -//import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup -//import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup -//import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup -//import com.pubnub.api.endpoints.files.DeleteFile -//import com.pubnub.api.endpoints.files.GetFileUrl -//import com.pubnub.api.endpoints.files.ListFiles -//import com.pubnub.api.endpoints.files.PublishFileMessage -//import com.pubnub.api.endpoints.message_actions.AddMessageAction -//import com.pubnub.api.endpoints.message_actions.GetMessageActions -//import com.pubnub.api.endpoints.message_actions.RemoveMessageAction -//import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata -//import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata -//import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata -//import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata -//import com.pubnub.api.endpoints.objects.member.GetChannelMembers -//import com.pubnub.api.endpoints.objects.member.ManageChannelMembers -//import com.pubnub.api.endpoints.objects.membership.GetMemberships -//import com.pubnub.api.endpoints.objects.membership.ManageMemberships -//import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata -//import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata -//import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata -//import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata -//import com.pubnub.api.endpoints.presence.GetState -//import com.pubnub.api.endpoints.presence.HereNow -//import com.pubnub.api.endpoints.presence.SetState -//import com.pubnub.api.endpoints.presence.WhereNow -//import com.pubnub.api.endpoints.pubsub.Publish -//import com.pubnub.api.endpoints.pubsub.Signal -//import com.pubnub.api.endpoints.push.AddChannelsToPush -//import com.pubnub.api.endpoints.push.ListPushProvisions -//import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice -//import com.pubnub.api.endpoints.push.RemoveChannelsFromPush -//import com.pubnub.api.enums.PNPushEnvironment -//import com.pubnub.api.enums.PNPushType -//import com.pubnub.api.models.consumer.PNBoundedPage -//import com.pubnub.api.models.consumer.PNPublishResult -//import com.pubnub.api.models.consumer.PNStatus -//import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant -//import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant -//import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant -//import com.pubnub.api.models.consumer.message_actions.PNMessageAction -//import com.pubnub.api.models.consumer.objects.PNKey -//import com.pubnub.api.models.consumer.objects.PNMemberKey -//import com.pubnub.api.models.consumer.objects.PNMembershipKey -//import com.pubnub.api.models.consumer.objects.PNPage -//import com.pubnub.api.models.consumer.objects.PNSortKey -//import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata -//import com.pubnub.api.models.consumer.objects.member.MemberInput -//import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel -//import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput -//import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -//import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -//import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -//import com.pubnub.api.models.consumer.pubsub.BasePubSubResult -//import com.pubnub.api.models.consumer.pubsub.PNEvent -//import com.pubnub.api.models.consumer.pubsub.PNMessageResult -//import com.pubnub.api.v2.PNConfiguration -//import com.pubnub.api.v2.callbacks.Consumer -//import com.pubnub.api.v2.callbacks.EventListener -//import com.pubnub.api.v2.callbacks.Result -//import com.pubnub.api.v2.callbacks.StatusListener -//import com.pubnub.kmp.CustomObject -//import kotlinx.coroutines.CoroutineScope -//import kotlinx.coroutines.SupervisorJob -//import kotlinx.coroutines.flow.MutableSharedFlow -//import kotlinx.coroutines.flow.MutableStateFlow -//import kotlinx.coroutines.flow.collectLatest -//import kotlinx.coroutines.flow.combine -//import kotlinx.coroutines.flow.mapNotNull -//import kotlinx.coroutines.flow.scan -//import kotlinx.coroutines.flow.transformLatest -//import kotlinx.coroutines.flow.update -//import kotlinx.coroutines.launch -//import kotlinx.datetime.Clock -//import kotlinx.datetime.Instant -//import kotlin.time.Duration.Companion.minutes -// -// -//expect fun EventListener.emit(pubnub: PubNub, event: PNEvent) -//expect fun StatusListener.emit(pubnub: PubNub, status: PNStatus) -//expect fun Any.toJsonElement(): JsonElement -// -////class FakePubNub(override val configuration: PNConfiguration) : PubNub { -//// -//// val scope = CoroutineScope(SupervisorJob()) -//// -//// fun Long.toEpochSeconds() = this / 10000000 -//// fun generateTimetoken() = Clock.System.now().toEpochMilliseconds() * 10000 -//// -//// val events = MutableSharedFlow(100, 100) -//// val subscriptionStream = events.mapNotNull { -//// val tt = it.timetoken ?: return@mapNotNull null -//// if (Clock.System.now() < Instant.fromEpochSeconds(tt.toEpochSeconds()) - 10.minutes) { -//// it -//// } else { -//// null -//// } -//// } -//// -//// private val subscribedChannelAndGroups = MutableStateFlow, Set>>(Pair(emptySet(), emptySet())) -//// private val timetoken = MutableSharedFlow() -//// -//// init { -//// scope.launch { -//// subscribedChannelAndGroups.scan(Pair(setOf(), setOf())) { last: Pair, Set>, next: Pair, Set> -> -//// if (last.first.isEmpty() && last.second.isEmpty() && (next.first.isNotEmpty() || next.second.isNotEmpty())) { -//// //emit connected -//// } else if (next.first.isEmpty() && next.second.isEmpty() && (last.first.isNotEmpty() || last.second.isNotEmpty())) { -//// timetoken.emit(0) -//// //emit disconnected -//// } else { -//// //emit changed -//// } -//// next -//// }.collectLatest { subscriptions: Pair, Set> -> -//// events.collect { event: PNEvent -> -//// if (event.channel in subscriptions.first) { -//// listeners.value.filterIsInstance().forEach { -//// it.emit(this@FakePubNub, event) -//// } -//// } -//// } -//// } -//// } -//// } -//// -//// -//// val messages: MutableList = mutableListOf() -//// val userMetadata: MutableMap = mutableMapOf() -//// val channelMetadata: MutableMap = mutableMapOf() -//// -//// private val listeners = MutableStateFlow(setOf()) -//// -//// override fun addListener(listener: EventListener) { -//// listeners.update { previousSet -> -//// buildSet { -//// addAll(previousSet) -//// add(listener) -//// } -//// } -//// } -//// -//// override fun addListener(listener: StatusListener) { -//// listeners.update { previousSet -> -//// buildSet { -//// addAll(previousSet) -//// add(listener) -//// } -//// } -//// } -//// -//// override fun removeListener(listener: Listener) { -//// listeners.update { previousSet -> -//// buildSet { -//// addAll(previousSet) -//// remove(listener) -//// } -//// } -//// } -//// -//// override fun removeAllListeners() { -//// listeners.update { -//// emptySet() -//// } -//// } -//// -//// override fun publish( -//// channel: String, -//// message: Any, -//// meta: Any?, -//// shouldStore: Boolean?, -//// usePost: Boolean, -//// replicate: Boolean, -//// ttl: Int? -//// ): Publish { -//// return object : Publish { -//// override fun async(callback: Consumer>) { -//// scope.launch { -//// events.emit(PNMessageResult( -//// BasePubSubResult( -//// channel, -//// null, -//// generateTimetoken(), -//// meta?.toJsonElement(), -//// configuration.userId.value -//// ), message.toJsonElement(), null -//// )) -//// } -//// } -//// } -//// } -//// -//// override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { -//// TODO("Not yet implemented") -//// } -//// -//// override fun signal(channel: String, message: Any): Signal { -//// TODO("Not yet implemented") -//// } -//// -//// override fun getSubscribedChannels(): List { -//// return subscribedChannelAndGroups.value.first.toList() -//// } -//// -//// override fun getSubscribedChannelGroups(): List { -//// return subscribedChannelAndGroups.value.second.toList() -//// } -//// -//// override fun addPushNotificationsOnChannels( -//// pushType: PNPushType, -//// channels: List, -//// deviceId: String, -//// topic: String?, -//// environment: PNPushEnvironment -//// ): AddChannelsToPush { -//// TODO("Not yet implemented") -//// } -//// -//// override fun auditPushChannelProvisions( -//// pushType: PNPushType, -//// deviceId: String, -//// topic: String?, -//// environment: PNPushEnvironment -//// ): ListPushProvisions { -//// TODO("Not yet implemented") -//// } -//// -//// override fun removePushNotificationsFromChannels( -//// pushType: PNPushType, -//// channels: List, -//// deviceId: String, -//// topic: String?, -//// environment: PNPushEnvironment -//// ): RemoveChannelsFromPush { -//// TODO("Not yet implemented") -//// } -//// -//// override fun removeAllPushNotificationsFromDeviceWithPushToken( -//// pushType: PNPushType, -//// deviceId: String, -//// topic: String?, -//// environment: PNPushEnvironment -//// ): RemoveAllPushChannelsForDevice { -//// TODO("Not yet implemented") -//// } -//// -//// override fun fetchMessages( -//// channels: List, -//// page: PNBoundedPage, -//// includeUUID: Boolean, -//// includeMeta: Boolean, -//// includeMessageActions: Boolean, -//// includeMessageType: Boolean -//// ): FetchMessages { -//// TODO("Not yet implemented") -//// } -//// -//// override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { -//// TODO("Not yet implemented") -//// } -//// -//// override fun messageCounts(channels: List, channelsTimetoken: List): MessageCounts { -//// TODO("Not yet implemented") -//// } -//// -//// override fun hereNow( -//// channels: List, -//// channelGroups: List, -//// includeState: Boolean, -//// includeUUIDs: Boolean -//// ): HereNow { -//// TODO("Not yet implemented") -//// } -//// -//// override fun whereNow(uuid: String): WhereNow { -//// TODO("Not yet implemented") -//// } -//// -//// override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { -//// TODO("Not yet implemented") -//// } -//// -//// override fun presence(channels: List, channelGroups: List, connected: Boolean) { -//// TODO("Not yet implemented") -//// } -//// -//// override fun addMessageAction(channel: String, messageAction: PNMessageAction): AddMessageAction { -//// TODO("Not yet implemented") -//// } -//// -//// override fun removeMessageAction( -//// channel: String, -//// messageTimetoken: Long, -//// actionTimetoken: Long -//// ): RemoveMessageAction { -//// TODO("Not yet implemented") -//// } -//// -//// override fun getMessageActions(channel: String, page: PNBoundedPage): GetMessageActions { -//// TODO("Not yet implemented") -//// } -//// -//// override fun addChannelsToChannelGroup(channels: List, channelGroup: String): AddChannelChannelGroup { -//// TODO("Not yet implemented") -//// } -//// -//// override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { -//// TODO("Not yet implemented") -//// } -//// -//// override fun removeChannelsFromChannelGroup( -//// channels: List, -//// channelGroup: String -//// ): RemoveChannelChannelGroup { -//// TODO("Not yet implemented") -//// } -//// -//// override fun listAllChannelGroups(): ListAllChannelGroup { -//// TODO("Not yet implemented") -//// } -//// -//// override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { -//// TODO("Not yet implemented") -//// } -//// -//// override fun revokeToken(token: String): RevokeToken { -//// TODO("Not yet implemented") -//// } -//// -//// override fun time(): Time { -//// TODO("Not yet implemented") -//// } -//// -//// override fun getAllChannelMetadata( -//// limit: Int?, -//// page: PNPage?, -//// filter: String?, -//// sort: Collection>, -//// includeCount: Boolean, -//// includeCustom: Boolean -//// ): GetAllChannelMetadata { -//// TODO("Not yet implemented") -//// } -//// -//// override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { -//// TODO("Not yet implemented") -//// } -//// -//// override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { -//// TODO("Not yet implemented") -//// } -//// -//// override fun getAllUUIDMetadata( -//// limit: Int?, -//// page: PNPage?, -//// filter: String?, -//// sort: Collection>, -//// includeCount: Boolean, -//// includeCustom: Boolean -//// ): GetAllUUIDMetadata { -//// TODO("Not yet implemented") -//// } -//// -//// override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { -//// TODO("Not yet implemented") -//// } -//// -//// override fun setUUIDMetadata( -//// uuid: String?, -//// name: String?, -//// externalId: String?, -//// profileUrl: String?, -//// email: String?, -//// custom: CustomObject?, -//// includeCustom: Boolean, -//// type: String?, -//// status: String? -//// ): SetUUIDMetadata { -//// val actualUuid = uuid ?: configuration.userId.value -//// val result = userMetadata.compute(actualUuid) { a: String, b: PNUUIDMetadata? -> -//// PNUUIDMetadata( -//// actualUuid, -//// name ?: b?.name, -//// externalId ?: b?.externalId, -//// profileUrl ?: b?.profileUrl, -//// email ?: b?.email, -//// custom?.toJsonElement()?.asMap() ?: b?.custom, -//// Clock.System.now().toString(), -//// null, -//// type ?: b?.type, -//// status ?: b?.status -//// ) -//// } -//// return object : SetUUIDMetadata { -//// override fun async(callback: Consumer>) { -//// callback.accept(Result.success(PNUUIDMetadataResult( -//// 200, -//// if (!includeCustom) { -//// result?.copy(custom = null) -//// } else { -//// result -//// } -//// ) -//// )) -//// } -//// } -//// } -//// -//// override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { -//// TODO("Not yet implemented") -//// } -//// -//// override fun getMemberships( -//// uuid: String?, -//// limit: Int?, -//// page: PNPage?, -//// filter: String?, -//// sort: Collection>, -//// includeCount: Boolean, -//// includeCustom: Boolean, -//// includeChannelDetails: PNChannelDetailsLevel? -//// ): GetMemberships { -//// TODO("Not yet implemented") -//// } -//// -//// override fun setMemberships( -//// channels: List, -//// uuid: String?, -//// limit: Int?, -//// page: PNPage?, -//// filter: String?, -//// sort: Collection>, -//// includeCount: Boolean, -//// includeCustom: Boolean, -//// includeChannelDetails: PNChannelDetailsLevel? -//// ): ManageMemberships { -//// TODO("Not yet implemented") -//// } -//// -//// override fun removeMemberships( -//// channels: List, -//// uuid: String?, -//// limit: Int?, -//// page: PNPage?, -//// filter: String?, -//// sort: Collection>, -//// includeCount: Boolean, -//// includeCustom: Boolean, -//// includeChannelDetails: PNChannelDetailsLevel? -//// ): ManageMemberships { -//// TODO("Not yet implemented") -//// } -//// -//// override fun getChannelMembers( -//// channel: String, -//// limit: Int?, -//// page: PNPage?, -//// filter: String?, -//// sort: Collection>, -//// includeCount: Boolean, -//// includeCustom: Boolean, -//// includeUUIDDetails: PNUUIDDetailsLevel? -//// ): GetChannelMembers { -//// TODO("Not yet implemented") -//// } -//// -//// override fun setChannelMembers( -//// channel: String, -//// uuids: List, -//// limit: Int?, -//// page: PNPage?, -//// filter: String?, -//// sort: Collection>, -//// includeCount: Boolean, -//// includeCustom: Boolean, -//// includeUUIDDetails: PNUUIDDetailsLevel? -//// ): ManageChannelMembers { -//// TODO("Not yet implemented") -//// } -//// -//// override fun removeChannelMembers( -//// channel: String, -//// uuids: List, -//// limit: Int?, -//// page: PNPage?, -//// filter: String?, -//// sort: Collection>, -//// includeCount: Boolean, -//// includeCustom: Boolean, -//// includeUUIDDetails: PNUUIDDetailsLevel? -//// ): ManageChannelMembers { -//// TODO("Not yet implemented") -//// } -//// -//// override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { -//// TODO("Not yet implemented") -//// } -//// -//// override fun getFileUrl(channel: String, fileName: String, fileId: String): GetFileUrl { -//// TODO("Not yet implemented") -//// } -//// -//// override fun deleteFile(channel: String, fileName: String, fileId: String): DeleteFile { -//// TODO("Not yet implemented") -//// } -//// -//// override fun publishFileMessage( -//// channel: String, -//// fileName: String, -//// fileId: String, -//// message: Any?, -//// meta: Any?, -//// ttl: Int?, -//// shouldStore: Boolean? -//// ): PublishFileMessage { -//// TODO("Not yet implemented") -//// } -//// -//// override fun subscribe( -//// channels: List, -//// channelGroups: List, -//// withPresence: Boolean, -//// withTimetoken: Long -//// ) { -//// subscribedChannelAndGroups.update { existingSubscriptions -> -//// Pair( -//// buildSet { -//// addAll(existingSubscriptions.first) -//// addAll(channels) -//// if (withPresence) { -//// addAll(channels.map { "${it}-pnpres" }) -//// } -//// }, -//// buildSet { -//// addAll(existingSubscriptions.second) -//// addAll(channelGroups) -//// if (withPresence) { -//// addAll(channelGroups.map { "${it}-pnpres" }) -//// } -//// } -//// ) -//// } -//// } -//// -//// override fun unsubscribe(channels: List, channelGroups: List) { -//// subscribedChannelAndGroups.update { existingSubscriptions -> -//// Pair( -//// buildSet { -//// addAll(existingSubscriptions.first) -//// removeAll(channels.toSet()) -//// removeAll(channels.map { "${it}-pnpres" }.toSet()) -//// }, -//// buildSet { -//// addAll(existingSubscriptions.second) -//// removeAll(channelGroups.toSet()) -//// removeAll(channelGroups.map { "${it}-pnpres" }.toSet()) -//// } -//// ) -//// } -//// } -//// -//// override fun setToken(token: String?) { -//// TODO("Not yet implemented") -//// } -//// -//// override fun setPresenceState(channels: List, channelGroups: List, state: Any): SetState { -//// TODO("Not yet implemented") -//// } -//// -//// override fun grantToken( -//// ttl: Int, -//// meta: CustomObject?, -//// authorizedUUID: String?, -//// channels: List, -//// channelGroups: List, -//// uuids: List -//// ): GrantToken { -//// TODO("Not yet implemented") -//// } -//// -//// override fun setChannelMetadata( -//// channel: String, -//// name: String?, -//// description: String?, -//// custom: CustomObject?, -//// includeCustom: Boolean, -//// type: String?, -//// status: String? -//// ): SetChannelMetadata { -//// TODO("Not yet implemented") -//// } -//// -//// override fun unsubscribeAll() { -//// TODO("Not yet implemented") -//// } -//// -//// override fun destroy() { -//// TODO("Not yet implemented") -//// } -//// -////} -////// -//// -////// -////// /** -////// * Remove a listener. -////// * -////// * @param listener The listener to be removed, previously added with [addListener]. -////// */ -////// override fun removeListener(listener: Listener) { -////// TODO("Not yet implemented") -////// } -////// -////// /** -////// * Removes all listeners. -////// */ -////// override fun removeAllListeners() { -////// TODO("Not yet implemented") -////// } -////// -////// override fun publish( -////// channel: String, -////// message: Any, -////// meta: Any?, -////// shouldStore: Boolean?, -////// usePost: Boolean, -////// replicate: Boolean, -////// ttl: Int? -////// ): Publish { -////// return createEndpoint { -////// val tt = Clock.System.now().toEpochMilliseconds() / 1000 -////// messages.add( -////// PNMessageResult( -////// BasePubSubResult(channel, null, tt, null, configuration.userId.value), -////// message as JsonElement, -////// null -////// ) -////// ) -////// PNPublishResult(tt) -////// } -////// // TODO emit message -////// } -////// -////// -////// override fun fire( -////// channel: String, -////// message: Any, -////// meta: Any?, -////// usePost: Boolean, -////// ttl: Int? -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun signal(channel: String, message: Any): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun getSubscribedChannels(): List { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun getSubscribedChannelGroups(): List { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun addPushNotificationsOnChannels( -////// pushType: PNPushType, -////// channels: List, -////// deviceId: String, -////// topic: String?, -////// environment: PNPushEnvironment -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun auditPushChannelProvisions( -////// pushType: PNPushType, -////// deviceId: String, -////// topic: String?, -////// environment: PNPushEnvironment -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun removePushNotificationsFromChannels( -////// pushType: PNPushType, -////// channels: List, -////// deviceId: String, -////// topic: String?, -////// environment: PNPushEnvironment -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun removeAllPushNotificationsFromDeviceWithPushToken( -////// pushType: PNPushType, -////// deviceId: String, -////// topic: String?, -////// environment: PNPushEnvironment -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun fetchMessages( -////// channels: List, -////// page: PNBoundedPage, -////// includeUUID: Boolean, -////// includeMeta: Boolean, -////// includeMessageActions: Boolean, -////// includeMessageType: Boolean -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun deleteMessages(channels: List, start: Long?, end: Long?): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun messageCounts(channels: List, channelsTimetoken: List): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun hereNow( -////// channels: List, -////// channelGroups: List, -////// includeState: Boolean, -////// includeUUIDs: Boolean -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun whereNow(uuid: String): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun setPresenceState( -////// channels: List, -////// channelGroups: List, -////// state: Any, -////// uuid: String -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun getPresenceState( -////// channels: List, -////// channelGroups: List, -////// uuid: String -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun presence(channels: List, channelGroups: List, connected: Boolean) { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun addMessageAction(channel: String, messageAction: PNMessageAction): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun removeMessageAction( -////// channel: String, -////// messageTimetoken: Long, -////// actionTimetoken: Long -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun getMessageActions(channel: String, page: PNBoundedPage): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun addChannelsToChannelGroup( -////// channels: List, -////// channelGroup: String -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun listChannelsForChannelGroup(channelGroup: String): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun removeChannelsFromChannelGroup( -////// channels: List, -////// channelGroup: String -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun listAllChannelGroups(): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun deleteChannelGroup(channelGroup: String): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun grant( -////// read: Boolean, -////// write: Boolean, -////// manage: Boolean, -////// delete: Boolean, -////// ttl: Int, -////// authKeys: List, -////// channels: List, -////// channelGroups: List, -////// uuids: List -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun grant( -////// read: Boolean, -////// write: Boolean, -////// manage: Boolean, -////// delete: Boolean, -////// get: Boolean, -////// update: Boolean, -////// join: Boolean, -////// ttl: Int, -////// authKeys: List, -////// channels: List, -////// channelGroups: List, -////// uuids: List -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun grantToken( -////// ttl: Int, -////// meta: Any?, -////// authorizedUUID: String?, -////// channels: List, -////// channelGroups: List, -////// uuids: List -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun grantToken( -////// ttl: Int, -////// meta: Any?, -////// authorizedUserId: UserId?, -////// spacesPermissions: List, -////// usersPermissions: List -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun revokeToken(token: String): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun time(): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun getAllChannelMetadata( -////// limit: Int?, -////// page: PNPage?, -////// filter: String?, -////// sort: Collection>, -////// includeCount: Boolean, -////// includeCustom: Boolean -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun getChannelMetadata(channel: String, includeCustom: Boolean): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun setChannelMetadata( -////// channel: String, -////// name: String?, -////// description: String?, -////// custom: Any?, -////// includeCustom: Boolean, -////// type: String?, -////// status: String? -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun removeChannelMetadata(channel: String): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun getAllUUIDMetadata( -////// limit: Int?, -////// page: PNPage?, -////// filter: String?, -////// sort: Collection>, -////// includeCount: Boolean, -////// includeCustom: Boolean -////// ): Endpoint { -////// return createEndpoint { -////// PNUUIDMetadataArrayResult(200, userMetadata.values, userMetadata.size, null, null) -////// } -////// } -////// -////// -////// override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): Endpoint { -////// return createEndpoint { -////// val actualUuid = uuid ?: configuration.userId.value -////// val result = userMetadata[actualUuid] -////// -////// PNUUIDMetadataResult( -////// 200, -////// if (!includeCustom) { -////// result?.copy(custom = null) -////// } else { -////// result -////// } -////// ) -////// } -////// } -////// -////// -////// -////// override fun removeUUIDMetadata(uuid: String?): Endpoint { -////// val actualUuid = uuid ?: configuration.userId.value -////// return createEndpoint { -////// userMetadata.remove(actualUuid) -////// PNRemoveMetadataResult(200) -////// } -////// } -////// -////// override fun getMemberships( -////// uuid: String?, -////// limit: Int?, -////// page: PNPage?, -////// filter: String?, -////// sort: Collection>, -////// includeCount: Boolean, -////// includeCustom: Boolean, -////// includeChannelDetails: PNChannelDetailsLevel? -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun setMemberships( -////// channels: List, -////// uuid: String?, -////// limit: Int?, -////// page: PNPage?, -////// filter: String?, -////// sort: Collection>, -////// includeCount: Boolean, -////// includeCustom: Boolean, -////// includeChannelDetails: PNChannelDetailsLevel? -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun removeMemberships( -////// channels: List, -////// uuid: String?, -////// limit: Int?, -////// page: PNPage?, -////// filter: String?, -////// sort: Collection>, -////// includeCount: Boolean, -////// includeCustom: Boolean, -////// includeChannelDetails: PNChannelDetailsLevel? -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun manageMemberships( -////// channelsToSet: List, -////// channelsToRemove: List, -////// uuid: String?, -////// limit: Int?, -////// page: PNPage?, -////// filter: String?, -////// sort: Collection>, -////// includeCount: Boolean, -////// includeCustom: Boolean, -////// includeChannelDetails: PNChannelDetailsLevel? -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun getChannelMembers( -////// channel: String, -////// limit: Int?, -////// page: PNPage?, -////// filter: String?, -////// sort: Collection>, -////// includeCount: Boolean, -////// includeCustom: Boolean, -////// includeUUIDDetails: PNUUIDDetailsLevel? -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun setChannelMembers( -////// channel: String, -////// uuids: List, -////// limit: Int?, -////// page: PNPage?, -////// filter: String?, -////// sort: Collection>, -////// includeCount: Boolean, -////// includeCustom: Boolean, -////// includeUUIDDetails: PNUUIDDetailsLevel? -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun removeChannelMembers( -////// channel: String, -////// uuids: List, -////// limit: Int?, -////// page: PNPage?, -////// filter: String?, -////// sort: Collection>, -////// includeCount: Boolean, -////// includeCustom: Boolean, -////// includeUUIDDetails: PNUUIDDetailsLevel? -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun manageChannelMembers( -////// channel: String, -////// uuidsToSet: Collection, -////// uuidsToRemove: Collection, -////// limit: Int?, -////// page: PNPage?, -////// filter: String?, -////// sort: Collection>, -////// includeCount: Boolean, -////// includeCustom: Boolean, -////// includeUUIDDetails: PNUUIDDetailsLevel? -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun getFileUrl(channel: String, fileName: String, fileId: String): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun deleteFile(channel: String, fileName: String, fileId: String): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun publishFileMessage( -////// channel: String, -////// fileName: String, -////// fileId: String, -////// message: Any?, -////// meta: Any?, -////// ttl: Int?, -////// shouldStore: Boolean? -////// ): Endpoint { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun subscribe( -////// channels: List, -////// channelGroups: List, -////// withPresence: Boolean, -////// withTimetoken: Long -////// ) { -////// TODO("Not yet implemented") -////// } -////// -////// -////// override fun unsubscribe(channels: List, channelGroups: List) { -////// TODO("Not yet implemented") -////// } -////// -////// override fun setToken(token: String?) { -////// TODO("Not yet implemented") -////// } -////// -////// override fun addListener(listener: EventListener) { -////// TODO("Not yet implemented") -////// } -////// -////// override fun addListener(listener: StatusListener) { -////// TODO("Not yet implemented") -////// } -//////} -////// -////private fun MutableMap.compute( -//// key: K, -//// remappingFunction: (K, V?) -> V -////): V? { -//// val oldValue: V? = get(key) -//// -//// val newValue: V = remappingFunction(key, oldValue) -//// if (newValue == null) { -//// // delete mapping -//// if (oldValue != null || containsKey(key)) { -//// // something to remove -//// remove(key) -//// return null -//// } else { -//// // nothing to do. Leave things as they were. -//// return null -//// } -//// } else { -//// // add or replace old mapping -//// put(key, newValue) -//// return newValue -//// } -////} -//// +package com.pubnub.test + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.endpoints.DeleteMessages +import com.pubnub.api.endpoints.FetchMessages +import com.pubnub.api.endpoints.MessageCounts +import com.pubnub.api.endpoints.Time +import com.pubnub.api.endpoints.access.GrantToken +import com.pubnub.api.endpoints.access.RevokeToken +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.DownloadFile +import com.pubnub.api.endpoints.files.GetFileUrl +import com.pubnub.api.endpoints.files.ListFiles +import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.files.SendFile +import com.pubnub.api.endpoints.message_actions.AddMessageAction +import com.pubnub.api.endpoints.message_actions.GetMessageActions +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +import com.pubnub.api.endpoints.objects.member.GetChannelMembers +import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +import com.pubnub.api.endpoints.objects.membership.GetMemberships +import com.pubnub.api.endpoints.objects.membership.ManageMemberships +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +import com.pubnub.api.endpoints.presence.GetState +import com.pubnub.api.endpoints.presence.HereNow +import com.pubnub.api.endpoints.presence.SetState +import com.pubnub.api.endpoints.presence.WhereNow +import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.endpoints.push.AddChannelsToPush +import com.pubnub.api.endpoints.push.ListPushProvisions +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNMemberKey +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.member.MemberInput +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.api.v2.entities.Channel +import com.pubnub.api.v2.entities.ChannelGroup +import com.pubnub.api.v2.entities.ChannelMetadata +import com.pubnub.api.v2.entities.UserMetadata +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.api.v2.subscriptions.SubscriptionSet +import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.PubNub +import com.pubnub.kmp.Uploadable + +private fun notImplemented(): Nothing = TODO("Not implemented") + +abstract class FakePubNub( + override val configuration: PNConfiguration, + private val addListener: (EventListener) -> Unit = { notImplemented() }, +) : PubNub { + override fun addListener(listener: EventListener) = addListener.invoke(listener) + + override fun addListener(listener: StatusListener) { + TODO("Not yet implemented") + } + + override fun removeListener(listener: Listener) { + TODO("Not yet implemented") + } + + override fun removeAllListeners() { + TODO("Not yet implemented") + } + + override fun publish( + channel: String, + message: Any, + meta: Any?, + shouldStore: Boolean, + usePost: Boolean, + replicate: Boolean, + ttl: Int?, + ): Publish { + TODO("Not yet implemented") + } + + override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { + TODO("Not yet implemented") + } + + override fun signal(channel: String, message: Any): Signal { + TODO("Not yet implemented") + } + + override fun getSubscribedChannels(): List { + TODO("Not yet implemented") + } + + override fun getSubscribedChannelGroups(): List { + TODO("Not yet implemented") + } + + override fun addPushNotificationsOnChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment, + ): AddChannelsToPush { + TODO("Not yet implemented") + } + + override fun auditPushChannelProvisions( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment, + ): ListPushProvisions { + TODO("Not yet implemented") + } + + override fun removePushNotificationsFromChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment, + ): RemoveChannelsFromPush { + TODO("Not yet implemented") + } + + override fun removeAllPushNotificationsFromDeviceWithPushToken( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment, + ): RemoveAllPushChannelsForDevice { + TODO("Not yet implemented") + } + + override fun fetchMessages( + channels: List, + page: PNBoundedPage, + includeUUID: Boolean, + includeMeta: Boolean, + includeMessageActions: Boolean, + includeMessageType: Boolean, + ): FetchMessages { + TODO("Not yet implemented") + } + + override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { + TODO("Not yet implemented") + } + + override fun messageCounts(channels: List, channelsTimetoken: List): MessageCounts { + TODO("Not yet implemented") + } + + override fun hereNow( + channels: List, + channelGroups: List, + includeState: Boolean, + includeUUIDs: Boolean, + ): HereNow { + TODO("Not yet implemented") + } + + override fun whereNow(uuid: String): WhereNow { + TODO("Not yet implemented") + } + + override fun setPresenceState(channels: List, channelGroups: List, state: Any): SetState { + TODO("Not yet implemented") + } + + override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { + TODO("Not yet implemented") + } + + override fun presence(channels: List, channelGroups: List, connected: Boolean) { + TODO("Not yet implemented") + } + + override fun addMessageAction(channel: String, messageAction: PNMessageAction): AddMessageAction { + TODO("Not yet implemented") + } + + override fun removeMessageAction( + channel: String, + messageTimetoken: Long, + actionTimetoken: Long, + ): RemoveMessageAction { + TODO("Not yet implemented") + } + + override fun getMessageActions(channel: String, page: PNBoundedPage): GetMessageActions { + TODO("Not yet implemented") + } + + override fun addChannelsToChannelGroup(channels: List, channelGroup: String): AddChannelChannelGroup { + TODO("Not yet implemented") + } + + override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { + TODO("Not yet implemented") + } + + override fun removeChannelsFromChannelGroup( + channels: List, + channelGroup: String, + ): RemoveChannelChannelGroup { + TODO("Not yet implemented") + } + + override fun listAllChannelGroups(): ListAllChannelGroup { + TODO("Not yet implemented") + } + + override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { + TODO("Not yet implemented") + } + + override fun grantToken( + ttl: Int, + meta: CustomObject?, + authorizedUUID: String?, + channels: List, + channelGroups: List, + uuids: List, + ): GrantToken { + TODO("Not yet implemented") + } + + override fun revokeToken(token: String): RevokeToken { + TODO("Not yet implemented") + } + + override fun time(): Time { + TODO("Not yet implemented") + } + + override fun getAllChannelMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + ): GetAllChannelMetadata { + TODO("Not yet implemented") + } + + override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { + TODO("Not yet implemented") + } + + override fun setChannelMetadata( + channel: String, + name: String?, + description: String?, + custom: CustomObject?, + includeCustom: Boolean, + type: String?, + status: String?, + ): SetChannelMetadata { + TODO("Not yet implemented") + } + + override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { + TODO("Not yet implemented") + } + + override fun getAllUUIDMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + ): GetAllUUIDMetadata { + TODO("Not yet implemented") + } + + override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { + TODO("Not yet implemented") + } + + override fun setUUIDMetadata( + uuid: String?, + name: String?, + externalId: String?, + profileUrl: String?, + email: String?, + custom: CustomObject?, + includeCustom: Boolean, + type: String?, + status: String?, + ): SetUUIDMetadata { + TODO("Not yet implemented") + } + + override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { + TODO("Not yet implemented") + } + + override fun getMemberships( + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, + ): GetMemberships { + TODO("Not yet implemented") + } + + override fun setMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, + ): ManageMemberships { + TODO("Not yet implemented") + } + + override fun removeMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean, + ): ManageMemberships { + TODO("Not yet implemented") + } + + override fun getChannelMembers( + channel: String, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, + ): GetChannelMembers { + TODO("Not yet implemented") + } + + override fun setChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, + ): ManageChannelMembers { + TODO("Not yet implemented") + } + + override fun removeChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean, + ): ManageChannelMembers { + TODO("Not yet implemented") + } + + override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { + TODO("Not yet implemented") + } + + override fun getFileUrl(channel: String, fileName: String, fileId: String): GetFileUrl { + TODO("Not yet implemented") + } + + override fun sendFile( + channel: String, + fileName: String, + inputStream: Uploadable, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, + cipherKey: String?, + ): SendFile { + TODO("Not yet implemented") + } + + override fun downloadFile(channel: String, fileName: String, fileId: String, cipherKey: String?): DownloadFile { + TODO("Not yet implemented") + } + + override fun deleteFile(channel: String, fileName: String, fileId: String): DeleteFile { + TODO("Not yet implemented") + } + + override fun publishFileMessage( + channel: String, + fileName: String, + fileId: String, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, + ): PublishFileMessage { + TODO("Not yet implemented") + } + + override fun subscribe( + channels: List, + channelGroups: List, + withPresence: Boolean, + withTimetoken: Long, + ) { + TODO("Not yet implemented") + } + + override fun unsubscribe(channels: List, channelGroups: List) { + TODO("Not yet implemented") + } + + override fun unsubscribeAll() { + TODO("Not yet implemented") + } + + override fun setToken(token: String?) { + TODO("Not yet implemented") + } + + override fun destroy() { + TODO("Not yet implemented") + } + + override fun channel(name: String): Channel { + TODO("Not yet implemented") + } + + override fun channelGroup(name: String): ChannelGroup { + TODO("Not yet implemented") + } + + override fun channelMetadata(id: String): ChannelMetadata { + TODO("Not yet implemented") + } + + override fun userMetadata(id: String): UserMetadata { + TODO("Not yet implemented") + } + + override fun subscriptionSetOf(subscriptions: Set): SubscriptionSet { + TODO("Not yet implemented") + } + + override fun subscriptionSetOf( + channels: Set, + channelGroups: Set, + options: SubscriptionOptions, + ): SubscriptionSet { + TODO("Not yet implemented") + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt b/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt deleted file mode 100644 index 08292c2d0..000000000 --- a/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/com.pubnub.test/FakePubNub.ios.kt +++ /dev/null @@ -1,39 +0,0 @@ -//package com.pubnub.test -// -//import com.pubnub.api.JsonElement -//import com.pubnub.api.PubNub -//import com.pubnub.api.models.consumer.PNStatus -//import com.pubnub.api.models.consumer.pubsub.PNEvent -//import com.pubnub.api.models.consumer.pubsub.PNMessageResult -//import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -//import com.pubnub.api.models.consumer.pubsub.PNSignalResult -//import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -//import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -//import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult -//import com.pubnub.api.v2.callbacks.EventListener -//import com.pubnub.api.v2.callbacks.StatusListener -// -//actual fun EventListener.emit( -// pubnub: PubNub, -// event: PNEvent -//) { -// when (event) { -// is PNMessageResult -> this.onMessage(pubnub, event) -// is PNMessageActionResult -> this.onMessageAction(pubnub, event) -// is PNFileEventResult -> this.onFile(pubnub, event) -// is PNObjectEventResult -> this.onObjects(pubnub, event) -// is PNSignalResult -> this.onSignal(pubnub, event) -// is PNPresenceEventResult -> this.onPresence(pubnub, event) -// } -//} -// -//actual fun Any.toJsonElement(): JsonElement { -// TODO("Not yet implemented") -//} -// -//actual fun StatusListener.emit( -// pubnub: PubNub, -// status: PNStatus -//) { -// TODO("Not yet implemented") -//} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt deleted file mode 100644 index 8acd2a877..000000000 --- a/pubnub-kotlin/pubnub-kotlin-test/src/jsMain/kotlin/com.pubnub.test/FakePubNub.js.kt +++ /dev/null @@ -1,27 +0,0 @@ -//package com.pubnub.test -// -//import com.pubnub.api.JsonElement -//import com.pubnub.api.JsonElementImpl -//import com.pubnub.api.PubNub -//import com.pubnub.api.models.consumer.PNStatus -//import com.pubnub.api.models.consumer.pubsub.PNEvent -//import com.pubnub.api.v2.callbacks.EventListener -//import com.pubnub.api.v2.callbacks.StatusListener -// -//actual fun EventListener.emit( -// pubnub: PubNub, -// event: PNEvent -//) { -// TODO("not implemented") -//} -// -//actual fun Any.toJsonElement(): JsonElement { -// return JsonElementImpl(this) -//} -// -//actual fun StatusListener.emit( -// pubnub: PubNub, -// status: PNStatus -//) { -// TODO("not implemented") -//} \ No newline at end of file diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt b/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt deleted file mode 100644 index b5b18984f..000000000 --- a/pubnub-kotlin/pubnub-kotlin-test/src/jvmMain/kotlin/com.pubnub.test/FakePubNub.jvm.kt +++ /dev/null @@ -1,42 +0,0 @@ -//package com.pubnub.test -// -//import com.pubnub.api.JsonElement -//import com.pubnub.api.PubNub -//import com.pubnub.api.models.consumer.PNStatus -//import com.pubnub.api.models.consumer.pubsub.PNEvent -//import com.pubnub.api.models.consumer.pubsub.PNMessageResult -//import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -//import com.pubnub.api.models.consumer.pubsub.PNSignalResult -//import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -//import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -//import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult -//import com.pubnub.api.v2.callbacks.EventListener -//import com.pubnub.api.v2.callbacks.StatusListener -//import com.pubnub.internal.managers.MapperManager -// -//actual fun EventListener.emit( -// pubnub: PubNub, -// event: PNEvent -//) { -// when (event) { -// is PNMessageResult -> this.message(pubnub, event) -// is PNMessageActionResult -> this.messageAction(pubnub, event) -// is PNFileEventResult -> this.file(pubnub, event) -// is PNObjectEventResult -> this.objects(pubnub, event) -// is PNSignalResult -> this.signal(pubnub, event) -// is PNPresenceEventResult -> this.presence(pubnub, event) -// } -//} -// -//private val mapper = MapperManager() -// -//actual fun Any.toJsonElement(): JsonElement { -// return mapper.toJsonTree(this) -//} -// -//actual fun StatusListener.emit( -// pubnub: PubNub, -// status: PNStatus -//) { -// this.status(pubnub, status) -//} \ No newline at end of file From 49f2c2969dca6d0c0b2710eb6c9849b92635f21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Wed, 10 Jul 2024 10:41:20 +0000 Subject: [PATCH 38/62] parseToken and test fixture changes (#254) --- .../src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt | 3 +++ .../iosMain/kotlin/com/pubnub/api/PubNubImpl.kt | 5 +++++ .../src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt | 5 +++++ .../kotlin/com.pubnub.test/BaseIntegrationTest.kt | 14 +++++++++----- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt index 1ceaf38e9..cbd6f38ca 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt @@ -48,6 +48,7 @@ import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNToken import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.api.models.consumer.objects.PNKey @@ -475,4 +476,6 @@ interface PubNub { channelGroups: Set = emptySet(), options: SubscriptionOptions = EmptyOptions, ): SubscriptionSet + + fun parseToken(token: String): PNToken } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 475c3d072..f22064e28 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -103,6 +103,7 @@ import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNToken import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.api.models.consumer.objects.PNKey @@ -814,6 +815,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { TODO("Not yet implemented") } + override fun parseToken(token: String): PNToken { + TODO("Not yet implemented") + } + override fun unsubscribeAll() { pubNubObjC.unsubscribeAll() } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index a1592ad50..56178c730 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -97,6 +97,7 @@ import com.pubnub.api.models.consumer.access_manager.v3.PNAbstractGrant import com.pubnub.api.models.consumer.access_manager.v3.PNGrant import com.pubnub.api.models.consumer.access_manager.v3.PNPatternGrant import com.pubnub.api.models.consumer.access_manager.v3.PNResourceGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNToken import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.api.models.consumer.objects.PNKey @@ -1038,6 +1039,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { return SubscriptionSetImpl(jsPubNub.asDynamic().subscriptionSet(params)) } + override fun parseToken(token: String): PNToken { + TODO("Not yet implemented") + } + override fun sendFile( channel: String, fileName: String, diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt index eb78b2a58..28bc83902 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt @@ -72,7 +72,8 @@ suspend fun PNFuture.await(): T { class PubNubTest( private val pubNub: PubNub, private val withPresenceOverride: Boolean, - backgroundScope: CoroutineScope + backgroundScope: CoroutineScope, + private val checkAllEvents: Boolean = true, ) { private val messageQueue = Channel(10) private val statusQueue = Channel(10) @@ -247,18 +248,21 @@ class PubNubTest( val remainingMessages = buildList { messageQueue.tryReceive().getOrNull()?.apply { add(this) } ?: return@buildList } - assertTrue( - "There were ${remainingMessages.size} unverified events in the test: ${remainingMessages.joinToString(", ")}" - ) { remainingMessages.isEmpty() } + if (checkAllEvents) { + assertTrue( + "There were ${remainingMessages.size} unverified events in the test: ${remainingMessages.joinToString(", ")}" + ) { remainingMessages.isEmpty() } + } } } suspend fun PubNub.test( backgroundScope: CoroutineScope, withPresence: Boolean = false, + checkAllEvents: Boolean = true, action: suspend PubNubTest.() -> Unit, ) { - val pubNubTest = PubNubTest(this, withPresence, backgroundScope) + val pubNubTest = PubNubTest(this, withPresence, backgroundScope, checkAllEvents) try { with(pubNubTest) { action() From c6c3c62437bf9a75ea8f4eb1de85f77cdccaac77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:04:45 +0000 Subject: [PATCH 39/62] Refactoring around PNConfiguration (#255) --- .../config/ktlint/baseline.xml | 25 +-- .../config/ktlint/baseline.xml | 162 ------------------ .../config/ktlint/baseline.xml | 119 ++++++++----- .../com/pubnub/api/v2/PNConfiguration.kt | 8 +- .../kotlin/com/pubnub/kmp/PubNub.kt | 2 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 31 +++- .../com/pubnub/api/v2/PNConfiguration.ios.kt | 14 +- .../kotlin/com/pubnub/api/PubNubImpl.kt | 18 +- .../com/pubnub/api/v2/PNConfiguration.js.kt | 16 +- .../kotlin/com/pubnub/api/PNConfiguration.kt | 2 +- .../com/pubnub/api/v2/PNConfiguration.jvm.kt | 14 +- .../config/ktlint/baseline.xml | 24 --- .../config/ktlint/baseline.xml | 10 ++ .../com.pubnub.test/BaseIntegrationTest.kt | 11 +- swift | 2 +- 15 files changed, 162 insertions(+), 296 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-test/config/ktlint/baseline.xml diff --git a/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml b/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml index 18826ba83..1e346c7d2 100644 --- a/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml +++ b/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml @@ -1,27 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/pubnub-core/pubnub-core-impl/config/ktlint/baseline.xml b/pubnub-core/pubnub-core-impl/config/ktlint/baseline.xml index e075bc3a9..faab705ca 100644 --- a/pubnub-core/pubnub-core-impl/config/ktlint/baseline.xml +++ b/pubnub-core/pubnub-core-impl/config/ktlint/baseline.xml @@ -1,151 +1,16 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -283,31 +148,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml b/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml index ec6e79cfd..ee5e6035a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml +++ b/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml @@ -1,48 +1,81 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt index c35ad4ea6..53f465b7c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt @@ -3,6 +3,7 @@ package com.pubnub.api.v2 import com.pubnub.api.UserId +import com.pubnub.api.enums.PNLogVerbosity expect interface PNConfiguration { val userId: UserId @@ -10,15 +11,14 @@ expect interface PNConfiguration { val publishKey: String val secretKey: String val authKey: String - val cryptoModule: CryptoModule? + val logVerbosity: PNLogVerbosity } -expect interface CryptoModule - expect fun createPNConfiguration( userId: UserId, subscribeKey: String, publishKey: String, secretKey: String? = null, - logVerbosity: Boolean = false, + authKey: String? = null, + logVerbosity: PNLogVerbosity = PNLogVerbosity.NONE, ): PNConfiguration diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt index cbd6f38ca..69a064570 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt @@ -81,7 +81,7 @@ interface PubNub { fun removeListener(listener: Listener) - fun removeAllListeners() //region api + fun removeAllListeners() fun publish( channel: String, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index f22064e28..d10f69e78 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -1,5 +1,6 @@ package com.pubnub.api +import cocoapods.PubNubSwift.PubNubObjC import cocoapods.PubNubSwift.addEventListenerWithListener import cocoapods.PubNubSwift.addStatusListenerWithListener import cocoapods.PubNubSwift.channelGroupWith @@ -7,6 +8,8 @@ import cocoapods.PubNubSwift.channelMetadataWith import cocoapods.PubNubSwift.channelWith import cocoapods.PubNubSwift.disconnect import cocoapods.PubNubSwift.removeAllListeners +import cocoapods.PubNubSwift.removeEventListenerWithListener +import cocoapods.PubNubSwift.removeStatusListenerWithListener import cocoapods.PubNubSwift.setWithToken import cocoapods.PubNubSwift.subscribeWithChannels import cocoapods.PubNubSwift.subscribedChannelGroups @@ -98,6 +101,7 @@ import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDeviceImpl import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.endpoints.push.RemoveChannelsFromPushImpl +import com.pubnub.api.enums.PNLogVerbosity import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage @@ -118,6 +122,7 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.api.v2.createPNConfiguration import com.pubnub.api.v2.entities.Channel import com.pubnub.api.v2.entities.ChannelGroup import com.pubnub.api.v2.entities.ChannelMetadata @@ -135,11 +140,22 @@ import com.pubnub.kmp.Uploadable import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) -class PubNubImpl(override val configuration: PNConfiguration) : PubNub { - private val pubNubObjC = cocoapods.PubNubSwift.PubNubObjC( - user = configuration.userId.value, - subKey = configuration.subscribeKey, - pubKey = configuration.publishKey +class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { + constructor(configuration: PNConfiguration) : this( + PubNubObjC( + user = configuration.userId.value, + subKey = configuration.subscribeKey, + pubKey = configuration.publishKey + ) + ) + + override val configuration: PNConfiguration = createPNConfiguration( + UserId(pubNubObjC.configObjC().userId()), + "", // todo + "", // todo + "", // todo + pubNubObjC.configObjC().authKey(), + PNLogVerbosity.NONE ) override fun addListener(listener: EventListener) { @@ -151,7 +167,10 @@ class PubNubImpl(override val configuration: PNConfiguration) : PubNub { } override fun removeListener(listener: Listener) { -// pubNubObjC.removeEventListenerWithListener(listener) + when (listener) { + is EventListener -> pubNubObjC.removeEventListenerWithListener(listener.underlying) + is StatusListener -> pubNubObjC.removeStatusListenerWithListener(listener.underlying) + } } override fun removeAllListeners() { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt index 349803290..8938c6e61 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/PNConfiguration.ios.kt @@ -1,6 +1,7 @@ package com.pubnub.api.v2 import com.pubnub.api.UserId +import com.pubnub.api.enums.PNLogVerbosity actual interface PNConfiguration { actual val userId: UserId @@ -8,17 +9,16 @@ actual interface PNConfiguration { actual val publishKey: String actual val secretKey: String actual val authKey: String - actual val cryptoModule: CryptoModule? + actual val logVerbosity: PNLogVerbosity } -actual interface CryptoModule - actual fun createPNConfiguration( userId: UserId, subscribeKey: String, publishKey: String, secretKey: String?, - logVerbosity: Boolean + authKey: String?, + logVerbosity: PNLogVerbosity ): PNConfiguration { return object : PNConfiguration { override val userId: UserId = userId @@ -27,8 +27,8 @@ actual fun createPNConfiguration( override val secretKey: String get() = secretKey.orEmpty() override val authKey: String - get() = TODO("Not yet implemented") - override val cryptoModule: CryptoModule? - get() = TODO("Not yet implemented") + get() = authKey.orEmpty() + override val logVerbosity: PNLogVerbosity + get() = logVerbosity } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 56178c730..960c6382b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -88,6 +88,7 @@ import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDeviceImpl import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.endpoints.push.RemoveChannelsFromPushImpl +import com.pubnub.api.enums.PNLogVerbosity import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage @@ -113,6 +114,7 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.api.v2.createPNConfiguration import com.pubnub.api.v2.entities.Channel import com.pubnub.api.v2.entities.ChannelGroup import com.pubnub.api.v2.entities.ChannelMetadata @@ -133,8 +135,18 @@ import com.pubnub.kmp.toOptional import kotlin.js.json import PubNub as PubNubJs -class PubNubImpl(override val configuration: PNConfiguration) : PubNub { - private val jsPubNub: PubNubJs = PubNubJs(configuration.toJs()) +class PubNubImpl(private val jsPubNub: PubNubJs) : PubNub { + constructor(configuration: PNConfiguration) : this(PubNubJs(configuration.toJs())) + + override val configuration: PNConfiguration + get() = createPNConfiguration( // todo test this! + UserId(jsPubNub.getUUID()), + jsPubNub.asDynamic().configuration.subscribeKey, + jsPubNub.asDynamic().configuration.publishKey, + jsPubNub.asDynamic().configuration.secretKey, + jsPubNub.asDynamic().configuration.authKey, + jsPubNub.asDynamic().configuration.logVerbosity + ) override fun addListener(listener: EventListener) { jsPubNub.addListener( @@ -1153,7 +1165,7 @@ fun PNConfiguration.toJs(): PubNubJs.PNConfiguration { config.subscribeKey = subscribeKey config.publishKey = publishKey config.secretKey = secretKey - config.logVerbosity = logVerbosity + config.logVerbosity = logVerbosity == PNLogVerbosity.BODY config.enableEventEngine = enableEventEngine // config.authKey // config.ssl: Boolean? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt index 7156d2279..61ec3d920 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/PNConfiguration.js.kt @@ -1,17 +1,16 @@ package com.pubnub.api.v2 import com.pubnub.api.UserId +import com.pubnub.api.enums.PNLogVerbosity -@JsExport actual interface PNConfiguration { actual val userId: UserId actual val subscribeKey: String actual val publishKey: String actual val secretKey: String actual val authKey: String - actual val cryptoModule: CryptoModule? + actual val logVerbosity: PNLogVerbosity val enableEventEngine: Boolean - val logVerbosity: Boolean } actual fun createPNConfiguration( @@ -19,7 +18,8 @@ actual fun createPNConfiguration( subscribeKey: String, publishKey: String, secretKey: String?, - logVerbosity: Boolean + authKey: String?, + logVerbosity: PNLogVerbosity ): PNConfiguration { return object : PNConfiguration { override val userId: UserId @@ -31,14 +31,10 @@ actual fun createPNConfiguration( override val secretKey: String get() = secretKey.orEmpty() override val authKey: String - get() = TODO("Not yet implemented") - override val cryptoModule: CryptoModule? - get() = TODO("Not yet implemented") + get() = authKey.orEmpty() override val enableEventEngine: Boolean get() = false - override val logVerbosity: Boolean + override val logVerbosity: PNLogVerbosity get() = logVerbosity } } - -actual interface CryptoModule diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PNConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PNConfiguration.kt index 9bcc6a23e..4802be24f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PNConfiguration.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PNConfiguration.kt @@ -126,7 +126,7 @@ class PNConfiguration(override var userId: UserId) : PNConfiguration { /** * Set to [PNLogVerbosity.BODY] to enable logging of network traffic, otherwise se to [PNLogVerbosity.NONE]. */ - override var logVerbosity = configuration.logVerbosity + override var logVerbosity: PNLogVerbosity = configuration.logVerbosity /** * Set Heartbeat notification options. diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt index f378ed295..364315638 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.jvm.kt @@ -1,7 +1,6 @@ package com.pubnub.api.v2 import com.pubnub.api.UserId -import com.pubnub.api.crypto.CryptoModule import com.pubnub.api.enums.PNLogVerbosity actual fun createPNConfiguration( @@ -9,17 +8,14 @@ actual fun createPNConfiguration( subscribeKey: String, publishKey: String, secretKey: String?, - logVerbosity: Boolean + authKey: String?, + logVerbosity: PNLogVerbosity ): PNConfiguration { return PNConfiguration.builder(userId, subscribeKey) { this.publishKey = publishKey this.secretKey = secretKey.orEmpty() - this.logVerbosity = if (logVerbosity) { - PNLogVerbosity.BODY - } else { - PNLogVerbosity.NONE - } + this.authKey = authKey.orEmpty() + this.secretKey = secretKey.orEmpty() + this.logVerbosity = logVerbosity }.build() } - -actual typealias CryptoModule = CryptoModule diff --git a/pubnub-kotlin/pubnub-kotlin-impl/config/ktlint/baseline.xml b/pubnub-kotlin/pubnub-kotlin-impl/config/ktlint/baseline.xml index 74ccb4382..981420778 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/config/ktlint/baseline.xml +++ b/pubnub-kotlin/pubnub-kotlin-impl/config/ktlint/baseline.xml @@ -1,27 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pubnub-kotlin/pubnub-kotlin-test/config/ktlint/baseline.xml b/pubnub-kotlin/pubnub-kotlin-test/config/ktlint/baseline.xml new file mode 100644 index 000000000..73faa4cf8 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-test/config/ktlint/baseline.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt index 28bc83902..da4cdf3e6 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt @@ -1,6 +1,7 @@ package com.pubnub.test import com.pubnub.api.UserId +import com.pubnub.api.enums.PNLogVerbosity import com.pubnub.api.enums.PNStatusCategory import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNEvent @@ -38,9 +39,15 @@ abstract class BaseIntegrationTest { @BeforeTest open fun before() { - config = createPNConfiguration(UserId(randomString()), Keys.subKey, Keys.pubKey, logVerbosity = true) + config = createPNConfiguration(UserId(randomString()), Keys.subKey, Keys.pubKey, logVerbosity = PNLogVerbosity.BODY) pubnub = createPubNub(config) - configPam = createPNConfiguration(UserId(randomString()), Keys.pamSubKey, Keys.pamPubKey, Keys.pamSecKey, logVerbosity = true) + configPam = createPNConfiguration( + UserId(randomString()), + Keys.pamSubKey, + Keys.pamPubKey, + Keys.pamSecKey, + logVerbosity = PNLogVerbosity.BODY + ) pubnubPam = createPubNub(configPam) } diff --git a/swift b/swift index cde54b05f..979313e1b 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit cde54b05f0c7aa546aefc0e050185b96ef31cb16 +Subproject commit 979313e1b7e793f9c143e15a4a710292acc95d74 From b10a4f4e9dde9b0aaf1a9c823a468e2119d9bd6b Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Thu, 18 Jul 2024 14:38:11 +0200 Subject: [PATCH 40/62] Fixing integration tests for iOS (#256) --- .../kotlin/com/pubnub/api/MembersTest.kt | 1 - .../kotlin/com/pubnub/api/PubNubImpl.kt | 18 ++++++++++++++++-- .../pubnub/api/endpoints/FetchMessages.ios.kt | 2 +- .../channel/GetAllChannelMetadata.ios.kt | 6 +++--- .../objects/member/GetChannelMembers.ios.kt | 6 +++--- .../objects/member/ManageChannelMembers.ios.kt | 6 +++--- .../objects/membership/GetMemberships.ios.kt | 6 +++--- .../membership/ManageMemberships.ios.kt | 6 +++--- .../objects/uuid/GetAllUUIDMetadata.ios.kt | 4 ++-- .../pubnub/api/endpoints/pubsub/Publish.ios.kt | 12 ++---------- .../internal/subscription/SubscriptionImpl.kt | 5 +++++ .../subscription/SubscriptionSetImpl.kt | 5 +++-- .../kotlin/com/pubnub/kmp/factories.ios.kt | 10 +++------- .../kotlin/com/pubnub/kmp/results.ios.kt | 9 ++++++++- swift | 2 +- 15 files changed, 56 insertions(+), 42 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt index 875fa8bc9..7147ed9c5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt @@ -37,7 +37,6 @@ class MembersTest : BaseIntegrationTest() { // then val pnChannelDetails = result.data.single { it.uuid?.id == pubnub.configuration.userId.value } assertEquals(customData, pnChannelDetails.custom) -// assertEquals(status, pnChannelDetails.status) } @Test diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index d10f69e78..e79ebc97b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -1,6 +1,8 @@ package com.pubnub.api import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.PubNubSubscriptionObjC +import cocoapods.PubNubSwift.PubNubSubscriptionSetObjC import cocoapods.PubNubSwift.addEventListenerWithListener import cocoapods.PubNubSwift.addStatusListenerWithListener import cocoapods.PubNubSwift.channelGroupWith @@ -134,6 +136,8 @@ import com.pubnub.internal.entities.ChannelGroupImpl import com.pubnub.internal.entities.ChannelImpl import com.pubnub.internal.entities.ChannelMetadataImpl import com.pubnub.internal.entities.UserMetadataImpl +import com.pubnub.internal.subscription.SubscriptionImpl +import com.pubnub.internal.subscription.SubscriptionSetImpl import com.pubnub.kmp.CustomObject import com.pubnub.kmp.PubNub import com.pubnub.kmp.Uploadable @@ -823,7 +827,9 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { } override fun subscriptionSetOf(subscriptions: Set): SubscriptionSet { - TODO("Not yet implemented") + return SubscriptionSetImpl( + PubNubSubscriptionSetObjC(subscriptions.filterIsInstance().map { it.objCSubscription }) + ) } override fun subscriptionSetOf( @@ -831,7 +837,15 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { channelGroups: Set, options: SubscriptionOptions ): SubscriptionSet { - TODO("Not yet implemented") + val channelSubscriptions = channels.map { pubNubObjC.channelWith(it) }.map { entity -> PubNubSubscriptionObjC(entity) } + val channelGroupSubscriptions = channelGroups.map { pubNubObjC.channelGroupWith(it) }.map { + entity -> + PubNubSubscriptionObjC(entity) + } + + return SubscriptionSetImpl( + PubNubSubscriptionSetObjC(channelGroupSubscriptions + channelSubscriptions) + ) } override fun parseToken(token: String): PNToken { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt index 5db35d84f..8117733fb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt @@ -86,7 +86,7 @@ open class FetchMessagesImpl( groupedEntry.value.map { PNFetchMessageItem.Action( uuid = it.publisher(), - actionTimetoken = it.published()?.longValue!! + actionTimetoken = it.actionTimetoken().toLong() ) } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt index 242b5afb9..7eba8e5b4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt @@ -42,13 +42,13 @@ class GetAllChannelMetadataImpl( sort = createObjectSortProperties(from = sort), includeCount = includeCount, includeCustom = includeCustom, - onSuccess = callback.onSuccessHandler3 { channels, totalCount, next -> + onSuccess = callback.onSuccessHandler3 { channels, totalCount, page -> PNChannelMetadataArrayResult( status = 200, data = channels.filterAndMap { rawValue: PubNubChannelMetadataObjC -> createPNChannelMetadata(rawValue) }, totalCount = totalCount?.intValue, - next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, - prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + next = page?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = page?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt index e9b53108a..3c3fa2573 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt @@ -47,13 +47,13 @@ class GetChannelMembersImpl( includeCustom = includeCustom, includeUUIDFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, includeUUIDCustomFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, - onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> + onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNMemberArrayResult( status = 200, data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNMember(rawValue) }, totalCount = totalCount?.intValue, - next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, - prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + next = page?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = page?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt index 9b6b153d4..9bcd51114 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt @@ -53,13 +53,13 @@ class SetChannelMembersImpl( includeCustom = includeCustom, includeUUIDFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, includeUUIDCustomFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, - onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> + onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNMemberArrayResult( status = 200, data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNMember(rawValue) }, totalCount = totalCount?.intValue, - next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, - prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + next = page?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = page?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt index cee734364..aa27302c9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt @@ -47,13 +47,13 @@ class GetMembershipsImpl( includeCustom = includeCustom, includeChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL || includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, includeChannelCustomFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, - onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> + onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNChannelMembershipArrayResult( status = 200, data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNChannelMembership(rawValue) }, totalCount = totalCount?.intValue, - next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, - prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + next = page?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = page?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt index 007abc899..327a8a04f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt @@ -53,13 +53,13 @@ class AddMembershipsImpl( includeCustom = includeCustom, includeChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL || includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, includeChannelCustomFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, - onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> + onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNChannelMembershipArrayResult( status = 200, data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNChannelMembership(rawValue) }, totalCount = totalCount?.intValue, - next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, - prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + next = page?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = page?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt index f5140774f..59205a483 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt @@ -47,8 +47,8 @@ class GetAllUUIDMetadataImpl( status = 200, data = uuids.filterAndMap { rawValue: PubNubUUIDMetadataObjC -> createPNUUIDMetadata(from = rawValue) }, totalCount = totalCount?.intValue ?: 0, - next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, - prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } + next = next?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, + prev = next?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt index 08fe2ebf3..9730d7b68 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt @@ -30,16 +30,8 @@ class PublishImpl( channel = channel, message = message, meta = meta, - shouldStore = if (shouldStore != null) { - NSNumber(bool = shouldStore) - } else { - null - }, - ttl = if (ttl != null) { - NSNumber(int = ttl) - } else { - null - }, + shouldStore = shouldStore?.let { NSNumber(bool = it) }, + ttl = ttl?.let { NSNumber(it) }, onSuccess = callback.onSuccessHandler { PNPublishResult(it.toLong()) }, onFailure = callback.onFailureHandler() ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt index eb2496733..740524607 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt @@ -45,18 +45,23 @@ class SubscriptionImpl( override var onMessage: ((PNMessageResult) -> Unit)? get() = TODO("Not yet implemented") set(value) {} + override var onPresence: ((PNPresenceEventResult) -> Unit)? get() = TODO("Not yet implemented") set(value) {} + override var onSignal: ((PNSignalResult) -> Unit)? get() = TODO("Not yet implemented") set(value) {} + override var onMessageAction: ((PNMessageActionResult) -> Unit)? get() = TODO("Not yet implemented") set(value) {} + override var onObjects: ((PNObjectEventResult) -> Unit)? get() = TODO("Not yet implemented") set(value) {} + override var onFile: ((PNFileEventResult) -> Unit)? get() = TODO("Not yet implemented") set(value) {} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt index e050d120e..deeeda5d7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt @@ -46,11 +46,11 @@ class SubscriptionSetImpl( get() = TODO("Not yet implemented") override fun subscribe(cursor: SubscriptionCursor) { - TODO("Not yet implemented") + objCSubscriptionSet.subscribeWith(cursor.timetoken.toULong()) } override fun unsubscribe() { - TODO("Not yet implemented") + objCSubscriptionSet.unsubscribe() } override var onMessage: ((PNMessageResult) -> Unit)? @@ -64,6 +64,7 @@ class SubscriptionSetImpl( override var onSignal: ((PNSignalResult) -> Unit)? get() = TODO("Not yet implemented") set(value) {} + override var onMessageAction: ((PNMessageActionResult) -> Unit)? get() = TODO("Not yet implemented") set(value) {} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index af747edf5..6d6897820 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -73,11 +73,7 @@ actual fun createEventListener( onPresence = { presenceEvents -> createPresenceEventResults(presenceEvents).forEach { onPresence(pubnub, it) } }, onSignal = { onSignal(pubnub, createSignalResult(it)) }, onMessageAction = { onMessageAction(pubnub, createMessageActionResult(it)) }, - onAppContext = { - if (createObjectEvent(it) != null) { - createObjectEvent(it) - } else {} - }, + onAppContext = { value -> createObjectEvent(value)?.let { res -> onObjects(pubnub, res) } }, onFile = { onFile(pubnub, createFileEventResult(it)) } ), onMessage = onMessage, @@ -252,8 +248,8 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM event = from.event(), type = from.type(), data = PNSetMembershipEvent( - channel = from.metadata().channel()?.name().orEmpty(), - uuid = from.metadata().uuid()?.id().orEmpty(), + channel = from.metadata().channelMetadataId(), + uuid = from.metadata().uuidMetadataId(), custom = from.metadata().custom()?.safeCast(), eTag = from.metadata().eTag().orEmpty(), updated = from.metadata().updated().orEmpty(), diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt index 0741f3db3..cb94f2810 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt @@ -1,8 +1,10 @@ package com.pubnub.kmp +import cocoapods.PubNubSwift.PubNubErrorObjC import com.pubnub.api.PubNubException import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result +import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSError fun Consumer>.onSuccessHandler(mapper: (T) -> U): (T) -> Unit { @@ -47,9 +49,14 @@ fun Consumer>.onSuccessReturnValue(value: T): () -> Unit { } } +@OptIn(ExperimentalForeignApi::class) fun Consumer>.onFailureHandler( mapper: (NSError?) -> Throwable = { error: NSError? -> - PubNubException(errorMessage = error?.localizedDescription) + if (error is PubNubErrorObjC) { + PubNubException(error.statusCode().toInt(), error.localizedDescription, null) + } else { + PubNubException(errorMessage = error?.localizedDescription) + } } ): (NSError?) -> Unit { return { error: NSError? -> diff --git a/swift b/swift index 979313e1b..42c7706e3 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit 979313e1b7e793f9c143e15a4a710292acc95d74 +Subproject commit 42c7706e3239fe26e0f2f0c1da047dec0b6bf877 From 6a433a3613f705ad6f6ee9c3016aa58fac7998ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Fri, 19 Jul 2024 11:56:25 +0000 Subject: [PATCH 41/62] iOS test changes (#257) --- .../pubnub/gradle/PubNubIosSimulatorTestPlugin.kt | 14 ++++++++++++++ .../gradle/PubNubKotlinMultiplatformPlugin.kt | 3 +++ pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts | 11 ----------- .../src/iosMain}/kotlin/testlauncher.kt | 0 4 files changed, 17 insertions(+), 11 deletions(-) rename pubnub-kotlin/{pubnub-kotlin-api/src/iosTest => pubnub-kotlin-test/src/iosMain}/kotlin/testlauncher.kt (100%) diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt index b233a2483..d22bcc6b9 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubIosSimulatorTestPlugin.kt @@ -4,9 +4,13 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.tasks.Exec import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.register import org.gradle.kotlin.dsl.withType +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget +import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest import java.io.ByteArrayOutputStream @@ -43,6 +47,16 @@ class PubNubIosSimulatorTestPlugin : Plugin { it.dependsOn(bootTask) // it.finalizedBy(shutdownTask) } + + extensions.configure { + targets.withType { + if (konanTarget.family.isAppleFamily) { + binaries.withType { + freeCompilerArgs += listOf("-e", "testlauncher.mainBackground") + } + } + } + } } } } \ No newline at end of file diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt index 44aea2d29..e1ed9f52f 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt @@ -5,12 +5,15 @@ import org.gradle.api.Project import org.gradle.api.plugins.ExtensionAware import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.withType import org.jetbrains.dokka.DokkaDefaults.moduleName import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin +import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType +import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable class PubNubKotlinMultiplatformPlugin : Plugin { override fun apply(target: Project) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index 825a22cfd..b39838bb5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -1,6 +1,3 @@ -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget -import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable - plugins { alias(libs.plugins.benmanes.versions) id("pubnub.shared") @@ -56,14 +53,6 @@ kotlin { } } } - - targets.withType { - if (konanTarget.family.isAppleFamily) { - binaries.withType { - freeCompilerArgs += listOf("-e", "testlauncher.mainBackground") - } - } - } } kotlin { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/testlauncher.kt b/pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/testlauncher.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-api/src/iosTest/kotlin/testlauncher.kt rename to pubnub-kotlin/pubnub-kotlin-test/src/iosMain/kotlin/testlauncher.kt From b140847e1a282d8d74b1260e9f7d80fedf5e4dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Tue, 23 Jul 2024 09:46:04 +0200 Subject: [PATCH 42/62] Add JsonElement test --- kotlin-js-store/yarn.lock | 359 +----------------- .../kotlin/com/pubnub/kmp/JsonElementTest.kt | 18 + .../kotlin/com/pubnub/api/JsonElement.ios.kt | 4 + swift | 2 +- 4 files changed, 29 insertions(+), 354 deletions(-) create mode 100644 pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 2a8e0ff3c..46d7315c0 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -99,11 +99,6 @@ resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz#821f8442f4175d8f0467b9daf26e3a18e2d02af2" integrity sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA== -"@tootallnate/quickjs-emscripten@^0.23.0": - version "0.23.0" - resolved "https://registry.yarnpkg.com/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz#db4ecfd499a9765ab24002c3b696d02e6d32a12c" - integrity sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA== - "@types/body-parser@*": version "1.19.5" resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.5.tgz#04ce9a3b677dc8bd681a17da1ab9835dc9d3ede4" @@ -440,20 +435,6 @@ acorn@^8.7.1, acorn@^8.8.2: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== -agent-base@^7.0.2, agent-base@^7.1.0, agent-base@^7.1.1: - version "7.1.1" - resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.1.tgz#bdbded7dfb096b751a2a087eeeb9664725b2e317" - integrity sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA== - dependencies: - debug "^4.3.4" - -agentkeepalive@^3.5.2: - version "3.5.3" - resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-3.5.3.tgz#c210afce942b4287e2df2fbfe6c0d57eda2ce634" - integrity sha512-yqXL+k5rr8+ZRpOAntkaaRgWgE5o8ESAj5DyRmVTCSoZxXmqemb9Dd7T4i5UzwuERdLAJUy6XzR9zFVuf0kzkw== - dependencies: - humanize-ms "^1.2.1" - ajv-formats@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520" @@ -543,38 +524,16 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== -ast-types@^0.13.4: - version "0.13.4" - resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.13.4.tgz#ee0d77b343263965ecc3fb62da16e7222b2b6782" - integrity sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w== - dependencies: - tslib "^2.0.1" - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== -base64-js@^1.3.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" - integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== - base64id@2.0.0, base64id@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== -basic-ftp@^5.0.2: - version "5.0.5" - resolved "https://registry.yarnpkg.com/basic-ftp/-/basic-ftp-5.0.5.tgz#14a474f5fffecca1f4f406f1c26b18f800225ac0" - integrity sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg== - batch@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" @@ -653,22 +612,6 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== -buffer@^5.4.3: - version "5.7.1" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" - integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.1.13" - -buffer@^6.0.3: - version "6.0.3" - resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" - integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== - dependencies: - base64-js "^1.3.1" - ieee754 "^1.2.1" - bundle-name@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/bundle-name/-/bundle-name-4.1.0.tgz#f3b96b34160d6431a19d7688135af7cfb8797889" @@ -707,16 +650,6 @@ caniuse-lite@^1.0.30001587: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001616.tgz#4342712750d35f71ebba9fcac65e2cf8870013c3" integrity sha512-RHVYKov7IcdNjVHJFNY/78RdG4oGVjbayxv8u5IO74Wv7Hlq4PnJE6mo/OjFijjVFNy5ijnCt6H3IIo4t+wfEw== -cbor-js@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/cbor-js/-/cbor-js-0.1.0.tgz#c80ce6120f387e8faa74370dfda21d965b8fc7f9" - integrity sha512-7sQ/TvDZPl7csT1Sif9G0+MA0I0JOVah8+wWlJVQdVEgIbCzlN/ab3x+uvMNsc34TUvO6osQTAmB2ls80JX6tw== - -cbor-sync@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/cbor-sync/-/cbor-sync-1.0.4.tgz#5a11a1ab75c2a14d1af1b237fd84aa8c1593662f" - integrity sha512-GWlXN4wiz0vdWWXBU71Dvc1q3aBo0HytqwAZnXF1wOwjqNnDWA1vZ1gDMFLlqohak31VQzmhiYfiCX5QSSfagA== - chalk@^4.1.0: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" @@ -795,13 +728,6 @@ colorette@^2.0.10, colorette@^2.0.14: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - commander@^10.0.1: version "10.0.1" resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" @@ -906,11 +832,6 @@ custom-event@~1.0.0: resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" integrity sha512-GAj5FOq0Hd+RsCGVJxZuKaIDXDf3h6GQoNEjFgbLLI/trgtavwUbSnZ5pVfg27DVCaWjIohryS0JFwIJyT2cMg== -data-uri-to-buffer@^6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz#8a58bb67384b261a38ef18bea1810cb01badd28b" - integrity sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw== - date-format@^4.0.14: version "4.0.14" resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.14.tgz#7a8e584434fb169a521c8b7aa481f355810d9400" @@ -923,7 +844,7 @@ debug@2.6.9: dependencies: ms "2.0.0" -debug@4, debug@4.3.4, debug@^4.1.0, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2, debug@~4.3.4: +debug@4.3.4, debug@^4.1.0, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2, debug@~4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== @@ -969,20 +890,6 @@ define-lazy-prop@^3.0.0: resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz#dbb19adfb746d7fc6d734a06b72f4a00d021255f" integrity sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg== -degenerator@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-5.0.1.tgz#9403bf297c6dad9a1ece409b37db27954f91f2f5" - integrity sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ== - dependencies: - ast-types "^0.13.4" - escodegen "^2.1.0" - esprima "^4.0.1" - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - depd@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" @@ -1131,17 +1038,6 @@ escape-string-regexp@4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -escodegen@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.1.0.tgz#ba93bbb7a43986d29d6041f99f5262da773e2e17" - integrity sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w== - dependencies: - esprima "^4.0.1" - estraverse "^5.2.0" - esutils "^2.0.2" - optionalDependencies: - source-map "~0.6.1" - eslint-scope@5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" @@ -1150,11 +1046,6 @@ eslint-scope@5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" -esprima@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" - integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== - esrecurse@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" @@ -1172,11 +1063,6 @@ estraverse@^5.2.0: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== -esutils@^2.0.2: - version "2.0.3" - resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" - integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== - etag@~1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" @@ -1343,15 +1229,6 @@ foreground-child@^3.1.0: cross-spawn "^7.0.0" signal-exit "^4.0.1" -form-data@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" - integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - format-util@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271" @@ -1367,15 +1244,6 @@ fresh@0.5.2: resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== -fs-extra@^11.2.0: - version "11.2.0" - resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b" - integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw== - dependencies: - graceful-fs "^4.2.0" - jsonfile "^6.0.1" - universalify "^2.0.0" - fs-extra@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" @@ -1421,16 +1289,6 @@ get-stream@^6.0.0: resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== -get-uri@^6.0.1: - version "6.0.3" - resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-6.0.3.tgz#0d26697bc13cf91092e519aa63aa60ee5b6f385a" - integrity sha512-BzUrJBS9EcUb4cFol8r4W3v1cPsSyajLSthNkz5BxbpDcHN5tIrM10E2eNvfnvBn3DaT3DUgx0OpsBKkaOpanw== - dependencies: - basic-ftp "^5.0.2" - data-uri-to-buffer "^6.0.2" - debug "^4.3.4" - fs-extra "^11.2.0" - glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -1574,14 +1432,6 @@ http-parser-js@>=0.5.1: resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.8.tgz#af23090d9ac4e24573de6f6aecc9d84a48bf20e3" integrity sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q== -http-proxy-agent@^7.0.0, http-proxy-agent@^7.0.1: - version "7.0.2" - resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz#9a8b1f246866c028509486585f62b8f2c18c270e" - integrity sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig== - dependencies: - agent-base "^7.1.0" - debug "^4.3.4" - http-proxy-middleware@^2.0.3: version "2.0.6" resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f" @@ -1602,26 +1452,11 @@ http-proxy@^1.18.1: follow-redirects "^1.0.0" requires-port "^1.0.0" -https-proxy-agent@^7.0.2, https-proxy-agent@^7.0.3: - version "7.0.4" - resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.4.tgz#8e97b841a029ad8ddc8731f26595bad868cb4168" - integrity sha512-wlwpilI7YdjSkWaQ/7omYBMTliDcmCN8OLihO6I9B86g06lMyAoqgoDpV0XqoaPOKj+0DIdAvnsWfyAAhmimcg== - dependencies: - agent-base "^7.0.2" - debug "4" - human-signals@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== -humanize-ms@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" - integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ== - dependencies: - ms "^2.0.0" - hyperdyperid@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/hyperdyperid/-/hyperdyperid-1.2.0.tgz#59668d323ada92228d2a869d3e474d5a33b69e6b" @@ -1641,11 +1476,6 @@ iconv-lite@^0.6.3: dependencies: safer-buffer ">= 2.1.2 < 3.0.0" -ieee754@^1.1.13, ieee754@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" - integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== - import-local@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" @@ -1677,14 +1507,6 @@ interpret@^3.1.1: resolved "https://registry.yarnpkg.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4" integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ== -ip-address@^9.0.5: - version "9.0.5" - resolved "https://registry.yarnpkg.com/ip-address/-/ip-address-9.0.5.tgz#117a960819b08780c3bd1f14ef3c1cc1d3f3ea5a" - integrity sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g== - dependencies: - jsbn "1.1.0" - sprintf-js "^1.1.3" - ipaddr.js@1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" @@ -1827,11 +1649,6 @@ js-yaml@4.1.0: dependencies: argparse "^2.0.1" -jsbn@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-1.1.0.tgz#b01307cb29b618a1ed26ec79e911f803c4da0040" - integrity sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A== - json-parse-even-better-errors@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" @@ -1854,15 +1671,6 @@ jsonfile@^4.0.0: optionalDependencies: graceful-fs "^4.1.6" -jsonfile@^6.0.1: - version "6.1.0" - resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" - integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== - dependencies: - universalify "^2.0.0" - optionalDependencies: - graceful-fs "^4.1.6" - karma-chrome-launcher@3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-3.2.0.tgz#eb9c95024f2d6dfbb3748d3415ac9b381906b9a9" @@ -1936,11 +1744,6 @@ launch-editor@^2.6.1: picocolors "^1.0.0" shell-quote "^1.8.1" -lil-uuid@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/lil-uuid/-/lil-uuid-0.1.1.tgz#f9edcf23f00e42bf43f0f843d98d8b53f3341f16" - integrity sha512-GhWI8f61tBlMeqULZ1QWhFiiyFIFdPlg//S8Udq1wjq1FJhpFKTfnbduSxAQjueofeUtpr7UvQ/lIK/sKUF8dg== - loader-runner@^4.2.0: version "4.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" @@ -1989,11 +1792,6 @@ lru-cache@^10.2.0: resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.2.tgz#48206bc114c1252940c41b25b41af5b545aca878" integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== -lru-cache@^7.14.1: - version "7.18.3" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.18.3.tgz#f793896e0fd0e954a59dfdd82f0773808df6aa89" - integrity sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA== - media-typer@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" @@ -2037,7 +1835,7 @@ mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@^2.1.12, mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34: +mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34: version "2.1.35" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== @@ -2145,7 +1943,7 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@2.1.3, ms@^2.0.0: +ms@2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -2168,18 +1966,6 @@ neo-async@^2.6.2: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== -netmask@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/netmask/-/netmask-2.0.2.tgz#8b01a07644065d536383835823bc52004ebac5e7" - integrity sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg== - -node-fetch@^2.7.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" - integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== - dependencies: - whatwg-url "^5.0.0" - node-forge@^1: version "1.3.1" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" @@ -2302,28 +2088,6 @@ p-try@^2.0.0: resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== -pac-proxy-agent@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-7.0.1.tgz#6b9ddc002ec3ff0ba5fdf4a8a21d363bcc612d75" - integrity sha512-ASV8yU4LLKBAjqIPMbrgtaKIvxQri/yh2OpI+S6hVa9JRkUI3Y3NPFbfngDtY7oFtSMD3w31Xns89mDa3Feo5A== - dependencies: - "@tootallnate/quickjs-emscripten" "^0.23.0" - agent-base "^7.0.2" - debug "^4.3.4" - get-uri "^6.0.1" - http-proxy-agent "^7.0.0" - https-proxy-agent "^7.0.2" - pac-resolver "^7.0.0" - socks-proxy-agent "^8.0.2" - -pac-resolver@^7.0.0: - version "7.0.1" - resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-7.0.1.tgz#54675558ea368b64d210fd9c92a640b5f3b8abb6" - integrity sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg== - dependencies: - degenerator "^5.0.0" - netmask "^2.0.2" - parseurl@~1.3.2, parseurl@~1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" @@ -2392,42 +2156,7 @@ proxy-addr@~2.0.7: forwarded "0.2.0" ipaddr.js "1.9.1" -proxy-agent@^6.3.0: - version "6.4.0" - resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-6.4.0.tgz#b4e2dd51dee2b377748aef8d45604c2d7608652d" - integrity sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ== - dependencies: - agent-base "^7.0.2" - debug "^4.3.4" - http-proxy-agent "^7.0.1" - https-proxy-agent "^7.0.3" - lru-cache "^7.14.1" - pac-proxy-agent "^7.0.1" - proxy-from-env "^1.1.0" - socks-proxy-agent "^8.0.2" - -proxy-from-env@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" - integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== - -pubnub@8.2.4: - version "8.2.4" - resolved "https://registry.yarnpkg.com/pubnub/-/pubnub-8.2.4.tgz#5461d5fc11df4a35dcaf0332a7967c182baedc6a" - integrity sha512-NlA1Kk6f1CfI5n1yNB5hICwDSIWXaOyjHwEm0jmxPbAS+Mj8+WVeUZBomDIrTS870r37ynT9BUkr71gHWUq7Xg== - dependencies: - agentkeepalive "^3.5.2" - buffer "^6.0.3" - cbor-js "^0.1.0" - cbor-sync "^1.0.4" - form-data "^4.0.0" - lil-uuid "^0.1.1" - node-fetch "^2.7.0" - proxy-agent "^6.3.0" - react-native-url-polyfill "^2.0.0" - text-encoding "^0.7.0" - -punycode@^2.1.0, punycode@^2.1.1: +punycode@^2.1.0: version "2.3.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== @@ -2466,13 +2195,6 @@ raw-body@2.5.2: iconv-lite "0.4.24" unpipe "1.0.0" -react-native-url-polyfill@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/react-native-url-polyfill/-/react-native-url-polyfill-2.0.0.tgz#db714520a2985cff1d50ab2e66279b9f91ffd589" - integrity sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA== - dependencies: - whatwg-url-without-unicode "8.0.0-3" - readable-stream@^2.0.1: version "2.3.8" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" @@ -2743,11 +2465,6 @@ signal-exit@^4.0.1: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== -smart-buffer@^4.2.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.2.0.tgz#6e1d71fa4f18c05f7d0ff216dd16a481d0e8d9ae" - integrity sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg== - socket.io-adapter@~2.5.2: version "2.5.4" resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-2.5.4.tgz#4fdb1358667f6d68f25343353bd99bd11ee41006" @@ -2786,23 +2503,6 @@ sockjs@^0.3.24: uuid "^8.3.2" websocket-driver "^0.7.4" -socks-proxy-agent@^8.0.2: - version "8.0.3" - resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-8.0.3.tgz#6b2da3d77364fde6292e810b496cb70440b9b89d" - integrity sha512-VNegTZKhuGq5vSD6XNKlbqWhyt/40CgoEw8XxD6dhnm8Jq9IEa3nIa4HwnM8XOqU0CdB0BwWVXusqiFXfHB3+A== - dependencies: - agent-base "^7.1.1" - debug "^4.3.4" - socks "^2.7.1" - -socks@^2.7.1: - version "2.8.3" - resolved "https://registry.yarnpkg.com/socks/-/socks-2.8.3.tgz#1ebd0f09c52ba95a09750afe3f3f9f724a800cb5" - integrity sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw== - dependencies: - ip-address "^9.0.5" - smart-buffer "^4.2.0" - sonic-forest@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/sonic-forest/-/sonic-forest-1.0.3.tgz#81363af60017daba39b794fce24627dc412563cb" @@ -2831,7 +2531,7 @@ source-map-support@~0.5.20: buffer-from "^1.0.0" source-map "^0.6.0" -source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: +source-map@^0.6.0, source-map@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== @@ -2859,11 +2559,6 @@ spdy@^4.0.2: select-hose "^2.0.0" spdy-transport "^3.0.0" -sprintf-js@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.3.tgz#4914b903a2f8b685d17fdf78a70e917e872e444a" - integrity sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA== - statuses@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" @@ -2984,11 +2679,6 @@ terser@^5.26.0: commander "^2.20.0" source-map-support "~0.5.20" -text-encoding@^0.7.0: - version "0.7.0" - resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.7.0.tgz#f895e836e45990624086601798ea98e8f36ee643" - integrity sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA== - thingies@^1.20.0: version "1.21.0" resolved "https://registry.yarnpkg.com/thingies/-/thingies-1.21.0.tgz#e80fbe58fd6fdaaab8fad9b67bd0a5c943c445c1" @@ -3016,17 +2706,12 @@ toidentifier@1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== -tr46@~0.0.3: - version "0.0.3" - resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" - integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== - tree-dump@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/tree-dump/-/tree-dump-1.0.1.tgz#b448758da7495580e6b7830d6b7834fca4c45b96" integrity sha512-WCkcRBVPSlHHq1dc/px9iOfqklvzCbdRwvlNfxGZsrHqf6aZttfPrd7DJTt6oR10dwUfpFFQeVTkPbBIZxX/YA== -tslib@^2.0.0, tslib@^2.0.1: +tslib@^2.0.0: version "2.6.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== @@ -3059,11 +2744,6 @@ universalify@^0.1.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== -universalify@^2.0.0: - version "2.0.1" - resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d" - integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw== - unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" @@ -3124,16 +2804,6 @@ wbuf@^1.1.0, wbuf@^1.7.3: dependencies: minimalistic-assert "^1.0.0" -webidl-conversions@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" - integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== - -webidl-conversions@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" - integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA== - webpack-cli@5.1.4: version "5.1.4" resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-5.1.4.tgz#c8e046ba7eaae4911d7e71e2b25b776fcc35759b" @@ -3266,23 +2936,6 @@ websocket-extensions@>=0.1.1: resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== -whatwg-url-without-unicode@8.0.0-3: - version "8.0.0-3" - resolved "https://registry.yarnpkg.com/whatwg-url-without-unicode/-/whatwg-url-without-unicode-8.0.0-3.tgz#ab6df4bf6caaa6c85a59f6e82c026151d4bb376b" - integrity sha512-HoKuzZrUlgpz35YO27XgD28uh/WJH4B0+3ttFqRo//lmq+9T/mIOJ6kqmINI9HpUpz1imRC/nR/lxKpJiv0uig== - dependencies: - buffer "^5.4.3" - punycode "^2.1.1" - webidl-conversions "^5.0.0" - -whatwg-url@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" - integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== - dependencies: - tr46 "~0.0.3" - webidl-conversions "^3.0.0" - which@^1.2.1: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" diff --git a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt new file mode 100644 index 000000000..41346d10f --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt @@ -0,0 +1,18 @@ +package com.pubnub.kmp + +import com.pubnub.api.asList +import com.pubnub.api.asString +import com.pubnub.api.createJsonElement +import kotlin.test.Test +import kotlin.test.assertEquals + +class JsonElementTest { + + @Test + fun asList() { + val list = listOf("abc", "def") + val jsonList = createJsonElement(list.map { createJsonElement(it) }) + + assertEquals(list, jsonList.asList()?.map { it.asString() }) + } +} \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt index 6c966dab9..ea46b4a9d 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt @@ -33,6 +33,10 @@ actual abstract class JsonElement(val value: Any?) { override fun hashCode(): Int { return value?.hashCode() ?: 0 } + + override fun toString(): String { + return "JSONElement(${value.toString()})" + } } class JsonElementImpl(value: Any?) : JsonElement(value) diff --git a/swift b/swift index 42c7706e3..e5bc7d3dc 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit 42c7706e3239fe26e0f2f0c1da047dec0b6bf877 +Subproject commit e5bc7d3dc8081450e892fb93ae57261f05e389f0 From e8d77b5d376f50563fa1b373ff54452cfe1be09f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Thu, 25 Jul 2024 15:22:30 +0200 Subject: [PATCH 43/62] Changes for Chat project --- .../gradle/tasks/GenerateVersionTask.kt | 21 +- kotlin-js-store/yarn.lock | 367 +++++++++++++++++- .../pubnub/internal/v2/PNConfigurationImpl.kt | 2 +- 3 files changed, 382 insertions(+), 8 deletions(-) diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/tasks/GenerateVersionTask.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/tasks/GenerateVersionTask.kt index 8f59e3cb6..e1e397f2d 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/tasks/GenerateVersionTask.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/tasks/GenerateVersionTask.kt @@ -12,12 +12,27 @@ import java.io.File @CacheableTask abstract class GenerateVersionTask : DefaultTask() { + @get:Input + abstract val fileName: Property + + @get:Input + abstract val packageName: Property + + @get:Input + abstract val constName: Property + @get:Input abstract val version: Property @get:OutputDirectory abstract val outputDirectory: DirectoryProperty + init { + fileName.convention("PubNubVersion") + packageName.convention("com.pubnub.internal") + constName.convention("PUBNUB_VERSION") + } + @TaskAction fun run() { val outputDir = outputDirectory.get().asFile @@ -29,10 +44,10 @@ abstract class GenerateVersionTask : DefaultTask() { throw IllegalStateException("Version can't be blank. Check gradle.properties VERSION_NAME= property") } - File(outputDir, "PubNubVersion.kt").writeText(""" - package com.pubnub.internal + File(outputDir, "${fileName.get()}.kt").writeText(""" + package ${packageName.get()} - internal const val PUBNUB_VERSION = "$versionString" + internal const val ${constName.get()} = "$versionString" """.trimIndent()) } diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 46d7315c0..597dc5594 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -99,6 +99,11 @@ resolved "https://registry.yarnpkg.com/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz#821f8442f4175d8f0467b9daf26e3a18e2d02af2" integrity sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA== +"@tootallnate/quickjs-emscripten@^0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz#db4ecfd499a9765ab24002c3b696d02e6d32a12c" + integrity sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA== + "@types/body-parser@*": version "1.19.5" resolved "https://registry.yarnpkg.com/@types/body-parser/-/body-parser-1.19.5.tgz#04ce9a3b677dc8bd681a17da1ab9835dc9d3ede4" @@ -435,6 +440,20 @@ acorn@^8.7.1, acorn@^8.8.2: resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" integrity sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg== +agent-base@^7.0.2, agent-base@^7.1.0, agent-base@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.1.tgz#bdbded7dfb096b751a2a087eeeb9664725b2e317" + integrity sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA== + dependencies: + debug "^4.3.4" + +agentkeepalive@^3.5.2: + version "3.5.3" + resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-3.5.3.tgz#c210afce942b4287e2df2fbfe6c0d57eda2ce634" + integrity sha512-yqXL+k5rr8+ZRpOAntkaaRgWgE5o8ESAj5DyRmVTCSoZxXmqemb9Dd7T4i5UzwuERdLAJUy6XzR9zFVuf0kzkw== + dependencies: + humanize-ms "^1.2.1" + ajv-formats@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520" @@ -524,16 +543,38 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg== +ast-types@^0.13.4: + version "0.13.4" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.13.4.tgz#ee0d77b343263965ecc3fb62da16e7222b2b6782" + integrity sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w== + dependencies: + tslib "^2.0.1" + +asynckit@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" + integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== + balanced-match@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== +base64-js@^1.3.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" + integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== + base64id@2.0.0, base64id@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== +basic-ftp@^5.0.2: + version "5.0.5" + resolved "https://registry.yarnpkg.com/basic-ftp/-/basic-ftp-5.0.5.tgz#14a474f5fffecca1f4f406f1c26b18f800225ac0" + integrity sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg== + batch@0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/batch/-/batch-0.6.1.tgz#dc34314f4e679318093fc760272525f94bf25c16" @@ -612,6 +653,22 @@ buffer-from@^1.0.0: resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5" integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ== +buffer@^5.4.3: + version "5.7.1" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" + integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.1.13" + +buffer@^6.0.3: + version "6.0.3" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6" + integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA== + dependencies: + base64-js "^1.3.1" + ieee754 "^1.2.1" + bundle-name@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/bundle-name/-/bundle-name-4.1.0.tgz#f3b96b34160d6431a19d7688135af7cfb8797889" @@ -650,6 +707,16 @@ caniuse-lite@^1.0.30001587: resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001616.tgz#4342712750d35f71ebba9fcac65e2cf8870013c3" integrity sha512-RHVYKov7IcdNjVHJFNY/78RdG4oGVjbayxv8u5IO74Wv7Hlq4PnJE6mo/OjFijjVFNy5ijnCt6H3IIo4t+wfEw== +cbor-js@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/cbor-js/-/cbor-js-0.1.0.tgz#c80ce6120f387e8faa74370dfda21d965b8fc7f9" + integrity sha512-7sQ/TvDZPl7csT1Sif9G0+MA0I0JOVah8+wWlJVQdVEgIbCzlN/ab3x+uvMNsc34TUvO6osQTAmB2ls80JX6tw== + +cbor-sync@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/cbor-sync/-/cbor-sync-1.0.4.tgz#5a11a1ab75c2a14d1af1b237fd84aa8c1593662f" + integrity sha512-GWlXN4wiz0vdWWXBU71Dvc1q3aBo0HytqwAZnXF1wOwjqNnDWA1vZ1gDMFLlqohak31VQzmhiYfiCX5QSSfagA== + chalk@^4.1.0: version "4.1.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01" @@ -728,6 +795,13 @@ colorette@^2.0.10, colorette@^2.0.14: resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a" integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w== +combined-stream@^1.0.8: + version "1.0.8" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" + integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== + dependencies: + delayed-stream "~1.0.0" + commander@^10.0.1: version "10.0.1" resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" @@ -832,6 +906,11 @@ custom-event@~1.0.0: resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" integrity sha512-GAj5FOq0Hd+RsCGVJxZuKaIDXDf3h6GQoNEjFgbLLI/trgtavwUbSnZ5pVfg27DVCaWjIohryS0JFwIJyT2cMg== +data-uri-to-buffer@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz#8a58bb67384b261a38ef18bea1810cb01badd28b" + integrity sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw== + date-format@^4.0.14: version "4.0.14" resolved "https://registry.yarnpkg.com/date-format/-/date-format-4.0.14.tgz#7a8e584434fb169a521c8b7aa481f355810d9400" @@ -844,6 +923,13 @@ debug@2.6.9: dependencies: ms "2.0.0" +debug@4: + version "4.3.5" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.5.tgz#e83444eceb9fedd4a1da56d671ae2446a01a6e1e" + integrity sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg== + dependencies: + ms "2.1.2" + debug@4.3.4, debug@^4.1.0, debug@^4.3.4, debug@~4.3.1, debug@~4.3.2, debug@~4.3.4: version "4.3.4" resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" @@ -890,6 +976,20 @@ define-lazy-prop@^3.0.0: resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz#dbb19adfb746d7fc6d734a06b72f4a00d021255f" integrity sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg== +degenerator@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-5.0.1.tgz#9403bf297c6dad9a1ece409b37db27954f91f2f5" + integrity sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ== + dependencies: + ast-types "^0.13.4" + escodegen "^2.1.0" + esprima "^4.0.1" + +delayed-stream@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" + integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== + depd@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" @@ -1038,6 +1138,17 @@ escape-string-regexp@4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== +escodegen@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.1.0.tgz#ba93bbb7a43986d29d6041f99f5262da773e2e17" + integrity sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w== + dependencies: + esprima "^4.0.1" + estraverse "^5.2.0" + esutils "^2.0.2" + optionalDependencies: + source-map "~0.6.1" + eslint-scope@5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" @@ -1046,6 +1157,11 @@ eslint-scope@5.1.1: esrecurse "^4.3.0" estraverse "^4.1.1" +esprima@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" + integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== + esrecurse@^4.3.0: version "4.3.0" resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921" @@ -1063,6 +1179,11 @@ estraverse@^5.2.0: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-5.3.0.tgz#2eea5290702f26ab8fe5370370ff86c965d21123" integrity sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA== +esutils@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== + etag@~1.8.1: version "1.8.1" resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" @@ -1229,6 +1350,15 @@ foreground-child@^3.1.0: cross-spawn "^7.0.0" signal-exit "^4.0.1" +form-data@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" + integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== + dependencies: + asynckit "^0.4.0" + combined-stream "^1.0.8" + mime-types "^2.1.12" + format-util@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271" @@ -1244,6 +1374,15 @@ fresh@0.5.2: resolved "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7" integrity sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q== +fs-extra@^11.2.0: + version "11.2.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b" + integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs-extra@^8.1.0: version "8.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.1.0.tgz#49d43c45a88cd9677668cb7be1b46efdb8d2e1c0" @@ -1289,6 +1428,16 @@ get-stream@^6.0.0: resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== +get-uri@^6.0.1: + version "6.0.3" + resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-6.0.3.tgz#0d26697bc13cf91092e519aa63aa60ee5b6f385a" + integrity sha512-BzUrJBS9EcUb4cFol8r4W3v1cPsSyajLSthNkz5BxbpDcHN5tIrM10E2eNvfnvBn3DaT3DUgx0OpsBKkaOpanw== + dependencies: + basic-ftp "^5.0.2" + data-uri-to-buffer "^6.0.2" + debug "^4.3.4" + fs-extra "^11.2.0" + glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" @@ -1432,6 +1581,14 @@ http-parser-js@>=0.5.1: resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.5.8.tgz#af23090d9ac4e24573de6f6aecc9d84a48bf20e3" integrity sha512-SGeBX54F94Wgu5RH3X5jsDtf4eHyRogWX1XGT3b4HuW3tQPM4AaBzoUji/4AAJNXCEOWZ5O0DgZmJw1947gD5Q== +http-proxy-agent@^7.0.0, http-proxy-agent@^7.0.1: + version "7.0.2" + resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz#9a8b1f246866c028509486585f62b8f2c18c270e" + integrity sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig== + dependencies: + agent-base "^7.1.0" + debug "^4.3.4" + http-proxy-middleware@^2.0.3: version "2.0.6" resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f" @@ -1452,11 +1609,26 @@ http-proxy@^1.18.1: follow-redirects "^1.0.0" requires-port "^1.0.0" +https-proxy-agent@^7.0.3, https-proxy-agent@^7.0.5: + version "7.0.5" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz#9e8b5013873299e11fab6fd548405da2d6c602b2" + integrity sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw== + dependencies: + agent-base "^7.0.2" + debug "4" + human-signals@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== +humanize-ms@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed" + integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ== + dependencies: + ms "^2.0.0" + hyperdyperid@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/hyperdyperid/-/hyperdyperid-1.2.0.tgz#59668d323ada92228d2a869d3e474d5a33b69e6b" @@ -1476,6 +1648,11 @@ iconv-lite@^0.6.3: dependencies: safer-buffer ">= 2.1.2 < 3.0.0" +ieee754@^1.1.13, ieee754@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" + integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== + import-local@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/import-local/-/import-local-3.1.0.tgz#b4479df8a5fd44f6cdce24070675676063c95cb4" @@ -1507,6 +1684,14 @@ interpret@^3.1.1: resolved "https://registry.yarnpkg.com/interpret/-/interpret-3.1.1.tgz#5be0ceed67ca79c6c4bc5cf0d7ee843dcea110c4" integrity sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ== +ip-address@^9.0.5: + version "9.0.5" + resolved "https://registry.yarnpkg.com/ip-address/-/ip-address-9.0.5.tgz#117a960819b08780c3bd1f14ef3c1cc1d3f3ea5a" + integrity sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g== + dependencies: + jsbn "1.1.0" + sprintf-js "^1.1.3" + ipaddr.js@1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" @@ -1649,6 +1834,11 @@ js-yaml@4.1.0: dependencies: argparse "^2.0.1" +jsbn@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-1.1.0.tgz#b01307cb29b618a1ed26ec79e911f803c4da0040" + integrity sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A== + json-parse-even-better-errors@^2.3.1: version "2.3.1" resolved "https://registry.yarnpkg.com/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz#7c47805a94319928e05777405dc12e1f7a4ee02d" @@ -1671,6 +1861,15 @@ jsonfile@^4.0.0: optionalDependencies: graceful-fs "^4.1.6" +jsonfile@^6.0.1: + version "6.1.0" + resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae" + integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ== + dependencies: + universalify "^2.0.0" + optionalDependencies: + graceful-fs "^4.1.6" + karma-chrome-launcher@3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/karma-chrome-launcher/-/karma-chrome-launcher-3.2.0.tgz#eb9c95024f2d6dfbb3748d3415ac9b381906b9a9" @@ -1744,6 +1943,11 @@ launch-editor@^2.6.1: picocolors "^1.0.0" shell-quote "^1.8.1" +lil-uuid@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/lil-uuid/-/lil-uuid-0.1.1.tgz#f9edcf23f00e42bf43f0f843d98d8b53f3341f16" + integrity sha512-GhWI8f61tBlMeqULZ1QWhFiiyFIFdPlg//S8Udq1wjq1FJhpFKTfnbduSxAQjueofeUtpr7UvQ/lIK/sKUF8dg== + loader-runner@^4.2.0: version "4.3.0" resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-4.3.0.tgz#c1b4a163b99f614830353b16755e7149ac2314e1" @@ -1792,6 +1996,11 @@ lru-cache@^10.2.0: resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.2.tgz#48206bc114c1252940c41b25b41af5b545aca878" integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== +lru-cache@^7.14.1: + version "7.18.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-7.18.3.tgz#f793896e0fd0e954a59dfdd82f0773808df6aa89" + integrity sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA== + media-typer@0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/media-typer/-/media-typer-0.3.0.tgz#8710d7af0aa626f8fffa1ce00168545263255748" @@ -1835,7 +2044,7 @@ mime-db@1.52.0, "mime-db@>= 1.43.0 < 2": resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34: +mime-types@^2.1.12, mime-types@^2.1.27, mime-types@^2.1.31, mime-types@~2.1.17, mime-types@~2.1.24, mime-types@~2.1.34: version "2.1.35" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== @@ -1943,7 +2152,7 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@2.1.3: +ms@2.1.3, ms@^2.0.0: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -1966,6 +2175,18 @@ neo-async@^2.6.2: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== +netmask@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/netmask/-/netmask-2.0.2.tgz#8b01a07644065d536383835823bc52004ebac5e7" + integrity sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg== + +node-fetch@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + node-forge@^1: version "1.3.1" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.1.tgz#be8da2af243b2417d5f646a770663a92b7e9ded3" @@ -2088,6 +2309,28 @@ p-try@^2.0.0: resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== +pac-proxy-agent@^7.0.1: + version "7.0.2" + resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-7.0.2.tgz#0fb02496bd9fb8ae7eb11cfd98386daaac442f58" + integrity sha512-BFi3vZnO9X5Qt6NRz7ZOaPja3ic0PhlsmCRYLOpN11+mWBCR6XJDqW5RF3j8jm4WGGQZtBA+bTfxYzeKW73eHg== + dependencies: + "@tootallnate/quickjs-emscripten" "^0.23.0" + agent-base "^7.0.2" + debug "^4.3.4" + get-uri "^6.0.1" + http-proxy-agent "^7.0.0" + https-proxy-agent "^7.0.5" + pac-resolver "^7.0.1" + socks-proxy-agent "^8.0.4" + +pac-resolver@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-7.0.1.tgz#54675558ea368b64d210fd9c92a640b5f3b8abb6" + integrity sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg== + dependencies: + degenerator "^5.0.0" + netmask "^2.0.2" + parseurl@~1.3.2, parseurl@~1.3.3: version "1.3.3" resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4" @@ -2156,7 +2399,42 @@ proxy-addr@~2.0.7: forwarded "0.2.0" ipaddr.js "1.9.1" -punycode@^2.1.0: +proxy-agent@^6.3.0: + version "6.4.0" + resolved "https://registry.yarnpkg.com/proxy-agent/-/proxy-agent-6.4.0.tgz#b4e2dd51dee2b377748aef8d45604c2d7608652d" + integrity sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ== + dependencies: + agent-base "^7.0.2" + debug "^4.3.4" + http-proxy-agent "^7.0.1" + https-proxy-agent "^7.0.3" + lru-cache "^7.14.1" + pac-proxy-agent "^7.0.1" + proxy-from-env "^1.1.0" + socks-proxy-agent "^8.0.2" + +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + +pubnub@8.2.4: + version "8.2.4" + resolved "https://registry.yarnpkg.com/pubnub/-/pubnub-8.2.4.tgz#5461d5fc11df4a35dcaf0332a7967c182baedc6a" + integrity sha512-NlA1Kk6f1CfI5n1yNB5hICwDSIWXaOyjHwEm0jmxPbAS+Mj8+WVeUZBomDIrTS870r37ynT9BUkr71gHWUq7Xg== + dependencies: + agentkeepalive "^3.5.2" + buffer "^6.0.3" + cbor-js "^0.1.0" + cbor-sync "^1.0.4" + form-data "^4.0.0" + lil-uuid "^0.1.1" + node-fetch "^2.7.0" + proxy-agent "^6.3.0" + react-native-url-polyfill "^2.0.0" + text-encoding "^0.7.0" + +punycode@^2.1.0, punycode@^2.1.1: version "2.3.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5" integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg== @@ -2195,6 +2473,13 @@ raw-body@2.5.2: iconv-lite "0.4.24" unpipe "1.0.0" +react-native-url-polyfill@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/react-native-url-polyfill/-/react-native-url-polyfill-2.0.0.tgz#db714520a2985cff1d50ab2e66279b9f91ffd589" + integrity sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA== + dependencies: + whatwg-url-without-unicode "8.0.0-3" + readable-stream@^2.0.1: version "2.3.8" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b" @@ -2465,6 +2750,11 @@ signal-exit@^4.0.1: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-4.1.0.tgz#952188c1cbd546070e2dd20d0f41c0ae0530cb04" integrity sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw== +smart-buffer@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/smart-buffer/-/smart-buffer-4.2.0.tgz#6e1d71fa4f18c05f7d0ff216dd16a481d0e8d9ae" + integrity sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg== + socket.io-adapter@~2.5.2: version "2.5.4" resolved "https://registry.yarnpkg.com/socket.io-adapter/-/socket.io-adapter-2.5.4.tgz#4fdb1358667f6d68f25343353bd99bd11ee41006" @@ -2503,6 +2793,23 @@ sockjs@^0.3.24: uuid "^8.3.2" websocket-driver "^0.7.4" +socks-proxy-agent@^8.0.2, socks-proxy-agent@^8.0.4: + version "8.0.4" + resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-8.0.4.tgz#9071dca17af95f483300316f4b063578fa0db08c" + integrity sha512-GNAq/eg8Udq2x0eNiFkr9gRg5bA7PXEWagQdeRX4cPSG+X/8V38v637gim9bjFptMk1QWsCTr0ttrJEiXbNnRw== + dependencies: + agent-base "^7.1.1" + debug "^4.3.4" + socks "^2.8.3" + +socks@^2.8.3: + version "2.8.3" + resolved "https://registry.yarnpkg.com/socks/-/socks-2.8.3.tgz#1ebd0f09c52ba95a09750afe3f3f9f724a800cb5" + integrity sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw== + dependencies: + ip-address "^9.0.5" + smart-buffer "^4.2.0" + sonic-forest@^1.0.0: version "1.0.3" resolved "https://registry.yarnpkg.com/sonic-forest/-/sonic-forest-1.0.3.tgz#81363af60017daba39b794fce24627dc412563cb" @@ -2531,7 +2838,7 @@ source-map-support@~0.5.20: buffer-from "^1.0.0" source-map "^0.6.0" -source-map@^0.6.0, source-map@^0.6.1: +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== @@ -2559,6 +2866,11 @@ spdy@^4.0.2: select-hose "^2.0.0" spdy-transport "^3.0.0" +sprintf-js@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.3.tgz#4914b903a2f8b685d17fdf78a70e917e872e444a" + integrity sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA== + statuses@2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" @@ -2679,6 +2991,11 @@ terser@^5.26.0: commander "^2.20.0" source-map-support "~0.5.20" +text-encoding@^0.7.0: + version "0.7.0" + resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.7.0.tgz#f895e836e45990624086601798ea98e8f36ee643" + integrity sha512-oJQ3f1hrOnbRLOcwKz0Liq2IcrvDeZRHXhd9RgLrsT+DjWY/nty1Hi7v3dtkaEYbPYe0mUoOfzRrMwfXXwgPUA== + thingies@^1.20.0: version "1.21.0" resolved "https://registry.yarnpkg.com/thingies/-/thingies-1.21.0.tgz#e80fbe58fd6fdaaab8fad9b67bd0a5c943c445c1" @@ -2706,6 +3023,11 @@ toidentifier@1.0.1: resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== +tr46@~0.0.3: + version "0.0.3" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" + integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== + tree-dump@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/tree-dump/-/tree-dump-1.0.1.tgz#b448758da7495580e6b7830d6b7834fca4c45b96" @@ -2716,6 +3038,11 @@ tslib@^2.0.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== +tslib@^2.0.1: + version "2.6.3" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" + integrity sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ== + type-is@~1.6.18: version "1.6.18" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" @@ -2744,6 +3071,11 @@ universalify@^0.1.0: resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66" integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg== +universalify@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.1.tgz#168efc2180964e6386d061e094df61afe239b18d" + integrity sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw== + unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" @@ -2804,6 +3136,16 @@ wbuf@^1.1.0, wbuf@^1.7.3: dependencies: minimalistic-assert "^1.0.0" +webidl-conversions@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871" + integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== + +webidl-conversions@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" + integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA== + webpack-cli@5.1.4: version "5.1.4" resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-5.1.4.tgz#c8e046ba7eaae4911d7e71e2b25b776fcc35759b" @@ -2936,6 +3278,23 @@ websocket-extensions@>=0.1.1: resolved "https://registry.yarnpkg.com/websocket-extensions/-/websocket-extensions-0.1.4.tgz#7f8473bc839dfd87608adb95d7eb075211578a42" integrity sha512-OqedPIGOfsDlo31UNwYbCFMSaO9m9G/0faIHj5/dZFDMFqPTcx6UwqyOy3COEaEOg/9VsGIpdqn62W5KhoKSpg== +whatwg-url-without-unicode@8.0.0-3: + version "8.0.0-3" + resolved "https://registry.yarnpkg.com/whatwg-url-without-unicode/-/whatwg-url-without-unicode-8.0.0-3.tgz#ab6df4bf6caaa6c85a59f6e82c026151d4bb376b" + integrity sha512-HoKuzZrUlgpz35YO27XgD28uh/WJH4B0+3ttFqRo//lmq+9T/mIOJ6kqmINI9HpUpz1imRC/nR/lxKpJiv0uig== + dependencies: + buffer "^5.4.3" + punycode "^2.1.1" + webidl-conversions "^5.0.0" + +whatwg-url@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d" + integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw== + dependencies: + tr46 "~0.0.3" + webidl-conversions "^3.0.0" + which@^1.2.1: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt index 666f13ece..e141c822d 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt @@ -59,7 +59,7 @@ class PNConfigurationImpl( override val retryConfiguration: RetryConfiguration, override val managePresenceListManually: Boolean, ) : BasePNConfigurationImpl(userId), PNConfiguration, PNConfigurationOverride { - class Builder internal constructor(defaultConfiguration: BasePNConfiguration) : + class Builder(defaultConfiguration: BasePNConfiguration) : BasePNConfigurationImpl.Builder(defaultConfiguration), PNConfiguration.Builder, PNConfigurationOverride.Builder { From 2d29625707ddcb6daf56c29dc8886d1f36d4234b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Mon, 29 Jul 2024 12:18:07 +0000 Subject: [PATCH 44/62] Get rid of com.pubnub.kmp.PubNub (#261) --- .../gradle/PubNubKotlinMultiplatformPlugin.kt | 22 +- pubnub-core/pubnub-core-api/build.gradle.kts | 1 - .../config/ktlint/baseline.xml | 3 - .../kotlin/com/pubnub/kmp/JsonElementTest.kt | 5 +- .../kotlin/com/pubnub/api/JsonElement.ios.kt | 2 +- .../config/ktlint/baseline.xml | 4 +- .../kotlin/com/pubnub/{kmp => api}/PubNub.kt | 6 +- .../kotlin/com/pubnub/kmp/factories.kt | 1 + .../kotlin/com/pubnub/api/PubNubImpl.kt | 1 - .../api/v2/callbacks/EventListener.ios.kt | 2 +- .../api/v2/callbacks/StatusListener.ios.kt | 2 +- .../kotlin/com/pubnub/kmp/factories.ios.kt | 1 + .../kotlin/com/pubnub/api/PubNubImpl.kt | 1 - .../kotlin/com/pubnub/kmp/factories.js.kt | 1 + .../jvmMain/kotlin/com/pubnub/api/PubNub.kt | 112 ++--- .../kotlin/com/pubnub/kmp/factories.jvm.kt | 21 +- .../kotlin/com/pubnub/api/PubNub.nonJvm.kt | 444 ++++++++++++++++++ .../pubnub/internal/v2/PNConfigurationImpl.kt | 242 +++++----- .../com.pubnub.test/BaseIntegrationTest.kt | 2 +- .../kotlin/com.pubnub.test/FakePubNub.kt | 2 +- 20 files changed, 670 insertions(+), 205 deletions(-) rename pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/{kmp => api}/PubNub.kt (99%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt index e1ed9f52f..fae6c68bf 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt @@ -5,10 +5,13 @@ import org.gradle.api.Project import org.gradle.api.plugins.ExtensionAware import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.creating +import org.gradle.kotlin.dsl.getting +import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.withType -import org.jetbrains.dokka.DokkaDefaults.moduleName import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetContainer import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget @@ -43,7 +46,6 @@ class PubNubKotlinMultiplatformPlugin : Plugin { listOf( iosArm64(), - // iosX64(), iosSimulatorArm64(), ).forEach { it.binaries { @@ -52,6 +54,22 @@ class PubNubKotlinMultiplatformPlugin : Plugin { } } } + applyDefaultHierarchyTemplate() + with (sourceSets) { + val commonMain = getByName("commonMain") + + val nonJvm = create("nonJvm") { + it.dependsOn(commonMain) + } + + val jsMain = getByName("jsMain") { + it.dependsOn(nonJvm) + } + + val iosMain = getByName("iosMain") { + it.dependsOn(nonJvm) + } + } (this as? ExtensionAware)?.extensions?.configure { ios.deploymentTarget = "14" diff --git a/pubnub-core/pubnub-core-api/build.gradle.kts b/pubnub-core/pubnub-core-api/build.gradle.kts index a350ba89b..23007352e 100644 --- a/pubnub-core/pubnub-core-api/build.gradle.kts +++ b/pubnub-core/pubnub-core-api/build.gradle.kts @@ -32,4 +32,3 @@ kotlin { } } } - diff --git a/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml b/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml index 1e346c7d2..981420778 100644 --- a/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml +++ b/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml @@ -1,6 +1,3 @@ - - - diff --git a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt index 41346d10f..e63308b60 100644 --- a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt +++ b/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt @@ -7,12 +7,11 @@ import kotlin.test.Test import kotlin.test.assertEquals class JsonElementTest { - @Test fun asList() { val list = listOf("abc", "def") - val jsonList = createJsonElement(list.map { createJsonElement(it) }) + val jsonList = createJsonElement(list) assertEquals(list, jsonList.asList()?.map { it.asString() }) } -} \ No newline at end of file +} diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt index ea46b4a9d..c4695a845 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt @@ -35,7 +35,7 @@ actual abstract class JsonElement(val value: Any?) { } override fun toString(): String { - return "JSONElement(${value.toString()})" + return "JSONElement($value)" } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml b/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml index ee5e6035a..7d091a9a8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml +++ b/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml @@ -75,7 +75,7 @@ - - + + diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt similarity index 99% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt index 69a064570..d626c11de 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt @@ -1,4 +1,4 @@ -package com.pubnub.kmp +package com.pubnub.api import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages @@ -71,8 +71,10 @@ import com.pubnub.api.v2.subscriptions.EmptyOptions import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet +import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.Uploadable -interface PubNub { +expect interface PubNub { val configuration: PNConfiguration fun addListener(listener: EventListener) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt index ca75391bd..c57dd3b12 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/factories.kt @@ -1,5 +1,6 @@ package com.pubnub.kmp +import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index e79ebc97b..3d6c1a6d9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -139,7 +139,6 @@ import com.pubnub.internal.entities.UserMetadataImpl import com.pubnub.internal.subscription.SubscriptionImpl import com.pubnub.internal.subscription.SubscriptionSetImpl import com.pubnub.kmp.CustomObject -import com.pubnub.kmp.PubNub import com.pubnub.kmp.Uploadable import kotlinx.cinterop.ExperimentalForeignApi diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt index 183734c2d..fd0965f19 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -1,13 +1,13 @@ package com.pubnub.api.v2.callbacks import cocoapods.PubNubSwift.PubNubEventListenerObjC +import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.kmp.PubNub import kotlinx.cinterop.ExperimentalForeignApi /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt index baf190dba..9723f6e24 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.v2.callbacks import cocoapods.PubNubSwift.PubNubStatusListenerObjC +import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.kmp.PubNub import kotlinx.cinterop.ExperimentalForeignApi /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 6d6897820..31c79bc1e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -22,6 +22,7 @@ import cocoapods.PubNubSwift.PubNubSetMembershipResultObjC import cocoapods.PubNubSwift.PubNubSetUUIDMetadataResultObjC import cocoapods.PubNubSwift.PubNubStatusListenerObjC import com.pubnub.api.JsonElementImpl +import com.pubnub.api.PubNub import com.pubnub.api.PubNubException import com.pubnub.api.PubNubImpl import com.pubnub.api.enums.PNStatusCategory diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt index 960c6382b..a58ba76e5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -127,7 +127,6 @@ import com.pubnub.internal.v2.entities.ChannelImpl import com.pubnub.internal.v2.subscriptions.SubscriptionSetImpl import com.pubnub.kmp.CustomObject import com.pubnub.kmp.Optional -import com.pubnub.kmp.PubNub import com.pubnub.kmp.Uploadable import com.pubnub.kmp.createJsObject import com.pubnub.kmp.toJsMap diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt index dcd6d45cd..312bf41c5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt @@ -1,6 +1,7 @@ package com.pubnub.kmp import com.pubnub.api.JsonElementImpl +import com.pubnub.api.PubNub import com.pubnub.api.PubNubImpl import com.pubnub.api.enums.PNStatusCategory import com.pubnub.api.models.consumer.PNStatus diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index b751c202a..d4ff9b6c7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -72,13 +72,13 @@ import com.pubnub.api.v2.entities.ChannelGroup import com.pubnub.api.v2.entities.ChannelMetadata import com.pubnub.api.v2.entities.UserMetadata import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.internal.BasePubNubImpl import com.pubnub.kmp.CustomObject import java.io.InputStream -interface PubNub : - com.pubnub.kmp.PubNub, +actual interface PubNub : BasePubNub, EventEmitter { companion object { @@ -131,7 +131,7 @@ interface PubNub : * Modifying the values in this configuration is not advised, as it may lead * to undefined behavior. */ - override val configuration: com.pubnub.api.v2.PNConfiguration + actual val configuration: com.pubnub.api.v2.PNConfiguration /** * Add a legacy listener for both client status and events. @@ -187,7 +187,7 @@ interface PubNub : * - If ttl isn't specified, then expiration of the message defaults * back to the expiry value for the key. */ - override fun publish( + actual fun publish( channel: String, message: Any, meta: Any?, @@ -227,7 +227,7 @@ interface PubNub : * - If ttl isn't specified, then expiration of the message defaults * back to the expiry value for the key. */ - override fun fire( + actual fun fire( channel: String, message: Any, meta: Any?, @@ -245,7 +245,7 @@ interface PubNub : * @param channel The channel which the signal will be sent to. * @param message The payload which will be serialized and sent. */ - override fun signal( + actual fun signal( channel: String, message: Any, ): Signal @@ -255,14 +255,14 @@ interface PubNub : * * @return A list of channels the client is currently subscribed to. */ - override fun getSubscribedChannels(): List + actual fun getSubscribedChannels(): List /** * Queries the local subscribe loop for channel groups currently in the mix. * * @return A list of channel groups the client is currently subscribed to. */ - override fun getSubscribedChannelGroups(): List + actual fun getSubscribedChannelGroups(): List /** * Enable push notifications on provided set of channels. @@ -276,7 +276,7 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - override fun addPushNotificationsOnChannels( + actual fun addPushNotificationsOnChannels( pushType: PNPushType, channels: List, deviceId: String, @@ -294,7 +294,7 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - override fun auditPushChannelProvisions( + actual fun auditPushChannelProvisions( pushType: PNPushType, deviceId: String, topic: String?, @@ -312,7 +312,7 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - override fun removePushNotificationsFromChannels( + actual fun removePushNotificationsFromChannels( pushType: PNPushType, channels: List, deviceId: String, @@ -330,7 +330,7 @@ interface PubNub : * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). * Required only if pushType set to [PNPushType.APNS2]. */ - override fun removeAllPushNotificationsFromDeviceWithPushToken( + actual fun removeAllPushNotificationsFromDeviceWithPushToken( pushType: PNPushType, deviceId: String, topic: String?, @@ -473,7 +473,7 @@ interface PubNub : * @param includeMessageType Whether to include message type in response. * Defaults to `false`. */ - override fun fetchMessages( + actual fun fetchMessages( channels: List, page: PNBoundedPage, includeUUID: Boolean, @@ -495,7 +495,7 @@ interface PubNub : * @param start Timetoken delimiting the start of time slice (exclusive) to delete messages from. * @param end Time token delimiting the end of time slice (inclusive) to delete messages from. */ - override fun deleteMessages( + actual fun deleteMessages( channels: List, start: Long?, end: Long?, @@ -511,7 +511,7 @@ interface PubNub : * Specify a single timetoken to apply it to all channels. * Otherwise, the list of timetokens must be the same length as the list of channels. */ - override fun messageCounts( + actual fun messageCounts( channels: List, channelsTimetoken: List, ): MessageCounts @@ -529,7 +529,7 @@ interface PubNub : * @param includeUUIDs Whether the response should include UUIDs od connected clients. * Defaults to `true`. */ - override fun hereNow( + actual fun hereNow( channels: List, channelGroups: List, includeState: Boolean, @@ -542,7 +542,7 @@ interface PubNub : * @param uuid UUID of the user to get its current channel subscriptions. Defaults to the UUID of the client. * @see [PNConfiguration.uuid] */ - override fun whereNow(uuid: String): WhereNow + actual fun whereNow(uuid: String): WhereNow /** * Set state information specific to a subscriber UUID. @@ -589,7 +589,7 @@ interface PubNub : * When calling [PubNub.setPresenceState], be sure to supply an initialized JsonObject * or POJO which can be serialized to a JsonObject. */ - override fun setPresenceState( + actual fun setPresenceState( channels: List, channelGroups: List, state: Any, @@ -605,7 +605,7 @@ interface PubNub : * @param uuid UUID of the user to get the state from. Defaults to the UUID of the client. * @see [PNConfiguration.uuid] */ - override fun getPresenceState( + actual fun getPresenceState( channels: List, channelGroups: List, uuid: String, @@ -620,7 +620,7 @@ interface PubNub : * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. */ - override fun presence( + actual fun presence( channels: List, channelGroups: List, connected: Boolean, @@ -633,7 +633,7 @@ interface PubNub : * @param messageAction The message action object containing the message action's type, * value and the publish timetoken of the original message. */ - override fun addMessageAction( + actual fun addMessageAction( channel: String, messageAction: PNMessageAction, ): AddMessageAction @@ -645,7 +645,7 @@ interface PubNub : * @param messageTimetoken The publish timetoken of the original message. * @param actionTimetoken The publish timetoken of the message action to be removed. */ - override fun removeMessageAction( + actual fun removeMessageAction( channel: String, messageTimetoken: Long, actionTimetoken: Long, @@ -683,7 +683,7 @@ interface PubNub : * @param channel Channel to fetch message actions from. * @param page The paging object used for pagination. @see [PNBoundedPage] */ - override fun getMessageActions( + actual fun getMessageActions( channel: String, page: PNBoundedPage, ): GetMessageActions @@ -694,7 +694,7 @@ interface PubNub : * @param channels The channels to add to the channel group. * @param channelGroup The channel group to add the channels to. */ - override fun addChannelsToChannelGroup( + actual fun addChannelsToChannelGroup( channels: List, channelGroup: String, ): AddChannelChannelGroup @@ -704,7 +704,7 @@ interface PubNub : * * @param channelGroup Channel group to fetch the belonging channels. */ - override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup + actual fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup /** * Removes channels from a channel group. @@ -712,7 +712,7 @@ interface PubNub : * @param channelGroup The channel group to remove channels from * @param channels The channels to remove from the channel group. */ - override fun removeChannelsFromChannelGroup( + actual fun removeChannelsFromChannelGroup( channels: List, channelGroup: String, ): RemoveChannelChannelGroup @@ -720,14 +720,14 @@ interface PubNub : /** * Lists all registered channel groups for the subscribe key. */ - override fun listAllChannelGroups(): ListAllChannelGroup + actual fun listAllChannelGroups(): ListAllChannelGroup /** * Removes the channel group. * * @param channelGroup The channel group to remove. */ - override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup + actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup /** * This function establishes access permissions for PubNub Access Manager (PAM) by setting the `read` or `write` @@ -819,7 +819,7 @@ interface PubNub : * @param uuids List of all uuid grants */ - override fun grantToken( + actual fun grantToken( ttl: Int, meta: Any?, authorizedUUID: String?, @@ -857,12 +857,12 @@ interface PubNub : * * @param token Existing token with embedded permissions. */ - override fun revokeToken(token: String): RevokeToken + actual fun revokeToken(token: String): RevokeToken /** * Returns a 17 digit precision Unix epoch from the server. */ - override fun time(): Time + actual fun time(): Time /** * Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each. @@ -882,7 +882,7 @@ interface PubNub : * Default is `false`. * @param includeCustom Include respective additional fields in the response. */ - override fun getAllChannelMetadata( + actual fun getAllChannelMetadata( limit: Int?, page: PNPage?, filter: String?, @@ -897,7 +897,7 @@ interface PubNub : * @param channel Channel name. * @param includeCustom Include respective additional fields in the response. */ - override fun getChannelMetadata( + actual fun getChannelMetadata( channel: String, includeCustom: Boolean, ): GetChannelMetadata @@ -911,7 +911,7 @@ interface PubNub : * @param custom Object with supported data types. * @param includeCustom Include respective additional fields in the response. */ - override fun setChannelMetadata( + actual fun setChannelMetadata( channel: String, name: String?, description: String?, @@ -926,7 +926,7 @@ interface PubNub : * * @param channel Channel name. */ - override fun removeChannelMetadata(channel: String): RemoveChannelMetadata + actual fun removeChannelMetadata(channel: String): RemoveChannelMetadata /** * Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each. @@ -946,7 +946,7 @@ interface PubNub : * Default is `false`. * @param includeCustom Include respective additional fields in the response. */ - override fun getAllUUIDMetadata( + actual fun getAllUUIDMetadata( limit: Int?, page: PNPage?, filter: String?, @@ -961,7 +961,7 @@ interface PubNub : * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. * @param includeCustom Include respective additional fields in the response. */ - override fun getUUIDMetadata( + actual fun getUUIDMetadata( uuid: String?, includeCustom: Boolean, ): GetUUIDMetadata @@ -977,7 +977,7 @@ interface PubNub : * @param custom Object with supported data types. * @param includeCustom Include respective additional fields in the response. */ - override fun setUUIDMetadata( + actual fun setUUIDMetadata( uuid: String?, name: String?, externalId: String?, @@ -994,7 +994,7 @@ interface PubNub : * * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. */ - override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata + actual fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata /** * The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions. @@ -1016,7 +1016,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - override fun getMemberships( + actual fun getMemberships( uuid: String?, limit: Int?, page: PNPage?, @@ -1075,7 +1075,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - override fun setMemberships( + actual fun setMemberships( channels: List, uuid: String?, limit: Int?, @@ -1109,7 +1109,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeChannelDetails Include custom fields for channels metadata. */ - override fun removeMemberships( + actual fun removeMemberships( channels: List, uuid: String?, limit: Int?, @@ -1203,7 +1203,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - override fun getChannelMembers( + actual fun getChannelMembers( channel: String, limit: Int?, page: PNPage?, @@ -1262,7 +1262,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - override fun setChannelMembers( + actual fun setChannelMembers( channel: String, uuids: List, limit: Int?, @@ -1321,7 +1321,7 @@ interface PubNub : * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. */ - override fun removeChannelMembers( + actual fun removeChannelMembers( channel: String, uuids: List, limit: Int?, @@ -1395,7 +1395,7 @@ interface PubNub : * @param cipherKey Key to be used to encrypt uploaded data. If not provided, * cipherKey in @see [PNConfiguration] will be used, if provided. */ - override fun sendFile( + actual fun sendFile( channel: String, fileName: String, inputStream: InputStream, @@ -1413,7 +1413,7 @@ interface PubNub : * @param limit Number of files to return. Minimum value is 1, and maximum is 100. Default value is 100. * @param next Previously-returned cursor bookmark for fetching the next page. @see [PNPage.PNNext] */ - override fun listFiles( + actual fun listFiles( channel: String, limit: Int?, next: PNPage.PNNext?, @@ -1426,7 +1426,7 @@ interface PubNub : * @param fileName Name under which the uploaded file is stored. * @param fileId Unique identifier for the file, assigned during upload. */ - override fun getFileUrl( + actual fun getFileUrl( channel: String, fileName: String, fileId: String, @@ -1441,7 +1441,7 @@ interface PubNub : * @param cipherKey Key to be used to decrypt downloaded data. If a key is not provided, * the SDK uses the cipherKey from the @see [PNConfiguration]. */ - override fun downloadFile( + actual fun downloadFile( channel: String, fileName: String, fileId: String, @@ -1455,7 +1455,7 @@ interface PubNub : * @param fileName Name under which the uploaded file is stored. * @param fileId Unique identifier for the file, assigned during upload. */ - override fun deleteFile( + actual fun deleteFile( channel: String, fileName: String, fileId: String, @@ -1485,7 +1485,7 @@ interface PubNub : * If not specified, then the history configuration of the key is used. * */ - override fun publishFileMessage( + actual fun publishFileMessage( channel: String, fileName: String, fileId: String, @@ -1513,7 +1513,7 @@ interface PubNub : * @param withPresence Also subscribe to related presence channel. * @param withTimetoken A timetoken to start the subscribe loop from. */ - override fun subscribe( + actual fun subscribe( channels: List, channelGroups: List, withPresence: Boolean, @@ -1537,8 +1537,14 @@ interface PubNub : * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. */ - override fun unsubscribe( + actual fun unsubscribe( channels: List, channelGroups: List, ) + + actual override fun subscriptionSetOf( + channels: Set, + channelGroups: Set, + options: SubscriptionOptions + ): SubscriptionSet } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt index b0daa24f0..4fba1c07f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/factories.jvm.kt @@ -11,20 +11,19 @@ import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.kmp.PubNub as PubNubKmp -actual fun createPubNub(config: PNConfiguration): PubNubKmp { +actual fun createPubNub(config: PNConfiguration): PubNub { return PubNub.create(config) } actual fun createEventListener( - pubnub: PubNubKmp, - onMessage: (PubNubKmp, PNMessageResult) -> Unit, - onPresence: (PubNubKmp, PNPresenceEventResult) -> Unit, - onSignal: (PubNubKmp, PNSignalResult) -> Unit, - onMessageAction: (PubNubKmp, PNMessageActionResult) -> Unit, - onObjects: (PubNubKmp, PNObjectEventResult) -> Unit, - onFile: (PubNubKmp, PNFileEventResult) -> Unit + pubnub: PubNub, + onMessage: (PubNub, PNMessageResult) -> Unit, + onPresence: (PubNub, PNPresenceEventResult) -> Unit, + onSignal: (PubNub, PNSignalResult) -> Unit, + onMessageAction: (PubNub, PNMessageActionResult) -> Unit, + onObjects: (PubNub, PNObjectEventResult) -> Unit, + onFile: (PubNub, PNFileEventResult) -> Unit ): EventListener { return object : EventListener { override fun message(pubnub: PubNub, result: PNMessageResult) { @@ -54,8 +53,8 @@ actual fun createEventListener( } actual fun createStatusListener( - pubnub: PubNubKmp, - onStatus: (PubNubKmp, PNStatus) -> Unit + pubnub: PubNub, + onStatus: (PubNub, PNStatus) -> Unit ): StatusListener { return object : StatusListener { override fun status(pubnub: PubNub, status: PNStatus) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt new file mode 100644 index 000000000..12e29a987 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt @@ -0,0 +1,444 @@ +package com.pubnub.api + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.endpoints.DeleteMessages +import com.pubnub.api.endpoints.FetchMessages +import com.pubnub.api.endpoints.MessageCounts +import com.pubnub.api.endpoints.Time +import com.pubnub.api.endpoints.access.GrantToken +import com.pubnub.api.endpoints.access.RevokeToken +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.endpoints.files.DeleteFile +import com.pubnub.api.endpoints.files.DownloadFile +import com.pubnub.api.endpoints.files.GetFileUrl +import com.pubnub.api.endpoints.files.ListFiles +import com.pubnub.api.endpoints.files.PublishFileMessage +import com.pubnub.api.endpoints.files.SendFile +import com.pubnub.api.endpoints.message_actions.AddMessageAction +import com.pubnub.api.endpoints.message_actions.GetMessageActions +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata +import com.pubnub.api.endpoints.objects.member.GetChannelMembers +import com.pubnub.api.endpoints.objects.member.ManageChannelMembers +import com.pubnub.api.endpoints.objects.membership.GetMemberships +import com.pubnub.api.endpoints.objects.membership.ManageMemberships +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata +import com.pubnub.api.endpoints.presence.GetState +import com.pubnub.api.endpoints.presence.HereNow +import com.pubnub.api.endpoints.presence.SetState +import com.pubnub.api.endpoints.presence.WhereNow +import com.pubnub.api.endpoints.pubsub.Publish +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.endpoints.push.AddChannelsToPush +import com.pubnub.api.endpoints.push.ListPushProvisions +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType +import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNToken +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.message_actions.PNMessageAction +import com.pubnub.api.models.consumer.objects.PNKey +import com.pubnub.api.models.consumer.objects.PNMemberKey +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNPage +import com.pubnub.api.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.member.MemberInput +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.api.v2.entities.Channel +import com.pubnub.api.v2.entities.ChannelGroup +import com.pubnub.api.v2.entities.ChannelMetadata +import com.pubnub.api.v2.entities.UserMetadata +import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.api.v2.subscriptions.SubscriptionSet +import com.pubnub.kmp.CustomObject +import com.pubnub.kmp.Uploadable + +actual interface PubNub { + actual val configuration: PNConfiguration + + actual fun addListener(listener: EventListener) + + actual fun addListener(listener: StatusListener) + + actual fun removeListener(listener: Listener) + + actual fun removeAllListeners() + + actual fun publish( + channel: String, + message: Any, + meta: Any?, + shouldStore: Boolean, + usePost: Boolean, + replicate: Boolean, + ttl: Int? + ): Publish + + actual fun fire( + channel: String, + message: Any, + meta: Any?, + usePost: Boolean, + ttl: Int? + ): Publish + + actual fun signal(channel: String, message: Any): Signal + + actual fun getSubscribedChannels(): List + + actual fun getSubscribedChannelGroups(): List + + actual fun addPushNotificationsOnChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): AddChannelsToPush + + actual fun auditPushChannelProvisions( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): ListPushProvisions + + actual fun removePushNotificationsFromChannels( + pushType: PNPushType, + channels: List, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): RemoveChannelsFromPush + + actual fun removeAllPushNotificationsFromDeviceWithPushToken( + pushType: PNPushType, + deviceId: String, + topic: String?, + environment: PNPushEnvironment + ): RemoveAllPushChannelsForDevice + + actual fun fetchMessages( + channels: List, + page: PNBoundedPage, + includeUUID: Boolean, + includeMeta: Boolean, + includeMessageActions: Boolean, + includeMessageType: Boolean + ): FetchMessages + + actual fun deleteMessages( + channels: List, + start: Long?, + end: Long? + ): DeleteMessages + + actual fun messageCounts( + channels: List, + channelsTimetoken: List + ): MessageCounts + + actual fun hereNow( + channels: List, + channelGroups: List, + includeState: Boolean, + includeUUIDs: Boolean + ): HereNow + + actual fun whereNow(uuid: String): WhereNow + + actual fun setPresenceState( + channels: List, + channelGroups: List, + state: Any + ): SetState + + actual fun getPresenceState( + channels: List, + channelGroups: List, + uuid: String + ): GetState + + actual fun presence( + channels: List, + channelGroups: List, + connected: Boolean + ) + + actual fun addMessageAction( + channel: String, + messageAction: PNMessageAction + ): AddMessageAction + + actual fun removeMessageAction( + channel: String, + messageTimetoken: Long, + actionTimetoken: Long + ): RemoveMessageAction + + actual fun getMessageActions( + channel: String, + page: PNBoundedPage + ): GetMessageActions + + actual fun addChannelsToChannelGroup( + channels: List, + channelGroup: String + ): AddChannelChannelGroup + + actual fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup + + actual fun removeChannelsFromChannelGroup( + channels: List, + channelGroup: String + ): RemoveChannelChannelGroup + + actual fun listAllChannelGroups(): ListAllChannelGroup + + actual fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup + + actual fun grantToken( + ttl: Int, + meta: CustomObject?, + authorizedUUID: String?, + channels: List, + channelGroups: List, + uuids: List + ): GrantToken + + actual fun revokeToken(token: String): RevokeToken + + actual fun time(): Time + + actual fun getAllChannelMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllChannelMetadata + + actual fun getChannelMetadata( + channel: String, + includeCustom: Boolean + ): GetChannelMetadata + + actual fun setChannelMetadata( + channel: String, + name: String?, + description: String?, + custom: CustomObject?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetChannelMetadata + + actual fun removeChannelMetadata(channel: String): RemoveChannelMetadata + + actual fun getAllUUIDMetadata( + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean + ): GetAllUUIDMetadata + + actual fun getUUIDMetadata( + uuid: String?, + includeCustom: Boolean + ): GetUUIDMetadata + + actual fun setUUIDMetadata( + uuid: String?, + name: String?, + externalId: String?, + profileUrl: String?, + email: String?, + custom: CustomObject?, + includeCustom: Boolean, + type: String?, + status: String? + ): SetUUIDMetadata + + actual fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata + + actual fun getMemberships( + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean + ): GetMemberships + + actual fun setMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean + ): ManageMemberships + + actual fun removeMemberships( + channels: List, + uuid: String?, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeChannelDetails: PNChannelDetailsLevel?, + includeType: Boolean + ): ManageMemberships + + actual fun getChannelMembers( + channel: String, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean + ): GetChannelMembers + + actual fun setChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean + ): ManageChannelMembers + + actual fun removeChannelMembers( + channel: String, + uuids: List, + limit: Int?, + page: PNPage?, + filter: String?, + sort: Collection>, + includeCount: Boolean, + includeCustom: Boolean, + includeUUIDDetails: PNUUIDDetailsLevel?, + includeType: Boolean + ): ManageChannelMembers + + actual fun listFiles( + channel: String, + limit: Int?, + next: PNPage.PNNext? + ): ListFiles + + actual fun getFileUrl( + channel: String, + fileName: String, + fileId: String + ): GetFileUrl + + actual fun sendFile( + channel: String, + fileName: String, + inputStream: Uploadable, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean?, + cipherKey: String? + ): SendFile + + actual fun downloadFile( + channel: String, + fileName: String, + fileId: String, + cipherKey: String? + ): DownloadFile + + actual fun deleteFile( + channel: String, + fileName: String, + fileId: String + ): DeleteFile + + actual fun publishFileMessage( + channel: String, + fileName: String, + fileId: String, + message: Any?, + meta: Any?, + ttl: Int?, + shouldStore: Boolean? + ): PublishFileMessage + + actual fun subscribe( + channels: List, + channelGroups: List, + withPresence: Boolean, + withTimetoken: Long + ) + + actual fun unsubscribe( + channels: List, + channelGroups: List + ) + + actual fun unsubscribeAll() + + actual fun setToken(token: String?) + + actual fun destroy() + + actual fun channel(name: String): Channel + + actual fun channelGroup(name: String): ChannelGroup + + actual fun channelMetadata(id: String): ChannelMetadata + + actual fun userMetadata(id: String): UserMetadata + + actual fun subscriptionSetOf(subscriptions: Set): SubscriptionSet + + actual fun subscriptionSetOf( + channels: Set, + channelGroups: Set, + options: SubscriptionOptions + ): SubscriptionSet + + actual fun parseToken(token: String): PNToken +} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt index e141c822d..8dab21e95 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt @@ -63,142 +63,142 @@ class PNConfigurationImpl( BasePNConfigurationImpl.Builder(defaultConfiguration), PNConfiguration.Builder, PNConfigurationOverride.Builder { - private val log = LoggerFactory.getLogger(this::class.simpleName) + private val log = LoggerFactory.getLogger(this::class.simpleName) - override var userId: UserId = super.userId + override var userId: UserId = super.userId - override var subscribeKey: String = super.subscribeKey + override var subscribeKey: String = super.subscribeKey - override var publishKey: String = super.publishKey + override var publishKey: String = super.publishKey - override var secretKey: String = super.secretKey + override var secretKey: String = super.secretKey - override var authKey: String = super.authKey + override var authKey: String = super.authKey - override var cryptoModule: CryptoModule? = super.cryptoModule + override var cryptoModule: CryptoModule? = super.cryptoModule - override var origin: String = super.origin + override var origin: String = super.origin - override var secure: Boolean = super.secure + override var secure: Boolean = super.secure - override var logVerbosity: PNLogVerbosity = super.logVerbosity + override var logVerbosity: PNLogVerbosity = super.logVerbosity - override var heartbeatNotificationOptions: PNHeartbeatNotificationOptions = super.heartbeatNotificationOptions + override var heartbeatNotificationOptions: PNHeartbeatNotificationOptions = super.heartbeatNotificationOptions - override var presenceTimeout: Int = super.presenceTimeout - set(value) { - field = - if (value < MINIMUM_PRESENCE_TIMEOUT) { - log.warn("Presence timeout is too low. Defaulting to: $MINIMUM_PRESENCE_TIMEOUT") - MINIMUM_PRESENCE_TIMEOUT - } else { - value - } - heartbeatInterval = (presenceTimeout / 2) - 1 - } + override var presenceTimeout: Int = super.presenceTimeout + set(value) { + field = + if (value < MINIMUM_PRESENCE_TIMEOUT) { + log.warn("Presence timeout is too low. Defaulting to: $MINIMUM_PRESENCE_TIMEOUT") + MINIMUM_PRESENCE_TIMEOUT + } else { + value + } + heartbeatInterval = (presenceTimeout / 2) - 1 + } - override var heartbeatInterval: Int = super.heartbeatInterval + override var heartbeatInterval: Int = super.heartbeatInterval - override var subscribeTimeout: Int = super.subscribeTimeout + override var subscribeTimeout: Int = super.subscribeTimeout - override var connectTimeout: Int = super.connectTimeout + override var connectTimeout: Int = super.connectTimeout - @Deprecated( - "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", - replaceWith = ReplaceWith("nonSubscribeReadTimeout") - ) - override var nonSubscribeRequestTimeout: Int - get() = nonSubscribeReadTimeout - set(value) { - nonSubscribeReadTimeout = value - } - - override var nonSubscribeReadTimeout: Int = super.nonSubscribeReadTimeout - - override var cacheBusting: Boolean = super.cacheBusting - - override var suppressLeaveEvents: Boolean = super.suppressLeaveEvents - - override var maintainPresenceState: Boolean = super.maintainPresenceState - - override var filterExpression: String = super.filterExpression - - override var includeInstanceIdentifier: Boolean = super.includeInstanceIdentifier - - override var includeRequestIdentifier: Boolean = super.includeRequestIdentifier - - override var maximumConnections: Int? = super.maximumConnections - - override var googleAppEngineNetworking: Boolean = super.googleAppEngineNetworking - - override var proxy: Proxy? = super.proxy - - override var proxySelector: ProxySelector? = super.proxySelector - - override var proxyAuthenticator: Authenticator? = super.proxyAuthenticator - - override var certificatePinner: CertificatePinner? = super.certificatePinner - - override var httpLoggingInterceptor: HttpLoggingInterceptor? = super.httpLoggingInterceptor - - override var sslSocketFactory: SSLSocketFactory? = super.sslSocketFactory - - override var x509ExtendedTrustManager: X509ExtendedTrustManager? = super.x509ExtendedTrustManager - - override var connectionSpec: ConnectionSpec? = super.connectionSpec - - override var hostnameVerifier: HostnameVerifier? = super.hostnameVerifier - - override var fileMessagePublishRetryLimit: Int = super.fileMessagePublishRetryLimit - override var dedupOnSubscribe: Boolean = super.dedupOnSubscribe - override var maximumMessagesCacheSize: Int = super.maximumMessagesCacheSize - override var pnsdkSuffixes: Map = super.pnsdkSuffixes - - override var retryConfiguration: RetryConfiguration = super.retryConfiguration - - override var managePresenceListManually: Boolean = super.managePresenceListManually - - override fun build(): PNConfiguration { - return PNConfigurationImpl( - userId = userId, - subscribeKey = subscribeKey, - publishKey = publishKey, - secretKey = secretKey, - authKey = authKey, - cryptoModule = cryptoModule, - origin = origin, - secure = secure, - logVerbosity = logVerbosity, - heartbeatNotificationOptions = heartbeatNotificationOptions, - presenceTimeout = presenceTimeout, - heartbeatInterval = heartbeatInterval, - subscribeTimeout = subscribeTimeout, - connectTimeout = connectTimeout, - nonSubscribeReadTimeout = nonSubscribeReadTimeout, - cacheBusting = cacheBusting, - suppressLeaveEvents = suppressLeaveEvents, - maintainPresenceState = maintainPresenceState, - filterExpression = filterExpression, - includeInstanceIdentifier = includeInstanceIdentifier, - includeRequestIdentifier = includeRequestIdentifier, - maximumConnections = maximumConnections, - googleAppEngineNetworking = googleAppEngineNetworking, - proxy = proxy, - proxySelector = proxySelector, - proxyAuthenticator = proxyAuthenticator, - certificatePinner = certificatePinner, - httpLoggingInterceptor = httpLoggingInterceptor, - sslSocketFactory = sslSocketFactory, - x509ExtendedTrustManager = x509ExtendedTrustManager, - connectionSpec = connectionSpec, - hostnameVerifier = hostnameVerifier, - fileMessagePublishRetryLimit = fileMessagePublishRetryLimit, - dedupOnSubscribe = dedupOnSubscribe, - maximumMessagesCacheSize = maximumMessagesCacheSize, - pnsdkSuffixes = pnsdkSuffixes, - retryConfiguration = retryConfiguration, - managePresenceListManually = managePresenceListManually, - ) + @Deprecated( + "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", + replaceWith = ReplaceWith("nonSubscribeReadTimeout") + ) + override var nonSubscribeRequestTimeout: Int + get() = nonSubscribeReadTimeout + set(value) { + nonSubscribeReadTimeout = value } + + override var nonSubscribeReadTimeout: Int = super.nonSubscribeReadTimeout + + override var cacheBusting: Boolean = super.cacheBusting + + override var suppressLeaveEvents: Boolean = super.suppressLeaveEvents + + override var maintainPresenceState: Boolean = super.maintainPresenceState + + override var filterExpression: String = super.filterExpression + + override var includeInstanceIdentifier: Boolean = super.includeInstanceIdentifier + + override var includeRequestIdentifier: Boolean = super.includeRequestIdentifier + + override var maximumConnections: Int? = super.maximumConnections + + override var googleAppEngineNetworking: Boolean = super.googleAppEngineNetworking + + override var proxy: Proxy? = super.proxy + + override var proxySelector: ProxySelector? = super.proxySelector + + override var proxyAuthenticator: Authenticator? = super.proxyAuthenticator + + override var certificatePinner: CertificatePinner? = super.certificatePinner + + override var httpLoggingInterceptor: HttpLoggingInterceptor? = super.httpLoggingInterceptor + + override var sslSocketFactory: SSLSocketFactory? = super.sslSocketFactory + + override var x509ExtendedTrustManager: X509ExtendedTrustManager? = super.x509ExtendedTrustManager + + override var connectionSpec: ConnectionSpec? = super.connectionSpec + + override var hostnameVerifier: HostnameVerifier? = super.hostnameVerifier + + override var fileMessagePublishRetryLimit: Int = super.fileMessagePublishRetryLimit + override var dedupOnSubscribe: Boolean = super.dedupOnSubscribe + override var maximumMessagesCacheSize: Int = super.maximumMessagesCacheSize + override var pnsdkSuffixes: Map = super.pnsdkSuffixes + + override var retryConfiguration: RetryConfiguration = super.retryConfiguration + + override var managePresenceListManually: Boolean = super.managePresenceListManually + + override fun build(): PNConfiguration { + return PNConfigurationImpl( + userId = userId, + subscribeKey = subscribeKey, + publishKey = publishKey, + secretKey = secretKey, + authKey = authKey, + cryptoModule = cryptoModule, + origin = origin, + secure = secure, + logVerbosity = logVerbosity, + heartbeatNotificationOptions = heartbeatNotificationOptions, + presenceTimeout = presenceTimeout, + heartbeatInterval = heartbeatInterval, + subscribeTimeout = subscribeTimeout, + connectTimeout = connectTimeout, + nonSubscribeReadTimeout = nonSubscribeReadTimeout, + cacheBusting = cacheBusting, + suppressLeaveEvents = suppressLeaveEvents, + maintainPresenceState = maintainPresenceState, + filterExpression = filterExpression, + includeInstanceIdentifier = includeInstanceIdentifier, + includeRequestIdentifier = includeRequestIdentifier, + maximumConnections = maximumConnections, + googleAppEngineNetworking = googleAppEngineNetworking, + proxy = proxy, + proxySelector = proxySelector, + proxyAuthenticator = proxyAuthenticator, + certificatePinner = certificatePinner, + httpLoggingInterceptor = httpLoggingInterceptor, + sslSocketFactory = sslSocketFactory, + x509ExtendedTrustManager = x509ExtendedTrustManager, + connectionSpec = connectionSpec, + hostnameVerifier = hostnameVerifier, + fileMessagePublishRetryLimit = fileMessagePublishRetryLimit, + dedupOnSubscribe = dedupOnSubscribe, + maximumMessagesCacheSize = maximumMessagesCacheSize, + pnsdkSuffixes = pnsdkSuffixes, + retryConfiguration = retryConfiguration, + managePresenceListManually = managePresenceListManually, + ) } + } } diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt index da4cdf3e6..10b159fa2 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt @@ -1,5 +1,6 @@ package com.pubnub.test +import com.pubnub.api.PubNub import com.pubnub.api.UserId import com.pubnub.api.enums.PNLogVerbosity import com.pubnub.api.enums.PNStatusCategory @@ -11,7 +12,6 @@ import com.pubnub.api.v2.createPNConfiguration import com.pubnub.api.v2.subscriptions.EmptyOptions import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.kmp.PNFuture -import com.pubnub.kmp.PubNub import com.pubnub.kmp.createEventListener import com.pubnub.kmp.createPubNub import com.pubnub.kmp.createStatusListener diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt index 94b0b93bd..035902256 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt @@ -1,5 +1,6 @@ package com.pubnub.test +import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener import com.pubnub.api.endpoints.DeleteMessages import com.pubnub.api.endpoints.FetchMessages @@ -70,7 +71,6 @@ import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.kmp.CustomObject -import com.pubnub.kmp.PubNub import com.pubnub.kmp.Uploadable private fun notImplemented(): Nothing = TODO("Not implemented") From 9cf07bb5db0957199b198dcced63b450e497843f Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:38:50 +0200 Subject: [PATCH 45/62] Using InputStream instead of URL in StreamUploadContent (#259) --- .../kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt | 2 +- .../src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt index 5c33f33a4..47ec51ace 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt @@ -73,7 +73,7 @@ class SendFileImpl( fileURL = content.url ) is StreamUploadContent -> PubNubInputStreamContentObjC( - stream = NSInputStream(content.url), + stream = content.stream, contentType = content.contentType, contentLength = content.contentLength.toLong() ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt index f740adc90..e13937fd7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/abstractions.ios.kt @@ -1,6 +1,7 @@ package com.pubnub.kmp import platform.Foundation.NSData +import platform.Foundation.NSInputStream import platform.Foundation.NSURL actual class CustomObject(val value: Any) @@ -17,7 +18,7 @@ data class FileUploadContent( ) : Uploadable() data class StreamUploadContent( - val url: NSURL, + val stream: NSInputStream, val contentType: String?, val contentLength: Int ) : Uploadable() From 108c726c053946127d1b352b5022e3e8617d4941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 30 Jul 2024 07:51:48 +0000 Subject: [PATCH 46/62] Merge changes from master to kmp-dev (#263) * Use large GitHub runner (#219) build(runner): change runner groups * Disallow DTDs in XML parser (#222) * Disallow DTDs in XML parser * GCM to FCM migration in PushPayloadHelper (#227) * GCM to FCM migration in PushPayloadHelper * Mc/add integ test (#226) * v.9.2.0 release with FCMPayloadV2 * Enforce string-only values in data * Fix enum values and use deprecation instead of breaking change * PubNub SDK v9.2.0 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> * Added sorting to integ test. (#233) * Add missing auth_method to APNS2 configuration (#249) * Add missing auth_method to APNS2 configuration * PubNub SDK v9.2.1 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> * SetState via Heartbeat fix. (#251) * PubNub SDK v9.2.2 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> * Fix RetryRemoteAction double callback (#262) * Fix RetryRemoteAction double callback * PubNub SDK v9.2.3 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> * lint --------- Co-authored-by: Serhii Mamontov Co-authored-by: marcin-cebo <102806110+marcin-cebo@users.noreply.github.com> Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> --- .pubnub.yml | 23 +++++++++++++++---- CHANGELOG.md | 18 +++++++++++++++ README.md | 4 ++-- gradle.properties | 2 +- .../push/payload/PushPayloadHelper.kt | 12 ++++++++++ .../remoteaction/RetryingRemoteAction.kt | 5 +++- .../com/pubnub/api/legacy/PubNubCoreTest.kt | 2 +- .../push/PushPayloadHelperHelperTest.kt | 2 ++ .../remoteaction/RetryingRemoteActionTest.kt | 7 ++++++ .../endpoints/presence/SetStateImpl.java | 12 +++++++++- .../api/endpoints/files/SendFile.ios.kt | 1 - .../api/integration/ObjectsIntegrationTest.kt | 3 +++ 12 files changed, 80 insertions(+), 11 deletions(-) diff --git a/.pubnub.yml b/.pubnub.yml index 312abc3b3..f5bf7ceee 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,9 +1,9 @@ name: kotlin -version: 9.2.0 +version: 9.2.3 schema: 1 scm: github.com/pubnub/kotlin files: - - build/libs/pubnub-kotlin-9.2.0-all.jar + - build/libs/pubnub-kotlin-9.2.3-all.jar sdks: - type: library @@ -23,8 +23,8 @@ sdks: - distribution-type: library distribution-repository: maven - package-name: pubnub-kotlin-9.2.0 - location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/9.2.0/pubnub-kotlin-9.2.0.jar + package-name: pubnub-kotlin-9.2.3 + location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/9.2.3/pubnub-kotlin-9.2.3.jar supported-platforms: supported-operating-systems: Android: @@ -114,6 +114,21 @@ sdks: license-url: https://www.apache.org/licenses/LICENSE-2.0.txt is-required: Required changelog: + - date: 2024-07-29 + version: v9.2.3 + changes: + - type: bug + text: "Fixed incorrect multiple callbacks (with exception) when sending files." + - date: 2024-07-04 + version: v9.2.2 + changes: + - type: bug + text: "SetState via Heartbeat fix." + - date: 2024-07-02 + version: v9.2.1 + changes: + - type: feature + text: "Add missing `auth_method` to APNS2 configuration." - date: 2024-06-11 version: v9.2.0 changes: diff --git a/CHANGELOG.md b/CHANGELOG.md index 4459c4655..5e6c60325 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## v9.2.3 +July 29 2024 + +#### Fixed +- Fixed incorrect multiple callbacks (with exception) when sending files. + +## v9.2.2 +July 04 2024 + +#### Fixed +- SetState via Heartbeat fix. + +## v9.2.1 +July 02 2024 + +#### Added +- Add missing `auth_method` to APNS2 configuration. + ## v9.2.0 June 11 2024 diff --git a/README.md b/README.md index f79edf725..8de582891 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,13 @@ You will need the publish and subscribe keys to authenticate your app. Get your com.pubnub pubnub-kotlin - 9.2.0 + 9.2.3 ``` * for Gradle, add the following dependency in your `gradle.build`: ```groovy - implementation 'com.pubnub:pubnub-kotlin:9.2.0' + implementation 'com.pubnub:pubnub-kotlin:9.2.3' ``` 2. Configure your keys and create PubNub instance: diff --git a/gradle.properties b/gradle.properties index 2296f83e9..a07e260f6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ RELEASE_SIGNING_ENABLED=true SONATYPE_HOST=DEFAULT SONATYPE_AUTOMATIC_RELEASE=false GROUP=com.pubnub -VERSION_NAME=9.2.0 +VERSION_NAME=9.2.3 POM_PACKAGING=jar POM_NAME=PubNub SDK diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt index 69262d432..21a7d9a64 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt @@ -87,6 +87,17 @@ class PushPayloadHelper { var expiration: String? = null var targets: List? = null var version: String? = null + var authMethod: APNS2AuthMethod? = null + + enum class APNS2AuthMethod { + TOKEN, + CERT, + CERTIFICATE; + + override fun toString(): String { + return name.lowercase() + } + } override fun toMap(): Map { return mutableMapOf().apply { @@ -100,6 +111,7 @@ class PushPayloadHelper { } } version?.let { put("version", it) } + authMethod?.let { put("auth_method", it.toString()) } } } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/remoteaction/RetryingRemoteAction.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/remoteaction/RetryingRemoteAction.kt index 27a417203..5759b6e50 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/remoteaction/RetryingRemoteAction.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/remoteaction/RetryingRemoteAction.kt @@ -46,11 +46,14 @@ internal class RetryingRemoteAction( for (i in 0 until maxNumberOfAutomaticRetries) { try { callback.accept(Result.success(remoteAction.sync())) + return@Runnable } catch (e: Throwable) { lastException = e } } - callback.accept(Result.failure(PubNubException.from(lastException!!).copy(remoteAction = this))) + lastException?.let { exception -> + callback.accept(Result.failure(PubNubException.from(exception).copy(remoteAction = this))) + } }, ) } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt index 57fbc8a19..5f414f7ab 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt @@ -66,7 +66,7 @@ class PubNubCoreTest : BaseTest() { fun getVersionAndTimeStamp() { val version = PubNubCore.SDK_VERSION val timeStamp = PubNubCore.timestamp() - assertEquals("9.2.0", version) + assertEquals("9.2.3", version) assertTrue(timeStamp > 0) } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt index fb64dcfbf..f08f83642 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt @@ -174,6 +174,7 @@ class PushPayloadHelperHelperTest : BaseTest() { expiration = "exp_1" version = "v1" targets = null + authMethod = APNS2Configuration.APNS2AuthMethod.TOKEN } val apns2Config2 = APNS2Configuration().apply { @@ -215,6 +216,7 @@ class PushPayloadHelperHelperTest : BaseTest() { assertEquals("exp_1", pnPushList[0]["expiration"]) assertEquals("collapse_1", pnPushList[0]["collapse_id"]) assertEquals("v1", pnPushList[0]["version"]) + assertEquals("token", pnPushList[0]["auth_method"]) assertFalse(pnPushList[0].containsKey("targets")) assertEquals("exp_2", pnPushList[1]["expiration"]) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/RetryingRemoteActionTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/RetryingRemoteActionTest.kt index 593bea5b1..154cbcabf 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/RetryingRemoteActionTest.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/RetryingRemoteActionTest.kt @@ -90,6 +90,7 @@ class RetryingRemoteActionTest { executorService, ) val asyncSynchronization = CountDownLatch(1) + val noFailureCallsSynchronization = CountDownLatch(1) // when retryingRemoteAction.async { result -> @@ -98,11 +99,17 @@ class RetryingRemoteActionTest { Assert.assertEquals(expectedValue, it) verify(exactly = 1) { remoteAction.sync() } asyncSynchronization.countDown() + }.onFailure { + noFailureCallsSynchronization.countDown() } } if (!asyncSynchronization.await(3, TimeUnit.SECONDS)) { Assert.fail("Callback have not been called") } + + if (noFailureCallsSynchronization.await(3, TimeUnit.SECONDS)) { + Assert.fail("onFailure has been called when it shouldn't!") + } } @Test diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/SetStateImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/SetStateImpl.java index 316cd6479..12bae7346 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/SetStateImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/SetStateImpl.java @@ -16,7 +16,9 @@ import org.json.JSONObject; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Setter @@ -86,7 +88,15 @@ protected EndpointInterface createAction() { } else { // Some clients require alternative way of setting it through Heartbeat // Which is a feature brought over from the legacy Java SDK, and we need to be compatible: - return (EndpointInterface) (Object) new HeartbeatEndpoint(pubnub, channels, channelGroups, state); + return (EndpointInterface) (Object) new HeartbeatEndpoint(pubnub, channels, channelGroups, composeStateParamValue()); } } + + private Object composeStateParamValue() { + Map stateParamValue = new HashMap<>(); + for (String channel : channels) { + stateParamValue.put(channel, state); + } + return stateParamValue; + } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt index 47ec51ace..aab596498 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt @@ -19,7 +19,6 @@ import com.pubnub.kmp.Uploadable import com.pubnub.kmp.onFailureHandler import com.pubnub.kmp.onSuccessHandler2 import kotlinx.cinterop.ExperimentalForeignApi -import platform.Foundation.NSInputStream import platform.Foundation.NSNumber /** diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt index f6a6e5b8c..2030718e8 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt @@ -3,6 +3,8 @@ package com.pubnub.api.integration import com.pubnub.api.PubNub import com.pubnub.api.callbacks.SubscribeCallback import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.models.consumer.objects.PNMembershipKey +import com.pubnub.api.models.consumer.objects.PNSortKey import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.member.PNMember import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel @@ -91,6 +93,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { val getAllResult = pubnub.getMemberships( uuid = testUuid, + sort = listOf(PNSortKey.PNDesc(PNMembershipKey.CHANNEL_ID)), includeChannelDetails = PNChannelDetailsLevel.CHANNEL, ).sync() From 55f86ce7bf2c05a87cf1d28a9bab78eb7a8f59ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Wed, 31 Jul 2024 17:00:03 +0200 Subject: [PATCH 47/62] Fix obvious typo in JS wrapper --- .../src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt index 312bf41c5..d2f8a62c3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/factories.js.kt @@ -106,7 +106,8 @@ actual fun createEventListener( messageActionEvent.data.value, messageActionEvent.data.messageTimetoken.toLong() ).apply { - actionTimetoken = messageActionEvent.data.messageTimetoken.toLong() + actionTimetoken = messageActionEvent.data.actionTimetoken.toLong() + uuid = messageActionEvent.data.uuid } ) ) From cff96bb04824f12f16eafdc7f886b43a48ad4d8c Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Thu, 1 Aug 2024 09:11:07 +0200 Subject: [PATCH 48/62] Handling missing includeType parameter (AppContext) (#264) --- .../kotlin/com/pubnub/api/PubNubImpl.kt | 18 ++++++++++++------ .../objects/member/GetChannelMembers.ios.kt | 4 +++- .../objects/member/ManageChannelMembers.ios.kt | 8 ++++++-- .../objects/membership/GetMemberships.ios.kt | 4 +++- .../membership/ManageMemberships.ios.kt | 8 ++++++-- .../kotlin/com/pubnub/kmp/converters.kt | 6 +++--- .../kotlin/com/pubnub/kmp/factories.ios.kt | 17 +++++++++++------ swift | 2 +- 8 files changed, 45 insertions(+), 22 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 3d6c1a6d9..aa16c8406 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -597,7 +597,8 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { sort = sort, includeCount = includeCount, includeCustom = includeCustom, - includeChannelDetails = includeChannelDetails + includeChannelDetails = includeChannelDetails, + includeChannelType = includeType ) } @@ -623,7 +624,8 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { sort = sort, includeCount = includeCount, includeCustom = includeCustom, - includeChannelDetails = includeChannelDetails + includeChannelDetails = includeChannelDetails, + includeChannelType = includeType ) } @@ -649,7 +651,8 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { sort = sort, includeCount = includeCount, includeCustom = includeCustom, - includeChannelDetails = includeChannelDetails + includeChannelDetails = includeChannelDetails, + includeChannelType = includeType ) } @@ -673,7 +676,8 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { sort = sort, includeCount = includeCount, includeCustom = includeCustom, - includeUUIDDetails = includeUUIDDetails + includeUUIDDetails = includeUUIDDetails, + includeUUIDType = includeType ) } @@ -699,7 +703,8 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { sort = sort, includeCount = includeCount, includeCustom = includeCustom, - includeUUIDDetails = includeUUIDDetails + includeUUIDDetails = includeUUIDDetails, + includeUUIDType = includeType ) } @@ -725,7 +730,8 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { sort = sort, includeCount = includeCount, includeCustom = includeCustom, - includeUUIDDetails = includeUUIDDetails + includeUUIDDetails = includeUUIDDetails, + includeUUIDType = includeType ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt index 3c3fa2573..1907de479 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt @@ -34,7 +34,8 @@ class GetChannelMembersImpl( private val sort: Collection>, private val includeCount: Boolean, private val includeCustom: Boolean, - private val includeUUIDDetails: PNUUIDDetailsLevel? + private val includeUUIDDetails: PNUUIDDetailsLevel?, + private val includeUUIDType: Boolean ) : GetChannelMembers { override fun async(callback: Consumer>) { pubnub.getChannelMembersWithChannel( @@ -47,6 +48,7 @@ class GetChannelMembersImpl( includeCustom = includeCustom, includeUUIDFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, includeUUIDCustomFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, + includeUUIDType = includeUUIDType, onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNMemberArrayResult( status = 200, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt index 9bcd51114..378bbdcbd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt @@ -39,7 +39,8 @@ class SetChannelMembersImpl( private val sort: Collection>, private val includeCount: Boolean, private val includeCustom: Boolean, - private val includeUUIDDetails: PNUUIDDetailsLevel? + private val includeUUIDDetails: PNUUIDDetailsLevel?, + private val includeUUIDType: Boolean ) : ManageChannelMembers { override fun async(callback: Consumer>) { pubnub.setChannelMembersWithChannel( @@ -53,6 +54,7 @@ class SetChannelMembersImpl( includeCustom = includeCustom, includeUUIDFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, includeUUIDCustomFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, + includeUUIDType = includeUUIDType, onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNMemberArrayResult( status = 200, @@ -78,7 +80,8 @@ class RemoveChannelMembersImpl( private val sort: Collection>, private val includeCount: Boolean, private val includeCustom: Boolean, - private val includeUUIDDetails: PNUUIDDetailsLevel? + private val includeUUIDDetails: PNUUIDDetailsLevel?, + private val includeUUIDType: Boolean ) : ManageChannelMembers { override fun async(callback: Consumer>) { pubnub.removeChannelMembersWithChannel( @@ -92,6 +95,7 @@ class RemoveChannelMembersImpl( includeCustom = includeCustom, includeUUIDFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID || includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, includeUUIDCustomFields = includeUUIDDetails == PNUUIDDetailsLevel.UUID_WITH_CUSTOM, + includeUUIDType = includeUUIDType, onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> PNMemberArrayResult( status = 200, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt index aa27302c9..79193ed56 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt @@ -34,7 +34,8 @@ class GetMembershipsImpl( private val sort: Collection>, private val includeCount: Boolean, private val includeCustom: Boolean, - private val includeChannelDetails: PNChannelDetailsLevel? + private val includeChannelDetails: PNChannelDetailsLevel?, + private val includeChannelType: Boolean ) : GetMemberships { override fun async(callback: Consumer>) { pubnub.getMembershipsWithUuid( @@ -47,6 +48,7 @@ class GetMembershipsImpl( includeCustom = includeCustom, includeChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL || includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, includeChannelCustomFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, + includeChannelType = includeChannelType, onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNChannelMembershipArrayResult( status = 200, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt index 327a8a04f..48c426235 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt @@ -39,7 +39,8 @@ class AddMembershipsImpl( private val sort: Collection>, private val includeCount: Boolean, private val includeCustom: Boolean, - private val includeChannelDetails: PNChannelDetailsLevel? + private val includeChannelDetails: PNChannelDetailsLevel?, + private val includeChannelType: Boolean ) : ManageMemberships { override fun async(callback: Consumer>) { pubnub.setMembershipsWithChannels( @@ -53,6 +54,7 @@ class AddMembershipsImpl( includeCustom = includeCustom, includeChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL || includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, includeChannelCustomFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, + includeChannelType = includeChannelType, onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNChannelMembershipArrayResult( status = 200, @@ -78,7 +80,8 @@ class RemoveMembershipsImpl( private val sort: Collection>, private val includeCount: Boolean, private val includeCustom: Boolean, - private val includeChannelDetails: PNChannelDetailsLevel? + private val includeChannelDetails: PNChannelDetailsLevel?, + private val includeChannelType: Boolean ) : ManageMemberships { override fun async(callback: Consumer>) { pubnub.removeMembershipsWithChannels( @@ -92,6 +95,7 @@ class RemoveMembershipsImpl( includeCustom = includeCustom, includeChannelFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL || includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, includeChannelCustomFields = includeChannelDetails == PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, + includeChannelType = includeChannelType, onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> PNChannelMembershipArrayResult( status = 200, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt index 00b27d3fa..a4b069d55 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt @@ -83,9 +83,9 @@ internal fun createObjectSortProperties(from: Collection>): Lis internal fun createPNChannelMembership(from: PubNubMembershipMetadataObjC): PNChannelMembership { return PNChannelMembership( channel = PNChannelMetadata( - id = from.channel()?.id().orEmpty(), - name = from.channel()?.name().orEmpty(), - description = from.channel()?.descr().orEmpty(), + id = from.channelMetadataId(), + name = from.channel()?.name(), + description = from.channel()?.descr(), custom = from.channel()?.custom()?.safeCast(), updated = from.channel()?.updated(), eTag = from.channel()?.eTag(), diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 31c79bc1e..5a41efe23 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -117,20 +117,25 @@ private fun createSignalResult(from: PubNubMessageObjC?): PNSignalResult { @OptIn(ExperimentalForeignApi::class) private fun createMessageActionResult(from: PubNubMessageActionObjC?): PNMessageActionResult { + val messageAction = PNMessageAction( + type = from!!.actionType(), + value = from.actionValue(), + messageTimetoken = from.messageTimetoken().toLong() + ).apply { + actionTimetoken = from.actionTimetoken().toLong() + uuid = from.publisher() + } + return PNMessageActionResult( result = BasePubSubResult( - channel = from!!.channel(), + channel = from.channel(), subscription = from.subscription(), timetoken = from.actionTimetoken().toLong(), userMetadata = null, publisher = from.publisher() ), event = from.event(), - data = PNMessageAction( - type = from.actionType(), - value = from.actionValue(), - messageTimetoken = from.messageTimetoken().toLong() - ) + data = messageAction ) } diff --git a/swift b/swift index e5bc7d3dc..d8c940837 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit e5bc7d3dc8081450e892fb93ae57261f05e389f0 +Subproject commit d8c940837704e4718e729f969b568efa4348690d From 3e82af34d882670d2c25d3785e4af747e7f53807 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Mon, 5 Aug 2024 07:12:16 +0000 Subject: [PATCH 49/62] Build scripts with non-JVM targets disabled (#265) * Selectively enable targets * Add test logging * Move integration tests * Revert configuration caching * Test utils for kmp-chat --- .github/workflows/run-tests.yml | 6 + .github/workflows/run-validations.yml | 2 +- build-logic/gradle-plugins/build.gradle.kts | 4 - build-logic/gradle-plugins/gradle.properties | 4 +- .../com/pubnub/gradle/PubNubDokkaPlugin.kt | 7 +- .../gradle/PubNubKotlinMultiplatformPlugin.kt | 145 +++++++++++------- .../com/pubnub/gradle/PubNubSharedPlugin.kt | 13 +- .../ktlint-custom-rules/build.gradle.kts | 5 +- .../ktlint-custom-rules/gradle.properties | 4 + .../ktlint-custom-rules/settings.gradle.kts | 17 ++ gradle.properties | 6 +- gradle/libs.versions.toml | 2 +- kotlin-js-store/yarn.lock | 2 +- .../pubnub-core-api/pubnub_core_api.podspec | 6 +- .../pubnub-kotlin-api/build.gradle.kts | 35 ++--- .../pubnub_kotlin_api.podspec | 6 +- .../integration}/ChannelMetadataTest.kt | 11 +- .../integration}/DeleteMessagesTest.kt | 2 +- .../{api => test/integration}/EntitiesTest.kt | 10 +- .../integration}/FetchMessagesTest.kt | 3 +- .../integration}/HereWhereNowTest.kt | 6 +- .../{api => test/integration}/MembersTest.kt | 6 +- .../integration}/MembershipsTest.kt | 10 +- .../integration}/MessageActionsTest.kt | 2 +- .../integration}/MessageCountsTest.kt | 2 +- .../{api => test/integration}/PublishTest.kt | 33 ++-- .../{api => test/integration}/PushTest.kt | 2 +- .../{api => test/integration}/TimeTest.kt | 2 +- .../integration}/UserMetadataTest.kt | 13 +- .../pubnub-kotlin-test/build.gradle.kts | 69 +++++---- .../com.pubnub.test/BaseIntegrationTest.kt | 28 +--- settings.gradle.kts | 2 +- 32 files changed, 259 insertions(+), 206 deletions(-) create mode 100644 build-logic/ktlint-custom-rules/gradle.properties create mode 100644 build-logic/ktlint-custom-rules/settings.gradle.kts rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/ChannelMetadataTest.kt (95%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/DeleteMessagesTest.kt (97%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/EntitiesTest.kt (86%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/FetchMessagesTest.kt (98%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/HereWhereNowTest.kt (91%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/MembersTest.kt (94%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/MembershipsTest.kt (92%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/MessageActionsTest.kt (98%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/MessageCountsTest.kt (97%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/PublishTest.kt (90%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/PushTest.kt (99%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/TimeTest.kt (90%) rename pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/{api => test/integration}/UserMetadataTest.kt (95%) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 38a41e131..b1df318a5 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -31,6 +31,12 @@ jobs: - name: Build and run tests run: | ./gradlew check + env: + SDK_PUB_KEY: ${{ secrets.SDK_PUB_KEY }} + SDK_SUB_KEY: ${{ secrets.SDK_SUB_KEY }} + SDK_PAM_SUB_KEY: ${{ secrets.SDK_PAM_SUB_KEY }} + SDK_PAM_PUB_KEY: ${{ secrets.SDK_PAM_PUB_KEY }} + SDK_PAM_SEC_KEY: ${{ secrets.SDK_PAM_SEC_KEY }} - name: Cancel workflow runs for commit on error if: failure() uses: ./.github/.release/actions/actions/utils/fast-jobs-failure diff --git a/.github/workflows/run-validations.yml b/.github/workflows/run-validations.yml index 5b7fc9cc4..38fe8bae1 100644 --- a/.github/workflows/run-validations.yml +++ b/.github/workflows/run-validations.yml @@ -49,7 +49,7 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Validate clean build - run: ./gradlew build + run: ./gradlew ktlintFormat publishAllPublicationsToRepoRepository -PRELEASE_SIGNING_ENABLED=false - name: Cancel workflow runs for commit on error if: failure() uses: ./.github/.release/actions/actions/utils/fast-jobs-failure diff --git a/build-logic/gradle-plugins/build.gradle.kts b/build-logic/gradle-plugins/build.gradle.kts index ab8ca4839..dfa4372f7 100644 --- a/build-logic/gradle-plugins/build.gradle.kts +++ b/build-logic/gradle-plugins/build.gradle.kts @@ -3,10 +3,6 @@ plugins { alias(libs.plugins.kotlin.jvm) } -kotlin { - jvmToolchain(8) -} - dependencies { compileOnly(gradleKotlinDsl()) compileOnly(libs.nexus.gradlePlugin) diff --git a/build-logic/gradle-plugins/gradle.properties b/build-logic/gradle-plugins/gradle.properties index 6977b7191..df6435931 100644 --- a/build-logic/gradle-plugins/gradle.properties +++ b/build-logic/gradle-plugins/gradle.properties @@ -1,3 +1,3 @@ -org.gradle.parallel=true +org.gradle.parallel=false org.gradle.caching=true -org.gradle.configureondemand=true \ No newline at end of file +org.gradle.configuration-cache=true \ No newline at end of file diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubDokkaPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubDokkaPlugin.kt index 876b002f1..56a4a07df 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubDokkaPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubDokkaPlugin.kt @@ -14,12 +14,13 @@ class PubNubDokkaPlugin : Plugin { apply() tasks.withType().configureEach { task -> - task.dokkaSourceSets.configureEach { - it.perPackageOption { + task.notCompatibleWithConfigurationCache("https://github.com/Kotlin/dokka/issues/2231") + task.dokkaSourceSets.configureEach { sourceSetBuilder -> + sourceSetBuilder.perPackageOption { it.matchingRegex.set(".*internal.*") it.suppress.set(true) } - it.skipEmptyPackages.set(true) + sourceSetBuilder.skipEmptyPackages.set(true) } } diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt index fae6c68bf..714017814 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt @@ -3,57 +3,70 @@ package com.pubnub.gradle import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.ExtensionAware +import org.gradle.api.tasks.testing.AbstractTestTask +import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.creating -import org.gradle.kotlin.dsl.getting -import org.gradle.kotlin.dsl.provideDelegate import org.gradle.kotlin.dsl.withType import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper -import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetContainer import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension import org.jetbrains.kotlin.gradle.plugin.cocoapods.KotlinCocoapodsPlugin -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType -import org.jetbrains.kotlin.gradle.plugin.mpp.TestExecutable +import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport +import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn class PubNubKotlinMultiplatformPlugin : Plugin { override fun apply(target: Project) { with(target) { apply() - apply() + if (enableAnyIosTarget) { + apply() + } // Kotlin extensions.configure { + compilerOptions.freeCompilerArgs.add("-Xexpect-actual-classes") jvmToolchain(8) - js { - browser { + if (enableJsTarget) { + js { -> + useEsModules() + browser { + testTask { + it.useMocha { + timeout = "10s" + } + } + } +// nodejs { +// testTask { +// it.useMocha { +// timeout = "5s" +// } +// } +// } } - binaries.executable() } - jvm { - compilations.all { - it.compileTaskProvider.configure { - it.compilerOptions { - freeCompilerArgs.add("-Xexpect-actual-classes") + + jvm { -> + compilations.configureEach { compilation -> + compilation.compileTaskProvider.configure { task -> + task.compilerOptions { javaParameters.set(true) } } } } - listOf( - iosArm64(), - iosSimulatorArm64(), - ).forEach { - it.binaries { - framework { - isStatic = true - } - } + + if (enableIosTarget) { + iosArm64() + } + if (enableIosSimulatorTarget) { + iosSimulatorArm64() } + applyDefaultHierarchyTemplate() with (sourceSets) { val commonMain = getByName("commonMain") @@ -62,54 +75,68 @@ class PubNubKotlinMultiplatformPlugin : Plugin { it.dependsOn(commonMain) } - val jsMain = getByName("jsMain") { - it.dependsOn(nonJvm) + if (enableJsTarget) { + getByName("jsMain") { + it.dependsOn(nonJvm) + } } - val iosMain = getByName("iosMain") { - it.dependsOn(nonJvm) + if (enableAnyIosTarget) { + getByName("iosMain") { + it.dependsOn(nonJvm) + } } } - (this as? ExtensionAware)?.extensions?.configure { - ios.deploymentTarget = "14" + if (enableAnyIosTarget) { + (this as? ExtensionAware)?.extensions?.configure { + ios.deploymentTarget = "14" +// +// summary = "Some description for a Kotlin/Native module" +// homepage = "Link to a Kotlin/Native module homepage" - // Required properties - // Specify the required Pod version here. Otherwise, the Gradle project version is used. - version = "1.0" - summary = "Some description for a Kotlin/Native module" - homepage = "Link to a Kotlin/Native module homepage" + // Maps custom Xcode configuration to NativeBuildType + xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG + xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE - // Maps custom Xcode configuration to NativeBuildType - xcodeConfigurationToNativeBuildType["CUSTOM_DEBUG"] = NativeBuildType.DEBUG - xcodeConfigurationToNativeBuildType["CUSTOM_RELEASE"] = NativeBuildType.RELEASE - -// podfile = project.file(project.file("Sample Chat app/Podfile")) - - framework { - // Required properties - // Framework name configuration. Use this property instead of deprecated 'frameworkName' - - // Optional properties - // Specify the framework linking type. It's dynamic by default. - isStatic = true - transitiveExport = true - } + framework { + isStatic = true + transitiveExport = true + } - pod("PubNubSwift") { + pod("PubNubSwift") { + val swiftPath = project.findProperty("SWIFT_PATH") as? String ?: "swift" // source = git("https://github.com/pubnub/swift") { // branch = "feat/kmp" // } -// headers = "PubNub/PubNub.h" - source = path(rootProject.file("swift")) -// version = "7.1.0" - - moduleName = "PubNub" - extraOpts += listOf("-compiler-option", "-fmodules") +// version = "7.1.0" + source = path(rootProject.file(swiftPath)) + moduleName = "PubNub" + extraOpts += listOf("-compiler-option", "-fmodules") + } } } } - + if (enableJsTarget) { + yarn.yarnLockMismatchReport = YarnLockMismatchReport.WARNING + yarn.yarnLockAutoReplace = true + } + tasks.withType { + testLogging { + it.showStackTraces = true + it.showCauses = true + it.showExceptions = true + it.exceptionFormat = TestExceptionFormat.FULL + } +// if (providers.environmentVariable("CI").isPresent && !providers.environmentVariable("CI_FORCE_RUN_INTEGRATION_TESTS").isPresent) { +// filter.excludeTestsMatching("com.pubnub.test.integration.*") +// } + } } } -} \ No newline at end of file +} + +val Project.enableJsTarget get() = project.findProperty("ENABLE_TARGET_JS") == "true" +val Project.enableIosTarget get() = project.findProperty("ENABLE_TARGET_IOS") == "true" +val Project.enableIosSimulatorTarget get() = project.findProperty("ENABLE_TARGET_IOS_SIMULATOR") == "true" +val Project.enableAnyIosTarget get() = enableIosTarget || enableIosSimulatorTarget \ No newline at end of file diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt index 7408aae61..92c6388db 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubSharedPlugin.kt @@ -3,10 +3,13 @@ package com.pubnub.gradle import com.vanniktech.maven.publish.MavenPublishPlugin import org.gradle.api.Plugin import org.gradle.api.Project +import org.gradle.api.publish.PublishingExtension import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.maven import org.gradle.kotlin.dsl.project +import org.gradle.kotlin.dsl.repositories import org.jlleitschuh.gradle.ktlint.KtlintExtension import org.jlleitschuh.gradle.ktlint.KtlintPlugin @@ -16,6 +19,14 @@ class PubNubSharedPlugin : Plugin { apply() apply() + extensions.configure { + repositories { + it.maven(uri(rootProject.layout.buildDirectory.dir("repo"))) { -> + name = "repo" + } + } + } + group = providers.gradleProperty("GROUP").get() version = providers.gradleProperty("VERSION_NAME").get() @@ -42,7 +53,7 @@ class PubNubSharedPlugin : Plugin { } dependencies { - "ktlintRuleset"(project(":build-logic:ktlint-custom-rules")) + "ktlintRuleset"("com.pubnub:ktlint-custom-rules:1.0.0") } } } diff --git a/build-logic/ktlint-custom-rules/build.gradle.kts b/build-logic/ktlint-custom-rules/build.gradle.kts index 5b18e392d..093880897 100644 --- a/build-logic/ktlint-custom-rules/build.gradle.kts +++ b/build-logic/ktlint-custom-rules/build.gradle.kts @@ -6,4 +6,7 @@ plugins { dependencies { compileOnly("com.pinterest.ktlint:ktlint-rule-engine-core:1.2.1") compileOnly("com.pinterest.ktlint:ktlint-cli-ruleset-core:1.2.1") -} \ No newline at end of file +} + +group = "com.pubnub" +version = "1.0.0" \ No newline at end of file diff --git a/build-logic/ktlint-custom-rules/gradle.properties b/build-logic/ktlint-custom-rules/gradle.properties new file mode 100644 index 000000000..cb5be073b --- /dev/null +++ b/build-logic/ktlint-custom-rules/gradle.properties @@ -0,0 +1,4 @@ +org.gradle.parallel=true +org.gradle.caching=true +#org.gradle.configureondemand=true +org.gradle.configuration-cache=true \ No newline at end of file diff --git a/build-logic/ktlint-custom-rules/settings.gradle.kts b/build-logic/ktlint-custom-rules/settings.gradle.kts new file mode 100644 index 000000000..8264b45dd --- /dev/null +++ b/build-logic/ktlint-custom-rules/settings.gradle.kts @@ -0,0 +1,17 @@ +pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + } +} +dependencyResolutionManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } + versionCatalogs { + create("libs") { + from(files("../../gradle/libs.versions.toml")) + } + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index a07e260f6..ad479b3ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,6 @@ org.gradle.caching=true org.gradle.parallel=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official -org.gradle.unsafe.configuration-cache=false RELEASE_SIGNING_ENABLED=true SONATYPE_HOST=DEFAULT @@ -40,3 +39,8 @@ POM_DEVELOPER_NAME=PubNub POM_DEVELOPER_URL=support@pubnub.com IOS_SIMULATOR_ID=iPhone 15 Pro +SWIFT_PATH=swift + +ENABLE_TARGET_JS=false +ENABLE_TARGET_IOS=false +ENABLE_TARGET_IOS_SIMULATOR=false \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e48586d62..976f1a759 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -6,7 +6,7 @@ okhttp = "4.12.0" retrofit2 = "2.9.0" nexus = "2.0.0-rc-2" kotlin = "2.0.0" -vanniktech = "0.22.0" +vanniktech = "0.29.0" ktlint = "12.1.0" dokka = "1.9.20" kotlinx_datetime = "0.6.0-RC.2" diff --git a/kotlin-js-store/yarn.lock b/kotlin-js-store/yarn.lock index 597dc5594..136e97e31 100644 --- a/kotlin-js-store/yarn.lock +++ b/kotlin-js-store/yarn.lock @@ -2830,7 +2830,7 @@ source-map-loader@5.0.0: iconv-lite "^0.6.3" source-map-js "^1.0.2" -source-map-support@~0.5.20: +source-map-support@0.5.21, source-map-support@~0.5.20: version "0.5.21" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f" integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w== diff --git a/pubnub-core/pubnub-core-api/pubnub_core_api.podspec b/pubnub-core/pubnub-core-api/pubnub_core_api.podspec index 124f07d68..df6fb5bc6 100644 --- a/pubnub-core/pubnub-core-api/pubnub_core_api.podspec +++ b/pubnub-core/pubnub-core-api/pubnub_core_api.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |spec| spec.name = 'pubnub_core_api' - spec.version = '1.0' - spec.homepage = 'Link to a Kotlin/Native module homepage' + spec.version = '9.2.3' + spec.homepage = '' spec.source = { :http=> ''} spec.authors = '' spec.license = '' - spec.summary = 'Some description for a Kotlin/Native module' + spec.summary = '' spec.vendored_frameworks = 'build/cocoapods/framework/pubnub_core_api.framework' spec.libraries = 'c++' spec.ios.deployment_target = '14' diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index b39838bb5..96e10880c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -1,3 +1,7 @@ +import com.pubnub.gradle.enableAnyIosTarget +import com.pubnub.gradle.enableJsTarget +import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension + plugins { alias(libs.plugins.benmanes.versions) id("pubnub.shared") @@ -7,18 +11,6 @@ plugins { } kotlin { - js { - browser { - testTask { -// useMocha { -// timeout = "30s" -// } - useKarma { - useChrome() - } - } - } - } sourceSets { val commonMain by getting { dependencies { @@ -33,9 +25,11 @@ kotlin { } } - val jsMain by getting { - dependencies { - implementation(npm("pubnub", "8.2.4")) + if (enableJsTarget) { + val jsMain by getting { + dependencies { + implementation(npm("pubnub", "8.2.4")) + } } } @@ -53,12 +47,11 @@ kotlin { } } } -} - -kotlin { - cocoapods { - framework { - export(project(":pubnub-core:pubnub-core-api")) + if (enableAnyIosTarget) { + (this as ExtensionAware).extensions.configure { + framework { + export(project(":pubnub-core:pubnub-core-api")) + } } } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec b/pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec index b0dd0413b..1f06b55b0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec +++ b/pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |spec| spec.name = 'pubnub_kotlin_api' - spec.version = '1.0' - spec.homepage = 'Link to a Kotlin/Native module homepage' + spec.version = '9.2.3' + spec.homepage = '' spec.source = { :http=> ''} spec.authors = '' spec.license = '' - spec.summary = 'Some description for a Kotlin/Native module' + spec.summary = '' spec.vendored_frameworks = 'build/cocoapods/framework/pubnub_kotlin_api.framework' spec.libraries = 'c++' spec.ios.deployment_target = '14' diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/ChannelMetadataTest.kt similarity index 95% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/ChannelMetadataTest.kt index af3140b3a..9d7d405fe 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/ChannelMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/ChannelMetadataTest.kt @@ -1,5 +1,6 @@ -package com.pubnub.api +package com.pubnub.test.integration +import com.pubnub.api.PubNubException import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage @@ -29,7 +30,7 @@ class ChannelMetadataTest : BaseIntegrationTest() { private val type = randomString() @Test - fun can_set_metadata() = runTest(timeout = defaultTimeout) { + fun can_set_metadata() = runTest { // when val result = pubnub.setChannelMetadata( channel, @@ -53,7 +54,7 @@ class ChannelMetadataTest : BaseIntegrationTest() { } @Test - fun can_receive_set_metadata_event() = runTest(timeout = defaultTimeout) { + fun can_receive_set_metadata_event() = runTest { pubnub.test(backgroundScope) { // given pubnub.awaitSubscribe(listOf(channel)) @@ -83,7 +84,7 @@ class ChannelMetadataTest : BaseIntegrationTest() { } @Test - fun can_delete_metadata() = runTest(timeout = defaultTimeout) { + fun can_delete_metadata() = runTest { // given pubnub.setChannelMetadata( channel, @@ -106,7 +107,7 @@ class ChannelMetadataTest : BaseIntegrationTest() { } @Test - fun can_receive_delete_metadata_event() = runTest(timeout = defaultTimeout) { + fun can_receive_delete_metadata_event() = runTest { pubnub.test(backgroundScope) { pubnub.setChannelMetadata( channel, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/DeleteMessagesTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/DeleteMessagesTest.kt similarity index 97% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/DeleteMessagesTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/DeleteMessagesTest.kt index ffb90746c..c9b818260 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/DeleteMessagesTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/DeleteMessagesTest.kt @@ -1,4 +1,4 @@ -package com.pubnub.api +package com.pubnub.test.integration import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.test.BaseIntegrationTest diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/EntitiesTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/EntitiesTest.kt similarity index 86% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/EntitiesTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/EntitiesTest.kt index 844cbaecf..da2658fb1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/EntitiesTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/EntitiesTest.kt @@ -1,4 +1,4 @@ -package com.pubnub.api +package com.pubnub.test.integration import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.kmp.createEventListener @@ -14,7 +14,7 @@ class EntitiesTest : BaseIntegrationTest() { private val channelName = "myChannel" @Test - fun can_subscribe_channel_subscription() = runTest(timeout = defaultTimeout) { + fun can_subscribe_channel_subscription() = runTest { pubnub.test(backgroundScope) { val channel = pubnub.channel(channelName) val subscription = channel.awaitSubscribe() @@ -23,7 +23,7 @@ class EntitiesTest : BaseIntegrationTest() { } @Test - fun can_get_events_from_channel_subscription() = runTest(timeout = defaultTimeout) { + fun can_get_events_from_channel_subscription() = runTest { pubnub.test(backgroundScope) { val channel = pubnub.channel(channelName) val subscription = channel.awaitSubscribe() @@ -43,7 +43,7 @@ class EntitiesTest : BaseIntegrationTest() { } @Test - fun can_subscribe_channel_subscriptionSet() = runTest(timeout = defaultTimeout) { + fun can_subscribe_channel_subscriptionSet() = runTest { pubnub.test(backgroundScope) { val channelSet = setOf(channelName, "abc") val set = pubnub.subscriptionSetOf(channelSet) @@ -55,7 +55,7 @@ class EntitiesTest : BaseIntegrationTest() { } @Test - fun can_get_events_from_channel_subscriptionSet() = runTest(timeout = defaultTimeout) { + fun can_get_events_from_channel_subscriptionSet() = runTest { pubnub.test(backgroundScope) { val channelSet = setOf(channelName, "abc") val set = pubnub.subscriptionSetOf(channelSet) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/FetchMessagesTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/FetchMessagesTest.kt similarity index 98% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/FetchMessagesTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/FetchMessagesTest.kt index adcb3aa0d..482ed19a7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/FetchMessagesTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/FetchMessagesTest.kt @@ -1,5 +1,6 @@ -package com.pubnub.api +package com.pubnub.test.integration +import com.pubnub.api.createJsonElement import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.HistoryMessageType import com.pubnub.api.models.consumer.history.PNFetchMessageItem diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/HereWhereNowTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/HereWhereNowTest.kt similarity index 91% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/HereWhereNowTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/HereWhereNowTest.kt index 89e1b9c66..922a311ec 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/HereWhereNowTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/HereWhereNowTest.kt @@ -1,4 +1,4 @@ -package com.pubnub.api +package com.pubnub.test.integration import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await @@ -13,7 +13,7 @@ import kotlin.test.assertEquals class HereWhereNowTest : BaseIntegrationTest() { @Test - fun hereNow() = runTest(timeout = defaultTimeout) { + fun hereNow() = runTest { val channel = randomString() pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) @@ -30,7 +30,7 @@ class HereWhereNowTest : BaseIntegrationTest() { } @Test - fun whereNow() = runTest(timeout = defaultTimeout) { + fun whereNow() = runTest { val channel = randomString() pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembersTest.kt similarity index 94% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembersTest.kt index 7147ed9c5..7012658c6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembersTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembersTest.kt @@ -1,4 +1,4 @@ -package com.pubnub.api +package com.pubnub.test.integration import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.member.PNMember @@ -25,7 +25,7 @@ class MembersTest : BaseIntegrationTest() { private val type = randomString() @Test - fun can_set_members() = runTest(timeout = defaultTimeout) { + fun can_set_members() = runTest { // when val result = pubnub.setChannelMembers( channel, @@ -55,7 +55,7 @@ class MembersTest : BaseIntegrationTest() { } @Test - fun can_delete_members() = runTest(timeout = defaultTimeout) { + fun can_delete_members() = runTest { // given pubnub.setChannelMembers( channel, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt similarity index 92% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt index 9a1562184..3f09676a7 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MembershipsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt @@ -1,4 +1,4 @@ -package com.pubnub.api +package com.pubnub.test.integration import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel @@ -27,7 +27,7 @@ class MembershipsTest : BaseIntegrationTest() { private val type = randomString() @Test - fun can_set_memberships() = runTest(timeout = defaultTimeout) { + fun can_set_memberships() = runTest { // when val result = pubnub.setMemberships( listOf(PNChannelMembership.Partial(channel, custom, status)), @@ -42,7 +42,7 @@ class MembershipsTest : BaseIntegrationTest() { } @Test - fun can_receive_set_membership_event() = runTest(timeout = defaultTimeout) { + fun can_receive_set_membership_event() = runTest { pubnub.test(backgroundScope) { // given pubnub.awaitSubscribe(listOf(channel)) @@ -65,7 +65,7 @@ class MembershipsTest : BaseIntegrationTest() { } @Test - fun can_delete_membership() = runTest(timeout = defaultTimeout) { + fun can_delete_membership() = runTest { // given pubnub.setMemberships( listOf(PNChannelMembership.Partial(channel, custom, status)) @@ -87,7 +87,7 @@ class MembershipsTest : BaseIntegrationTest() { } @Test - fun can_receive_delete_membership_event() = runTest(timeout = defaultTimeout) { + fun can_receive_delete_membership_event() = runTest { pubnub.test(backgroundScope) { // given pubnub.setMemberships( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageActionsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MessageActionsTest.kt similarity index 98% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageActionsTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MessageActionsTest.kt index 8df69e9e4..85682b4cc 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageActionsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MessageActionsTest.kt @@ -1,4 +1,4 @@ -package com.pubnub.api +package com.pubnub.test.integration import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.message_actions.PNMessageAction diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageCountsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MessageCountsTest.kt similarity index 97% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageCountsTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MessageCountsTest.kt index 4c41ccc5c..3cd4e8d99 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/MessageCountsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MessageCountsTest.kt @@ -1,4 +1,4 @@ -package com.pubnub.api +package com.pubnub.test.integration import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PublishTest.kt similarity index 90% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PublishTest.kt index 9fe2c8e1b..495e90ebb 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PublishTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PublishTest.kt @@ -1,5 +1,12 @@ -package com.pubnub.api - +package com.pubnub.test.integration + +import com.pubnub.api.JsonElement +import com.pubnub.api.asDouble +import com.pubnub.api.asList +import com.pubnub.api.asLong +import com.pubnub.api.asMap +import com.pubnub.api.asString +import com.pubnub.api.isNull import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.kmp.PLATFORM import com.pubnub.test.BaseIntegrationTest @@ -24,28 +31,28 @@ class PublishTest : BaseIntegrationTest() { @Test fun can_publish_message_string() = - runTest(timeout = defaultTimeout) { + runTest { val result = pubnub.publish(channel, "some message").await() assertTrue { result.timetoken > 0 } } @Test fun can_signal() = - runTest(timeout = defaultTimeout) { + runTest { val result = pubnub.signal(channel, "some message").await() assertTrue { result.timetoken > 0 } } @Test fun can_publish_message_map() = - runTest(timeout = defaultTimeout) { + runTest { val result = pubnub.publish(channel, mapOf("platform" to PLATFORM, "otherKey" to 123, "another" to true)).await() assertTrue { result.timetoken > 0 } } @Test fun can_signal_map() = - runTest(timeout = defaultTimeout) { + runTest { val result = pubnub.signal(channel, mapOf("platform" to PLATFORM, "otherKey" to 123, "another" to true)).await() assertTrue { result.timetoken > 0 } } @@ -53,13 +60,13 @@ class PublishTest : BaseIntegrationTest() { @Test @Ignore // only JVM supports custom classes fun can_publish_message_object() = - runTest(timeout = defaultTimeout) { + runTest { val result = pubnub.publish(channel, ABC()).await() assertTrue { result.timetoken > 0 } } @Test - fun can_receive_message_with_map_metadata() = runTest(timeout = defaultTimeout) { + fun can_receive_message_with_map_metadata() = runTest { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) val mapData = mapOf( @@ -82,7 +89,7 @@ class PublishTest : BaseIntegrationTest() { private fun isIOS() = PLATFORM == "iOS" @Test - fun can_receive_message_with_primitive_payload() = runTest(timeout = defaultTimeout) { + fun can_receive_message_with_primitive_payload() = runTest { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) pubnub.publish( @@ -102,7 +109,7 @@ class PublishTest : BaseIntegrationTest() { } @Test - fun can_receive_message_with_map_payload() = runTest(timeout = defaultTimeout) { + fun can_receive_message_with_map_payload() = runTest { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) val mapData = mapOf( @@ -123,7 +130,7 @@ class PublishTest : BaseIntegrationTest() { } @Test - fun can_receive_signal_with_map_payload() = runTest(timeout = defaultTimeout) { + fun can_receive_signal_with_map_payload() = runTest { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) val mapData = mapOf( @@ -140,7 +147,7 @@ class PublishTest : BaseIntegrationTest() { } @Test - fun can_receive_message_with_payload_with_floats() = runTest(timeout = defaultTimeout) { + fun can_receive_message_with_payload_with_floats() = runTest { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) val mapData = mapOf( @@ -163,7 +170,7 @@ class PublishTest : BaseIntegrationTest() { @Test @Ignore // todo js doesn't support primitive metadata? - fun can_receive_message_with_primitive_metadata() = runTest(timeout = defaultTimeout) { + fun can_receive_message_with_primitive_metadata() = runTest { pubnub.test(backgroundScope) { pubnub.awaitSubscribe(listOf(channel)) pubnub.publish(channel, "some message", "some meta").await() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PushTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PushTest.kt similarity index 99% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PushTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PushTest.kt index d89688ed5..a9d701f4f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/PushTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PushTest.kt @@ -1,4 +1,4 @@ -package com.pubnub.api +package com.pubnub.test.integration import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/TimeTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/TimeTest.kt similarity index 90% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/TimeTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/TimeTest.kt index a96749b39..0774f6c2f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/TimeTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/TimeTest.kt @@ -1,4 +1,4 @@ -package com.pubnub.api +package com.pubnub.test.integration import com.pubnub.test.BaseIntegrationTest import com.pubnub.test.await diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/UserMetadataTest.kt similarity index 95% rename from pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/UserMetadataTest.kt index a61a7ac34..6b8167fd3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/UserMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/UserMetadataTest.kt @@ -1,5 +1,6 @@ -package com.pubnub.api +package com.pubnub.test.integration +import com.pubnub.api.PubNubException import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult @@ -31,7 +32,7 @@ class UserMetadataTest : BaseIntegrationTest() { private val type = randomString() @Test - fun can_set_metadata() = runTest(timeout = defaultTimeout) { + fun can_set_metadata() = runTest { // when val result = pubnub.setUUIDMetadata( uuid, @@ -59,7 +60,7 @@ class UserMetadataTest : BaseIntegrationTest() { } @Test - fun can_receive_set_metadata_event() = runTest(timeout = defaultTimeout) { + fun can_receive_set_metadata_event() = runTest { pubnub.test(backgroundScope) { // given pubnub.awaitSubscribe(listOf(uuid)) @@ -93,7 +94,7 @@ class UserMetadataTest : BaseIntegrationTest() { } @Test - fun can_delete_metadata() = runTest(timeout = defaultTimeout) { + fun can_delete_metadata() = runTest { // given pubnub.setUUIDMetadata( uuid, @@ -117,7 +118,7 @@ class UserMetadataTest : BaseIntegrationTest() { } @Test - fun can_receive_delete_metadata_event() = runTest(timeout = defaultTimeout) { + fun can_receive_delete_metadata_event() = runTest { pubnub.test(backgroundScope) { // given pubnub.setUUIDMetadata( @@ -144,7 +145,7 @@ class UserMetadataTest : BaseIntegrationTest() { } @Test - fun can_get_metadata() = runTest(timeout = defaultTimeout) { + fun can_get_metadata() = runTest { // given pubnub.setUUIDMetadata( uuid, diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts index 2d4e701ec..287854eb3 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -1,5 +1,8 @@ import com.codingfeline.buildkonfig.compiler.FieldSpec.Type +import com.pubnub.gradle.enableIosSimulatorTarget +import com.pubnub.gradle.enableIosTarget +import com.pubnub.gradle.enableJsTarget import java.util.Properties plugins { @@ -15,14 +18,20 @@ plugins { kotlin { jvmToolchain(8) - js { - browser { + if (enableJsTarget) { + js { + useEsModules() + browser() + nodejs() } - binaries.executable() } jvm() - iosArm64() - iosSimulatorArm64() + if (enableIosTarget) { + iosArm64() + } + if (enableIosSimulatorTarget) { + iosSimulatorArm64() + } sourceSets { val commonMain by getting { @@ -31,38 +40,21 @@ kotlin { api(project(":pubnub-core:pubnub-core-api")) api(kotlin("test")) api(libs.coroutines.test) -// implementation(libs.datetime) } } -// -// val commonTest by getting { -// dependencies { -// implementation(kotlin("test")) -// implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1") -// implementation(libs.coroutines.test) -// } -// } -// + val jvmMain by getting { dependencies { api(kotlin("test-junit")) } } -// -// val jvmTest by getting { -// dependencies { -// implementation(project(":pubnub-kotlin:pubnub-kotlin-impl")) -// } -// } } -// targets.withType { -// if (konanTarget.family.isAppleFamily) { -// binaries.withType { -// freeCompilerArgs += listOf("-e", "testlauncher.mainBackground") -// } -// } -// } + ktlint { + filter { + exclude { it: FileTreeElement -> it.file.absolutePath.also { println(it) }.contains("/build/") } + } + } buildkonfig { packageName = "com.pubnub.test" @@ -75,12 +67,21 @@ kotlin { testProps.load(it) } } catch (e: Exception) { - println("No test.properties found in root project. Using 'demo' for all keys.") - testProps.setProperty("pubKey", "demo") - testProps.setProperty("subKey", "demo") - testProps.setProperty("pamPubKey", "demo") - testProps.setProperty("pamSubKey", "demo") - testProps.setProperty("pamSecKey", "demo") + println("No test.properties found in root project. Trying to get keys from env") + try { + testProps.setProperty("pubKey", providers.environmentVariable("SDK_PUB_KEY").get()) + testProps.setProperty("subKey", providers.environmentVariable("SDK_SUB_KEY").get()) + testProps.setProperty("pamPubKey", providers.environmentVariable("SDK_PAM_PUB_KEY").get()) + testProps.setProperty("pamSubKey", providers.environmentVariable("SDK_PAM_SUB_KEY").get()) + testProps.setProperty("pamSecKey", providers.environmentVariable("SDK_PAM_SEC_KEY").get()) + } catch (e: IllegalStateException) { + println("No env variables found. Setting all keys to demo") + testProps.setProperty("pubKey", "demo") + testProps.setProperty("subKey", "demo") + testProps.setProperty("pamPubKey", "demo") + testProps.setProperty("pamSubKey", "demo") + testProps.setProperty("pamSecKey", "demo") + } } buildConfigField(Type.STRING, "pubKey", testProps.getProperty("pubKey")) buildConfigField(Type.STRING, "subKey", testProps.getProperty("subKey")) diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt index 10b159fa2..7bfd8411b 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt @@ -27,11 +27,8 @@ import kotlin.coroutines.resumeWithException import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.assertTrue -import kotlin.time.Duration.Companion.seconds abstract class BaseIntegrationTest { - val defaultTimeout = 10.seconds - lateinit var config: PNConfiguration lateinit var configPam: PNConfiguration lateinit var pubnub: PubNub @@ -175,29 +172,12 @@ class PubNubTest( customSubscriptionBlock() } -// fun subscribe( -// channels: Collection = emptyList(), -// channelGroups: Collection = emptyList(), -// withPresence: Boolean = false, -// ) { -// pubNub.subscribe(channels.toList(), channelGroups.toList(), withPresence = withPresence || withPresenceOverride) -// val status = statusQueue.take() -// Assert.assertTrue( -// status.category == PNStatusCategory.PNConnectedCategory || status.category == PNStatusCategory.PNSubscriptionChanged, -// ) -// if (status.category == PNStatusCategory.PNConnectedCategory) { -// Assert.assertTrue(status.affectedChannels.containsAll(channels)) -// Assert.assertTrue(status.affectedChannelGroups.containsAll(channelGroups)) -// } else if (status.category == PNStatusCategory.PNSubscriptionChanged) { -// Assert.assertTrue(status.affectedChannels.containsAll(channels)) -// Assert.assertTrue(status.affectedChannelGroups.containsAll(channelGroups)) -// } -// } - suspend fun PubNub.awaitUnsubscribe( channels: Collection = setOf(), channelGroups: Collection = setOf(), - withPresence: Boolean = false + customUnsubscribeBlock: () -> Unit = { + unsubscribe(channels.toList(), channelGroups.toList()) + } ) = suspendCancellableCoroutine { cont -> val statusListener = createStatusListener(pubNub) { _, pnStatus -> if (pnStatus.category == PNStatusCategory.PNDisconnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged && @@ -215,7 +195,7 @@ class PubNubTest( cont.invokeOnCancellation { pubNub.removeListener(statusListener) } - unsubscribe(channels.toList(), channelGroups.toList()) + customUnsubscribeBlock() } // fun unsubscribeAll() { diff --git a/settings.gradle.kts b/settings.gradle.kts index fd606fa16..74449c59f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -24,4 +24,4 @@ include("pubnub-gson:pubnub-gson-api") include("pubnub-gson:pubnub-gson-impl") include("examples:kotlin-app") include("examples:java-app") -include("build-logic:ktlint-custom-rules") +includeBuild("build-logic/ktlint-custom-rules") From f5d37b8bf748f7505d3c49483eee064b5b95414b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:21:27 +0000 Subject: [PATCH 50/62] [Kotlin] Change PNChannelMetadata and PNUUIDMetadata to contain partial update information (#266) * Add partial updates when querying channel metadata * Add partial updates when querying user metadata * Deprecate TTL parameter in PubNub.fire() --- .../objects/channel/PNChannelMetadata.kt | 33 ++++++-- .../channel/PNChannelMetadataResult.kt | 2 +- .../consumer/objects/uuid/PNUUIDMetadata.kt | 40 +++++++--- .../kotlin/com/pubnub/api/utils/PatchValue.kt | 17 ++++ .../kotlin/com/pubnub/internal/PubNubCore.kt | 2 - .../pubnub/internal/managers/MapperManager.kt | 61 ++++++++++++++- .../objects/membership/PNChannelMembership.kt | 2 +- .../server/objects_api/EntityEnvelope.kt | 2 +- .../channelmetadata/step/WhenSteps.kt | 10 +-- .../contract/uuidmetadata/step/WhenSteps.kt | 14 ++-- .../internal/managers/MapperManagerTest.kt | 26 +++++++ .../channel/PNChannelMetadata.java | 25 +++--- .../objects_api/uuid/PNUUIDMetadata.java | 18 ++--- .../callbacks/DelegatingEventListenerTest.kt | 46 +++++++++-- .../config/ktlint/baseline.xml | 78 ------------------- .../kotlin/com/pubnub/api/PubNub.kt | 1 - .../objects/membership/PNChannelMembership.kt | 2 +- .../com/pubnub/api/v2/entities/Channel.kt | 6 +- .../objects/channel/PNChannelMetadataTest.kt | 43 ++++++++++ .../objects/uuid/PNUUIDMetadataTest.kt | 47 +++++++++++ .../test/integration/ChannelMetadataTest.kt | 36 ++++----- .../test/integration/UserMetadataTest.kt | 58 +++++++------- .../jvmMain/kotlin/com/pubnub/api/PubNub.kt | 41 ++++++++-- .../api/integration/HistoryIntegrationTest.kt | 2 +- .../api/integration/ObjectsIntegrationTest.kt | 16 ++-- .../kotlin/com/pubnub/internal/PubNubImpl.kt | 21 +++-- .../config/ktlint/baseline.xml | 7 -- 27 files changed, 429 insertions(+), 227 deletions(-) create mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataTest.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataTest.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt index ebb59c444..2f2d1980d 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt @@ -1,12 +1,29 @@ package com.pubnub.api.models.consumer.objects.channel +import com.pubnub.api.utils.PatchValue + data class PNChannelMetadata( val id: String, - val name: String?, - val description: String?, - val custom: Map?, - val updated: String?, - val eTag: String?, - val type: String?, - val status: String?, -) + val name: PatchValue? = null, + val description: PatchValue? = null, + val custom: PatchValue?>? = null, + val updated: PatchValue? = null, + val eTag: PatchValue? = null, + val type: PatchValue? = null, + val status: PatchValue? = null, +) { + /** + * Merge information from this `PNChannelMetadata` with new data from `update`, returning a new `PNChannelMetadata` instance. + */ + operator fun plus(update: PNChannelMetadata): PNChannelMetadata { + return copy( + name = update.name ?: name, + description = update.description ?: description, + custom = update.custom ?: custom, + updated = update.updated ?: updated, + eTag = update.eTag ?: eTag, + type = update.type ?: type, + status = update.status ?: status, + ) + } +} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt index a2dc22110..771bec6f1 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt @@ -2,5 +2,5 @@ package com.pubnub.api.models.consumer.objects.channel data class PNChannelMetadataResult( val status: Int, - val data: PNChannelMetadata?, + val data: PNChannelMetadata, ) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt index 852e37412..a1379b325 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt @@ -1,14 +1,34 @@ package com.pubnub.api.models.consumer.objects.uuid +import com.pubnub.api.utils.PatchValue + +// TODO add a test that checks sending patch values to server and reading them back when we have the "sending" part data class PNUUIDMetadata( val id: String, - val name: String?, - val externalId: String?, - val profileUrl: String?, - val email: String?, - val custom: Map?, - val updated: String?, - val eTag: String?, - val type: String?, - val status: String?, -) + val name: PatchValue? = null, + val externalId: PatchValue? = null, + val profileUrl: PatchValue? = null, + val email: PatchValue? = null, + val custom: PatchValue?>? = null, + val updated: PatchValue? = null, + val eTag: PatchValue? = null, + val type: PatchValue? = null, + val status: PatchValue? = null, +) { + /** + * Merge information from this `PNUUIDMetadata` with new data from `update`, returning a new `PNUUIDMetadata` instance. + */ + operator fun plus(update: PNUUIDMetadata): PNUUIDMetadata { + return copy( + name = update.name ?: name, + externalId = update.externalId ?: externalId, + profileUrl = update.profileUrl ?: profileUrl, + email = update.email ?: email, + custom = update.custom ?: custom, + updated = update.updated ?: updated, + eTag = update.eTag ?: eTag, + type = update.type ?: type, + status = update.status ?: status, + ) + } +} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt new file mode 100644 index 000000000..c60d7b801 --- /dev/null +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt @@ -0,0 +1,17 @@ +package com.pubnub.api.utils + +/** + * An optional that accepts nullable values. Thus, it can represent two (`PatchValue`) or three (`PatchValue?`) states: + * * `PatchValue.of(someValue)` - value is present and that value is `someValue` + * * `PatchValue.of(null)` - value is present and that value is `null` + * * `null` - lack of information about value (no update for this field) + */ +data class PatchValue internal constructor(val value: T) { + companion object { + /** + * Create an optional with the specified value (which can be null). + */ + @JvmStatic + fun of(value: T): PatchValue = PatchValue(value) + } +} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt index 142783209..b6a4b4751 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt @@ -298,7 +298,6 @@ class PubNubCore internal constructor( message: Any, meta: Any? = null, usePost: Boolean = false, - ttl: Int? = null, ) = publish( channel = channel, message = message, @@ -306,7 +305,6 @@ class PubNubCore internal constructor( shouldStore = false, usePost = usePost, replicate = false, - ttl = ttl, ) /** diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt index 0b917e2fb..69e2b9538 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt @@ -12,16 +12,20 @@ import com.google.gson.JsonSerializationContext import com.google.gson.JsonSerializer import com.google.gson.ToNumberPolicy import com.google.gson.TypeAdapter +import com.google.gson.TypeAdapterFactory +import com.google.gson.reflect.TypeToken import com.google.gson.stream.JsonReader import com.google.gson.stream.JsonToken import com.google.gson.stream.JsonWriter import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.utils.PatchValue import org.json.JSONArray import org.json.JSONException import org.json.JSONObject import retrofit2.Converter import retrofit2.converter.gson.GsonConverterFactory +import java.lang.reflect.ParameterizedType import java.lang.reflect.Type class MapperManager { @@ -42,7 +46,7 @@ class MapperManager { } } - override fun read(_in: JsonReader): Boolean? { + override fun read(_in: JsonReader): Boolean { val peek: JsonToken = _in.peek() return when (peek) { JsonToken.BOOLEAN -> _in.nextBoolean() @@ -53,6 +57,58 @@ class MapperManager { } } + val patchValueTypeFactory = object : TypeAdapterFactory { + override fun create(gson: Gson, type: TypeToken): TypeAdapter? { + if (type.rawType != PatchValue::class.java) { + return null + } + val factory = this + return object : TypeAdapter() { + override fun write(out: JsonWriter, patchValue: T) { + val writeNulls = out.serializeNulls + try { + if (patchValue == null) { + // value is PatchValue.none(), skip it (serializeNulls is false) + out.nullValue() + } else { + patchValue as PatchValue + if (patchValue.value == null) { + // value is PatchValue.of(null), write it out to JSON: + out.serializeNulls = true + out.nullValue() + } else { + // value is PatchValue.of(something), write it out using the right adapter: + val delegate = gson.getDelegateAdapter( + factory, + TypeToken.get(patchValue.value!!::class.java) + ) as TypeAdapter + delegate.write(out, patchValue.value) + } + } + } finally { + out.serializeNulls = writeNulls + } + } + + override fun read(reader: JsonReader): T { + val token = reader.peek() + if (token == JsonToken.NULL) { + reader.nextNull() + @Suppress("UNCHECKED_CAST") + return PatchValue.of(null) as T + } else { + val delegate = gson.getDelegateAdapter( + factory, + TypeToken.get((type.type as ParameterizedType).actualTypeArguments.first()) + ) + @Suppress("UNCHECKED_CAST") + return PatchValue.of(delegate.read(reader)) as T + } + } + } + } + } + objectMapper = GsonBuilder() .registerTypeAdapter(Boolean::class.javaObjectType, booleanAsIntAdapter) @@ -60,6 +116,7 @@ class MapperManager { .registerTypeAdapter(Boolean::class.java, booleanAsIntAdapter) .registerTypeAdapter(JSONObject::class.java, JSONObjectAdapter()) .registerTypeAdapter(JSONArray::class.java, JSONArrayAdapter()) + .registerTypeAdapterFactory(patchValueTypeFactory) .disableHtmlEscaping() .setObjectToNumberStrategy(ToNumberPolicy.LAZILY_PARSED_NUMBER) .create() @@ -144,7 +201,7 @@ class MapperManager { clazz: Class, ): T { return try { - this.objectMapper.fromJson(input, clazz) + this.objectMapper.fromJson(input, clazz) } catch (e: JsonParseException) { throw PubNubException( pubnubError = PubNubError.PARSING_ERROR, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt index 8178158fb..fd72a11d5 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt @@ -3,7 +3,7 @@ package com.pubnub.internal.models.consumer.objects.membership import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata data class PNChannelMembership( - val channel: PNChannelMetadata?, + val channel: PNChannelMetadata, val custom: Map?, val updated: String, val eTag: String, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityEnvelope.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityEnvelope.kt index f23192acc..e5078f99f 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityEnvelope.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityEnvelope.kt @@ -2,5 +2,5 @@ package com.pubnub.internal.models.server.objects_api data class EntityEnvelope( val status: Int, - val data: T? = null, + val data: T, ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/WhenSteps.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/WhenSteps.kt index b93f324ac..de57d3909 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/WhenSteps.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/WhenSteps.kt @@ -21,11 +21,11 @@ class WhenSteps( val channelMetadata = channelMetadataState.channelMetadata!! world.pubnub.pubNubCore.setChannelMetadata( channel = channelMetadata.id, - name = channelMetadata.name, - description = channelMetadata.description, - custom = channelMetadata.custom, - type = channelMetadata.type, - status = channelMetadata.status, + name = channelMetadata.name?.value, + description = channelMetadata.description?.value, + custom = channelMetadata.custom?.value, + type = channelMetadata.type?.value, + status = channelMetadata.status?.value, ).sync().let { channelMetadataState.channelMetadata = it.data world.responseStatus = it.status diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/WhenSteps.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/WhenSteps.kt index 50a9d47a4..8e045606b 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/WhenSteps.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/WhenSteps.kt @@ -30,13 +30,13 @@ class WhenSteps( world.pubnub.pubNubCore.setUUIDMetadata( uuid = uuidMetadata.id, custom = uuidMetadata.custom, - externalId = uuidMetadata.externalId, - profileUrl = uuidMetadata.profileUrl, - email = uuidMetadata.email, - name = uuidMetadata.name, - status = uuidMetadata.status, - type = uuidMetadata.type, - ).sync()?.let { + externalId = uuidMetadata.externalId?.value, + profileUrl = uuidMetadata.profileUrl?.value, + email = uuidMetadata.email?.value, + name = uuidMetadata.name?.value, + status = uuidMetadata.status?.value, + type = uuidMetadata.type?.value, + ).sync().let { uuidMetadataState.uuidMetadata = it.data world.responseStatus = it.status } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt index 251d61854..ce31bb4aa 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt @@ -1,7 +1,10 @@ package com.pubnub.internal.managers import com.pubnub.api.PubNubException +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertNotNull +import org.junit.jupiter.api.Assertions.assertNull import org.junit.jupiter.api.Test internal class MapperManagerTest { @@ -94,6 +97,29 @@ internal class MapperManagerTest { assertEquals(map["f"], decodedMap["f"]) assertEquals(map["f"].toString().toLong(), decodedMap["f"].tryLong()) } + + @Test + fun fromJson_optionalsAndNulls() { + val mapperManager = MapperManager() + val input = """ + { "id" : "myId", "name": null, "description": "myDescription", "eTag": "myEtag", "custom": { "a" : "b" } } + """.trimIndent() + + val output: PNChannelMetadata = mapperManager.fromJson(input, PNChannelMetadata::class.java) + + assertEquals("myId", output.id) + assertNotNull(output.name) + assertNull(output.name?.value) + + assertEquals("myDescription", output.description?.value) + + assertNull(output.updated) + assertNull(output.status) + + assertEquals(mapOf("a" to "b"), output.custom?.value) + + assertEquals("myEtag", output.eTag?.value) + } } private fun Any?.tryLong(): Long? { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNChannelMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNChannelMetadata.java index 5b4cfb67f..84d7f77be 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNChannelMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNChannelMetadata.java @@ -6,7 +6,7 @@ import lombok.Setter; import lombok.ToString; import lombok.experimental.Accessors; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.NotNull; import java.util.ArrayList; import java.util.Collection; @@ -39,26 +39,25 @@ public PNChannelMetadata setCustom(Object custom) { return this; } - @Nullable - public static PNChannelMetadata from(@Nullable com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata data) { - if (data == null) { - return null; - } + @NotNull + public static PNChannelMetadata from(@NotNull com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata data) { PNChannelMetadata newData = new PNChannelMetadata( - data.getId(), data.getName(), data.getDescription() + data.getId(), + data.getName() != null ? data.getName().getValue() : null, + data.getDescription() != null ? data.getDescription().getValue() : null ); - newData.setETag(data.getETag()); - newData.setType(data.getType()); - newData.setStatus(data.getStatus()); - newData.setCustom(data.getCustom()); - newData.setUpdated(data.getUpdated()); + newData.setETag(data.getETag() != null ? data.getETag().getValue() : null); + newData.setType(data.getType() != null ? data.getType().getValue() : null); + newData.setStatus(data.getStatus() != null ? data.getStatus().getValue() : null); + newData.setCustom(data.getCustom() != null ? data.getCustom().getValue() : null); + newData.setUpdated(data.getUpdated() != null ? data.getUpdated().getValue() : null); return newData; } public static List from(Collection data) { List channels = new ArrayList<>(data.size()); for (com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata datum : data) { - channels.add(PNChannelMetadata.from(datum)); + channels.add(from(datum)); } return channels; } diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNUUIDMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNUUIDMetadata.java index 57220cc6b..409eab008 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNUUIDMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNUUIDMetadata.java @@ -51,16 +51,16 @@ public static PNUUIDMetadata from(com.pubnub.api.models.consumer.objects.uuid.PN if (data == null) { return null; } - PNUUIDMetadata newData = new PNUUIDMetadata(data.getId(), data.getName()) - .setProfileUrl(data.getProfileUrl()) - .setEmail(data.getEmail()) - .setExternalId(data.getExternalId()) - .setStatus(data.getStatus()) - .setType(data.getType()) - .setCustom(data.getCustom()); + PNUUIDMetadata newData = new PNUUIDMetadata(data.getId(), data.getName() != null ? data.getName().getValue() : null) + .setProfileUrl(data.getProfileUrl() != null ? data.getProfileUrl().getValue() : null) + .setEmail(data.getEmail() != null ? data.getEmail().getValue() : null) + .setExternalId(data.getExternalId() != null ? data.getExternalId().getValue() : null) + .setStatus(data.getStatus() != null ? data.getStatus().getValue() : null) + .setType(data.getType() != null ? data.getType().getValue() : null) + .setCustom(data.getCustom() != null ? data.getCustom().getValue() : null); - newData.setETag(data.getETag()); - newData.setUpdated(data.getUpdated()); + newData.setETag(data.getETag() != null ? data.getETag().getValue() : null); + newData.setUpdated(data.getUpdated() != null ? data.getUpdated().getValue() : null); return newData; } } diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt index 4d63fafa0..49563754f 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt @@ -4,12 +4,12 @@ import com.google.gson.JsonPrimitive import com.pubnub.api.PNConfiguration import com.pubnub.api.PubNub import com.pubnub.api.UserId -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult import com.pubnub.api.models.consumer.pubsub.BasePubSubResult +import com.pubnub.api.utils.PatchValue import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteMembershipEvent @@ -82,7 +82,13 @@ internal class DelegatingEventListenerTest { pn, PNObjectEventResult( BasePubSubResult("a", "b", 0L, null, null), - PNSetUUIDMetadataEventMessage("a", "b", "c", "d", PNUUIDMetadata("a", "b", null, "c", "d", null, null, null, null, null)), + PNSetUUIDMetadataEventMessage( + "a", + "b", + "c", + "d", + PNUUIDMetadata("a", PatchValue.of("b"), null, PatchValue.of("c"), PatchValue.of("d"), null, null, null, null, null) + ), ), ) delegating.objects( @@ -94,7 +100,16 @@ internal class DelegatingEventListenerTest { "b", "c", "d", - PNChannelMetadata("a", "b", null, mapOf("c" to "c"), "d", null, null, null) + com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata( + "a", + PatchValue.of("b"), + null, + PatchValue.of(mapOf("c" to "c")), + PatchValue.of("d"), + null, + null, + null + ) ), ), ) @@ -129,7 +144,18 @@ internal class DelegatingEventListenerTest { @Test fun getSetUuidMetadataResult() { - val metadata = PNUUIDMetadata(id, name, externalId, profileUrl, email, custom, updated, eTag, type, status) + val metadata = PNUUIDMetadata( + id, + PatchValue.of(name), + PatchValue.of(externalId), + PatchValue.of(profileUrl), + PatchValue.of(email), + PatchValue.of(custom), + PatchValue.of(updated), + PatchValue.of(eTag), + PatchValue.of(type), + PatchValue.of(status) + ) val message = PNSetUUIDMetadataEventMessage(source, version, event, type, metadata) val objectEvent = PNObjectEventResult(BasePubSubResult(channel, subscription, timetoken, userMetadata, publisher), message) @@ -183,7 +209,17 @@ internal class DelegatingEventListenerTest { @Test fun getSetChannelMetadataResult() { - val metadata = PNChannelMetadata(id, name, description, custom, updated, eTag, type, status) + val metadata = + com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata( + id, + PatchValue.of(name), + PatchValue.of(description), + PatchValue.of(custom), + PatchValue.of(updated), + PatchValue.of(eTag), + PatchValue.of(type), + PatchValue.of(status) + ) val message = PNSetChannelMetadataEventMessage(source, version, event, type, metadata) val objectEvent = PNObjectEventResult(BasePubSubResult(channel, subscription, timetoken, userMetadata, publisher), message) diff --git a/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml b/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml index 7d091a9a8..981420778 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml +++ b/pubnub-kotlin/pubnub-kotlin-api/config/ktlint/baseline.xml @@ -1,81 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt index d626c11de..f410310e8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt @@ -100,7 +100,6 @@ expect interface PubNub { message: Any, meta: Any? = null, usePost: Boolean = false, - ttl: Int? = null, ): Publish fun signal( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt index e857e892c..98284a856 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt @@ -4,7 +4,7 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.kmp.CustomObject data class PNChannelMembership( - val channel: PNChannelMetadata?, + val channel: PNChannelMetadata, val custom: Map?, val updated: String, val eTag: String, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt index 2ed22defb..5b5ad4df1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt @@ -110,9 +110,9 @@ interface Channel : BaseChannel { */ fun fire( message: Any, - meta: Any?, - usePost: Boolean, - ttl: Int? + meta: Any? = null, + usePost: Boolean = false, + ttl: Int? = null ): Publish /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataTest.kt new file mode 100644 index 000000000..0c454aeea --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataTest.kt @@ -0,0 +1,43 @@ +package com.pubnub.api.models.consumer.objects.channel + +import com.pubnub.api.utils.PatchValue +import com.pubnub.test.randomString +import kotlin.test.Test +import kotlin.test.assertEquals + +class PNChannelMetadataTest { + @Test + fun plus() { + val originalMetadata = PNChannelMetadata( + randomString(), + name = PatchValue.of(randomString()), + description = PatchValue.of(randomString()), + custom = PatchValue.of(mapOf(randomString() to randomString())), + updated = PatchValue.of(randomString()), + eTag = PatchValue.of(randomString()), + type = PatchValue.of(randomString()), + status = PatchValue.of(randomString()) + ) + val updateMetadata = PNChannelMetadata( + originalMetadata.id, + name = PatchValue.of(randomString()), + description = PatchValue.of(randomString()), + custom = PatchValue.of(null), + ) + + val resultingMetadata = originalMetadata + updateMetadata + + val expectedMetadata = PNChannelMetadata( + originalMetadata.id, + name = updateMetadata.name, + description = updateMetadata.description, + custom = updateMetadata.custom, + updated = originalMetadata.updated, + type = originalMetadata.type, + status = originalMetadata.status, + eTag = originalMetadata.eTag, + ) + + assertEquals(expectedMetadata, resultingMetadata) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataTest.kt new file mode 100644 index 000000000..818501625 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataTest.kt @@ -0,0 +1,47 @@ +package com.pubnub.api.models.consumer.objects.uuid + +import com.pubnub.api.utils.PatchValue +import com.pubnub.test.randomString +import kotlin.test.Test +import kotlin.test.assertEquals + +class PNUUIDMetadataTest { + @Test + fun plus() { + val originalMetadata = PNUUIDMetadata( + randomString(), + name = PatchValue.of(randomString()), + externalId = PatchValue.of(randomString()), + profileUrl = PatchValue.of(randomString()), + email = PatchValue.of(randomString()), + custom = PatchValue.of(mapOf(randomString() to randomString())), + updated = PatchValue.of(randomString()), + eTag = PatchValue.of(randomString()), + type = PatchValue.of(randomString()), + status = PatchValue.of(randomString()) + ) + val updateMetadata = PNUUIDMetadata( + originalMetadata.id, + name = PatchValue.of(randomString()), + updated = PatchValue.of(randomString()), + custom = PatchValue.of(null), + ) + + val resultingMetadata = originalMetadata + updateMetadata + + val expectedMetadata = PNUUIDMetadata( + originalMetadata.id, + updateMetadata.name, + originalMetadata.externalId, + originalMetadata.profileUrl, + originalMetadata.email, + updateMetadata.custom, + updateMetadata.updated, + originalMetadata.eTag, + originalMetadata.type, + originalMetadata.status + ) + + assertEquals(expectedMetadata, resultingMetadata) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/ChannelMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/ChannelMetadataTest.kt index 9d7d405fe..49cc63043 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/ChannelMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/ChannelMetadataTest.kt @@ -44,13 +44,12 @@ class ChannelMetadataTest : BaseIntegrationTest() { // then val pnuuidMetadata = result.data - requireNotNull(pnuuidMetadata) assertEquals(channel, pnuuidMetadata.id) - assertEquals(name, pnuuidMetadata.name) - assertEquals(status, pnuuidMetadata.status) - assertEquals(customData, pnuuidMetadata.custom) - assertEquals(type, pnuuidMetadata.type) - assertEquals(description, pnuuidMetadata.description) + assertEquals(name, pnuuidMetadata.name?.value) + assertEquals(status, pnuuidMetadata.status?.value) + assertEquals(customData, pnuuidMetadata.custom?.value) + assertEquals(type, pnuuidMetadata.type?.value) + assertEquals(description, pnuuidMetadata.description?.value) } @Test @@ -63,9 +62,9 @@ class ChannelMetadataTest : BaseIntegrationTest() { pubnub.setChannelMetadata( channel, name = name, - status = status, + status = null, custom = custom, - includeCustom = includeCustom, + includeCustom = false, type = type, description = description ).await() @@ -75,11 +74,11 @@ class ChannelMetadataTest : BaseIntegrationTest() { val message = result.extractedMessage message as PNSetChannelMetadataEventMessage assertEquals(channel, message.data.id) - assertEquals(name, message.data.name) - assertEquals(description, message.data.description) - assertEquals(status, message.data.status) - assertEquals(customData, message.data.custom) - assertEquals(type, message.data.type) + assertEquals(name, message.data.name?.value) + assertEquals(description, message.data.description?.value) + assertEquals(null, message.data.status?.value) + assertEquals(customData, message.data.custom?.value) + assertEquals(type, message.data.type?.value) } } @@ -146,7 +145,6 @@ class ChannelMetadataTest : BaseIntegrationTest() { custom = custom, includeCustom = includeCustom, type = type, - description = description ).await() } @@ -177,11 +175,11 @@ class ChannelMetadataTest : BaseIntegrationTest() { repeat(6) { index -> val pnChannelMetadata = allChannels.firstOrNull { it.id == channel + index } assertNotNull(pnChannelMetadata) - assertEquals(name, pnChannelMetadata.name) - assertEquals(description, pnChannelMetadata.description) - assertEquals(status, pnChannelMetadata.status) - assertEquals(customData, pnChannelMetadata.custom) - assertEquals(type, pnChannelMetadata.type) + assertEquals(name, pnChannelMetadata.name?.value) + assertEquals(null, pnChannelMetadata.description!!.value) + assertEquals(status, pnChannelMetadata.status?.value) + assertEquals(customData, pnChannelMetadata.custom?.value) + assertEquals(type, pnChannelMetadata.type?.value) } } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/UserMetadataTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/UserMetadataTest.kt index 6b8167fd3..7ec496231 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/UserMetadataTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/UserMetadataTest.kt @@ -17,6 +17,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertNotNull +import kotlin.test.assertNull import kotlin.time.Duration.Companion.seconds class UserMetadataTest : BaseIntegrationTest() { @@ -50,13 +51,13 @@ class UserMetadataTest : BaseIntegrationTest() { val pnuuidMetadata = result.data requireNotNull(pnuuidMetadata) assertEquals(uuid, pnuuidMetadata.id) - assertEquals(name, pnuuidMetadata.name) - assertEquals(externalId, pnuuidMetadata.externalId) - assertEquals(profileUrl, pnuuidMetadata.profileUrl) - assertEquals(email, pnuuidMetadata.email) - assertEquals(status, pnuuidMetadata.status) - assertEquals(customData, pnuuidMetadata.custom) - assertEquals(type, pnuuidMetadata.type) + assertEquals(name, pnuuidMetadata.name?.value) + assertEquals(externalId, pnuuidMetadata.externalId?.value) + assertEquals(profileUrl, pnuuidMetadata.profileUrl?.value) + assertEquals(email, pnuuidMetadata.email?.value) + assertEquals(status, pnuuidMetadata.status?.value) + assertEquals(customData, pnuuidMetadata.custom?.value) + assertEquals(type, pnuuidMetadata.type?.value) } @Test @@ -68,7 +69,6 @@ class UserMetadataTest : BaseIntegrationTest() { // when pubnub.setUUIDMetadata( uuid, - name = name, externalId = externalId, profileUrl = profileUrl, email = email, @@ -83,13 +83,13 @@ class UserMetadataTest : BaseIntegrationTest() { val message = result.extractedMessage message as PNSetUUIDMetadataEventMessage assertEquals(uuid, message.data.id) - assertEquals(name, message.data.name) - assertEquals(externalId, message.data.externalId) - assertEquals(profileUrl, message.data.profileUrl) - assertEquals(email, message.data.email) - assertEquals(status, message.data.status) - assertEquals(customData, message.data.custom) - assertEquals(type, message.data.type) + assertNull(message.data.name) + assertEquals(externalId, message.data.externalId?.value) + assertEquals(profileUrl, message.data.profileUrl?.value) + assertEquals(email, message.data.email?.value) + assertEquals(status, message.data.status?.value) + assertEquals(customData, message.data.custom?.value) + assertEquals(type, message.data.type?.value) } } @@ -166,13 +166,13 @@ class UserMetadataTest : BaseIntegrationTest() { val pnuuidMetadata = result.data requireNotNull(pnuuidMetadata) assertEquals(uuid, pnuuidMetadata.id) - assertEquals(name, pnuuidMetadata.name) - assertEquals(externalId, pnuuidMetadata.externalId) - assertEquals(profileUrl, pnuuidMetadata.profileUrl) - assertEquals(email, pnuuidMetadata.email) - assertEquals(status, pnuuidMetadata.status) - assertEquals(customData, pnuuidMetadata.custom) - assertEquals(type, pnuuidMetadata.type) + assertEquals(name, pnuuidMetadata.name?.value) + assertEquals(externalId, pnuuidMetadata.externalId?.value) + assertEquals(profileUrl, pnuuidMetadata.profileUrl?.value) + assertEquals(email, pnuuidMetadata.email?.value) + assertEquals(status, pnuuidMetadata.status?.value) + assertEquals(customData, pnuuidMetadata.custom?.value) + assertEquals(type, pnuuidMetadata.type?.value) } @Test @@ -219,13 +219,13 @@ class UserMetadataTest : BaseIntegrationTest() { repeat(6) { val pnuuidMetadata = allUsers.firstOrNull { user -> user.id == uuid + it } assertNotNull(pnuuidMetadata) - assertEquals(name, pnuuidMetadata.name) - assertEquals(externalId, pnuuidMetadata.externalId) - assertEquals(profileUrl, pnuuidMetadata.profileUrl) - assertEquals(email, pnuuidMetadata.email) - assertEquals(status, pnuuidMetadata.status) - assertEquals(customData, pnuuidMetadata.custom) - assertEquals(type, pnuuidMetadata.type) + assertEquals(name, pnuuidMetadata.name?.value) + assertEquals(externalId, pnuuidMetadata.externalId?.value) + assertEquals(profileUrl, pnuuidMetadata.profileUrl?.value) + assertEquals(email, pnuuidMetadata.email?.value) + assertEquals(status, pnuuidMetadata.status?.value) + assertEquals(customData, pnuuidMetadata.custom?.value) + assertEquals(type, pnuuidMetadata.type?.value) } } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index d4ff9b6c7..e9a4336bc 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -218,20 +218,45 @@ actual interface PubNub : * @param meta Metadata object which can be used with the filtering ability. * If not specified, then the history configuration of the key is used. * @param usePost Use HTTP POST to publish. Default is `false` - * @param ttl Set a per message time to live in storage. - * - If `shouldStore = true`, and `ttl = 0`, the message is stored - * with no expiry time. - * - If `shouldStore = true` and `ttl = X` (`X` is an Integer value), - * the message is stored with an expiry time of `X` hours. - * - If `shouldStore = false`, the `ttl` parameter is ignored. - * - If ttl isn't specified, then expiration of the message defaults - * back to the expiry value for the key. */ actual fun fire( channel: String, message: Any, meta: Any?, usePost: Boolean, + ): Publish + + /** + * Send a message to PubNub Functions Event Handlers. + * + * These messages will go directly to any Event Handlers registered on the channel that you fire to + * and will trigger their execution. The content of the fired request will be available for processing + * within the Event Handler. + * + * The message sent via `fire()` isn't replicated, and so won't be received by any subscribers to the channel. + * The message is also not stored in history. + * + * + * @param message The payload. + * **Warning:** It is important to note that you should not serialize JSON + * when sending signals/messages via PubNub. + * Why? Because the serialization is done for you automatically. + * Instead just pass the full object as the message payload. + * PubNub takes care of everything for you. + * @param channel Destination of the message. + * @param meta Metadata object which can be used with the filtering ability. + * If not specified, then the history configuration of the key is used. + * @param usePost Use HTTP POST to publish. Default is `false` + */ + @Deprecated( + "`fire()` never used the `ttl` parameter, please use the version without `ttl`.", + replaceWith = ReplaceWith("fire(channel, message, meta, usePost)") + ) + fun fire( + channel: String, + message: Any, + meta: Any?, + usePost: Boolean, ttl: Int?, ): Publish diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/HistoryIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/HistoryIntegrationTest.kt index 792075ff2..8439ce8be 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/HistoryIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/HistoryIntegrationTest.kt @@ -176,7 +176,7 @@ class HistoryIntegrationTest : BaseIntegrationTest() { expectedActionValue to listOf( PNFetchMessageItem.Action( - actionTimetoken = actionResult.actionTimetoken.toString(), + actionTimetoken = actionResult.actionTimetoken!!, uuid = pubnub.configuration.userId.value, ), ), diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt index 2030718e8..b0867fb02 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt @@ -65,8 +65,8 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { type = type, ).sync() - assertEquals(status, setResult.data?.status) - assertEquals(type, setResult.data?.type) + assertEquals(status, setResult.data?.status?.value) + assertEquals(type, setResult.data?.type?.value) val getAllResult = pubnub.getAllUUIDMetadata(filter = "id == \"$testUuid\"").sync() val getSingleResult = pubnub.getUUIDMetadata(uuid = testUuid).sync() @@ -267,12 +267,12 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { custom = expectedCustom, includeCustom = true, ).sync().apply { - assertEquals(this.data?.id, expectedUUID) - assertEquals(this.data?.name, expectedName) - assertEquals(this.data?.email, expectedEmail) - assertEquals(this.data?.externalId, expectedExternalId) - assertEquals(this.data?.profileUrl, expectedProfileUrl) - assertEquals(this.data?.custom, expectedCustom) + assertEquals(expectedUUID, this.data?.id) + assertEquals(expectedName, this.data?.name?.value) + assertEquals(expectedEmail, this.data?.email?.value) + assertEquals(expectedExternalId, this.data?.externalId?.value) + assertEquals(expectedProfileUrl, this.data?.profileUrl?.value) + assertEquals(expectedCustom, this.data?.custom?.value) } } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt index 05ce4e890..9203fbad7 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt @@ -283,24 +283,29 @@ class PubNubImpl( ) } - override fun fire( - channel: String, - message: Any, - meta: Any?, - usePost: Boolean, - ttl: Int?, - ): Publish { + override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean): Publish { return com.pubnub.internal.endpoints.pubsub.PublishImpl( pubNubCore.fire( channel, message, meta, usePost, - ttl, ), ) } + @Deprecated( + "`fire()` never used the `ttl` parameter, please use the version without `ttl`.", + replaceWith = ReplaceWith("fire(channel, message, meta, usePost)") + ) + override fun fire( + channel: String, + message: Any, + meta: Any?, + usePost: Boolean, + ttl: Int?, + ): Publish = fire(channel, message, meta, usePost) + override fun signal( channel: String, message: Any, diff --git a/pubnub-kotlin/pubnub-kotlin-test/config/ktlint/baseline.xml b/pubnub-kotlin/pubnub-kotlin-test/config/ktlint/baseline.xml index 73faa4cf8..981420778 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/config/ktlint/baseline.xml +++ b/pubnub-kotlin/pubnub-kotlin-test/config/ktlint/baseline.xml @@ -1,10 +1,3 @@ - - - - - - - From 6919320c4d98edc7335d65edff9e0b11a75c2123 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Thu, 8 Aug 2024 17:31:33 +0000 Subject: [PATCH 51/62] Partial updates for membership information (#267) --- .../consumer/objects/member/PNMember.kt | 7 ++-- .../objects/membership/PNChannelMembership.kt | 5 ++- .../objects/uuid/PNUUIDMetadataResult.kt | 2 +- .../pubsub/objects/PNObjectEventResult.kt | 5 ++- .../contract/membership/step/WhenSteps.kt | 24 ++++++------ .../objects_api/member/PNMembers.java | 4 +- .../objects_api/membership/PNMembership.java | 4 +- .../v2/callbacks/DelegatingEventListener.java | 4 +- .../callbacks/DelegatingEventListenerTest.kt | 2 +- .../consumer/objects/member/PNMember.kt | 18 +++++++-- .../objects/membership/PNChannelMembership.kt | 30 +++++++++++++- .../objects/uuid/PNUUIDMetadataResult.kt | 2 +- .../pubsub/objects/PNObjectEventResult.kt | 5 ++- .../membership/PNChannelMembershipTest.kt | 39 +++++++++++++++++++ .../pubnub/test/integration/MembersTest.kt | 10 ++--- .../test/integration/MembershipsTest.kt | 10 ++--- .../com/pubnub/test/integration/PushTest.kt | 12 ++++++ .../api/integration/ObjectsIntegrationTest.kt | 9 +++-- 18 files changed, 143 insertions(+), 49 deletions(-) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt index a6c889284..049e31a09 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt @@ -1,13 +1,14 @@ package com.pubnub.internal.models.consumer.objects.member import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.utils.PatchValue data class PNMember( - val uuid: PNUUIDMetadata?, - val custom: Map? = null, + val uuid: PNUUIDMetadata, + val custom: PatchValue?>? = null, val updated: String, val eTag: String, - val status: String?, + val status: PatchValue? = null, ) { data class Partial( val uuidId: String, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt index fd72a11d5..ea3e52fc1 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt @@ -1,13 +1,14 @@ package com.pubnub.internal.models.consumer.objects.membership import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.utils.PatchValue data class PNChannelMembership( val channel: PNChannelMetadata, - val custom: Map?, + val custom: PatchValue?>? = null, val updated: String, val eTag: String, - val status: String?, + val status: PatchValue? = null, ) { data class Partial( val channelId: String, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt index 6f837e122..d743391e2 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt @@ -4,5 +4,5 @@ import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata data class PNUUIDMetadataResult( val status: Int, - val data: PNUUIDMetadata?, + val data: PNUUIDMetadata, ) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt index 398c848fa..860a9d5cc 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt +++ b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt @@ -7,6 +7,7 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.pubsub.BasePubSubResult import com.pubnub.api.models.consumer.pubsub.PubSubResult +import com.pubnub.api.utils.PatchValue import com.pubnub.internal.utils.PolymorphicDeserializer import com.pubnub.internal.utils.UnwrapSingleField @@ -95,10 +96,10 @@ data class PNSetMembershipEvent( val channel: String, @JsonAdapter(UnwrapSingleField::class) val uuid: String, - val custom: Map?, + val custom: PatchValue?>?, val eTag: String, val updated: String, - val status: String?, + val status: PatchValue?, ) data class PNDeleteMembershipEvent( diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt index 21bb8e4c3..b9056a3a4 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt +++ b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt @@ -43,9 +43,9 @@ class WhenSteps( val channels = membershipState.memberships.map { PNChannelMembership.Partial( - channelId = it.channel!!.id, - custom = it.custom, - status = it.status, + channelId = it.channel.id, + custom = it.custom?.value, + status = it.status?.value, ) } @@ -63,9 +63,9 @@ class WhenSteps( val channels = membershipState.memberships.map { PNChannelMembership.Partial( - channelId = it.channel!!.id, - custom = it.custom, - status = it.status, + channelId = it.channel.id, + custom = it.custom?.value, + status = it.status?.value, ) } @@ -79,7 +79,7 @@ class WhenSteps( @When("I remove the membership") fun i_remove_the_membership() { - val channels = membershipState.memberships.map { it.channel!!.id } + val channels = membershipState.memberships.map { it.channel.id } world.pubnub.pubNubCore.removeMemberships( uuid = membershipState.uuid(), channels = channels, @@ -91,7 +91,7 @@ class WhenSteps( @When("I remove the membership for current user") fun i_remove_the_membership_for_current_user() { - val channels = membershipState.memberships.map { it.channel!!.id } + val channels = membershipState.memberships.map { it.channel.id } world.pubnub.pubNubCore.removeMemberships( channels = channels, ).sync().let { @@ -105,12 +105,12 @@ class WhenSteps( val channelsToSet = membershipState.memberships.map { PNChannelMembership.Partial( - channelId = it.channel!!.id, - custom = it.custom, - status = it.status, + channelId = it.channel.id, + custom = it.custom?.value, + status = it.status?.value, ) } - val channelsToRemove = membershipState.membershipsToRemove.map { it.channel!!.id } + val channelsToRemove = membershipState.membershipsToRemove.map { it.channel.id } world.pubnub.pubNubCore.manageMemberships( channelsToSet = channelsToSet, channelsToRemove = channelsToRemove, diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNMembers.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNMembers.java index 1504726fe..23403bb6a 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNMembers.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNMembers.java @@ -36,10 +36,10 @@ public static PNMembers from(@Nullable PNMember member) { } return new PNMembers() .setUuid(PNUUIDMetadata.from(member.getUuid())) - .setCustom(member.getCustom()) + .setCustom(member.getCustom() != null ? member.getCustom().getValue() : null) .setUpdated(member.getUpdated()) .setETag(member.getETag()) - .setStatus(member.getStatus()); + .setStatus(member.getStatus() != null ? member.getStatus().getValue() : null); } public static List from(Collection members) { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembership.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembership.java index 6d4abefc3..0427f1a57 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembership.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembership.java @@ -39,11 +39,11 @@ public static PNMembership from(@Nullable PNChannelMembership data) { } PNChannelMetadata metadata = PNChannelMetadata.from(data.getChannel()); PNMembership newData = new PNMembership(metadata); - newData.setCustom(data.getCustom()); + newData.setCustom(data.getCustom() != null ? data.getCustom().getValue() : null); // newData.setUuid(data.get) //TODO where to get this? does it even exist in server responses? newData.setUpdated(data.getUpdated()); newData.setETag(data.getETag()); - newData.setStatus(data.getStatus()); + newData.setStatus(data.getStatus() != null ? data.getStatus().getValue() : null); return newData; } } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingEventListener.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingEventListener.java index 38b707cb7..106615008 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingEventListener.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingEventListener.java @@ -164,8 +164,8 @@ static PNMembershipResult getSetMembershipResult(@NotNull PNObjectEventResult ob new PNChannelMetadata(data.getChannel(), null) ); membership.setUuid(data.getUuid()); - membership.setCustom(data.getCustom()); - membership.setStatus(data.getStatus()); + membership.setCustom(data.getCustom() != null ? data.getCustom().getValue() : null); + membership.setStatus(data.getStatus() != null ? data.getStatus().getValue() : null); membership.setUpdated(data.getUpdated()); membership.setETag(data.getETag()); return new PNMembershipResult( diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt index 49563754f..36caea8b0 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt @@ -294,7 +294,7 @@ internal class DelegatingEventListenerTest { @Test fun getSetMembershipResult() { - val metadata = PNSetMembershipEvent(channel, uuid, custom, eTag, updated, status) + val metadata = PNSetMembershipEvent(channel, uuid, PatchValue.of(custom), eTag, updated, PatchValue.of(status)) val message = PNSetMembershipEventMessage(source, version, event, type, metadata) val objectEvent = PNObjectEventResult(BasePubSubResult(channel, subscription, timetoken, userMetadata, publisher), message) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt index bbbc6cf8c..8ba1650c4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/member/PNMember.kt @@ -1,14 +1,15 @@ package com.pubnub.api.models.consumer.objects.member import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.utils.PatchValue import com.pubnub.kmp.CustomObject data class PNMember( - val uuid: PNUUIDMetadata?, - val custom: Map? = null, + val uuid: PNUUIDMetadata, + val custom: PatchValue?>? = null, val updated: String, val eTag: String, - val status: String?, + val status: PatchValue?, ) { data class Partial( val uuidId: String, @@ -17,4 +18,15 @@ data class PNMember( ) : MemberInput { override val uuid: String = uuidId } + + // let's not make this public for now, but keep the implementation around in case it's needed + private operator fun plus(update: PNMember): PNMember { + return PNMember( + uuid + update.uuid, + update.custom ?: custom, + update.updated, + update.eTag, + update.status ?: status + ) + } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt index 98284a856..c51aec9c5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembership.kt @@ -1,14 +1,16 @@ package com.pubnub.api.models.consumer.objects.membership import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent +import com.pubnub.api.utils.PatchValue import com.pubnub.kmp.CustomObject data class PNChannelMembership( val channel: PNChannelMetadata, - val custom: Map?, + val custom: PatchValue?>? = null, val updated: String, val eTag: String, - val status: String?, + val status: PatchValue? = null, ) { data class Partial( val channelId: String, @@ -17,4 +19,28 @@ data class PNChannelMembership( ) : ChannelMembershipInput { override val channel: String = channelId } + + // let's not make this public for now, but keep the implementation around in case it's needed + private operator fun plus(update: PNChannelMembership): PNChannelMembership { + return PNChannelMembership( + channel + update.channel, + update.custom ?: custom, + update.updated, + update.eTag, + update.status ?: status + ) + } + + /** + * Merge information from this `PNChannelMembership` with new data from `update`, returning a new `PNChannelMembership` instance. + */ + operator fun plus(update: PNSetMembershipEvent): PNChannelMembership { + return PNChannelMembership( + channel, + update.custom ?: custom, + update.updated, + update.eTag, + update.status ?: status + ) + } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt index 0ab32b35c..7c67daf43 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadataResult.kt @@ -2,5 +2,5 @@ package com.pubnub.api.models.consumer.objects.uuid data class PNUUIDMetadataResult( val status: Int, - val data: PNUUIDMetadata?, + val data: PNUUIDMetadata, ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt index dab9b4cc2..94b46dcb2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/PNObjectEventResult.kt @@ -4,6 +4,7 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.pubsub.BasePubSubResult import com.pubnub.api.models.consumer.pubsub.PubSubResult +import com.pubnub.api.utils.PatchValue data class PNObjectEventResult( private val result: BasePubSubResult, @@ -68,10 +69,10 @@ data class PNDeleteUUIDMetadataEventMessage( data class PNSetMembershipEvent( val channel: String, val uuid: String, - val custom: Map?, + val custom: PatchValue?>?, val eTag: String, val updated: String, - val status: String?, + val status: PatchValue?, ) data class PNDeleteMembershipEvent( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipTest.kt new file mode 100644 index 000000000..e29593098 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/api/models/consumer/objects/membership/PNChannelMembershipTest.kt @@ -0,0 +1,39 @@ +package com.pubnub.api.models.consumer.objects.membership + +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent +import com.pubnub.api.utils.PatchValue +import com.pubnub.test.randomString +import kotlin.test.Test +import kotlin.test.assertEquals + +class PNChannelMembershipTest { + @Test + fun plus() { + val originalMembership = PNChannelMembership( + PNChannelMetadata(randomString()), + custom = PatchValue.of(mapOf(randomString() to randomString())), + updated = randomString(), + eTag = randomString(), + status = null + ) + + val updateMembership = PNSetMembershipEvent( + originalMembership.channel.id, + randomString(), + custom = null, + updated = randomString(), + eTag = randomString(), + status = PatchValue.of(randomString()) + ) + val expectedMembership = originalMembership.copy( + updated = updateMembership.updated, + eTag = updateMembership.eTag, + status = updateMembership.status + ) + + val actualMembership = originalMembership + updateMembership + + assertEquals(expectedMembership, actualMembership) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembersTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembersTest.kt index 7012658c6..06f22a160 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembersTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembersTest.kt @@ -35,8 +35,8 @@ class MembersTest : BaseIntegrationTest() { ).await() // then - val pnChannelDetails = result.data.single { it.uuid?.id == pubnub.configuration.userId.value } - assertEquals(customData, pnChannelDetails.custom) + val pnChannelDetails = result.data.single { it.uuid.id == pubnub.configuration.userId.value } + assertEquals(customData, pnChannelDetails.custom?.value) } @Test @@ -50,8 +50,8 @@ class MembersTest : BaseIntegrationTest() { ).await() // then - val pnChannelDetails = result.data.single { it.uuid?.id == pubnub.configuration.userId.value } - assertEquals(status, pnChannelDetails.status) + val pnChannelDetails = result.data.single { it.uuid.id == pubnub.configuration.userId.value } + assertEquals(status, pnChannelDetails.status?.value) } @Test @@ -71,7 +71,7 @@ class MembersTest : BaseIntegrationTest() { yield() val result = pubnub.getMemberships(pubnub.configuration.userId.value, page = next).await() next = result.next - assertFalse { result.data.any { it.channel?.id == channel } } + assertFalse { result.data.any { it.channel.id == channel } } if (next == null || result.data.isEmpty()) { break } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt index 3f09676a7..f42fb4f2f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/MembershipsTest.kt @@ -36,9 +36,9 @@ class MembershipsTest : BaseIntegrationTest() { ).await() // then - val pnChannelDetails = result.data.single { it.channel?.id == channel } - assertEquals(channel, pnChannelDetails.channel?.id) - assertEquals(customData, pnChannelDetails.custom) + val pnChannelDetails = result.data.single { it.channel.id == channel } + assertEquals(channel, pnChannelDetails.channel.id) + assertEquals(customData, pnChannelDetails.custom?.value) } @Test @@ -60,7 +60,7 @@ class MembershipsTest : BaseIntegrationTest() { message as PNSetMembershipEventMessage assertEquals(channel, message.data.channel) assertEquals(pubnub.configuration.userId.value, message.data.uuid) - assertEquals(customData, message.data.custom) + assertEquals(customData, message.data.custom?.value) } } @@ -79,7 +79,7 @@ class MembershipsTest : BaseIntegrationTest() { while (true) { val result = pubnub.getChannelMembers(channel, page = next).await() next = result.next - assertFalse { result.data.any { it.uuid?.id == pubnub.configuration.userId.value } } + assertFalse { result.data.any { it.uuid.id == pubnub.configuration.userId.value } } if (next == null || result.data.isEmpty()) { break } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PushTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PushTest.kt index a9d701f4f..b0b76f133 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PushTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/test/integration/PushTest.kt @@ -94,6 +94,10 @@ class PushTest : BaseIntegrationTest() { PNPushEnvironment.PRODUCTION ).await() + withContext(Dispatchers.Default) { + delay(1000) + } + val result = pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) .await() @@ -107,6 +111,10 @@ class PushTest : BaseIntegrationTest() { PNPushEnvironment.PRODUCTION ).await() + withContext(Dispatchers.Default) { + delay(1000) + } + assertTrue { pubnub.auditPushChannelProvisions(PNPushType.APNS2, deviceId, topic, PNPushEnvironment.PRODUCTION) .await().channels.isEmpty() @@ -127,6 +135,10 @@ class PushTest : BaseIntegrationTest() { deviceId, ).await() + withContext(Dispatchers.Default) { + delay(1000) + } + assertEquals(emptyList(), pubnub.auditPushChannelProvisions(PNPushType.FCM, deviceId).await().channels) } } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt index b0867fb02..0197ce6fe 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/ObjectsIntegrationTest.kt @@ -12,6 +12,7 @@ import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.utils.PatchValue import com.pubnub.test.CommonUtils.randomValue import com.pubnub.test.subscribeToBlocking import org.hamcrest.MatcherAssert.assertThat @@ -296,7 +297,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { PNMember( uuidMetadata(id = otherTestUuid), custom = null, - status = status, + status = PatchValue.of(status), eTag = noEtag, updated = noUpdated, ) @@ -304,7 +305,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { PNMember( uuidMetadata(id = testUuid), custom = null, - status = status, + status = PatchValue.of(status), eTag = noEtag, updated = noUpdated, ) @@ -344,7 +345,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { PNChannelMembership( channelMetadata(id = channel), custom = null, - status = status, + status = PatchValue.of(status), eTag = noEtag, updated = noUpdated, ) @@ -352,7 +353,7 @@ class ObjectsIntegrationTest : BaseIntegrationTest() { PNChannelMembership( channelMetadata(id = otherChannel), custom = null, - status = status, + status = PatchValue.of(status), eTag = noEtag, updated = noUpdated, ) From 22a7566d8d2faa335c377fbc8ac5422242a1f681 Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Tue, 13 Aug 2024 18:34:00 +0200 Subject: [PATCH 52/62] Added missing implementations for iOS target (#268) --- .../kotlin/com/pubnub/api/utils/PatchValue.kt | 1 + .../kotlin/com/pubnub/api/PubNubImpl.kt | 2 +- .../objects/channel/GetChannelMetadata.ios.kt | 2 +- .../objects/channel/SetChannelMetadata.ios.kt | 2 +- .../objects/uuid/GetUUIDMetadata.ios.kt | 2 +- .../objects/uuid/SetUUIDMetadata.ios.kt | 2 +- .../kotlin/com/pubnub/kmp/converters.kt | 71 ++++++++++--------- .../kotlin/com/pubnub/kmp/factories.ios.kt | 38 +++++----- .../kotlin/com/pubnub/api/PubNub.nonJvm.kt | 3 +- .../kotlin/com.pubnub.test/FakePubNub.kt | 2 +- swift | 2 +- 11 files changed, 67 insertions(+), 60 deletions(-) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt index c60d7b801..38c7acc88 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt +++ b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt @@ -1,4 +1,5 @@ package com.pubnub.api.utils +import kotlin.jvm.JvmStatic /** * An optional that accepts nullable values. Thus, it can represent two (`PatchValue`) or three (`PatchValue?`) states: diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index aa16c8406..074b29045 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -201,7 +201,7 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { } // TODO: usePost parameter is not present in Swift SDK - override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { + override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean): Publish { return PublishImpl( pubnub = pubNubObjC, channel = channel, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt index cd80a1b52..9a07c32d4 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt @@ -29,7 +29,7 @@ class GetChannelMetadataImpl( onSuccess = callback.onSuccessHandler { PNChannelMetadataResult( status = 200, - data = it?.let { rawValue -> createPNChannelMetadata(from = rawValue) } + data = createPNChannelMetadata(it) ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt index 6177d3515..a041e47fd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt @@ -41,7 +41,7 @@ class SetChannelMetadataImpl( onSuccess = callback.onSuccessHandler { PNChannelMetadataResult( status = 200, - data = it?.let { rawValue -> createPNChannelMetadata(from = rawValue) } + data = createPNChannelMetadata(it) ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt index b32946178..b1f358303 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt @@ -29,7 +29,7 @@ class GetUUIDMetadataImpl( onSuccess = callback.onSuccessHandler { PNUUIDMetadataResult( status = 200, - data = it?.let { createPNUUIDMetadata(from = it) } + data = createPNUUIDMetadata(it) ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt index d61123679..e64a18747 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt @@ -45,7 +45,7 @@ class SetUUIDMetadataImpl( onSuccess = callback.onSuccessHandler { PNUUIDMetadataResult( status = 200, - data = it?.let { createPNUUIDMetadata(from = it) } + data = createPNUUIDMetadata(it) ) }, onFailure = callback.onFailureHandler() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt index a4b069d55..d19491906 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt @@ -12,6 +12,7 @@ import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.member.PNMember import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.utils.PatchValue import kotlinx.cinterop.ExperimentalForeignApi import platform.Foundation.NSData import platform.Foundation.NSString @@ -39,33 +40,35 @@ internal fun createPubNubHashedPage(from: PNPage?): PubNubHashedPageObjC { ) } +// TODO: PatchValue should consider cases where there is no response for a given field @OptIn(ExperimentalForeignApi::class) -internal fun createPNUUIDMetadata(from: PubNubUUIDMetadataObjC): PNUUIDMetadata { +internal fun createPNUUIDMetadata(from: PubNubUUIDMetadataObjC?): PNUUIDMetadata { return PNUUIDMetadata( - id = from.id(), - name = from.name(), - externalId = from.externalId(), - profileUrl = from.profileUrl(), - email = from.email(), - custom = from.custom()?.safeCast(), - updated = from.updated(), - eTag = from.eTag(), - type = from.type(), - status = from.status() + id = from!!.id(), + name = PatchValue.of(from.name()), + externalId = PatchValue.of(from.externalId()), + profileUrl = PatchValue.of(from.profileUrl()), + email = PatchValue.of(from.email()), + custom = PatchValue.of(from.custom()?.safeCast()), + updated = PatchValue.of(from.updated().orEmpty()), + eTag = PatchValue.of(from.eTag().orEmpty()), + type = PatchValue.of(from.type()), + status = PatchValue.of(from.status()) ) } +// TODO: PatchValue should consider cases where there is no response for a given field @OptIn(ExperimentalForeignApi::class) -internal fun createPNChannelMetadata(from: PubNubChannelMetadataObjC): PNChannelMetadata { +internal fun createPNChannelMetadata(from: PubNubChannelMetadataObjC?): PNChannelMetadata { return PNChannelMetadata( - id = from.id(), - name = from.name(), - description = from.descr(), - custom = from.custom()?.safeCast(), - updated = from.updated(), - eTag = from.eTag(), - type = from.type(), - status = from.status() + id = from!!.id(), + name = PatchValue.of(from.name()), + description = PatchValue.of(from.descr()), + custom = PatchValue.of(from.custom()?.safeCast()), + updated = PatchValue.of(from.updated().orEmpty()), + eTag = PatchValue.of(from.eTag().orEmpty()), + type = PatchValue.of(from.type()), + status = PatchValue.of(from.status()) ) } @@ -79,34 +82,36 @@ internal fun createObjectSortProperties(from: Collection>): Lis } } +// TODO: PatchValue should consider cases where there is no response for a given field @OptIn(ExperimentalForeignApi::class) internal fun createPNChannelMembership(from: PubNubMembershipMetadataObjC): PNChannelMembership { return PNChannelMembership( channel = PNChannelMetadata( id = from.channelMetadataId(), - name = from.channel()?.name(), - description = from.channel()?.descr(), - custom = from.channel()?.custom()?.safeCast(), - updated = from.channel()?.updated(), - eTag = from.channel()?.eTag(), - type = from.channel()?.type(), - status = from.channel()?.status() + name = PatchValue.of(from.channel()?.name()), + description = PatchValue.of(from.channel()?.descr()), + custom = PatchValue.of(from.channel()?.custom()?.safeCast()), + updated = PatchValue.of(from.channel()?.updated().orEmpty()), + eTag = PatchValue.of(from.channel()?.eTag().orEmpty()), + type = PatchValue.of(from.channel()?.type()), + status = PatchValue.of(from.channel()?.status()) ), - custom = from.custom()?.safeCast(), + custom = PatchValue.of(from.custom()?.safeCast()), updated = from.updated().orEmpty(), eTag = from.eTag().orEmpty(), - status = from.status() + status = PatchValue.of(from.status()) ) } +// TODO: PatchValue should consider cases where there is no response for a given field @OptIn(ExperimentalForeignApi::class) -internal fun createPNMember(from: PubNubMembershipMetadataObjC): PNMember { +internal fun createPNMember(from: PubNubMembershipMetadataObjC?): PNMember { return PNMember( - uuid = from.uuid()?.let { createPNUUIDMetadata(from = it) }, - custom = from.custom()?.safeCast(), + uuid = createPNUUIDMetadata(from = from!!.uuid()), + custom = PatchValue.of(from.custom()?.safeCast()), updated = from.updated().orEmpty(), eTag = from.eTag().orEmpty(), - status = from.status() + status = PatchValue.of(from.status()) ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 5a41efe23..10b5ae134 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -47,6 +47,7 @@ import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMe import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage import com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage +import com.pubnub.api.utils.PatchValue import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.EventListenerImpl @@ -192,6 +193,7 @@ private fun createObjectEvent(from: PubNubAppContextEventObjC?): PNObjectEventRe } } +// TODO: PatchValue should consider cases where there is no response for a given field @OptIn(ExperimentalForeignApi::class) private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventMessage? { when (from) { @@ -203,15 +205,15 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM type = from.type(), data = PNUUIDMetadata( id = from.metadata().id(), - name = from.metadata().name(), - externalId = from.metadata().externalId(), - profileUrl = from.metadata().profileUrl(), - email = from.metadata().email(), - custom = from.metadata().custom()?.safeCast(), - updated = from.metadata().updated(), - eTag = from.metadata().eTag(), - type = from.metadata().type(), - status = from.metadata().status() + name = PatchValue.of(from.metadata().name()), + externalId = PatchValue.of(from.metadata().externalId()), + profileUrl = PatchValue.of(from.metadata().profileUrl()), + email = PatchValue.of(from.metadata().email()), + custom = PatchValue.of(from.metadata().custom()?.safeCast()), + updated = PatchValue.of(from.metadata().updated().orEmpty()), + eTag = PatchValue.of(from.metadata().eTag().orEmpty()), + type = PatchValue.of(from.metadata().type()), + status = PatchValue.of(from.metadata().status()) ) ) is PubNubRemoveUUIDMetadataResultObjC -> @@ -230,13 +232,13 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM type = from.type(), data = PNChannelMetadata( id = from.metadata().id(), - name = from.metadata().name(), - description = from.metadata().descr(), - custom = from.metadata().custom()?.safeCast(), - updated = from.metadata().updated(), - eTag = from.metadata().eTag(), - type = from.metadata().type(), - status = from.metadata().status() + name = PatchValue.of(from.metadata().name()), + description = PatchValue.of(from.metadata().descr()), + custom = PatchValue.of(from.metadata().custom()?.safeCast()), + updated = PatchValue.of(from.metadata().updated().orEmpty()), + eTag = PatchValue.of(from.metadata().eTag().orEmpty()), + type = PatchValue.of(from.metadata().type()), + status = PatchValue.of(from.metadata().status()) ) ) is PubNubRemoveChannelMetadataResultObjC -> @@ -256,10 +258,10 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM data = PNSetMembershipEvent( channel = from.metadata().channelMetadataId(), uuid = from.metadata().uuidMetadataId(), - custom = from.metadata().custom()?.safeCast(), + custom = PatchValue.of(from.metadata().custom()?.safeCast()), eTag = from.metadata().eTag().orEmpty(), updated = from.metadata().updated().orEmpty(), - status = from.metadata().status().orEmpty() + status = PatchValue.of(from.metadata().status().orEmpty()) ) ) is PubNubRemoveMembershipResultObjC -> diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt index 12e29a987..f6e54ec7b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt @@ -98,8 +98,7 @@ actual interface PubNub { channel: String, message: Any, meta: Any?, - usePost: Boolean, - ttl: Int? + usePost: Boolean ): Publish actual fun signal(channel: String, message: Any): Signal diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt index 035902256..7f7831328 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt @@ -105,7 +105,7 @@ abstract class FakePubNub( TODO("Not yet implemented") } - override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean, ttl: Int?): Publish { + override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean): Publish { TODO("Not yet implemented") } diff --git a/swift b/swift index d8c940837..f1dd87e0a 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit d8c940837704e4718e729f969b568efa4348690d +Subproject commit f1dd87e0af69b2a7b7195b41f9f0077152101fa0 From d02cefba134aa45de6d7781cda9c1b18d3822548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Thu, 5 Sep 2024 12:08:17 +0000 Subject: [PATCH 53/62] Version bumps, test fixture fix (#273) --- gradle.properties | 2 +- gradle/libs.versions.toml | 6 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../kotlin/com.pubnub.test/BaseIntegrationTest.kt | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index ad479b3ff..bda640c82 100644 --- a/gradle.properties +++ b/gradle.properties @@ -43,4 +43,4 @@ SWIFT_PATH=swift ENABLE_TARGET_JS=false ENABLE_TARGET_IOS=false -ENABLE_TARGET_IOS_SIMULATOR=false \ No newline at end of file +ENABLE_TARGET_IOS_SIMULATOR=true \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 976f1a759..d8a865f51 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,12 +4,12 @@ cucumber = "6.10.4" logback = "1.2.11" okhttp = "4.12.0" retrofit2 = "2.9.0" -nexus = "2.0.0-rc-2" -kotlin = "2.0.0" +nexus = "2.0.0" +kotlin = "2.0.20" vanniktech = "0.29.0" ktlint = "12.1.0" dokka = "1.9.20" -kotlinx_datetime = "0.6.0-RC.2" +kotlinx_datetime = "0.6.0" kotlinx_coroutines = "1.8.1" [libraries] diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 920d5cc69..8d1eb3e63 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Feb 26 22:01:31 CET 2024 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt index 7bfd8411b..a5a73c1bf 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/BaseIntegrationTest.kt @@ -180,6 +180,9 @@ class PubNubTest( } ) = suspendCancellableCoroutine { cont -> val statusListener = createStatusListener(pubNub) { _, pnStatus -> + if (cont.isCompleted) { + return@createStatusListener + } if (pnStatus.category == PNStatusCategory.PNDisconnectedCategory || pnStatus.category == PNStatusCategory.PNSubscriptionChanged && pnStatus.affectedChannels.containsAll(channels) && pnStatus.affectedChannelGroups.containsAll( channelGroups From 2ce7724c046a7de815c987bf760ebcb891eee77b Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Mon, 9 Sep 2024 10:45:03 +0200 Subject: [PATCH 54/62] Handling missing ReceivePresenceEvents options (#274) --- .../kotlin/com/pubnub/internal/entities/ChannelImpl.kt | 8 ++++++-- swift | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt index 6aa8b15cc..58603d55d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt @@ -7,6 +7,7 @@ import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.pubsub.Publish import com.pubnub.api.endpoints.pubsub.Signal import com.pubnub.api.v2.entities.Channel +import com.pubnub.api.v2.subscriptions.ReceivePresenceEventsImpl import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.internal.subscription.SubscriptionImpl @@ -55,8 +56,11 @@ class ChannelImpl( override val name: String get() = channel.name() + // TODO: Add support for handling SubscriptionOptions override fun subscription(options: SubscriptionOptions): Subscription { - // TODO: Add support for handling SubscriptionOptions - return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = channel)) + val presenceOptions = options.allOptions.filterIsInstance() + val objcSubscription = PubNubSubscriptionObjC(channel, presenceOptions.isNotEmpty()) + + return SubscriptionImpl(objcSubscription) } } diff --git a/swift b/swift index f1dd87e0a..6abd60bac 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit f1dd87e0af69b2a7b7195b41f9f0077152101fa0 +Subproject commit 6abd60bac31a4e693d9a91f1a78e0b49f91e78a3 From 0f119945eb9958d214db6f44fe4d97c38ee09c1b Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Tue, 10 Sep 2024 08:15:00 +0200 Subject: [PATCH 55/62] Updating Channel/UUID metadata with PatchValue (#271) --- .../kotlin/com/pubnub/kmp/factories.ios.kt | 32 +++++++++---------- swift | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 10b5ae134..9acba9bb6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -205,15 +205,15 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM type = from.type(), data = PNUUIDMetadata( id = from.metadata().id(), - name = PatchValue.of(from.metadata().name()), - externalId = PatchValue.of(from.metadata().externalId()), - profileUrl = PatchValue.of(from.metadata().profileUrl()), - email = PatchValue.of(from.metadata().email()), - custom = PatchValue.of(from.metadata().custom()?.safeCast()), - updated = PatchValue.of(from.metadata().updated().orEmpty()), - eTag = PatchValue.of(from.metadata().eTag().orEmpty()), - type = PatchValue.of(from.metadata().type()), - status = PatchValue.of(from.metadata().status()) + name = if (from.metadata().hasName()) { PatchValue.of(from.metadata().name()) } else { null }, + externalId = if (from.metadata().hasExternalId()) { PatchValue.of(from.metadata().externalId()) } else { null }, + profileUrl = if (from.metadata().hasProfileUrl()) { PatchValue.of(from.metadata().profileUrl()) } else { null }, + email = if (from.metadata().hasEmail()) { PatchValue.of(from.metadata().email()) } else { null }, + custom = if (from.metadata().hasCustom()) { PatchValue.of(from.metadata().custom()?.safeCast()) } else { null }, + updated = from.metadata().updated()?.let { PatchValue.of(it) }, + eTag = from.metadata().eTag()?.let { PatchValue.of(it) }, + type = if (from.metadata().hasType()) { PatchValue.of(from.metadata().type()) } else { null }, + status = if (from.metadata().hasStatus()) { PatchValue.of(from.metadata().status()) } else { null } ) ) is PubNubRemoveUUIDMetadataResultObjC -> @@ -232,13 +232,13 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM type = from.type(), data = PNChannelMetadata( id = from.metadata().id(), - name = PatchValue.of(from.metadata().name()), - description = PatchValue.of(from.metadata().descr()), - custom = PatchValue.of(from.metadata().custom()?.safeCast()), - updated = PatchValue.of(from.metadata().updated().orEmpty()), - eTag = PatchValue.of(from.metadata().eTag().orEmpty()), - type = PatchValue.of(from.metadata().type()), - status = PatchValue.of(from.metadata().status()) + name = if (from.metadata().hasName()) { PatchValue.of(from.metadata().name()) } else { null }, + description = if (from.metadata().hasDescr()) { PatchValue.of(from.metadata().descr()) } else { null }, + custom = if (from.metadata().hasCustom()) { PatchValue.of(from.metadata().custom()?.safeCast()) } else { null }, + updated = from.metadata().updated()?.let { PatchValue.of(it) }, + eTag = from.metadata().eTag()?.let { PatchValue.of(it) }, + type = if (from.metadata().hasType()) { PatchValue.of(from.metadata().type()) } else { null }, + status = if (from.metadata().hasStatus()) { PatchValue.of(from.metadata().status()) } else { null } ) ) is PubNubRemoveChannelMetadataResultObjC -> diff --git a/swift b/swift index 6abd60bac..07252d87d 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit 6abd60bac31a4e693d9a91f1a78e0b49f91e78a3 +Subproject commit 07252d87d1ba39a950e316a7be328ddb43e6b658 From f59b6e6fdf9299e8312705d1ae1b1bf124b8d9f5 Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Thu, 12 Sep 2024 14:22:41 +0200 Subject: [PATCH 56/62] Fixes according to swift module changes (#276) * Fixed import statements in iosMain due to names refactor (adding the KMP prefix) in the swift submodule * Made changes in the swift submodule, replacing the product name with PubNubSDK * Changed module name in PubNubKotlinMultiplatformPlugin.kt due to the point mentioned above --- .gitmodules | 2 +- .../gradle/PubNubKotlinMultiplatformPlugin.kt | 2 +- .../kotlin/com/pubnub/api/JsonElement.ios.kt | 20 +-- .../kotlin/com/pubnub/api/PubNubImpl.kt | 18 +- .../api/endpoints/DeleteMessages.ios.kt | 4 +- .../pubnub/api/endpoints/FetchMessages.ios.kt | 16 +- .../pubnub/api/endpoints/MessageCounts.ios.kt | 4 +- .../com/pubnub/api/endpoints/Time.ios.kt | 4 +- .../AddChannelChannelGroup.ios.kt | 4 +- .../AllChannelsChannelGroup.ios.kt | 4 +- .../channel_groups/DeleteChannelGroup.ios.kt | 4 +- .../channel_groups/ListAllChannelGroup.ios.kt | 4 +- .../RemoveChannelChannelGroup.ios.kt | 4 +- .../api/endpoints/files/DeleteFile.ios.kt | 4 +- .../api/endpoints/files/DownloadFile.ios.kt | 4 +- .../api/endpoints/files/GetFileUrl.ios.kt | 4 +- .../api/endpoints/files/ListFiles.ios.kt | 8 +- .../endpoints/files/PublishFileMessage.ios.kt | 4 +- .../api/endpoints/files/SendFile.ios.kt | 20 +-- .../message_actions/AddMessageAction.ios.kt | 4 +- .../message_actions/GetMessageActions.ios.kt | 14 +- .../RemoveMessageAction.ios.kt | 4 +- .../channel/GetAllChannelMetadata.ios.kt | 8 +- .../objects/channel/GetChannelMetadata.ios.kt | 4 +- .../channel/RemoveChannelMetadata.ios.kt | 4 +- .../objects/channel/SetChannelMetadata.ios.kt | 8 +- .../objects/member/GetChannelMembers.ios.kt | 8 +- .../member/ManageChannelMembers.ios.kt | 18 +- .../objects/membership/GetMemberships.ios.kt | 8 +- .../membership/ManageMemberships.ios.kt | 18 +- .../objects/uuid/GetAllUUIDMetadata.ios.kt | 8 +- .../objects/uuid/GetUUIDMetadata.ios.kt | 4 +- .../objects/uuid/RemoveUUIDMetadata.ios.kt | 4 +- .../objects/uuid/SetUUIDMetadata.ios.kt | 8 +- .../api/endpoints/presence/GetState.ios.kt | 4 +- .../api/endpoints/presence/HereNow.ios.kt | 12 +- .../api/endpoints/presence/SetState.ios.kt | 8 +- .../api/endpoints/presence/WhereNow.ios.kt | 4 +- .../api/endpoints/pubsub/Publish.ios.kt | 4 +- .../pubnub/api/endpoints/pubsub/Signal.ios.kt | 4 +- .../endpoints/push/AddChannelsToPush.ios.kt | 4 +- .../endpoints/push/ListPushProvisions.ios.kt | 4 +- .../RemoveAllPushChannelsForDevice.ios.kt | 4 +- .../push/RemoveChannelsFromPush.ios.kt | 4 +- .../api/v2/callbacks/EventListener.ios.kt | 6 +- .../api/v2/callbacks/StatusListener.ios.kt | 6 +- .../internal/entities/ChannelGroupImpl.kt | 8 +- .../pubnub/internal/entities/ChannelImpl.kt | 8 +- .../internal/entities/ChannelMetadataImpl.kt | 8 +- .../internal/entities/UserMetadataImpl.kt | 8 +- .../internal/subscription/SubscriptionImpl.kt | 4 +- .../subscription/SubscriptionSetImpl.kt | 4 +- .../kotlin/com/pubnub/kmp/converters.kt | 26 +-- .../kotlin/com/pubnub/kmp/factories.ios.kt | 160 ++++++++++++------ .../kotlin/com/pubnub/kmp/results.ios.kt | 4 +- swift | 2 +- 56 files changed, 300 insertions(+), 252 deletions(-) diff --git a/.gitmodules b/.gitmodules index 0d0f41a47..572d75e98 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "swift"] path = swift url = https://github.com/pubnub/swift - branch = feat/kmp + branch = feat/kmp2 diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt index 714017814..9d075c685 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt @@ -111,7 +111,7 @@ class PubNubKotlinMultiplatformPlugin : Plugin { // } // version = "7.1.0" source = path(rootProject.file(swiftPath)) - moduleName = "PubNub" + moduleName = "PubNubSDK" extraOpts += listOf("-compiler-option", "-fmodules") } } diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt index c4695a845..c3f5b3237 100644 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt +++ b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt @@ -2,7 +2,7 @@ package com.pubnub.api -import cocoapods.PubNubSwift.AnyJSONObjC +import cocoapods.PubNubSwift.KMPAnyJSON import kotlinx.cinterop.ExperimentalForeignApi actual abstract class JsonElement(val value: Any?) { @@ -43,7 +43,7 @@ class JsonElementImpl(value: Any?) : JsonElement(value) actual fun JsonElement.asString(): String? { return when (value) { - is AnyJSONObjC -> value.asString() + is KMPAnyJSON -> value.asString() is String -> value else -> null } @@ -51,7 +51,7 @@ actual fun JsonElement.asString(): String? { actual fun JsonElement.asMap(): Map? { return when (value) { - is AnyJSONObjC -> (value.asMap() as? Map)?.mapValues { + is KMPAnyJSON -> (value.asMap() as? Map)?.mapValues { JsonElementImpl(it.value) } is Map<*, *> -> (value as Map)?.mapValues { JsonElementImpl(it.value) } @@ -60,12 +60,12 @@ actual fun JsonElement.asMap(): Map? { } actual fun JsonElement.isNull(): Boolean { - return value == null || (value as? AnyJSONObjC)?.isNull() == true + return value == null || (value as? KMPAnyJSON)?.isNull() == true } actual fun JsonElement.asList(): List? { return when (value) { - is AnyJSONObjC -> value.asList()?.map { + is KMPAnyJSON -> value.asList()?.map { JsonElementImpl(it) } is List<*> -> value.map { JsonElementImpl(it) } @@ -75,7 +75,7 @@ actual fun JsonElement.asList(): List? { actual fun JsonElement.asLong(): Long? { return when (value) { - is AnyJSONObjC -> value.asInt()?.longValue + is KMPAnyJSON -> value.asInt()?.longValue is Long -> value is Int -> value.toLong() is Boolean -> if (value) { @@ -89,7 +89,7 @@ actual fun JsonElement.asLong(): Long? { actual fun JsonElement.asBoolean(): Boolean? { return when (value) { - is AnyJSONObjC -> value.asBool()?.boolValue + is KMPAnyJSON -> value.asBool()?.boolValue is Boolean -> value else -> null } @@ -97,7 +97,7 @@ actual fun JsonElement.asBoolean(): Boolean? { actual fun JsonElement.asDouble(): Double? { return when (value) { - is AnyJSONObjC -> value.asDouble()?.doubleValue + is KMPAnyJSON -> value.asDouble()?.doubleValue is Number -> value.toDouble() is Boolean -> if (value) { 1.0 @@ -110,7 +110,7 @@ actual fun JsonElement.asDouble(): Double? { actual fun JsonElement.asNumber(): Number? { return when (value) { - is AnyJSONObjC -> value.asNumber() as? Number + is KMPAnyJSON -> value.asNumber() as? Number is Number -> value is Boolean -> if (value) { 1 @@ -122,5 +122,5 @@ actual fun JsonElement.asNumber(): Number? { } actual fun createJsonElement(any: Any?): JsonElement { - return JsonElementImpl(AnyJSONObjC(any)) + return JsonElementImpl(KMPAnyJSON(any)) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 074b29045..a6e9d6bac 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -1,8 +1,8 @@ package com.pubnub.api -import cocoapods.PubNubSwift.PubNubObjC -import cocoapods.PubNubSwift.PubNubSubscriptionObjC -import cocoapods.PubNubSwift.PubNubSubscriptionSetObjC +import cocoapods.PubNubSwift.KMPPubNub +import cocoapods.PubNubSwift.KMPSubscription +import cocoapods.PubNubSwift.KMPSubscriptionSet import cocoapods.PubNubSwift.addEventListenerWithListener import cocoapods.PubNubSwift.addStatusListenerWithListener import cocoapods.PubNubSwift.channelGroupWith @@ -143,9 +143,9 @@ import com.pubnub.kmp.Uploadable import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) -class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { +class PubNubImpl(private val pubNubObjC: KMPPubNub) : PubNub { constructor(configuration: PNConfiguration) : this( - PubNubObjC( + KMPPubNub( user = configuration.userId.value, subKey = configuration.subscribeKey, pubKey = configuration.publishKey @@ -833,7 +833,7 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { override fun subscriptionSetOf(subscriptions: Set): SubscriptionSet { return SubscriptionSetImpl( - PubNubSubscriptionSetObjC(subscriptions.filterIsInstance().map { it.objCSubscription }) + KMPSubscriptionSet(subscriptions.filterIsInstance().map { it.objCSubscription }) ) } @@ -842,14 +842,14 @@ class PubNubImpl(private val pubNubObjC: PubNubObjC) : PubNub { channelGroups: Set, options: SubscriptionOptions ): SubscriptionSet { - val channelSubscriptions = channels.map { pubNubObjC.channelWith(it) }.map { entity -> PubNubSubscriptionObjC(entity) } + val channelSubscriptions = channels.map { pubNubObjC.channelWith(it) }.map { entity -> KMPSubscription(entity) } val channelGroupSubscriptions = channelGroups.map { pubNubObjC.channelGroupWith(it) }.map { entity -> - PubNubSubscriptionObjC(entity) + KMPSubscription(entity) } return SubscriptionSetImpl( - PubNubSubscriptionSetObjC(channelGroupSubscriptions + channelSubscriptions) + KMPSubscriptionSet(channelGroupSubscriptions + channelSubscriptions) ) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt index b39d52e6b..34efb2685 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/DeleteMessages.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.deleteMessagesFrom import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult import com.pubnub.api.v2.callbacks.Consumer @@ -18,7 +18,7 @@ actual interface DeleteMessages : PNFuture @OptIn(ExperimentalForeignApi::class) class DeleteMessagesImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channels: List, private val start: Long?, private val end: Long? diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt index 8117733fb..eed1f07d6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/FetchMessages.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints -import cocoapods.PubNubSwift.PubNubBoundedPageObjC -import cocoapods.PubNubSwift.PubNubMessageActionObjC -import cocoapods.PubNubSwift.PubNubMessageObjC -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPBoundedPage +import cocoapods.PubNubSwift.KMPMessage +import cocoapods.PubNubSwift.KMPMessageAction +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.fetchMessagesFrom import com.pubnub.api.JsonElementImpl import com.pubnub.api.models.consumer.PNBoundedPage @@ -26,7 +26,7 @@ actual interface FetchMessages : PNFuture @OptIn(ExperimentalForeignApi::class) open class FetchMessagesImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channels: List, private val page: PNBoundedPage, private val includeUUID: Boolean, @@ -41,7 +41,7 @@ open class FetchMessagesImpl( includeMeta = includeMeta, includeMessageActions = includeMessageActions, includeMessageType = includeMessageType, - page = PubNubBoundedPageObjC( + page = KMPBoundedPage( start = page.start?.let { NSNumber(long = it) }, end = page.end?.let { NSNumber(long = it) }, limit = page.limit?.let { NSNumber(int = it) } @@ -61,7 +61,7 @@ open class FetchMessagesImpl( } private fun mapMessages(rawValue: Map?): Map> { - return (rawValue?.safeCast>())?.mapValues { entry -> + return (rawValue?.safeCast>())?.mapValues { entry -> entry.value.map { PNFetchMessageItem( uuid = it.publisher(), @@ -77,7 +77,7 @@ open class FetchMessagesImpl( } private fun mapMessageActions(rawValue: List<*>): Map>>? { - return rawValue.filterIsInstance().groupBy { messageAction -> + return rawValue.filterIsInstance().groupBy { messageAction -> messageAction.actionType() }.mapValues { entry -> entry.value.groupBy { groupedMessageAction -> diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt index 551634f11..d51397563 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/MessageCounts.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.messageCountsFor import com.pubnub.api.models.consumer.history.PNMessageCountResult import com.pubnub.api.v2.callbacks.Consumer @@ -18,7 +18,7 @@ actual interface MessageCounts : PNFuture @OptIn(ExperimentalForeignApi::class) class MessageCountsImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channels: List, private val channelsTimetoken: List ) : MessageCounts { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt index c0d053d80..a59411b43 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/Time.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.timeOnSuccess import com.pubnub.api.models.consumer.PNTimeResult import com.pubnub.api.v2.callbacks.Consumer @@ -17,7 +17,7 @@ actual interface Time : PNFuture @OptIn(ExperimentalForeignApi::class) class TimeImpl( - private val pubnub: PubNubObjC + private val pubnub: KMPPubNub ) : Time { override fun async(callback: Consumer>) { pubnub.timeOnSuccess( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt index 6a2498a67..469f86ae8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.channel_groups -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.addChannelsTo import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult import com.pubnub.api.v2.callbacks.Consumer @@ -17,7 +17,7 @@ actual interface AddChannelChannelGroup : PNFuture, private val channelGroup: String ) : AddChannelChannelGroup { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt index 38ec8d7eb..0f12d7937 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.channel_groups -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.listChannelsFor import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult import com.pubnub.api.v2.callbacks.Consumer @@ -17,7 +17,7 @@ actual interface AllChannelsChannelGroup : PNFuture>) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt index da9f2b4f6..1e1989868 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.channel_groups -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.deleteWithChannelGroup import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult import com.pubnub.api.v2.callbacks.Consumer @@ -17,7 +17,7 @@ actual interface DeleteChannelGroup : PNFuture @OptIn(ExperimentalForeignApi::class) class DeleteChannelGroupImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channelGroup: String ) : DeleteChannelGroup { override fun async(callback: Consumer>) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt index 2b3b466f7..8451ccf1c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.channel_groups -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.listChannelGroupsOnSuccess import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult import com.pubnub.api.v2.callbacks.Consumer @@ -17,7 +17,7 @@ actual interface ListAllChannelGroup : PNFuture @OptIn(ExperimentalForeignApi::class) class ListAllChannelGroupImpl( - private val pubnub: PubNubObjC + private val pubnub: KMPPubNub ) : ListAllChannelGroup { override fun async(callback: Consumer>) { pubnub.listChannelGroupsOnSuccess( diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt index c5fcec488..8cf48e4f1 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.channel_groups -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.removeWithChannels import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult import com.pubnub.api.v2.callbacks.Consumer @@ -17,7 +17,7 @@ actual interface RemoveChannelChannelGroup : PNFuture, private val channelGroup: String ) : RemoveChannelChannelGroup { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt index 61e764ae1..e5f7ba38d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DeleteFile.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.files -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.deleteFileWithChannel import com.pubnub.api.models.consumer.files.PNDeleteFileResult import com.pubnub.api.v2.callbacks.Consumer @@ -17,7 +17,7 @@ actual interface DeleteFile : PNFuture @OptIn(ExperimentalForeignApi::class) class DeleteFileImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val fileName: String, private val fileId: String diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt index 9068eb1aa..69a0fac6b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/DownloadFile.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.files -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.downloadFileWithChannel import com.pubnub.api.models.consumer.files.PNDownloadFileResult import com.pubnub.api.v2.callbacks.Consumer @@ -19,7 +19,7 @@ actual interface DownloadFile : PNFuture @OptIn(ExperimentalForeignApi::class) class DownloadFileImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val fileName: String, private val fileId: String diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt index 0d56362d5..c0b56740b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/GetFileUrl.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.files -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.getFileUrlWithChannel import com.pubnub.api.models.consumer.files.PNFileUrlResult import com.pubnub.api.v2.callbacks.Consumer @@ -17,7 +17,7 @@ actual interface GetFileUrl : PNFuture @OptIn(ExperimentalForeignApi::class) class GetFileUrlImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val fileName: String, private val fileId: String diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt index b15e8aab1..9787cda56 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/ListFiles.ios.kt @@ -1,7 +1,7 @@ package com.pubnub.api.endpoints.files -import cocoapods.PubNubSwift.PubNubFileObjC -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPFile +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.listFilesWithChannel import com.pubnub.api.models.consumer.files.PNListFilesResult import com.pubnub.api.models.consumer.files.PNUploadedFile @@ -23,7 +23,7 @@ actual interface ListFiles : PNFuture @OptIn(ExperimentalForeignApi::class) class ListFilesImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val limit: Int?, private val next: PNPage.PNNext? @@ -38,7 +38,7 @@ class ListFilesImpl( count = files?.size ?: 0, // TODO: count property is not retrieved from ListFilesSuccessResponse in Swift SDK next = nextPageHash?.let { PNPage.PNNext(pageHash = it) }, status = 200, - data = files.filterAndMap { rawValue: PubNubFileObjC -> + data = files.filterAndMap { rawValue: KMPFile -> PNUploadedFile( id = rawValue.id(), name = rawValue.name(), diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt index c43045f68..4109c3cb9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/PublishFileMessage.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.files -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.publishFileMessageWithChannel import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult import com.pubnub.api.v2.callbacks.Consumer @@ -18,7 +18,7 @@ actual interface PublishFileMessage : PNFuture @OptIn(ExperimentalForeignApi::class) class PublishFileMessageImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val fileName: String, private val fileId: String, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt index aab596498..bc944a013 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/files/SendFile.ios.kt @@ -1,10 +1,10 @@ package com.pubnub.api.endpoints.files -import cocoapods.PubNubSwift.PubNubDataContentObjC -import cocoapods.PubNubSwift.PubNubFileContentObjC -import cocoapods.PubNubSwift.PubNubInputStreamContentObjC -import cocoapods.PubNubSwift.PubNubObjC -import cocoapods.PubNubSwift.PubNubUploadableObjC +import cocoapods.PubNubSwift.KMPDataUploadContent +import cocoapods.PubNubSwift.KMPFileUploadContent +import cocoapods.PubNubSwift.KMPInputStreamUploadContent +import cocoapods.PubNubSwift.KMPPubNub +import cocoapods.PubNubSwift.KMPUploadable import cocoapods.PubNubSwift.sendFileWithChannel import com.pubnub.api.PubNubException import com.pubnub.api.models.consumer.files.PNBaseFile @@ -28,7 +28,7 @@ actual interface SendFile : PNFuture @OptIn(ExperimentalForeignApi::class) class SendFileImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val fileName: String, private val inputStream: Uploadable, @@ -62,16 +62,16 @@ class SendFileImpl( } ?: callback.accept(Result.failure(PubNubException("Invalid argument $inputStream"))) } - private fun mapContent(content: Uploadable): PubNubUploadableObjC? { + private fun mapContent(content: Uploadable): KMPUploadable? { return when (content) { - is DataUploadContent -> return PubNubDataContentObjC( + is DataUploadContent -> return KMPDataUploadContent( data = content.data, contentType = content.contentType ) - is FileUploadContent -> PubNubFileContentObjC( + is FileUploadContent -> KMPFileUploadContent( fileURL = content.url ) - is StreamUploadContent -> PubNubInputStreamContentObjC( + is StreamUploadContent -> KMPInputStreamUploadContent( stream = content.stream, contentType = content.contentType, contentLength = content.contentLength.toLong() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt index 5705704c3..4370c4986 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/AddMessageAction.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.message_actions -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.addMessageActionWithChannel import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction @@ -18,7 +18,7 @@ actual interface AddMessageAction : PNFuture @OptIn(ExperimentalForeignApi::class) class AddMessageActionImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val actionType: String, private val actionValue: String, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt index a14395785..eae16ab41 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/GetMessageActions.ios.kt @@ -1,8 +1,8 @@ package com.pubnub.api.endpoints.message_actions -import cocoapods.PubNubSwift.PubNubBoundedPageObjC -import cocoapods.PubNubSwift.PubNubMessageActionObjC -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPBoundedPage +import cocoapods.PubNubSwift.KMPMessageAction +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.getMessageActionsFrom import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult @@ -24,20 +24,20 @@ actual interface GetMessageActions : PNFuture @OptIn(ExperimentalForeignApi::class) class GetMessageActionsImpl( private val channel: String, - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val page: PNBoundedPage ) : GetMessageActions { override fun async(callback: Consumer>) { pubnub.getMessageActionsFrom( channel = channel, - page = PubNubBoundedPageObjC( + page = KMPBoundedPage( start = page.start?.let { NSNumber(long = it) }, end = page.end?.let { NSNumber(long = it) }, limit = page.limit?.let { NSNumber(it) } ), onSuccess = callback.onSuccessHandler2 { messageActions, next -> PNGetMessageActionsResult( - actions = messageActions.filterAndMap { rawValue: PubNubMessageActionObjC -> createMessageAction(rawValue) }.toList(), + actions = messageActions.filterAndMap { rawValue: KMPMessageAction -> createMessageAction(rawValue) }.toList(), page = PNBoundedPage( start = next?.start()?.longValue(), end = next?.end()?.longValue(), @@ -49,7 +49,7 @@ class GetMessageActionsImpl( ) } - private fun createMessageAction(rawValue: PubNubMessageActionObjC): PNMessageAction { + private fun createMessageAction(rawValue: KMPMessageAction): PNMessageAction { return PNMessageAction( type = rawValue.actionType(), value = rawValue.actionValue(), diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt index 0dd0bf2d9..d494913d9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.message_actions -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.removeMessageActionWithChannel import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult import com.pubnub.api.v2.callbacks.Consumer @@ -17,7 +17,7 @@ actual interface RemoveMessageAction : PNFuture @OptIn(ExperimentalForeignApi::class) class RemoveMessageActionImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val messageTimetoken: Long, private val actionTimetoken: Long diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt index 7eba8e5b4..7355472f0 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetAllChannelMetadata.ios.kt @@ -1,7 +1,7 @@ package com.pubnub.api.endpoints.objects.channel -import cocoapods.PubNubSwift.PubNubChannelMetadataObjC -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPChannelMetadata +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.getAllChannelMetadataWithLimit import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNPage @@ -26,7 +26,7 @@ actual interface GetAllChannelMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class GetAllChannelMetadataImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val limit: Int?, private val page: PNPage?, private val filter: String?, @@ -45,7 +45,7 @@ class GetAllChannelMetadataImpl( onSuccess = callback.onSuccessHandler3 { channels, totalCount, page -> PNChannelMetadataArrayResult( status = 200, - data = channels.filterAndMap { rawValue: PubNubChannelMetadataObjC -> createPNChannelMetadata(rawValue) }, + data = channels.filterAndMap { rawValue: KMPChannelMetadata -> createPNChannelMetadata(rawValue) }, totalCount = totalCount?.intValue, next = page?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, prev = page?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt index 9a07c32d4..643dd1d5c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/GetChannelMetadata.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.objects.channel -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.getChannelMetadataWithChannel import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult import com.pubnub.api.v2.callbacks.Consumer @@ -18,7 +18,7 @@ actual interface GetChannelMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class GetChannelMetadataImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val includeCustom: Boolean ) : GetChannelMetadata { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt index 9900edc9b..d2dd66ede 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/RemoveChannelMetadata.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.objects.channel -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.removeChannelMetadataWithChannel import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult import com.pubnub.api.v2.callbacks.Consumer @@ -14,7 +14,7 @@ actual interface RemoveChannelMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class RemoveChannelMetadataImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String ) : RemoveChannelMetadata { override fun async(callback: Consumer>) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt index a041e47fd..bb05dac20 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/channel/SetChannelMetadata.ios.kt @@ -1,7 +1,7 @@ package com.pubnub.api.endpoints.objects.channel -import cocoapods.PubNubSwift.AnyJSONObjC -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPAnyJSON +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.setChannelMetadataWithChannel import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult import com.pubnub.api.v2.callbacks.Consumer @@ -20,7 +20,7 @@ actual interface SetChannelMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class SetChannelMetadataImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val name: String?, private val description: String?, @@ -34,7 +34,7 @@ class SetChannelMetadataImpl( channel = channel, name = name, description = description, - custom = AnyJSONObjC(value = custom?.value), + custom = KMPAnyJSON(value = custom?.value), includeCustom = includeCustom, type = type, status = status, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt index 1907de479..9436dd491 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/GetChannelMembers.ios.kt @@ -1,7 +1,7 @@ package com.pubnub.api.endpoints.objects.member -import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPMembershipMetadata +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.getChannelMembersWithChannel import com.pubnub.api.models.consumer.objects.PNMemberKey import com.pubnub.api.models.consumer.objects.PNPage @@ -26,7 +26,7 @@ actual interface GetChannelMembers : PNFuture @OptIn(ExperimentalForeignApi::class) class GetChannelMembersImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val limit: Int?, private val page: PNPage?, @@ -52,7 +52,7 @@ class GetChannelMembersImpl( onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNMemberArrayResult( status = 200, - data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNMember(rawValue) }, + data = memberships.filterAndMap { rawValue: KMPMembershipMetadata -> createPNMember(rawValue) }, totalCount = totalCount?.intValue, next = page?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, prev = page?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt index 378bbdcbd..164ac142f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/member/ManageChannelMembers.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.member -import cocoapods.PubNubSwift.AnyJSONObjC -import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC -import cocoapods.PubNubSwift.PubNubObjC -import cocoapods.PubNubSwift.PubNubUUIDMetadataObjC +import cocoapods.PubNubSwift.KMPAnyJSON +import cocoapods.PubNubSwift.KMPMembershipMetadata +import cocoapods.PubNubSwift.KMPPubNub +import cocoapods.PubNubSwift.KMPUUIDMetadata import cocoapods.PubNubSwift.removeChannelMembersWithChannel import cocoapods.PubNubSwift.setChannelMembersWithChannel import com.pubnub.api.models.consumer.objects.PNMemberKey @@ -30,7 +30,7 @@ actual interface ManageChannelMembers : PNFuture @OptIn(ExperimentalForeignApi::class) class SetChannelMembersImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val uuids: List, private val limit: Int?, @@ -45,7 +45,7 @@ class SetChannelMembersImpl( override fun async(callback: Consumer>) { pubnub.setChannelMembersWithChannel( channel = channel, - uuids = uuids.map { PubNubUUIDMetadataObjC(id = it.uuid, custom = AnyJSONObjC(it.custom?.value), status = it.status) }, + uuids = uuids.map { KMPUUIDMetadata(id = it.uuid, custom = KMPAnyJSON(it.custom?.value), status = it.status) }, limit = limit?.let { NSNumber(it) }, page = createPubNubHashedPage(from = page), filter = filter, @@ -58,7 +58,7 @@ class SetChannelMembersImpl( onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNMemberArrayResult( status = 200, - data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNMember(rawValue) }, + data = memberships.filterAndMap { rawValue: KMPMembershipMetadata -> createPNMember(rawValue) }, totalCount = totalCount?.intValue, next = page?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, prev = page?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } @@ -71,7 +71,7 @@ class SetChannelMembersImpl( @OptIn(ExperimentalForeignApi::class) class RemoveChannelMembersImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val uuids: List, private val limit: Int?, @@ -99,7 +99,7 @@ class RemoveChannelMembersImpl( onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> PNMemberArrayResult( status = 200, - data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNMember(rawValue) }, + data = memberships.filterAndMap { rawValue: KMPMembershipMetadata -> createPNMember(rawValue) }, totalCount = totalCount?.intValue, next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt index 79193ed56..b15cc3e46 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/GetMemberships.ios.kt @@ -1,7 +1,7 @@ package com.pubnub.api.endpoints.objects.membership -import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPMembershipMetadata +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.getMembershipsWithUuid import com.pubnub.api.models.consumer.objects.PNMembershipKey import com.pubnub.api.models.consumer.objects.PNPage @@ -26,7 +26,7 @@ actual interface GetMemberships : PNFuture @OptIn(ExperimentalForeignApi::class) class GetMembershipsImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val uuid: String?, private val limit: Int?, private val page: PNPage?, @@ -52,7 +52,7 @@ class GetMembershipsImpl( onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNChannelMembershipArrayResult( status = 200, - data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNChannelMembership(rawValue) }, + data = memberships.filterAndMap { rawValue: KMPMembershipMetadata -> createPNChannelMembership(rawValue) }, totalCount = totalCount?.intValue, next = page?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, prev = page?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt index 48c426235..d78f81aa2 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/membership/ManageMemberships.ios.kt @@ -1,9 +1,9 @@ package com.pubnub.api.endpoints.objects.membership -import cocoapods.PubNubSwift.AnyJSONObjC -import cocoapods.PubNubSwift.PubNubChannelMetadataObjC -import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPAnyJSON +import cocoapods.PubNubSwift.KMPChannelMetadata +import cocoapods.PubNubSwift.KMPMembershipMetadata +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.removeMembershipsWithChannels import cocoapods.PubNubSwift.setMembershipsWithChannels import com.pubnub.api.models.consumer.objects.PNMembershipKey @@ -30,7 +30,7 @@ actual interface ManageMemberships : PNFuture @OptIn(ExperimentalForeignApi::class) class AddMembershipsImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channels: List, private val uuid: String?, private val limit: Int?, @@ -44,7 +44,7 @@ class AddMembershipsImpl( ) : ManageMemberships { override fun async(callback: Consumer>) { pubnub.setMembershipsWithChannels( - channels = channels.map { PubNubChannelMetadataObjC(it.channel, AnyJSONObjC(it.custom?.value), it.status) }, + channels = channels.map { KMPChannelMetadata(it.channel, KMPAnyJSON(it.custom?.value), it.status) }, uuid = uuid, limit = limit?.let { NSNumber(it) }, page = createPubNubHashedPage(from = page), @@ -58,7 +58,7 @@ class AddMembershipsImpl( onSuccess = callback.onSuccessHandler3 { memberships, totalCount, page -> PNChannelMembershipArrayResult( status = 200, - data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNChannelMembership(rawValue) }, + data = memberships.filterAndMap { rawValue: KMPMembershipMetadata -> createPNChannelMembership(rawValue) }, totalCount = totalCount?.intValue, next = page?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, prev = page?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } @@ -71,7 +71,7 @@ class AddMembershipsImpl( @OptIn(ExperimentalForeignApi::class) class RemoveMembershipsImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channels: List, private val uuid: String?, private val limit: Int?, @@ -99,7 +99,7 @@ class RemoveMembershipsImpl( onSuccess = callback.onSuccessHandler3 { memberships, totalCount, next -> PNChannelMembershipArrayResult( status = 200, - data = memberships.filterAndMap { rawValue: PubNubMembershipMetadataObjC -> createPNChannelMembership(rawValue) }, + data = memberships.filterAndMap { rawValue: KMPMembershipMetadata -> createPNChannelMembership(rawValue) }, totalCount = totalCount?.intValue, next = next?.end()?.let { hash -> PNPage.PNNext(pageHash = hash) }, prev = next?.start()?.let { hash -> PNPage.PNPrev(pageHash = hash) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt index 59205a483..11738872e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetAllUUIDMetadata.ios.kt @@ -1,7 +1,7 @@ package com.pubnub.api.endpoints.objects.uuid -import cocoapods.PubNubSwift.PubNubObjC -import cocoapods.PubNubSwift.PubNubUUIDMetadataObjC +import cocoapods.PubNubSwift.KMPPubNub +import cocoapods.PubNubSwift.KMPUUIDMetadata import cocoapods.PubNubSwift.getAllUUIDMetadataWithLimit import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNPage @@ -26,7 +26,7 @@ actual interface GetAllUUIDMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class GetAllUUIDMetadataImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val limit: Int?, private val page: PNPage?, private val filter: String?, @@ -45,7 +45,7 @@ class GetAllUUIDMetadataImpl( onSuccess = callback.onSuccessHandler3 { uuids, totalCount, next -> PNUUIDMetadataArrayResult( status = 200, - data = uuids.filterAndMap { rawValue: PubNubUUIDMetadataObjC -> createPNUUIDMetadata(from = rawValue) }, + data = uuids.filterAndMap { rawValue: KMPUUIDMetadata -> createPNUUIDMetadata(from = rawValue) }, totalCount = totalCount?.intValue ?: 0, next = next?.start()?.let { hash -> PNPage.PNNext(pageHash = hash) }, prev = next?.end()?.let { hash -> PNPage.PNPrev(pageHash = hash) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt index b1f358303..839ddff90 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/GetUUIDMetadata.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.objects.uuid -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.getUUIDMetadataWithUuid import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.api.v2.callbacks.Consumer @@ -18,7 +18,7 @@ actual interface GetUUIDMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class GetUUIDMetadataImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val uuid: String?, private val includeCustom: Boolean ) : GetUUIDMetadata { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt index 606c03108..86e871e83 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/RemoveUUIDMetadata.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.objects.uuid -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.removeUUIDMetadataWithUuid import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult import com.pubnub.api.v2.callbacks.Consumer @@ -14,7 +14,7 @@ actual interface RemoveUUIDMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class RemoveUUIDMetadataImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val uuid: String? ) : RemoveUUIDMetadata { override fun async(callback: Consumer>) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt index e64a18747..9ebe4849d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/objects/uuid/SetUUIDMetadata.ios.kt @@ -1,7 +1,7 @@ package com.pubnub.api.endpoints.objects.uuid -import cocoapods.PubNubSwift.AnyJSONObjC -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPAnyJSON +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.setUUIDMetadataWithUuid import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.api.v2.callbacks.Consumer @@ -20,7 +20,7 @@ actual interface SetUUIDMetadata : PNFuture @OptIn(ExperimentalForeignApi::class) class SetUUIDMetadataImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val uuid: String?, private val name: String?, private val externalId: String?, @@ -38,7 +38,7 @@ class SetUUIDMetadataImpl( externalId = externalId, profileUrl = profileUrl, email = email, - custom = AnyJSONObjC(value = custom?.value), + custom = KMPAnyJSON(value = custom?.value), includeCustom = includeCustom, type = type, status = status, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt index b15846ffd..06fb582bd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/GetState.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.presence -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.getPresenceStateWithChannels import com.pubnub.api.models.consumer.presence.PNGetStateResult import com.pubnub.api.v2.callbacks.Consumer @@ -18,7 +18,7 @@ actual interface GetState : PNFuture @OptIn(ExperimentalForeignApi::class) class GetStateImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channels: List, private val channelGroups: List, private val uuid: String diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt index eece52b2e..e1043b2a3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/HereNow.ios.kt @@ -1,8 +1,8 @@ package com.pubnub.api.endpoints.presence -import cocoapods.PubNubSwift.PubNubHereNowChannelDataObjC -import cocoapods.PubNubSwift.PubNubHereNowOccupantDataObjC -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPHereNowChannelData +import cocoapods.PubNubSwift.KMPHereNowOccupantData +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.hereNowWithChannels import com.pubnub.api.JsonElementImpl import com.pubnub.api.models.consumer.presence.PNHereNowChannelData @@ -23,7 +23,7 @@ actual interface HereNow : PNFuture @OptIn(ExperimentalForeignApi::class) class HereNowImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channels: List, private val channelGroups: List, private val includeState: Boolean, @@ -39,11 +39,11 @@ class HereNowImpl( PNHereNowResult( totalChannels = it?.totalChannels()?.toInt() ?: 0, totalOccupancy = it?.totalOccupancy()?.toInt() ?: 0, - channels = (it?.channels()?.safeCast())?.mapValues { entry -> + channels = (it?.channels()?.safeCast())?.mapValues { entry -> PNHereNowChannelData( channelName = entry.value.channelName(), occupancy = entry.value.occupancy().toInt(), - occupants = (entry.value.occupants().filterIsInstance()).map { occupant -> + occupants = (entry.value.occupants().filterIsInstance()).map { occupant -> PNHereNowOccupantData( uuid = occupant.uuid(), state = JsonElementImpl(occupant.state()) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt index caada0cf9..1bbca2a4e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/SetState.ios.kt @@ -1,7 +1,7 @@ package com.pubnub.api.endpoints.presence -import cocoapods.PubNubSwift.AnyJSONObjC -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPAnyJSON +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.setPresenceStateWithChannels import com.pubnub.api.JsonElementImpl import com.pubnub.api.models.consumer.presence.PNSetStateResult @@ -19,7 +19,7 @@ actual interface SetState : PNFuture @OptIn(ExperimentalForeignApi::class) class SetStateImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channels: List, private val channelGroups: List, private val state: Any, @@ -28,7 +28,7 @@ class SetStateImpl( pubnub.setPresenceStateWithChannels( channels = channels, channelGroups = channelGroups, - state = AnyJSONObjC(value = state), + state = KMPAnyJSON(value = state), onSuccess = callback.onSuccessHandler { PNSetStateResult(state = JsonElementImpl(it)) }, onFailure = callback.onFailureHandler() ) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt index a567c636b..43dfc89e5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/presence/WhereNow.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.presence -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.whereNowWithUuid import com.pubnub.api.models.consumer.presence.PNWhereNowResult import com.pubnub.api.v2.callbacks.Consumer @@ -17,7 +17,7 @@ actual interface WhereNow : PNFuture @OptIn(ExperimentalForeignApi::class) class WhereNowImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val uuid: String ) : WhereNow { override fun async(callback: Consumer>) { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt index 9730d7b68..468d91acd 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Publish.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.pubsub -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.publishWithChannel import com.pubnub.api.models.consumer.PNPublishResult import com.pubnub.api.v2.callbacks.Consumer @@ -18,7 +18,7 @@ actual interface Publish : PNFuture @OptIn(ExperimentalForeignApi::class) class PublishImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val message: Any, private val meta: Any?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt index 5ee9883ea..43784bb9d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/pubsub/Signal.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.pubsub -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.signalWithChannel import com.pubnub.api.models.consumer.PNPublishResult import com.pubnub.api.v2.callbacks.Consumer @@ -17,7 +17,7 @@ actual interface Signal : PNFuture @OptIn(ExperimentalForeignApi::class) class SignalImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channel: String, private val message: Any ) : Signal { diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt index 520e31309..11d9fd059 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.push -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.addChannelsToPushNotificationsWithChannels import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushEnvironment @@ -23,7 +23,7 @@ actual interface AddChannelsToPush : PNFuture @OptIn(ExperimentalForeignApi::class) class AddChannelsToPushImpl( private val pushType: PNPushType, - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channels: List, private val deviceId: String, private val topic: String?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt index effb89c53..ed9eb3ce8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.push -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.listPushChannelsWithDeviceId import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushEnvironment @@ -22,7 +22,7 @@ actual interface ListPushProvisions : PNFuture @OptIn(ExperimentalForeignApi::class) class ListPushProvisionsImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val deviceId: String, private val pushType: PNPushType, private val topic: String?, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt index 89c42fdae..646918755 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.endpoints.push -import cocoapods.PubNubSwift.PubNubObjC +import cocoapods.PubNubSwift.KMPPubNub import cocoapods.PubNubSwift.removeAllChannelsFromPushWithPushType import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNPushEnvironment @@ -22,7 +22,7 @@ actual interface RemoveAllPushChannelsForDevice : PNFuture @OptIn(ExperimentalForeignApi::class) class RemoveChannelsFromPushImpl( - private val pubnub: PubNubObjC, + private val pubnub: KMPPubNub, private val channels: List, private val deviceId: String, private val pushType: PNPushType, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt index fd0965f19..a77aeb352 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.v2.callbacks -import cocoapods.PubNubSwift.PubNubEventListenerObjC +import cocoapods.PubNubSwift.KMPEventListener import com.pubnub.api.PubNub import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult @@ -17,7 +17,7 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) actual interface EventListener : BaseEventListener { - val underlying: PubNubEventListenerObjC + val underlying: KMPEventListener val onMessage: (PubNub, PNMessageResult) -> Unit val onPresence: (PubNub, PNPresenceEventResult) -> Unit val onSignal: (PubNub, PNSignalResult) -> Unit @@ -28,7 +28,7 @@ actual interface EventListener : BaseEventListener { @OptIn(ExperimentalForeignApi::class) class EventListenerImpl( - override val underlying: PubNubEventListenerObjC, + override val underlying: KMPEventListener, override val onMessage: (PubNub, PNMessageResult) -> Unit, override val onPresence: (PubNub, PNPresenceEventResult) -> Unit, override val onSignal: (PubNub, PNSignalResult) -> Unit, diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt index 9723f6e24..24f44e92e 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.api.v2.callbacks -import cocoapods.PubNubSwift.PubNubStatusListenerObjC +import cocoapods.PubNubSwift.KMPStatusListener import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.PNStatus @@ -12,12 +12,12 @@ import kotlinx.cinterop.ExperimentalForeignApi */ @OptIn(ExperimentalForeignApi::class) actual interface StatusListener : Listener { - val underlying: PubNubStatusListenerObjC + val underlying: KMPStatusListener val onStatusChange: (PubNub, PNStatus) -> Unit } @OptIn(ExperimentalForeignApi::class) class StatusListenerImpl( - override val underlying: PubNubStatusListenerObjC, + override val underlying: KMPStatusListener, override val onStatusChange: (PubNub, PNStatus) -> Unit ) : StatusListener diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt index c97695055..9b0ebc575 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelGroupImpl.kt @@ -1,7 +1,7 @@ package com.pubnub.internal.entities -import cocoapods.PubNubSwift.PubNubChannelGroupEntityObjC -import cocoapods.PubNubSwift.PubNubSubscriptionObjC +import cocoapods.PubNubSwift.KMPChannelGroupEntity +import cocoapods.PubNubSwift.KMPSubscription import com.pubnub.api.v2.entities.ChannelGroup import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions @@ -10,13 +10,13 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) class ChannelGroupImpl( - private val channelGroup: PubNubChannelGroupEntityObjC + private val channelGroup: KMPChannelGroupEntity ) : ChannelGroup { override val name: String get() = channelGroup.name() override fun subscription(options: SubscriptionOptions): Subscription { // TODO: Add support for handling SubscriptionOptions - return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = channelGroup)) + return SubscriptionImpl(objCSubscription = KMPSubscription(entity = channelGroup)) } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt index 58603d55d..59fe410f5 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelImpl.kt @@ -1,7 +1,7 @@ package com.pubnub.internal.entities -import cocoapods.PubNubSwift.PubNubChannelEntityObjC -import cocoapods.PubNubSwift.PubNubSubscriptionObjC +import cocoapods.PubNubSwift.KMPChannelEntity +import cocoapods.PubNubSwift.KMPSubscription import com.pubnub.api.endpoints.files.DeleteFile import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.pubsub.Publish @@ -16,7 +16,7 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) class ChannelImpl( - private val channel: PubNubChannelEntityObjC + private val channel: KMPChannelEntity ) : Channel { override fun publish( message: Any, @@ -59,7 +59,7 @@ class ChannelImpl( // TODO: Add support for handling SubscriptionOptions override fun subscription(options: SubscriptionOptions): Subscription { val presenceOptions = options.allOptions.filterIsInstance() - val objcSubscription = PubNubSubscriptionObjC(channel, presenceOptions.isNotEmpty()) + val objcSubscription = KMPSubscription(channel, presenceOptions.isNotEmpty()) return SubscriptionImpl(objcSubscription) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt index 0ea026c27..2cb1b01d9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/ChannelMetadataImpl.kt @@ -1,7 +1,7 @@ package com.pubnub.internal.entities -import cocoapods.PubNubSwift.PubNubChannelMetadataEntityObjC -import cocoapods.PubNubSwift.PubNubSubscriptionObjC +import cocoapods.PubNubSwift.KMPChannelMetadataEntity +import cocoapods.PubNubSwift.KMPSubscription import com.pubnub.api.v2.entities.ChannelMetadata import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions @@ -10,13 +10,13 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) class ChannelMetadataImpl( - private val channelMetadata: PubNubChannelMetadataEntityObjC + private val channelMetadata: KMPChannelMetadataEntity ) : ChannelMetadata { override val id: String get() = channelMetadata.name() override fun subscription(options: SubscriptionOptions): Subscription { // TODO: Add support for handling SubscriptionOptions - return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = channelMetadata)) + return SubscriptionImpl(objCSubscription = KMPSubscription(entity = channelMetadata)) } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt index 429c39398..b680b2f52 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/entities/UserMetadataImpl.kt @@ -1,7 +1,7 @@ package com.pubnub.internal.entities -import cocoapods.PubNubSwift.PubNubSubscriptionObjC -import cocoapods.PubNubSwift.PubNubUserMetadataEntityObjC +import cocoapods.PubNubSwift.KMPSubscription +import cocoapods.PubNubSwift.KMPUserMetadataEntity import com.pubnub.api.v2.entities.UserMetadata import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions @@ -10,13 +10,13 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) class UserMetadataImpl( - private val userMetadata: PubNubUserMetadataEntityObjC + private val userMetadata: KMPUserMetadataEntity ) : UserMetadata { override val id: String get() = userMetadata.name() override fun subscription(options: SubscriptionOptions): Subscription { // TODO: Add support for handling SubscriptionOptions - return SubscriptionImpl(objCSubscription = PubNubSubscriptionObjC(entity = userMetadata)) + return SubscriptionImpl(objCSubscription = KMPSubscription(entity = userMetadata)) } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt index 740524607..ee0d43194 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionImpl.kt @@ -1,6 +1,6 @@ package com.pubnub.internal.subscription -import cocoapods.PubNubSwift.PubNubSubscriptionObjC +import cocoapods.PubNubSwift.KMPSubscription import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult @@ -16,7 +16,7 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) class SubscriptionImpl( - val objCSubscription: PubNubSubscriptionObjC + val objCSubscription: KMPSubscription ) : Subscription { override fun close() { objCSubscription.dispose() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt index deeeda5d7..341eab207 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/internal/subscription/SubscriptionSetImpl.kt @@ -1,6 +1,6 @@ package com.pubnub.internal.subscription -import cocoapods.PubNubSwift.PubNubSubscriptionSetObjC +import cocoapods.PubNubSwift.KMPSubscriptionSet import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult @@ -16,7 +16,7 @@ import kotlinx.cinterop.ExperimentalForeignApi @OptIn(ExperimentalForeignApi::class) class SubscriptionSetImpl( - private val objCSubscriptionSet: PubNubSubscriptionSetObjC + private val objCSubscriptionSet: KMPSubscriptionSet ) : SubscriptionSet { override fun close() { objCSubscriptionSet.dispose() diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt index d19491906..c4ac69228 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/converters.kt @@ -1,10 +1,10 @@ package com.pubnub.kmp -import cocoapods.PubNubSwift.PubNubChannelMetadataObjC -import cocoapods.PubNubSwift.PubNubHashedPageObjC -import cocoapods.PubNubSwift.PubNubMembershipMetadataObjC -import cocoapods.PubNubSwift.PubNubObjectSortPropertyObjC -import cocoapods.PubNubSwift.PubNubUUIDMetadataObjC +import cocoapods.PubNubSwift.KMPChannelMetadata +import cocoapods.PubNubSwift.KMPHashedPage +import cocoapods.PubNubSwift.KMPMembershipMetadata +import cocoapods.PubNubSwift.KMPObjectSortProperty +import cocoapods.PubNubSwift.KMPUUIDMetadata import com.pubnub.api.models.consumer.objects.PNKey import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.PNSortKey @@ -24,8 +24,8 @@ internal fun String.toNSData(): NSData? { } @OptIn(ExperimentalForeignApi::class) -internal fun createPubNubHashedPage(from: PNPage?): PubNubHashedPageObjC { - return PubNubHashedPageObjC( +internal fun createPubNubHashedPage(from: PNPage?): KMPHashedPage { + return KMPHashedPage( start = if (from is PNPage.PNNext) { from.pageHash } else { @@ -42,7 +42,7 @@ internal fun createPubNubHashedPage(from: PNPage?): PubNubHashedPageObjC { // TODO: PatchValue should consider cases where there is no response for a given field @OptIn(ExperimentalForeignApi::class) -internal fun createPNUUIDMetadata(from: PubNubUUIDMetadataObjC?): PNUUIDMetadata { +internal fun createPNUUIDMetadata(from: KMPUUIDMetadata?): PNUUIDMetadata { return PNUUIDMetadata( id = from!!.id(), name = PatchValue.of(from.name()), @@ -59,7 +59,7 @@ internal fun createPNUUIDMetadata(from: PubNubUUIDMetadataObjC?): PNUUIDMetadata // TODO: PatchValue should consider cases where there is no response for a given field @OptIn(ExperimentalForeignApi::class) -internal fun createPNChannelMetadata(from: PubNubChannelMetadataObjC?): PNChannelMetadata { +internal fun createPNChannelMetadata(from: KMPChannelMetadata?): PNChannelMetadata { return PNChannelMetadata( id = from!!.id(), name = PatchValue.of(from.name()), @@ -73,9 +73,9 @@ internal fun createPNChannelMetadata(from: PubNubChannelMetadataObjC?): PNChanne } @OptIn(ExperimentalForeignApi::class) -internal fun createObjectSortProperties(from: Collection>): List { +internal fun createObjectSortProperties(from: Collection>): List { return from.map { - PubNubObjectSortPropertyObjC( + KMPObjectSortProperty( key = it.key.fieldName, direction = it.dir ) @@ -84,7 +84,7 @@ internal fun createObjectSortProperties(from: Collection>): Lis // TODO: PatchValue should consider cases where there is no response for a given field @OptIn(ExperimentalForeignApi::class) -internal fun createPNChannelMembership(from: PubNubMembershipMetadataObjC): PNChannelMembership { +internal fun createPNChannelMembership(from: KMPMembershipMetadata): PNChannelMembership { return PNChannelMembership( channel = PNChannelMetadata( id = from.channelMetadataId(), @@ -105,7 +105,7 @@ internal fun createPNChannelMembership(from: PubNubMembershipMetadataObjC): PNCh // TODO: PatchValue should consider cases where there is no response for a given field @OptIn(ExperimentalForeignApi::class) -internal fun createPNMember(from: PubNubMembershipMetadataObjC?): PNMember { +internal fun createPNMember(from: KMPMembershipMetadata?): PNMember { return PNMember( uuid = createPNUUIDMetadata(from = from!!.uuid()), custom = PatchValue.of(from.custom()?.safeCast()), diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt index 9acba9bb6..e6605c6c6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/factories.ios.kt @@ -1,26 +1,26 @@ package com.pubnub.kmp -import cocoapods.PubNubSwift.PubNubAppContextEventObjC -import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCConnected -import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCConnectionError -import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCDisconnected -import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCDisconnectedUnexpectedly -import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCHeartbeatFailed -import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCHeartbeatSuccess -import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCMalformedResponseCategory -import cocoapods.PubNubSwift.PubNubConnectionStatusCategoryObjCSubscriptionChanged -import cocoapods.PubNubSwift.PubNubEventListenerObjC -import cocoapods.PubNubSwift.PubNubFileChangeEventObjC -import cocoapods.PubNubSwift.PubNubMessageActionObjC -import cocoapods.PubNubSwift.PubNubMessageObjC -import cocoapods.PubNubSwift.PubNubPresenceChangeObjC -import cocoapods.PubNubSwift.PubNubRemoveChannelMetadataResultObjC -import cocoapods.PubNubSwift.PubNubRemoveMembershipResultObjC -import cocoapods.PubNubSwift.PubNubRemoveUUIDMetadataResultObjC -import cocoapods.PubNubSwift.PubNubSetChannelMetadataResultObjC -import cocoapods.PubNubSwift.PubNubSetMembershipResultObjC -import cocoapods.PubNubSwift.PubNubSetUUIDMetadataResultObjC -import cocoapods.PubNubSwift.PubNubStatusListenerObjC +import cocoapods.PubNubSwift.KMPAppContextEventResult +import cocoapods.PubNubSwift.KMPConnectionStatusCategoryConnected +import cocoapods.PubNubSwift.KMPConnectionStatusCategoryConnectionError +import cocoapods.PubNubSwift.KMPConnectionStatusCategoryDisconnected +import cocoapods.PubNubSwift.KMPConnectionStatusCategoryDisconnectedUnexpectedly +import cocoapods.PubNubSwift.KMPConnectionStatusCategoryHeartbeatFailed +import cocoapods.PubNubSwift.KMPConnectionStatusCategoryHeartbeatSuccess +import cocoapods.PubNubSwift.KMPConnectionStatusCategoryMalformedResponseCategory +import cocoapods.PubNubSwift.KMPConnectionStatusCategorySubscriptionChanged +import cocoapods.PubNubSwift.KMPEventListener +import cocoapods.PubNubSwift.KMPFileChangeEvent +import cocoapods.PubNubSwift.KMPMessage +import cocoapods.PubNubSwift.KMPMessageAction +import cocoapods.PubNubSwift.KMPPresenceChange +import cocoapods.PubNubSwift.KMPRemoveChannelMetadataResult +import cocoapods.PubNubSwift.KMPRemoveMembershipResult +import cocoapods.PubNubSwift.KMPRemoveUUIDMetadataResult +import cocoapods.PubNubSwift.KMPSetChannelMetadataResult +import cocoapods.PubNubSwift.KMPSetMembershipResult +import cocoapods.PubNubSwift.KMPSetUUIDMetadataResult +import cocoapods.PubNubSwift.KMPStatusListener import com.pubnub.api.JsonElementImpl import com.pubnub.api.PubNub import com.pubnub.api.PubNubException @@ -70,7 +70,7 @@ actual fun createEventListener( onFile: (PubNub, PNFileEventResult) -> Unit ): EventListener { return EventListenerImpl( - underlying = PubNubEventListenerObjC( + underlying = KMPEventListener( onMessage = { onMessage(pubnub, createMessageResult(it)) }, onPresence = { presenceEvents -> createPresenceEventResults(presenceEvents).forEach { onPresence(pubnub, it) } }, onSignal = { onSignal(pubnub, createSignalResult(it)) }, @@ -88,7 +88,7 @@ actual fun createEventListener( } @OptIn(ExperimentalForeignApi::class) -private fun createMessageResult(from: PubNubMessageObjC?): PNMessageResult { +private fun createMessageResult(from: KMPMessage?): PNMessageResult { return PNMessageResult( basePubSubResult = BasePubSubResult( channel = from!!.channel(), @@ -103,7 +103,7 @@ private fun createMessageResult(from: PubNubMessageObjC?): PNMessageResult { } @OptIn(ExperimentalForeignApi::class) -private fun createSignalResult(from: PubNubMessageObjC?): PNSignalResult { +private fun createSignalResult(from: KMPMessage?): PNSignalResult { return PNSignalResult( basePubSubResult = BasePubSubResult( channel = from!!.channel(), @@ -117,7 +117,7 @@ private fun createSignalResult(from: PubNubMessageObjC?): PNSignalResult { } @OptIn(ExperimentalForeignApi::class) -private fun createMessageActionResult(from: PubNubMessageActionObjC?): PNMessageActionResult { +private fun createMessageActionResult(from: KMPMessageAction?): PNMessageActionResult { val messageAction = PNMessageAction( type = from!!.actionType(), value = from.actionValue(), @@ -142,7 +142,7 @@ private fun createMessageActionResult(from: PubNubMessageActionObjC?): PNMessage @OptIn(ExperimentalForeignApi::class) private fun createPresenceEventResults(from: List<*>?): List { - return from.filterAndMap { rawValue: PubNubPresenceChangeObjC -> + return from.filterAndMap { rawValue: KMPPresenceChange -> PNPresenceEventResult( event = rawValue.event(), uuid = rawValue.uuid(), @@ -162,7 +162,7 @@ private fun createPresenceEventResults(from: List<*>?): List + is KMPSetUUIDMetadataResult -> return PNSetUUIDMetadataEventMessage( source = from.source(), version = from.version(), @@ -205,18 +205,46 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM type = from.type(), data = PNUUIDMetadata( id = from.metadata().id(), - name = if (from.metadata().hasName()) { PatchValue.of(from.metadata().name()) } else { null }, - externalId = if (from.metadata().hasExternalId()) { PatchValue.of(from.metadata().externalId()) } else { null }, - profileUrl = if (from.metadata().hasProfileUrl()) { PatchValue.of(from.metadata().profileUrl()) } else { null }, - email = if (from.metadata().hasEmail()) { PatchValue.of(from.metadata().email()) } else { null }, - custom = if (from.metadata().hasCustom()) { PatchValue.of(from.metadata().custom()?.safeCast()) } else { null }, + name = if (from.metadata().hasName()) { + PatchValue.of(from.metadata().name()) + } else { + null + }, + externalId = if (from.metadata().hasExternalId()) { + PatchValue.of(from.metadata().externalId()) + } else { + null + }, + profileUrl = if (from.metadata().hasProfileUrl()) { + PatchValue.of(from.metadata().profileUrl()) + } else { + null + }, + email = if (from.metadata().hasEmail()) { + PatchValue.of(from.metadata().email()) + } else { + null + }, + custom = if (from.metadata().hasCustom()) { + PatchValue.of(from.metadata().custom()?.safeCast()) + } else { + null + }, updated = from.metadata().updated()?.let { PatchValue.of(it) }, eTag = from.metadata().eTag()?.let { PatchValue.of(it) }, - type = if (from.metadata().hasType()) { PatchValue.of(from.metadata().type()) } else { null }, - status = if (from.metadata().hasStatus()) { PatchValue.of(from.metadata().status()) } else { null } + type = if (from.metadata().hasType()) { + PatchValue.of(from.metadata().type()) + } else { + null + }, + status = if (from.metadata().hasStatus()) { + PatchValue.of(from.metadata().status()) + } else { + null + } ) ) - is PubNubRemoveUUIDMetadataResultObjC -> + is KMPRemoveUUIDMetadataResult -> return PNDeleteUUIDMetadataEventMessage( source = from.source(), version = from.version(), @@ -224,7 +252,7 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM type = from.type(), uuid = from.uuid() ) - is PubNubSetChannelMetadataResultObjC -> + is KMPSetChannelMetadataResult -> return PNSetChannelMetadataEventMessage( source = from.source(), version = from.version(), @@ -232,16 +260,36 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM type = from.type(), data = PNChannelMetadata( id = from.metadata().id(), - name = if (from.metadata().hasName()) { PatchValue.of(from.metadata().name()) } else { null }, - description = if (from.metadata().hasDescr()) { PatchValue.of(from.metadata().descr()) } else { null }, - custom = if (from.metadata().hasCustom()) { PatchValue.of(from.metadata().custom()?.safeCast()) } else { null }, + name = if (from.metadata().hasName()) { + PatchValue.of(from.metadata().name()) + } else { + null + }, + description = if (from.metadata().hasDescr()) { + PatchValue.of(from.metadata().descr()) + } else { + null + }, + custom = if (from.metadata().hasCustom()) { + PatchValue.of(from.metadata().custom()?.safeCast()) + } else { + null + }, updated = from.metadata().updated()?.let { PatchValue.of(it) }, eTag = from.metadata().eTag()?.let { PatchValue.of(it) }, - type = if (from.metadata().hasType()) { PatchValue.of(from.metadata().type()) } else { null }, - status = if (from.metadata().hasStatus()) { PatchValue.of(from.metadata().status()) } else { null } + type = if (from.metadata().hasType()) { + PatchValue.of(from.metadata().type()) + } else { + null + }, + status = if (from.metadata().hasStatus()) { + PatchValue.of(from.metadata().status()) + } else { + null + } ) ) - is PubNubRemoveChannelMetadataResultObjC -> + is KMPRemoveChannelMetadataResult -> return PNDeleteChannelMetadataEventMessage( source = from.source(), version = from.version(), @@ -249,7 +297,7 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM type = from.type(), channel = from.channel() ) - is PubNubSetMembershipResultObjC -> + is KMPSetMembershipResult -> return PNSetMembershipEventMessage( source = from.source(), version = from.version(), @@ -264,7 +312,7 @@ private fun mapAppContextEvent(from: PubNubAppContextEventObjC?): PNObjectEventM status = PatchValue.of(from.metadata().status().orEmpty()) ) ) - is PubNubRemoveMembershipResultObjC -> + is KMPRemoveMembershipResult -> return PNDeleteMembershipEventMessage( source = from.source(), version = from.version(), @@ -285,23 +333,23 @@ actual fun createStatusListener( onStatus: (PubNub, PNStatus) -> Unit ): StatusListener { return StatusListenerImpl( - underlying = PubNubStatusListenerObjC(onStatusChange = { status -> + underlying = KMPStatusListener(onStatusChange = { status -> when (status?.category()) { - PubNubConnectionStatusCategoryObjCConnected -> + KMPConnectionStatusCategoryConnected -> PNStatusCategory.PNConnectedCategory - PubNubConnectionStatusCategoryObjCDisconnected -> + KMPConnectionStatusCategoryDisconnected -> PNStatusCategory.PNDisconnectedCategory - PubNubConnectionStatusCategoryObjCDisconnectedUnexpectedly -> + KMPConnectionStatusCategoryDisconnectedUnexpectedly -> PNStatusCategory.PNUnexpectedDisconnectCategory - PubNubConnectionStatusCategoryObjCConnectionError -> + KMPConnectionStatusCategoryConnectionError -> PNStatusCategory.PNConnectionError - PubNubConnectionStatusCategoryObjCMalformedResponseCategory -> + KMPConnectionStatusCategoryMalformedResponseCategory -> PNStatusCategory.PNMalformedResponseCategory - PubNubConnectionStatusCategoryObjCHeartbeatFailed -> + KMPConnectionStatusCategoryHeartbeatFailed -> PNStatusCategory.PNHeartbeatFailed - PubNubConnectionStatusCategoryObjCHeartbeatSuccess -> + KMPConnectionStatusCategoryHeartbeatSuccess -> PNStatusCategory.PNHeartbeatSuccess - PubNubConnectionStatusCategoryObjCSubscriptionChanged -> + KMPConnectionStatusCategorySubscriptionChanged -> PNStatusCategory.PNSubscriptionChanged else -> null }?.let { category -> diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt index cb94f2810..6bccdf23b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/results.ios.kt @@ -1,6 +1,6 @@ package com.pubnub.kmp -import cocoapods.PubNubSwift.PubNubErrorObjC +import cocoapods.PubNubSwift.KMPError import com.pubnub.api.PubNubException import com.pubnub.api.v2.callbacks.Consumer import com.pubnub.api.v2.callbacks.Result @@ -52,7 +52,7 @@ fun Consumer>.onSuccessReturnValue(value: T): () -> Unit { @OptIn(ExperimentalForeignApi::class) fun Consumer>.onFailureHandler( mapper: (NSError?) -> Throwable = { error: NSError? -> - if (error is PubNubErrorObjC) { + if (error is KMPError) { PubNubException(error.statusCode().toInt(), error.localizedDescription, null) } else { PubNubException(errorMessage = error?.localizedDescription) diff --git a/swift b/swift index 07252d87d..73803fb25 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit 07252d87d1ba39a950e316a7be328ddb43e6b658 +Subproject commit 73803fb25f374a01a9d1350725fcf23e1fc11516 From 1c54fa45384b13c14fbfdb38eacf6f04d44526d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:57:01 +0200 Subject: [PATCH 57/62] Change dependencies so that Java SDK depends on Kotlin SDK (#269) * Use large GitHub runner (#219) build(runner): change runner groups * Disallow DTDs in XML parser (#222) * Disallow DTDs in XML parser * GCM to FCM migration in PushPayloadHelper (#227) * GCM to FCM migration in PushPayloadHelper * Mc/add integ test (#226) * v.9.2.0 release with FCMPayloadV2 * Enforce string-only values in data * Fix enum values and use deprecation instead of breaking change * PubNub SDK v9.2.0 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> * Added sorting to integ test. (#233) * Add missing auth_method to APNS2 configuration (#249) * Add missing auth_method to APNS2 configuration * PubNub SDK v9.2.1 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> * SetState via Heartbeat fix. (#251) * PubNub SDK v9.2.2 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> * Fix RetryRemoteAction double callback (#262) * Fix RetryRemoteAction double callback * PubNub SDK v9.2.3 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> * Java SDK now depends on Kotlin SDK * java.Subscription should not inherint kotlin.Subscription * Some more minor changes, migration generator * Rename PubNubForJava to PubNub * Fix crash on Android in retry logic after destroy called (#270) * Fix crash on Android in retry logic after destroy called * PubNub SDK v9.2.4 release. --------- Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> * Fix iOS build * Move checkstyle settings to plugin --------- Co-authored-by: Serhii Mamontov Co-authored-by: marcin-cebo <102806110+marcin-cebo@users.noreply.github.com> Co-authored-by: PubNub Release Bot <120067856+pubnub-release-bot@users.noreply.github.com> Co-authored-by: marcin.cebo --- .pubnub.yml | 13 +- CHANGELOG.md | 6 + README.md | 4 +- .../pubnub/gradle/PubNubJavaLibraryPlugin.kt | 23 + .../gradle/PubNubKotlinLibraryPlugin.kt | 5 +- .../gradle/PubNubKotlinMultiplatformPlugin.kt | 1 + gradle/libs.versions.toml | 3 +- migration_utils/replace_in_file.sh | 13 + migration_utils/replacements.txt | 187 ++ migration_utils/upgrade_v10.sh | 39 + pubnub-core/pubnub-core-api/build.gradle.kts | 34 - .../config/ktlint/baseline.xml | 3 - .../pubnub-core-api/pubnub_core_api.podspec | 54 - .../api/v2/callbacks/BaseEventListener.kt | 5 - .../api/v2/callbacks/BaseStatusEmitter.kt | 24 - .../api/v2/callbacks/BaseStatusListener.kt | 5 - .../com/pubnub/api/v2/entities/BaseChannel.kt | 39 - .../api/v2/entities/BaseChannelMetadata.kt | 24 - .../api/v2/entities/BaseUserMetadata.kt | 24 - .../api/v2/subscriptions/BaseSubscription.kt | 18 - .../v2/subscriptions/BaseSubscriptionSet.kt | 35 - .../PNGetMessageActionsResult.ios.kt | 8 - .../kotlin/com/pubnub/api/BasePubNub.kt | 229 -- .../api/endpoints/HasOverridableConfig.kt | 9 - .../PNGetMessageActionsResult.jvm.kt | 11 - .../com/pubnub/api/v2/BasePNConfiguration.kt | 558 ---- .../api/v2/BasePNConfigurationOverride.kt | 87 - pubnub-core/pubnub-core-impl/build.gradle.kts | 59 - .../config/ktlint/baseline.xml | 151 -- .../com/pubnub/internal/BasePubNubImpl.kt | 143 - .../com/pubnub/internal/EndpointCore.kt | 446 --- .../com/pubnub/internal/EndpointInterface.kt | 6 - .../kotlin/com/pubnub/internal/PubNubCore.kt | 2382 ----------------- .../kotlin/com/pubnub/internal/SpaceId.kt | 3 - .../pubnub/internal/SubscriptionFactory.kt | 11 - .../internal/callbacks/SubscribeCallback.kt | 6 - .../endpoints/DeleteMessagesInterface.kt | 10 - .../endpoints/FetchMessagesInterface.kt | 14 - .../internal/endpoints/HistoryInterface.kt | 14 - .../endpoints/MessageCountsInterface.kt | 9 - .../internal/endpoints/TimeInterface.kt | 6 - .../endpoints/access/GrantInterface.kt | 18 - .../endpoints/access/GrantTokenInterface.kt | 8 - .../endpoints/access/RevokeTokenInterface.kt | 5 - .../AddChannelChannelGroupInterface.kt | 9 - .../AllChannelsChannelGroupInterface.kt | 8 - .../DeleteChannelGroupInterface.kt | 8 - .../ListAllChannelGroupInterface.kt | 6 - .../RemoveChannelChannelGroupInterface.kt | 9 - .../endpoints/files/DeleteFileInterface.kt | 6 - .../endpoints/files/DownloadFileInterface.kt | 6 - .../endpoints/files/GetFileUrlInterface.kt | 6 - .../endpoints/files/ListFilesInterface.kt | 6 - .../files/PublishFileMessageInterface.kt | 6 - .../endpoints/files/SendFileInterface.kt | 6 - .../AddMessageActionInterface.kt | 10 - .../GetMessageActionsInterface.kt | 10 - .../RemoveMessageActionInterface.kt | 10 - .../channel/GetAllChannelMetadataInterface.kt | 5 - .../channel/GetChannelMetadataInterface.kt | 6 - .../channel/RemoveChannelMetadataInterface.kt | 5 - .../channel/SetChannelMetadataInterface.kt | 6 - .../member/GetChannelMembersInterface.kt | 5 - .../member/ManageChannelMembersInterface.kt | 5 - .../membership/GetMembershipsInterface.kt | 5 - .../membership/ManageMembershipsInterface.kt | 5 - .../uuid/GetAllUUIDMetadataInterface.kt | 5 - .../objects/uuid/GetUUIDMetadataInterface.kt | 7 - .../uuid/RemoveUUIDMetadataInterface.kt | 7 - .../objects/uuid/SetUUIDMetadataInterface.kt | 5 - .../endpoints/presence/GetStateInterface.kt | 10 - .../endpoints/presence/HereNowInterface.kt | 11 - .../endpoints/presence/SetStateInterface.kt | 11 - .../endpoints/presence/WhereNowInterface.kt | 7 - .../endpoints/pubsub/PublishInterface.kt | 14 - .../endpoints/pubsub/SignalInterface.kt | 9 - .../push/AddChannelsToPushInterface.kt | 14 - .../push/ListPushProvisionsInterface.kt | 13 - ...RemoveAllPushChannelsForDeviceInterface.kt | 13 - .../push/RemoveChannelsFromPushInterface.kt | 14 - .../PNAccessManagerGrantResults.kt | 63 - .../access_manager/sum/SpacePermissions.kt | 65 - .../access_manager/sum/UserPermissions.kt | 49 - .../access_manager/v3/ChannelGrant.kt | 51 - .../access_manager/v3/ChannelGroupGrant.kt | 27 - .../consumer/access_manager/v3/Grants.kt | 155 -- .../consumer/access_manager/v3/UUIDGrant.kt | 31 - .../objects/PNRemoveMetadataResult.kt | 3 - .../models/consumer/objects/PNSortKey.kt | 50 - .../models/consumer/objects/ResultSortKey.kt | 12 - .../channel/PNChannelMetadataArrayResult.kt | 23 - .../consumer/objects/member/MemberInput.kt | 7 - .../consumer/objects/member/PNMember.kt | 20 - .../objects/member/PNMemberArrayResult.kt | 11 - .../objects/member/PNUUIDDetailsLevel.kt | 6 - .../objects/member/PNUUIDWithCustom.kt | 33 - .../membership/ChannelMembershipInput.kt | 7 - .../membership/PNChannelDetailsLevel.kt | 6 - .../objects/membership/PNChannelMembership.kt | 20 - .../PNChannelMembershipArrayResult.kt | 11 - .../objects/membership/PNChannelWithCustom.kt | 33 - .../objects/uuid/PNUUIDMetadataArrayResult.kt | 12 - .../objects/uuid/PNUUIDMetadataResult.kt | 8 - .../consumer/presence/PNWhereNowResult.kt | 12 - .../internal/v2/BasePNConfigurationImpl.kt | 154 -- .../v2/callbacks/EventListenerCore.kt | 84 - .../v2/callbacks/StatusListenerCore.kt | 20 - .../v2/entities/BaseChannelGroupImpl.kt | 65 - .../internal/v2/entities/BaseChannelImpl.kt | 79 - .../v2/entities/BaseChannelMetadataImpl.kt | 52 - .../v2/entities/BaseUserMetadataImpl.kt | 52 - .../v2/subscription/BaseSubscriptionImpl.kt | 109 - .../subscription/BaseSubscriptionSetImpl.kt | 73 - .../workers/SubscribeMessageWorker.kt | 54 - .../pubnub/api/BasePNConfigurationImplTest.kt | 17 - .../kotlin/com/pubnub/internal/TestPubNub.kt | 179 -- .../BaseSubscriptionSetImplTest.kt | 146 - .../pubnub/test/TestPNConfigurationImpl.kt | 348 --- pubnub-gson/build.gradle.kts | 18 - pubnub-gson/pubnub-gson-api/build.gradle.kts | 20 +- .../java/com/pubnub/api/PNConfiguration.kt | 700 ----- .../api/callbacks/SubscribeCallback.java | 15 - .../com/pubnub/api/endpoints/Endpoint.java | 23 - .../java/com/pubnub/api/endpoints/Time.java | 6 - .../api/endpoints/access/GrantToken.java | 18 - .../channel_groups/ListAllChannelGroup.java | 7 - .../memberships/GetMemberships.java | 22 - .../objects_api/uuid/GetUUIDMetadata.java | 10 - .../objects_api/uuid/RemoveUUIDMetadata.java | 8 - .../api/endpoints/presence/WhereNow.java | 8 - .../java/com/pubnub/api/{ => java}/PubNub.kt | 276 +- .../{ => java}/PubNubRuntimeException.java | 3 +- .../com/pubnub/api/{ => java}/SpaceId.java | 2 +- .../{ => java}/builder/PresenceBuilder.java | 6 +- .../builder/PubNubErrorBuilder.java | 2 +- .../api/{ => java}/builder/PubSubBuilder.java | 8 +- .../{ => java}/builder/SubscribeBuilder.java | 6 +- .../builder/UnsubscribeBuilder.java | 6 +- .../ChangeTemporaryUnavailableOperation.java | 2 +- .../builder/dto/PresenceOperation.java | 2 +- .../builder/dto/PubSubOperation.java | 2 +- .../builder/dto/StateOperation.java | 2 +- .../dto/TimetokenAndRegionOperation.java | 2 +- .../builder/dto/UnsubscribeOperation.java | 2 +- .../api/{ => java}/callbacks/PNCallback.java | 2 +- .../api/java/callbacks/SubscribeCallback.kt | 13 + .../{ => java}/endpoints/BuilderSteps.java | 2 +- .../{ => java}/endpoints/DeleteMessages.java | 2 +- .../com/pubnub/api/java/endpoints/Endpoint.kt | 25 + .../{ => java}/endpoints/FetchMessages.java | 2 +- .../api/{ => java}/endpoints/History.java | 2 +- .../{ => java}/endpoints/MessageCounts.java | 2 +- .../{ => java}/endpoints/access/Grant.java | 6 +- .../api/java/endpoints/access/GrantToken.java | 23 + .../endpoints/access/RevokeToken.java | 4 +- .../builder/AbstractGrantTokenBuilder.java | 4 +- .../access/builder/GrantTokenBuilder.java | 16 +- .../builder/GrantTokenEntitiesBuilder.java | 8 +- .../builder/GrantTokenObjectsBuilder.java | 12 +- .../AddChannelChannelGroup.java | 4 +- .../AllChannelsChannelGroup.java | 4 +- .../channel_groups/DeleteChannelGroup.java | 4 +- .../RemoveChannelChannelGroup.java | 4 +- .../endpoints/files/DeleteFile.java | 8 +- .../endpoints/files/DownloadFile.java | 8 +- .../endpoints/files/GetFileUrl.java | 8 +- .../{ => java}/endpoints/files/ListFiles.java | 6 +- .../endpoints/files/PublishFileMessage.java | 8 +- .../{ => java}/endpoints/files/SendFile.java | 6 +- .../FilesBuilderSteps.java | 4 +- .../message_actions/AddMessageAction.java | 4 +- .../message_actions/GetMessageActions.java | 4 +- .../message_actions/RemoveMessageAction.java | 4 +- .../channel/GetAllChannelsMetadata.java | 9 +- .../channel/GetChannelMetadata.java | 8 +- .../channel/RemoveChannelMetadata.java | 8 +- .../channel/SetChannelMetadata.java | 8 +- .../members/GetChannelMembers.java | 14 +- .../members/ManageChannelMembers.java | 16 +- .../members/RemoveChannelMembers.java | 16 +- .../members/SetChannelMembers.java | 16 +- .../memberships/GetMemberships.java | 24 + .../memberships/ManageMemberships.java | 20 +- .../memberships/RemoveMemberships.java | 18 +- .../memberships/SetMemberships.java | 14 +- .../endpoints/objects_api/utils/Include.java | 2 +- .../utils/ObjectsBuilderSteps.java | 8 +- .../objects_api/utils/PNSortKey.java | 6 +- .../objects_api/uuid/GetAllUUIDMetadata.java | 9 +- .../objects_api/uuid/GetUUIDMetadata.java | 10 + .../objects_api/uuid/RemoveUUIDMetadata.java | 8 + .../objects_api/uuid/SetUUIDMetadata.java | 6 +- .../endpoints/presence/GetState.java | 4 +- .../endpoints/presence/Heartbeat.java | 4 +- .../endpoints/presence/HereNow.java | 4 +- .../{ => java}/endpoints/presence/Leave.java | 4 +- .../endpoints/presence/SetState.java | 4 +- .../api/java/endpoints/presence/WhereNow.java | 8 + .../{ => java}/endpoints/pubsub/Publish.java | 4 +- .../{ => java}/endpoints/pubsub/Signal.java | 4 +- .../endpoints/push/AddChannelsToPush.java | 4 +- .../endpoints/push/ListPushProvisions.java | 4 +- .../push/RemoveAllPushChannelsForDevice.java | 4 +- .../push/RemoveChannelsFromPush.java | 4 +- .../PNAccessManagerGrantResult.java | 10 +- .../PNAccessManagerKeyData.java | 4 +- .../PNAccessManagerKeysData.java | 2 +- .../access_manager/sum/SpacePermissions.java | 6 +- .../access_manager/sum/UserPermissions.java | 4 +- .../access_manager/v3/ChannelGrant.java | 2 +- .../access_manager/v3/ChannelGroupGrant.java | 2 +- .../access_manager/v3/PNResource.java | 2 +- .../v3/PNRevokeTokenResult.java | 2 +- .../consumer/access_manager/v3/UUIDGrant.java | 2 +- .../objects_api/EntityArrayEnvelope.java | 2 +- .../consumer/objects_api/EntityEnvelope.java | 2 +- .../models/consumer/objects_api/PNObject.java | 2 +- .../channel/PNChannelMetadata.java | 4 +- .../channel/PNChannelMetadataResult.java | 2 +- .../PNGetAllChannelsMetadataResult.java | 6 +- .../channel/PNGetChannelMetadataResult.java | 4 +- .../PNRemoveChannelMetadataResult.java | 4 +- .../channel/PNSetChannelMetadataResult.java | 4 +- .../member/PNGetChannelMembersResult.java | 6 +- .../member/PNManageChannelMembersResult.java | 6 +- .../objects_api/member/PNMembers.java | 6 +- .../member/PNRemoveChannelMembersResult.java | 6 +- .../member/PNSetChannelMembersResult.java | 6 +- .../consumer/objects_api/member/PNUUID.java | 2 +- .../membership/PNChannelMembership.java | 2 +- .../membership/PNGetMembershipsResult.java | 6 +- .../membership/PNManageMembershipResult.java | 6 +- .../objects_api/membership/PNMembership.java | 12 +- .../membership/PNMembershipResult.java | 2 +- .../membership/PNRemoveMembershipResult.java | 6 +- .../membership/PNSetMembershipResult.java | 6 +- .../uuid/PNGetAllUUIDMetadataResult.java | 6 +- .../uuid/PNGetUUIDMetadataResult.java | 4 +- .../uuid/PNRemoveUUIDMetadataResult.java | 4 +- .../uuid/PNSetUUIDMetadataResult.java | 4 +- .../objects_api/uuid/PNUUIDMetadata.java | 4 +- .../uuid/PNUUIDMetadataResult.java | 2 +- .../api/{ => java}/v2/PNConfiguration.kt | 301 ++- .../api/java/v2/callbacks/EventEmitter.kt | 243 ++ .../api/java/v2/callbacks/EventListener.kt | 46 + .../api/java/v2/callbacks/StatusEmitter.kt | 10 +- .../api/java/v2/callbacks/StatusListener.kt | 22 + .../handlers/OnChannelMetadataHandler.java | 4 +- .../v2/callbacks/handlers/OnFileHandler.java | 2 +- .../handlers/OnMembershipHandler.java | 4 +- .../handlers/OnMessageActionHandler.java | 2 +- .../callbacks/handlers/OnMessageHandler.java | 2 +- .../callbacks/handlers/OnPresenceHandler.java | 2 +- .../callbacks/handlers/OnSignalHandler.java | 2 +- .../handlers/OnUuidMetadataHandler.java | 4 +- .../v2/endpoints/pubsub/PublishBuilder.java | 4 +- .../v2/endpoints/pubsub/SignalBuilder.java | 6 + .../api/{ => java}/v2/entities/Channel.kt | 43 +- .../api/java/v2/entities/ChannelGroup.kt | 22 +- .../api/java/v2/entities/ChannelMetadata.kt | 41 + .../api/java/v2/entities/Subscribable.kt | 18 + .../api/java/v2/entities/UserMetadata.kt | 41 + .../v2/subscriptions/Subscription.kt | 13 +- .../java/v2/subscriptions/SubscriptionSet.kt | 65 + .../pubnub/api/v2/callbacks/EventEmitter.java | 223 -- .../api/v2/callbacks/EventListener.java | 45 - .../api/v2/callbacks/StatusEmitter.java | 8 - .../api/v2/callbacks/StatusListener.java | 14 - .../v2/endpoints/pubsub/SignalBuilder.java | 7 - .../pubnub/api/v2/entities/ChannelGroup.kt | 23 - .../pubnub/api/v2/entities/ChannelMetadata.kt | 23 - .../pubnub/api/v2/entities/UserMetadata.kt | 23 - .../api/v2/subscriptions/SubscriptionSet.kt | 26 - pubnub-gson/pubnub-gson-impl/build.gradle.kts | 21 +- .../config/ktlint/baseline.xml | 6 + .../integration/FilesIntegrationTests.java | 4 +- .../integration/HeartbeatIntegrationTest.java | 8 +- .../integration/HistoryIntegrationTest.java | 8 +- .../api/integration/MessageActionsTest.java | 48 +- .../integration/PAMFilesIntegrationTests.java | 4 +- .../PNConfigurationIntegrationTests.java | 6 +- .../PresenceEventsIntegrationTests.java | 148 +- .../integration/PresenceIntegrationTests.java | 6 +- .../integration/PublishIntegrationTests.java | 256 +- .../RetryConfigurationIntegrationTest.java | 12 +- .../integration/SignalIntegrationTests.java | 59 +- .../StreamFilteringIntegrationTests.java | 181 +- .../SubscribeIntegrationTests.java | 99 +- .../AbstractReconnectionProblemIT.java | 104 +- ...ectionProblemWithReconnectionPolicyIT.java | 27 +- ...ionProblemWithoutReconnectionPolicyIT.java | 26 +- .../SubscribeCallbackAdapter.java | 61 - .../integration/objects/ObjectsApiBaseIT.java | 16 +- .../objects/ObjectsApiSubscriptionIT.java | 49 +- .../objects/channel/ChannelMetadataIT.java | 10 +- .../objects/members/ChannelMembersIT.java | 16 +- .../CustomMetadataInMembersPropagationIT.java | 10 +- ...stomMetadataInMembershipPropagationIT.java | 29 +- .../objects/memberships/MembershipIT.java | 14 +- .../objects/uuid/UUIDMetadataIT.java | 8 +- .../pam/AccessManagerIntegrationTest.java | 48 +- .../pubnub/api/integration/pam/GrantIT.java | 4 +- .../api/integration/pam/GrantTokenIT.java | 12 +- .../integration/util/BaseIntegrationTest.java | 112 +- .../api/integration/util/RandomGenerator.java | 2 +- .../pubnub/api/integration/util/Utils.java | 6 +- .../java/com/pubnub/internal/PubNubImpl.java | 673 ----- .../pubnub/internal/endpoints/TimeImpl.java | 20 - .../DeleteChannelGroupImpl.java | 33 - .../ListAllChannelGroupImpl.java | 23 - .../endpoints/presence/HeartbeatImpl.java | 33 - .../endpoints/presence/LeaveImpl.java | 32 - .../endpoints/presence/WhereNowImpl.java | 28 - .../pubnub/internal/java/PubNubForJavaImpl.kt | 430 +++ .../endpoints/DelegatingEndpoint.kt | 15 +- .../endpoints/DelegatingRemoteAction.kt | 12 +- .../endpoints/DeleteMessagesImpl.java | 16 +- .../endpoints/FetchMessagesImpl.java | 15 +- .../{ => java}/endpoints/HistoryImpl.java | 14 +- .../endpoints/MessageCountsImpl.java | 16 +- .../endpoints/access/GrantImpl.java | 22 +- .../endpoints/access/GrantTokenImpl.java | 64 +- .../endpoints/access/RevokeTokenImpl.java | 18 +- .../AddChannelChannelGroupImpl.java | 18 +- .../AllChannelsChannelGroupImpl.java | 18 +- .../DeleteChannelGroupImpl.java | 33 + .../RemoveChannelChannelGroupImpl.java | 18 +- .../endpoints/files/DeleteFileImpl.java | 30 +- .../endpoints/files/DownloadFileImpl.java | 28 +- .../endpoints/files/GetFileUrlImpl.java | 28 +- .../endpoints/files/ListFilesImpl.java | 22 +- .../files/PublishFileMessageImpl.java | 28 +- .../endpoints/files/SendFileImpl.java | 26 +- .../ChannelFileNameFileIdBuilder.java | 8 +- .../message_actions/AddMessageActionImpl.java | 24 +- .../GetMessageActionsImpl.java | 16 +- .../RemoveMessageActionImpl.java | 16 +- .../channel/GetAllChannelsMetadataImpl.java | 34 +- .../channel/GetChannelMetadataImpl.java | 26 +- .../channel/RemoveChannelMetadataImpl.java | 26 +- .../channel/SetChannelMetadataImpl.java | 26 +- .../members/GetChannelMembersImpl.java | 30 +- .../members/ManageChannelMembersImpl.java | 38 +- .../members/RemoveChannelMembersImpl.java | 34 +- .../members/SetChannelMembersImpl.java | 50 +- .../memberships/GetMembershipsImpl.java | 22 +- .../memberships/ManageMembershipsImpl.java | 36 +- .../memberships/RemoveMembershipsImpl.java | 32 +- .../memberships/SetMembershipsImpl.java | 52 +- .../uuid/GetAllUUIDMetadataImpl.java | 22 +- .../objects_api/uuid/GetUUIDMetadataImpl.java | 20 +- .../uuid/RemoveUUIDMetadataImpl.java | 18 +- .../objects_api/uuid/SetUUIDMetadataImpl.java | 23 +- .../endpoints/presence/GetStateImpl.java | 16 +- .../endpoints/presence/HeartbeatImpl.java | 34 + .../endpoints/presence/HereNowImpl.java | 16 +- .../java/endpoints/presence/LeaveImpl.java | 34 + .../endpoints/presence/SetStateImpl.java | 25 +- .../java/endpoints/presence/WhereNowImpl.java | 28 + .../endpoints/pubsub/PublishImpl.java | 20 +- .../endpoints/pubsub/SignalImpl.java | 20 +- .../endpoints/push/AddChannelsToPushImpl.java | 17 +- .../push/ListPushProvisionsImpl.java | 17 +- .../RemoveAllPushChannelsForDeviceImpl.java | 17 +- .../push/RemoveChannelsFromPushImpl.java | 17 +- .../{ => java}/v2/PNConfigurationImpl.kt | 213 +- .../v2/callbacks/Converters.java} | 128 +- .../v2/callbacks/DelegatingEventListener.kt | 52 + .../v2/callbacks/DelegatingStatusListener.kt | 14 + .../java/v2/callbacks/EventEmitterInternal.kt | 269 ++ .../java/v2/entities/ChannelGroupImpl.kt | 20 + .../internal/java/v2/entities/ChannelImpl.kt | 33 + .../java/v2/entities/ChannelMetadataImpl.kt | 20 + .../java/v2/entities/UserMetadataImpl.kt | 20 + .../java/v2/subscription/EmitterHelper.kt | 96 + .../java/v2/subscription/SubscriptionImpl.kt | 60 + .../v2/subscription/SubscriptionSetImpl.kt | 41 + .../v2/callbacks/DelegatingStatusListener.kt | 16 - .../callbacks/DelegatingSubscribeCallback.kt | 22 - .../internal/v2/entities/ChannelGroupImpl.kt | 20 - .../internal/v2/entities/ChannelImpl.kt | 36 - .../v2/entities/ChannelMetadataImpl.kt | 20 - .../internal/v2/entities/UserMetadataImpl.kt | 20 - .../internal/v2/subscription/EmitterHelper.kt | 96 - .../v2/subscription/SubscriptionImpl.kt | 112 - .../v2/subscription/SubscriptionSetImpl.kt | 92 - .../com/pubnub/api/PNConfigurationTest.kt | 211 +- .../pubnub/internal/MigrationGeneratorTest.kt | 22 + .../endpoints/DelegatingEndpointTest.kt | 96 +- .../endpoints/DelegatingRemoteActionTest.kt | 8 +- .../endpoints/DeleteMessagesImplTest.kt | 8 +- .../endpoints/FetchMessagesImplTest.kt | 8 +- .../endpoints/access/GrantTokenImplTest.kt | 27 +- .../{ => java}/v2/PNConfigurationImplTest.kt | 25 +- .../callbacks/DelegatingEventListenerTest.kt | 61 +- .../callbacks/DelegatingStatusListenerTest.kt | 16 +- .../v2/entities/ChannelGroupImplTest.kt | 14 +- .../{ => java}/v2/entities/ChannelImplTest.kt | 11 +- .../v2/subscription/SubscriptionImplTest.kt | 188 ++ .../subscription/SubscriptionSetImplTest.kt | 157 ++ .../DelegatingSubscribeCallbackTest.kt | 38 - .../v2/subscription/SubscriptionImplTest.kt | 160 -- .../subscription/SubscriptionSetImplTest.kt | 106 - pubnub-kotlin/build.gradle.kts | 2 - .../pubnub-kotlin-api/build.gradle.kts | 13 +- .../kotlin/com/pubnub/api/JsonElement.kt | 0 .../kotlin/com/pubnub/api/PubNub.kt | 2 +- .../kotlin/com/pubnub/api/PubNubError.kt | 0 .../kotlin/com/pubnub/api/PubNubException.kt | 0 .../kotlin/com/pubnub/api/UserId.kt | 0 .../com/pubnub/api/callbacks/Listener.kt | 0 .../endpoints/remoteaction/RemoteAction.kt | 0 .../enums/PNHeartbeatNotificationOptions.kt | 0 .../com/pubnub/api/enums/PNLogVerbosity.kt | 0 .../com/pubnub/api/enums/PNOperationType.kt | 0 .../com/pubnub/api/enums/PNPushEnvironment.kt | 0 .../kotlin/com/pubnub/api/enums/PNPushType.kt | 0 .../pubnub/api/enums/PNReconnectionPolicy.kt | 0 .../com/pubnub/api/enums/PNStatusCategory.kt | 0 .../com/pubnub/api/models/TokenBitmask.kt | 0 .../api/models/consumer/PNBoundedPage.kt | 0 .../api/models/consumer/PNPublishResult.kt | 0 .../pubnub/api/models/consumer/PNStatus.kt | 0 .../api/models/consumer/PNTimeResult.kt | 0 .../PNAccessManagerGrantResults.kt | 14 + .../consumer/access_manager/v3/Grants.kt | 6 +- .../access_manager/v3/PNGrantTokenResult.kt | 0 .../consumer/access_manager/v3/PNToken.kt | 0 .../channel_group/PNChannelGroupsResults.kt | 0 .../consumer/files/PNDeleteFileResult.kt | 0 .../consumer/files/PNDownloadFileResult.kt | 0 .../consumer/files/PNDownloadableFile.kt | 0 .../api/models/consumer/files/PNFile.kt | 0 .../consumer/files/PNFileUploadResult.kt | 0 .../models/consumer/files/PNFileUrlResult.kt | 0 .../consumer/files/PNListFilesResult.kt | 0 .../files/PNPublishFileMessageResult.kt | 0 .../consumer/history/HistoryMessageType.kt | 0 .../history/PNDeleteMessagesResult.kt | 0 .../models/consumer/history/PNFetchMessage.kt | 0 .../consumer/history/PNHistoryResult.kt | 0 .../consumer/history/PNMessageCountResult.kt | 0 .../PNAddMessageActionResult.kt | 0 .../PNGetMessageActionsResult.kt | 12 +- .../message_actions/PNMessageAction.kt | 0 .../PNRemoveMessageActionResult.kt | 0 .../api/models/consumer/objects/PNPage.kt | 0 .../objects/channel/PNChannelMetadata.kt | 0 .../channel/PNChannelMetadataArrayResult.kt | 0 .../channel/PNChannelMetadataResult.kt | 0 .../consumer/objects/uuid/PNUUIDMetadata.kt | 0 .../consumer/presence/PNGetStateResult.kt | 0 .../api/models/consumer/presence/PNHereNow.kt | 0 .../consumer/presence/PNSetStateResult.kt | 0 .../consumer/pubsub/BasePubSubResult.kt | 0 .../models/consumer/pubsub/MessageResult.kt | 0 .../api/models/consumer/pubsub/PNEvent.kt | 0 .../models/consumer/pubsub/PNMessageResult.kt | 0 .../consumer/pubsub/PNPresenceEventResult.kt | 0 .../models/consumer/pubsub/PNSignalResult.kt | 0 .../pubsub/files/PNFileEventResult.kt | 0 .../message_actions/PNMessageActionResult.kt | 0 .../consumer/pubsub/objects/ObjectPayload.kt | 0 .../consumer/pubsub/objects/ObjectResult.kt | 0 .../consumer/push/PNPushAddChannelResult.kt | 0 .../push/PNPushListProvisionsResult.kt | 0 .../push/PNPushRemoveAllChannelsResult.kt | 0 .../push/PNPushRemoveChannelResult.kt | 0 .../push/payload/PushPayloadHelper.kt | 0 .../push/payload/PushPayloadSerializer.kt | 0 .../pubnub/api/retry/RetryConfiguration.kt | 0 .../api/retry/RetryableEndpointGroup.kt | 0 .../kotlin/com/pubnub/api/utils/PatchValue.kt | 1 + .../com/pubnub/api/utils/SerializedName.kt | 7 + .../com/pubnub/api/v2/callbacks/Consumer.kt | 0 .../pubnub/api/v2/callbacks/EventEmitter.kt | 34 +- .../pubnub/api/v2/callbacks/EventListener.kt | 4 +- .../com/pubnub/api/v2/callbacks/Result.kt | 0 .../com/pubnub/api/v2/entities/Channel.kt | 29 +- .../pubnub/api/v2/entities/ChannelGroup.kt | 40 +- .../pubnub/api/v2/entities/ChannelMetadata.kt | 21 +- .../pubnub/api/v2/entities/Subscribable.kt | 7 +- .../pubnub/api/v2/entities/UserMetadata.kt | 21 +- .../api/v2/subscriptions/SubscribeCapable.kt | 0 .../api/v2/subscriptions/Subscription.kt | 3 +- .../v2/subscriptions/SubscriptionCursor.kt | 2 +- .../v2/subscriptions/SubscriptionOptions.kt | 0 .../api/v2/subscriptions/SubscriptionSet.kt | 28 +- .../kotlin/com/pubnub/kmp/Downloadable.kt | 0 .../kotlin/com/pubnub/kmp/PNFuture.kt | 0 .../kotlin/com/pubnub/kmp/futures.kt | 0 .../kotlin/com/pubnub/kmp/JsonElementTest.kt | 0 .../kotlin/com/pubnub/kmp/PNFutureTest.kt | 0 .../kotlin/com/pubnub/api/JsonElement.ios.kt | 0 .../com/pubnub/api/PubNubException.ios.kt | 0 .../kotlin/com/pubnub/api/PubNubImpl.kt | 2 +- .../pubnub/api/v2/callbacks/Consumer.ios.kt | 0 .../api/v2/callbacks/EventListener.ios.kt | 3 +- .../kotlin/com/pubnub/kmp/Downloadable.ios.kt | 0 .../kotlin/com/pubnub/api/JsonElement.js.kt | 0 .../com/pubnub/api/PubNubException.js.kt | 0 .../PNGetMessageActionsResult.js.kt | 0 .../pubnub/api/v2/callbacks/Consumer.js.kt | 0 .../kotlin/com/pubnub/kmp/Downloadable.js.kt | 0 .../src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt | 0 .../kotlin/com/pubnub/api/JsonElement.jvm.kt | 0 .../kotlin/com/pubnub/api/PNConfiguration.kt | 394 --- .../jvmMain/kotlin/com/pubnub/api/PubNub.kt | 296 +- .../kotlin/com/pubnub/api/PubNubException.kt | 0 .../com/pubnub/api/crypto/CryptoModule.kt | 0 .../com/pubnub/api/crypto/cryptor/Cryptor.kt | 0 .../pubnub/api/crypto/data/EncryptedData.kt | 0 .../api/crypto/data/EncryptedStreamData.kt | 0 .../api/endpoints/push/AddChannelsToPush.kt | 10 +- .../api/endpoints/push/ListPushProvisions.kt | 9 +- .../push/RemoveAllPushChannelsForDevice.kt | 9 +- .../endpoints/push/RemoveChannelsFromPush.kt | 10 +- .../remoteaction/ComposableRemoteAction.kt | 0 .../remoteaction/MappingRemoteAction.kt | 0 .../pubnub/api/utils/SerializedName.jvm.kt | 5 + .../com/pubnub/api/v2/PNConfiguration.kt | 676 ++++- .../pubnub/api/v2/callbacks/Consumer.jvm.kt | 0 .../pubnub/api/v2/callbacks/EventListener.kt | 2 +- .../pubnub/api/v2/callbacks/StatusEmitter.kt | 23 +- .../pubnub/api/v2/callbacks/StatusListener.kt | 3 +- .../endpoints/HasOverridableConfig.kt | 9 + .../kotlin/com/pubnub/kmp/Downloadable.jvm.kt | 0 .../kotlin/com/pubnub/api/PubNub.nonJvm.kt | 20 +- .../pubnub-kotlin-impl/build.gradle.kts | 51 +- .../config/ktlint/baseline.xml | 157 ++ .../com/pubnub/api/integration/AppTest.kt | 7 +- .../kotlin/com/pubnub/test/SignatureUtils.kt | 2 +- .../internal/vendor/AppEngineFactory.java | 14 +- .../com/pubnub/internal/vendor/Base64.java | 0 .../com/pubnub/internal/vendor/Crypto.java | 0 .../com/pubnub/internal/DelegatingEndpoint.kt | 35 - .../com/pubnub/internal/EndpointCore.kt | 458 ++++ .../com/pubnub/internal/EndpointImpl.kt | 19 - .../kotlin/com/pubnub/internal/PubNubImpl.kt | 1622 ++++++----- .../internal/PubNubRetryableException.kt | 0 .../kotlin/com/pubnub/internal/PubNubUtil.kt | 8 +- .../callbacks/ReconnectionCallback.kt | 0 .../internal/crypto/CryptoModuleImpl.kt | 0 .../internal/crypto/cryptor/AesCbcCryptor.kt | 0 .../internal/crypto/cryptor/CryptorHeader.kt | 0 .../crypto/cryptor/CryptorHeaderVersion.kt | 0 .../internal/crypto/cryptor/HeaderParser.kt | 0 .../crypto/cryptor/InputStreamSeparator.kt | 0 .../internal/crypto/cryptor/LegacyCryptor.kt | 0 .../endpoints/DeleteMessagesEndpoint.kt | 9 +- .../internal/endpoints/DeleteMessagesImpl.kt | 14 - .../endpoints/FetchMessagesEndpoint.kt | 9 +- .../internal/endpoints/FetchMessagesImpl.kt | 14 - .../internal/endpoints/HistoryEndpoint.kt | 9 +- .../pubnub/internal/endpoints/HistoryImpl.kt | 14 - .../endpoints/MessageCountsEndpoint.kt | 9 +- .../internal/endpoints/MessageCountsImpl.kt | 14 - .../pubnub/internal/endpoints/TimeEndpoint.kt | 9 +- .../com/pubnub/internal/endpoints/TimeImpl.kt | 14 - .../endpoints/access/GrantEndpoint.kt | 15 +- .../internal/endpoints/access/GrantImpl.kt | 54 - .../endpoints/access/GrantTokenEndpoint.kt | 15 +- .../endpoints/access/GrantTokenImpl.kt | 10 - .../endpoints/access/RevokeTokenEndpoint.kt | 9 +- .../endpoints/access/RevokeTokenImpl.kt | 9 - .../AddChannelChannelGroupEndpoint.kt | 9 +- .../AddChannelChannelGroupImpl.kt | 14 - .../AllChannelsChannelGroupEndpoint.kt | 9 +- .../AllChannelsChannelGroupImpl.kt | 14 - .../DeleteChannelGroupEndpoint.kt | 9 +- .../channel_groups/DeleteChannelGroupImpl.kt | 14 - .../ListAllChannelGroupEndpoint.kt | 9 +- .../channel_groups/ListAllChannelGroupImpl.kt | 14 - .../RemoveChannelChannelGroupEndpoint.kt | 9 +- .../RemoveChannelChannelGroupImpl.kt | 14 - .../endpoints/files/DeleteFileEndpoint.kt | 9 +- .../endpoints/files/DeleteFileImpl.kt | 14 - .../endpoints/files/DownloadFileEndpoint.kt | 9 +- .../endpoints/files/DownloadFileImpl.kt | 14 - .../files/GenerateUploadUrlEndpoint.kt | 6 +- .../endpoints/files/GetFileUrlEndpoint.kt | 11 +- .../endpoints/files/GetFileUrlImpl.kt | 14 - .../endpoints/files/ListFilesEndpoint.kt | 9 +- .../internal/endpoints/files/ListFilesImpl.kt | 14 - .../files/PublishFileMessageEndpoint.kt | 11 +- .../endpoints/files/PublishFileMessageImpl.kt | 14 - .../endpoints/files/SendFileEndpoint.kt | 7 +- .../internal/endpoints/files/SendFileImpl.kt | 9 - .../endpoints/files/UploadFileEndpoint.kt | 4 +- .../AddMessageActionEndpoint.kt | 9 +- .../message_actions/AddMessageActionImpl.kt | 14 - .../GetMessageActionsEndpoint.kt | 9 +- .../message_actions/GetMessageActionsImpl.kt | 14 - .../RemoveMessageActionEndpoint.kt | 9 +- .../RemoveMessageActionImpl.kt | 14 - .../channel/GetAllChannelMetadataEndpoint.kt | 11 +- .../channel/GetAllChannelMetadataImpl.kt | 26 - .../channel/GetChannelMetadataEndpoint.kt | 10 +- .../objects/channel/GetChannelMetadataImpl.kt | 14 - .../channel/RemoveChannelMetadataEndpoint.kt | 9 +- .../channel/RemoveChannelMetadataImpl.kt | 20 - .../channel/SetChannelMetadataEndpoint.kt | 9 +- .../objects/channel/SetChannelMetadataImpl.kt | 14 - .../internal/CollectionQueryParameters.kt | 2 +- .../objects/internal/IncludeQueryParam.kt | 4 +- .../member/GetChannelMembersEndpoint.kt | 13 +- .../objects/member/GetChannelMembersImpl.kt | 27 - .../member/ManageChannelMembersEndpoint.kt | 15 +- .../member/ManageChannelMembersImpl.kt | 27 - .../membership/GetMembershipsEndpoint.kt | 13 +- .../objects/membership/GetMembershipsImpl.kt | 27 - .../membership/ManageMembershipsEndpoint.kt | 15 +- .../membership/ManageMembershipsImpl.kt | 27 - .../uuid/GetAllUUIDMetadataEndpoint.kt | 11 +- .../objects/uuid/GetAllUUIDMetadataImpl.kt | 27 - .../objects/uuid/GetUUIDMetadataEndpoint.kt | 11 +- .../objects/uuid/GetUUIDMetadataImpl.kt | 23 - .../uuid/RemoveUUIDMetadataEndpoint.kt | 9 +- .../objects/uuid/RemoveUUIDMetadataImpl.kt | 20 - .../objects/uuid/SetUUIDMetadataEndpoint.kt | 11 +- .../objects/uuid/SetUUIDMetadataImpl.kt | 24 - .../endpoints/presence/GetStateEndpoint.kt | 9 +- .../endpoints/presence/GetStateImpl.kt | 14 - .../endpoints/presence/HeartbeatEndpoint.kt | 4 +- .../endpoints/presence/HereNowEndpoint.kt | 9 +- .../endpoints/presence/HereNowImpl.kt | 14 - .../endpoints/presence/LeaveEndpoint.kt | 4 +- .../endpoints/presence/SetStateEndpoint.kt | 9 +- .../endpoints/presence/SetStateImpl.kt | 14 - .../endpoints/presence/WhereNowEndpoint.kt | 11 +- .../endpoints/presence/WhereNowImpl.kt | 25 - .../endpoints/pubsub/PublishEndpoint.kt | 9 +- .../internal/endpoints/pubsub/PublishImpl.kt | 13 - .../endpoints/pubsub/SignalEndpoint.kt | 9 +- .../internal/endpoints/pubsub/SignalImpl.kt | 14 - .../endpoints/pubsub/SubscribeEndpoint.kt | 4 +- .../push/AddChannelsToPushEndpoint.kt | 9 +- .../endpoints/push/AddChannelsToPushImpl.kt | 14 - .../push/ListPushProvisionsEndpoint.kt | 9 +- .../endpoints/push/ListPushProvisionsImpl.kt | 14 - .../RemoveAllPushChannelsForDeviceEndpoint.kt | 9 +- .../RemoveAllPushChannelsForDeviceImpl.kt | 15 - .../push/RemoveChannelsFromPushEndpoint.kt | 9 +- .../push/RemoveChannelsFromPushImpl.kt | 15 - .../remoteaction/RetryingRemoteAction.kt | 0 .../com/pubnub/internal/eventengine/Effect.kt | 0 .../internal/eventengine/EffectDispatcher.kt | 0 .../internal/eventengine/EffectFactory.kt | 0 .../internal/eventengine/EffectInvocation.kt | 0 .../com/pubnub/internal/eventengine/Event.kt | 0 .../internal/eventengine/EventEngine.kt | 0 .../internal/eventengine/EventEngineConf.kt | 0 .../eventengine/EventEngineManager.kt | 0 .../internal/eventengine/ManagedEffect.kt | 0 .../internal/eventengine/QueueSinkSource.kt | 0 .../com/pubnub/internal/eventengine/Sink.kt | 0 .../com/pubnub/internal/eventengine/Source.kt | 0 .../com/pubnub/internal/eventengine/State.kt | 0 .../pubnub/internal/eventengine/Transition.kt | 0 .../com/pubnub/internal/extension/Boolean.kt | 0 .../com/pubnub/internal/extension/Int.kt | 0 .../pubnub/internal/extension/JsonElement.kt | 0 .../internal/extension/RetrofitResponse.kt | 8 +- .../extension/ScheduledExecutorService.kt | 0 .../com/pubnub/internal/extension/String.kt | 0 .../interceptor/SignatureInterceptor.kt | 8 +- .../internal/managers/BasePathManager.kt | 6 +- .../internal/managers/DuplicationManager.kt | 4 +- .../internal/managers/ListenerManager.kt | 50 +- .../pubnub/internal/managers/MapperManager.kt | 0 .../managers/PresenceEventEngineManager.kt | 0 .../managers/PublishSequenceManager.kt | 0 .../internal/managers/RetrofitManager.kt | 12 +- .../managers/SubscribeEventEngineManager.kt | 0 .../pubnub/internal/managers/TokenManager.kt | 0 .../pubnub/internal/managers/TokenParser.kt | 0 .../com/pubnub/internal/models/Converters.kt | 467 ---- .../pubsub/objects/PNObjectEventResult.kt | 86 +- .../pubnub/internal/models/server/Envelope.kt | 0 .../models/server/FetchMessagesEnvelope.kt | 0 .../models/server/OriginationMetaData.kt | 0 .../models/server/PresenceEnvelope.kt | 0 .../internal/models/server/PublishMetaData.kt | 0 .../models/server/SubscribeEnvelope.kt | 0 .../models/server/SubscribeMessage.kt | 0 .../models/server/SubscribeMetaData.kt | 0 .../AccessManagerGrantPayload.kt | 4 +- .../v3/GrantTokenRequestBody.kt | 12 +- .../access_manager/v3/GrantTokenResponse.kt | 0 .../access_manager/v3/RevokeTokenResponse.kt | 0 .../server/files/FileUploadNotification.kt | 0 .../server/files/FileUploadRequestDetails.kt | 0 .../internal/models/server/files/FormField.kt | 0 .../server/files/GenerateUploadUrlPayload.kt | 0 .../files/GeneratedUploadUrlResponse.kt | 0 .../models/server/files/ListFilesResult.kt | 0 .../server/history/ServerFetchMessageItem.kt | 0 .../history/ServerFetchMessagesResult.kt | 0 .../message_actions/MessageActionsResponse.kt | 0 .../server/objects_api/ChangeMemberInput.kt | 0 .../objects_api/ChangeMembershipInput.kt | 0 .../objects_api/ChannelMetadataInput.kt | 0 .../server/objects_api/EntityArrayEnvelope.kt | 0 .../server/objects_api/EntityEnvelope.kt | 0 .../server/objects_api/ServerMemberInput.kt | 0 .../objects_api/ServerMembershipInput.kt | 0 .../server/objects_api/UUIDMetadataInput.kt | 0 .../models/server/presence/WhereNowPayload.kt | 0 .../com/pubnub/internal/presence/Presence.kt | 0 .../eventengine/PresenceEventEngine.kt | 0 .../presence/eventengine/data/PresenceData.kt | 0 .../eventengine/effect/HeartbeatEffect.kt | 0 .../eventengine/effect/LeaveEffect.kt | 0 .../effect/PresenceEffectFactory.kt | 0 .../effect/PresenceEffectInvocation.kt | 0 .../presence/eventengine/effect/WaitEffect.kt | 13 +- .../effectprovider/HeartbeatProvider.kt | 0 .../effectprovider/HeartbeatProviderImpl.kt | 4 +- .../effect/effectprovider/LeaveProvider.kt | 0 .../effectprovider/LeaveProviderImpl.kt | 4 +- .../eventengine/event/PresenceEvent.kt | 0 .../eventengine/state/PresenceState.kt | 0 .../pubnub/internal/retry/RetryableBase.kt | 0 .../internal/retry/RetryableCallback.kt | 9 +- .../internal/retry/RetryableRestCaller.kt | 0 .../internal/services/AccessManagerService.kt | 0 .../internal/services/ChannelGroupService.kt | 0 .../pubnub/internal/services/FilesService.kt | 0 .../internal/services/HistoryService.kt | 0 .../internal/services/MessageActionService.kt | 0 .../internal/services/ObjectsService.kt | 4 +- .../internal/services/PresenceService.kt | 0 .../internal/services/PublishService.kt | 0 .../pubnub/internal/services/PushService.kt | 0 .../com/pubnub/internal/services/S3Service.kt | 0 .../pubnub/internal/services/SignalService.kt | 0 .../internal/services/SubscribeService.kt | 0 .../pubnub/internal/services/TimeService.kt | 0 .../pubnub/internal/subscribe/Subscribe.kt | 6 +- .../eventengine/SubscribeEventEngine.kt | 0 .../configuration/EventEnginesConf.kt | 3 +- .../eventengine/data/SubscriptionData.kt | 0 .../eventengine/effect/EmitMessagesEffect.kt | 2 +- .../eventengine/effect/EmitStatusEffect.kt | 0 .../eventengine/effect/HandshakeEffect.kt | 0 .../eventengine/effect/MessagesConsumer.kt | 2 +- .../effect/ReceiveMessagesEffect.kt | 0 .../eventengine/effect/ReconnectionPolicy.kt | 0 .../eventengine/effect/StatusConsumer.kt | 0 .../effect/SubscribeEffectFactory.kt | 0 .../effect/SubscribeEffectInvocation.kt | 0 .../effectprovider/HandshakeProvider.kt | 0 .../effectprovider/HandshakeProviderImpl.kt | 4 +- .../effectprovider/ReceiveMessagesProvider.kt | 0 .../ReceiveMessagesProviderImpl.kt | 4 +- .../eventengine/event/SubscribeEvent.kt | 0 .../eventengine/event/SubscriptionCursor.kt | 0 .../eventengine/state/SubscribeState.kt | 0 .../internal/utils/PolymorphicDeserializer.kt | 0 .../internal/utils/UnwrapSingleField.kt | 0 .../pubnub/internal/v2/PNConfigurationImpl.kt | 167 +- .../v2/callbacks/DelegatingEventListener.kt | 74 - .../v2/callbacks/DelegatingStatusListener.kt | 15 - .../callbacks/DelegatingSubscribeCallback.kt | 17 - .../internal/v2/callbacks/EventEmitterImpl.kt | 37 +- .../internal/v2/entities/ChannelGroupImpl.kt | 63 +- .../internal/v2/entities/ChannelImpl.kt | 77 +- .../v2/entities/ChannelMetadataImpl.kt | 50 +- .../internal/v2/entities/UserMetadataImpl.kt | 50 +- .../subscription/BaseSubscriptionSetImpl.kt | 96 + .../internal/v2/subscription/EmitterHelper.kt | 84 +- .../v2/subscription/SubscriptionImpl.kt | 132 +- .../v2/subscription/SubscriptionSetImpl.kt | 55 +- .../internal/vendor/FileEncryptionUtil.kt | 6 +- .../workers/SubscribeMessageProcessor.kt | 17 +- .../pubnub/api/BasePNConfigurationImplTest.kt | 16 + .../src/test/kotlin/com/pubnub/api/Keys.kt | 0 .../com/pubnub/api/PNConfigurationTest.kt | 124 - .../kotlin/com/pubnub/api/PubNubUtilTest.kt | 0 .../test/kotlin/com/pubnub/api/UserIdTest.kt | 0 .../com/pubnub/api/crypto/CryptoModuleTest.kt | 0 .../api/crypto/algorithm/AesCBCCryptorTest.kt | 0 .../api/crypto/algorithm/LegacyCryptorTest.kt | 0 .../api/crypto/cryptor/HeaderParserTest.kt | 0 .../api/endpoints/access/GrantTokenTest.kt | 15 +- .../api/endpoints/pubsub/PublishTest.kt | 17 +- .../kotlin/com/pubnub/api/legacy/BaseTest.kt | 19 +- .../com/pubnub/api/legacy/PubNubCoreTest.kt | 25 +- .../DeleteMessagesCoreEndpointTest.kt | 0 .../api/legacy/endpoints/EndpointCoreTest.kt | 14 +- .../endpoints/HeartbeatCoreEndpointTest.kt | 0 .../endpoints/access/GrantEndpointTest.kt | 2 +- ...ChannelBaseChannelGroupCoreEndpointTest.kt | 0 ...hannelsBaseChannelGroupCoreEndpointTest.kt | 0 .../DeleteBaseChannelGroupCoreEndpointTest.kt | 0 ...ListAllBaseChannelGroupCoreEndpointTest.kt | 0 ...ChannelBaseChannelGroupCoreEndpointTest.kt | 0 .../legacy/endpoints/files/GetFileUrlTest.kt | 24 +- .../legacy/endpoints/files/SendFileTest.kt | 27 +- .../legacy/endpoints/files/TestsWithFiles.kt | 0 .../legacy/endpoints/files/UploadFileTest.kt | 0 .../history/FetchMessagesCoreEndpointTest.kt | 0 .../history/HistoryCoreEndpointTest.kt | 0 .../endpoints/history/MessageCountTest.kt | 0 .../AddMessageActionCoreEndpointTest.kt | 0 .../GetMessageActionCoreEndpointTest.kt | 0 .../message_actions/ReceiveMessageActions.kt | 32 +- .../RemoveMessageActionCoreEndpointTest.kt | 0 .../presence/GetStateCoreEndpointTest.kt | 0 .../presence/HereNowCoreEndpointTest.kt | 0 .../legacy/endpoints/presence/LeaveTest.kt | 0 .../presence/StateSetCoreEndpointEETest.kt | 0 .../presence/StateSetCoreEndpointTest.kt | 0 .../presence/WhereNowCoreEndpointTest.kt | 0 .../legacy/endpoints/pubsub/PublishTest.kt | 0 .../api/legacy/endpoints/pubsub/SignalTest.kt | 18 +- .../pubsub/SubscribeCoreEndpointTest.kt | 0 .../endpoints/push/AddChannelsToPushTest.kt | 0 .../endpoints/push/ListPushProvisionsTest.kt | 0 .../push/PushPayloadHelperHelperTest.kt | 0 .../RemoveAllPushChannelsForDeviceTest.kt | 0 .../push/RemoveChannelsFromPushTest.kt | 0 .../remoteaction/CancellableRemoteAction.kt | 0 .../ComposableRemoteActionTest.kt | 0 .../remoteaction/RetryingRemoteActionTest.kt | 0 .../remoteaction/TestRemoteAction.kt | 0 .../legacy/managers/BasePathManagerTest.kt | 0 .../managers/PublishSequenceManagerTest.kt | 0 .../managers/SubscriptionManagerTest.kt | 313 +-- .../api/legacy/vendor/EncryptDecryptTest.kt | 0 .../api/retry/RetryConfigurationTest.kt | 0 .../com/pubnub/contract/ContractTestConfig.kt | 0 .../test/kotlin/com/pubnub/contract/Hooks.kt | 0 .../com/pubnub/contract/MockPubnubService.kt | 0 .../pubnub/contract/RunMainCucumberTest.kt | 0 .../test/kotlin/com/pubnub/contract/Utils.kt | 4 +- .../access/parameter/PermissionType.kt | 0 .../contract/access/parameter/ResourceType.kt | 0 .../contract/access/parameter/TTLType.kt | 0 .../contract/access/state/GrantTokenState.kt | 2 +- .../pubnub/contract/access/step/GivenSteps.kt | 20 +- .../pubnub/contract/access/step/ThenSteps.kt | 8 +- .../pubnub/contract/access/step/WhenSteps.kt | 20 +- .../state/ChannelMetadataState.kt | 0 .../channelmetadata/step/GivenSteps.kt | 0 .../channelmetadata/step/ThenSteps.kt | 0 .../channelmetadata/step/WhenSteps.kt | 12 +- .../contract/crypto/CryptoModuleState.kt | 0 .../contract/crypto/CryptoModuleSteps.kt | 0 .../contract/member/state/MemberState.kt | 2 +- .../pubnub/contract/member/step/GivenSteps.kt | 0 .../pubnub/contract/member/step/ThenSteps.kt | 0 .../pubnub/contract/member/step/WhenSteps.kt | 34 +- .../membership/state/MembershipState.kt | 2 +- .../contract/membership/step/GivenSteps.kt | 0 .../contract/membership/step/ThenSteps.kt | 0 .../contract/membership/step/WhenSteps.kt | 20 +- .../pubnub/contract/parameter/SpaceIdType.kt | 2 +- .../step/PresenceEventEngineSteps.kt | 18 +- .../kotlin/com/pubnub/contract/state/World.kt | 13 +- .../step/ErrorMessageAndDetailsStep.kt | 0 .../com/pubnub/contract/step/KeysetStep.kt | 0 .../com/pubnub/contract/step/ThenSteps.kt | 0 .../eventEngine/state/EventEngineState.kt | 6 +- .../eventEngine/state/TestSinkSource.kt | 0 .../eventEngine/step/EventEngineSteps.kt | 42 +- .../uuidmetadata/state/UUIDMetadataState.kt | 0 .../contract/uuidmetadata/step/GivenSteps.kt | 0 .../contract/uuidmetadata/step/ThenSteps.kt | 0 .../contract/uuidmetadata/step/WhenSteps.kt | 14 +- .../endpoints/DelegatingEndpointTest.kt | 94 - .../eventengine/EffectDispatcherTest.kt | 0 .../eventengine/EventEngineManagerTest.kt | 0 .../internal/eventengine/EventEngineTest.kt | 0 .../internal/extension/JsonElementTest.kt | 0 .../internal/managers/MapperManagerTest.kt | 0 .../internal/managers/RetrofitManagerTest.kt | 0 .../internal/managers/TokenParserTest.kt | 0 .../pubnub/internal/presence/PresenceTest.kt | 0 .../eventengine/effect/HeartbeatEffectTest.kt | 0 .../eventengine/effect/LeaveEffectTest.kt | 0 .../effect/PresenceEffectFactoryTest.kt | 0 .../eventengine/effect/WaitEffectTest.kt | 0 .../eventengine/event/PresenceEventTest.kt | 0 ...ransitionFromHeartbeatCooldownStateTest.kt | 0 .../TransitionFromHeartbeatFailedStateTest.kt | 0 ...ransitionFromHeartbeatInactiveStateTest.kt | 0 ...TransitionFromHeartbeatStoppedStateTest.kt | 0 .../TransitionFromHeartbeatingStateTest.kt | 0 .../internal/retry/RetryableCallbackTest.kt | 0 .../internal/retry/RetryableRestCallerTest.kt | 0 .../internal/subscribe/SubscribeTest.kt | 0 .../effect/EmitMessagesEffectTest.kt | 6 +- .../effect/EmitStatusEffectTest.kt | 0 .../eventengine/effect/HandshakeEffectTest.kt | 0 .../effect/ReceiveMessagesEffectTest.kt | 0 .../effect/SubscribeEffectFactoryTest.kt | 0 .../eventengine/event/SubscribeEventTest.kt | 0 ...entConsumerWorkerTransitionFunctionTest.kt | 0 .../TransitionFromHandshakeFailedStateTest.kt | 0 ...TransitionFromHandshakeStoppedStateTest.kt | 0 .../TransitionFromHandshakingStateTest.kt | 0 .../TransitionFromReceiveFailedStateTest.kt | 0 .../TransitionFromReceiveStoppedStateTest.kt | 0 .../TransitionFromReceivingStateTest.kt | 0 .../TransitionFromUnsubscribedStateTest.kt | 0 .../internal/suite/CoreEndpointTestSuite.kt | 4 +- .../pubnub/internal/suite/TimeTestSuite.kt | 6 +- .../AddChannelChannelGroupTestSuite.kt | 6 +- .../AllChannelsChannelGroupTestSuite.kt | 6 +- .../DeleteChannelGroupTestSuite.kt | 6 +- .../ListAllChannelGroupTestSuite.kt | 6 +- .../RemoveChannelChannelGroupTestSuite.kt | 6 +- .../internal/suite/grant/GrantTestSuite.kt | 8 +- .../suite/history/DeleteMessagesTestSuite.kt | 6 +- .../history/counts/MessageCountsTestSuite.kt | 6 +- .../suite/history/v2/HistoryMetaTestSuite.kt | 6 +- .../suite/history/v2/HistoryTestSuite.kt | 6 +- .../v3/FetchMessagesMetaActionsTestSuite.kt | 6 +- .../history/v3/FetchMessagesTestSuite.kt | 6 +- .../AddMessageActionTestSuite.kt | 6 +- .../GetMessageActionsMultipleTestSuite.kt | 6 +- .../GetMessageActionsTestSuite.kt | 6 +- .../RemoveMessageActionsTestSuite.kt | 6 +- .../suite/presence/GetStateTestSuite.kt | 6 +- .../suite/presence/HeartbeatTestSuite.kt | 0 .../suite/presence/HereNowTestSuite.kt | 6 +- .../internal/suite/presence/LeaveTestSuite.kt | 0 .../suite/presence/StateSetTestSuite.kt | 6 +- .../suite/presence/WhereNowTestSuite.kt | 8 +- .../suite/pubsub/PublishGetTestSuite.kt | 6 +- .../suite/pubsub/PublishPostTestSuite.kt | 6 +- .../internal/suite/pubsub/SignalTestSuite.kt | 6 +- .../suite/pubsub/SubscribeTestSuite.kt | 0 .../push/add/AddChannelsToPushV1TestSuite.kt | 6 +- .../push/add/AddChannelsToPushV2TestSuite.kt | 6 +- .../list/ListPushProvisionsV1TestSuite.kt | 6 +- .../list/ListPushProvisionsV2TestSuite.kt | 6 +- .../remove/RemoveAllFromPushV1TestSuite.kt | 6 +- .../remove/RemoveAllFromPushV2TestSuite.kt | 6 +- .../RemoveChannelsFromPushV1TestSuite.kt | 6 +- .../RemoveChannelsFromPushV2TestSuite.kt | 6 +- .../utils/PolymorphicDeserializerTest.kt | 0 .../internal/utils/UnwrapSingleFieldTest.kt | 0 .../internal/v2/PNConfigurationImplTest.kt | 52 +- .../callbacks/DelegatingEventListenerTest.kt | 23 - .../callbacks/DelegatingStatusListenerTest.kt | 37 - .../DelegatingSubscribeCallbackTest.kt | 38 - .../v2/callbacks/EventEmitterImplTest.kt | 79 +- .../v2/entities/BaseChannelGroupImplTest.kt | 18 +- .../v2/entities/BaseChannelImplTest.kt | 19 +- .../subscription/BaseSubscriptionImplTest.kt | 67 +- .../BaseSubscriptionSetImplTest.kt | 121 + .../subscription/SubscriptionSetImplTest.kt | 7 +- .../workers/SubscribeMessageProcessorTest.kt | 20 +- .../kotlin/com/pubnub/test/CommonUtils.kt | 6 +- .../test/kotlin/com/pubnub/test/Extensions.kt | 3 +- .../src/test/kotlin/com/pubnub/test/Keys.kt | 0 .../kotlin/com/pubnub/test/SignatureUtils.kt | 8 +- .../src/test/resources/entityTooLarge.xml | 0 .../test/resources/junit-platform.properties | 0 .../src/test/resources/logback.xml | 0 .../src/test/resources/special_chars.json | 0 .../pubnub-kotlin-test/build.gradle.kts | 5 +- .../kotlin/com.pubnub.test/FakePubNub.kt | 509 ---- settings.gradle.kts | 4 +- 966 files changed, 8989 insertions(+), 16953 deletions(-) create mode 100755 migration_utils/replace_in_file.sh create mode 100644 migration_utils/replacements.txt create mode 100755 migration_utils/upgrade_v10.sh delete mode 100644 pubnub-core/pubnub-core-api/build.gradle.kts delete mode 100644 pubnub-core/pubnub-core-api/config/ktlint/baseline.xml delete mode 100644 pubnub-core/pubnub-core-api/pubnub_core_api.podspec delete mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventListener.kt delete mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusEmitter.kt delete mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusListener.kt delete mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannel.kt delete mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelMetadata.kt delete mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseUserMetadata.kt delete mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt delete mode 100644 pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscriptionSet.kt delete mode 100644 pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.ios.kt delete mode 100644 pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt delete mode 100644 pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/HasOverridableConfig.kt delete mode 100644 pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.jvm.kt delete mode 100644 pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfiguration.kt delete mode 100644 pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfigurationOverride.kt delete mode 100644 pubnub-core/pubnub-core-impl/build.gradle.kts delete mode 100644 pubnub-core/pubnub-core-impl/config/ktlint/baseline.xml delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/BasePubNubImpl.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/SpaceId.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/SubscriptionFactory.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/callbacks/SubscribeCallback.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushInterface.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/PNAccessManagerGrantResults.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/sum/SpacePermissions.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/sum/UserPermissions.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/ChannelGrant.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/ChannelGroupGrant.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/Grants.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/UUIDGrant.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/PNRemoveMetadataResult.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/PNSortKey.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/ResultSortKey.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/MemberInput.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMemberArrayResult.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNUUIDDetailsLevel.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNUUIDWithCustom.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/ChannelMembershipInput.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelDetailsLevel.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembershipArrayResult.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelWithCustom.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/presence/PNWhereNowResult.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/BasePNConfigurationImpl.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/EventListenerCore.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/StatusListenerCore.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelGroupImpl.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelImpl.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelMetadataImpl.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseUserMetadataImpl.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionImpl.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImpl.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/workers/SubscribeMessageWorker.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/BasePNConfigurationImplTest.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/TestPubNub.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImplTest.kt delete mode 100644 pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/TestPNConfigurationImpl.kt delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/PNConfiguration.kt delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/callbacks/SubscribeCallback.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/Endpoint.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/Time.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/GrantToken.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/GetMemberships.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/GetUUIDMetadata.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/RemoveUUIDMetadata.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/WhereNow.java rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/PubNub.kt (72%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/PubNubRuntimeException.java (95%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/SpaceId.java (92%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/builder/PresenceBuilder.java (86%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/builder/PubNubErrorBuilder.java (99%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/builder/PubSubBuilder.java (86%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/builder/SubscribeBuilder.java (92%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/builder/UnsubscribeBuilder.java (69%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/builder/dto/ChangeTemporaryUnavailableOperation.java (91%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/builder/dto/PresenceOperation.java (90%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/builder/dto/PubSubOperation.java (95%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/builder/dto/StateOperation.java (90%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/builder/dto/TimetokenAndRegionOperation.java (80%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/builder/dto/UnsubscribeOperation.java (85%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/callbacks/PNCallback.java (91%) create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/callbacks/SubscribeCallback.kt rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/BuilderSteps.java (73%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/DeleteMessages.java (88%) create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/Endpoint.kt rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/FetchMessages.java (93%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/History.java (91%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/MessageCounts.java (87%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/access/Grant.java (75%) create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/GrantToken.java rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/access/RevokeToken.java (55%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/access/builder/AbstractGrantTokenBuilder.java (62%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/access/builder/GrantTokenBuilder.java (61%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/access/builder/GrantTokenEntitiesBuilder.java (66%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/access/builder/GrantTokenObjectsBuilder.java (60%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/channel_groups/AddChannelChannelGroup.java (75%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/channel_groups/AllChannelsChannelGroup.java (70%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/channel_groups/DeleteChannelGroup.java (70%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/channel_groups/RemoveChannelChannelGroup.java (76%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/files/DeleteFile.java (54%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/files/DownloadFile.java (59%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/files/GetFileUrl.java (54%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/files/ListFiles.java (69%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/files/PublishFileMessage.java (68%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/files/SendFile.java (75%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/files/requiredparambuilder/FilesBuilderSteps.java (76%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/message_actions/AddMessageAction.java (77%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/message_actions/GetMessageActions.java (76%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/message_actions/RemoveMessageAction.java (77%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/channel/GetAllChannelsMetadata.java (57%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/channel/GetChannelMetadata.java (54%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/channel/RemoveChannelMetadata.java (50%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/channel/SetChannelMetadata.java (69%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/members/GetChannelMembers.java (51%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/members/ManageChannelMembers.java (53%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/members/RemoveChannelMembers.java (52%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/members/SetChannelMembers.java (52%) create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/GetMemberships.java rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/memberships/ManageMemberships.java (50%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/memberships/RemoveMemberships.java (53%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/memberships/SetMemberships.java (52%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/utils/Include.java (94%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/utils/ObjectsBuilderSteps.java (73%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/utils/PNSortKey.java (84%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/uuid/GetAllUUIDMetadata.java (54%) create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/GetUUIDMetadata.java create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/RemoveUUIDMetadata.java rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/objects_api/uuid/SetUUIDMetadata.java (73%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/presence/GetState.java (75%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/presence/Heartbeat.java (69%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/presence/HereNow.java (78%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/presence/Leave.java (64%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/presence/SetState.java (79%) create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/WhereNow.java rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/pubsub/Publish.java (80%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/pubsub/Signal.java (67%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/push/AddChannelsToPush.java (83%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/push/ListPushProvisions.java (82%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/push/RemoveAllPushChannelsForDevice.java (84%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/endpoints/push/RemoveChannelsFromPush.java (84%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/access_manager/PNAccessManagerGrantResult.java (68%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/access_manager/PNAccessManagerKeyData.java (85%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/access_manager/PNAccessManagerKeysData.java (81%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/access_manager/sum/SpacePermissions.java (87%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/access_manager/sum/UserPermissions.java (86%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/access_manager/v3/ChannelGrant.java (94%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/access_manager/v3/ChannelGroupGrant.java (92%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/access_manager/v3/PNResource.java (95%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/access_manager/v3/PNRevokeTokenResult.java (50%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/access_manager/v3/UUIDGrant.java (91%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/EntityArrayEnvelope.java (89%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/EntityEnvelope.java (69%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/PNObject.java (90%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/channel/PNChannelMetadata.java (94%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/channel/PNChannelMetadataResult.java (93%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/channel/PNGetAllChannelsMetadataResult.java (84%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/channel/PNGetChannelMetadataResult.java (71%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/channel/PNRemoveChannelMetadataResult.java (75%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/channel/PNSetChannelMetadataResult.java (71%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/member/PNGetChannelMembersResult.java (84%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/member/PNManageChannelMembersResult.java (85%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/member/PNMembers.java (86%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/member/PNRemoveChannelMembersResult.java (85%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/member/PNSetChannelMembersResult.java (84%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/member/PNUUID.java (96%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/membership/PNChannelMembership.java (95%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/membership/PNGetMembershipsResult.java (84%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/membership/PNManageMembershipResult.java (85%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/membership/PNMembership.java (79%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/membership/PNMembershipResult.java (93%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/membership/PNRemoveMembershipResult.java (82%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/membership/PNSetMembershipResult.java (85%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/uuid/PNGetAllUUIDMetadataResult.java (86%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/uuid/PNGetUUIDMetadataResult.java (81%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/uuid/PNRemoveUUIDMetadataResult.java (81%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/uuid/PNSetUUIDMetadataResult.java (81%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/uuid/PNUUIDMetadata.java (94%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/models/consumer/objects_api/uuid/PNUUIDMetadataResult.java (93%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/PNConfiguration.kt (54%) create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/EventEmitter.kt create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/EventListener.kt rename pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventEmitter.kt => pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/StatusEmitter.kt (59%) create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/StatusListener.kt rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/callbacks/handlers/OnChannelMetadataHandler.java (86%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/callbacks/handlers/OnFileHandler.java (94%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/callbacks/handlers/OnMembershipHandler.java (85%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/callbacks/handlers/OnMessageActionHandler.java (94%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/callbacks/handlers/OnMessageHandler.java (94%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/callbacks/handlers/OnPresenceHandler.java (94%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/callbacks/handlers/OnSignalHandler.java (94%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/callbacks/handlers/OnUuidMetadataHandler.java (86%) rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/endpoints/pubsub/PublishBuilder.java (78%) create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/endpoints/pubsub/SignalBuilder.java rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/entities/Channel.kt (75%) rename pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelGroup.kt => pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/entities/ChannelGroup.kt (72%) create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/entities/ChannelMetadata.kt create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/entities/Subscribable.kt create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/entities/UserMetadata.kt rename pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/{ => java}/v2/subscriptions/Subscription.kt (67%) create mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/subscriptions/SubscriptionSet.kt delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/EventEmitter.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/EventListener.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/StatusEmitter.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/StatusListener.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/endpoints/pubsub/SignalBuilder.java delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/ChannelGroup.kt delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/ChannelMetadata.kt delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/UserMetadata.kt delete mode 100644 pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/SubscribeCallbackAdapter.java delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/PubNubImpl.java delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/TimeImpl.java delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupImpl.java delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupImpl.java delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/HeartbeatImpl.java delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/LeaveImpl.java delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/WhereNowImpl.java create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/PubNubForJavaImpl.kt rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/DelegatingEndpoint.kt (59%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/DelegatingRemoteAction.kt (81%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/DeleteMessagesImpl.java (61%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/FetchMessagesImpl.java (87%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/HistoryImpl.java (68%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/MessageCountsImpl.java (73%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/access/GrantImpl.java (59%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/access/GrantTokenImpl.java (65%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/access/RevokeTokenImpl.java (53%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/channel_groups/AddChannelChannelGroupImpl.java (55%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/channel_groups/AllChannelsChannelGroupImpl.java (51%) create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/DeleteChannelGroupImpl.java rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/channel_groups/RemoveChannelChannelGroupImpl.java (55%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/files/DeleteFileImpl.java (54%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/files/DownloadFileImpl.java (59%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/files/GetFileUrlImpl.java (56%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/files/ListFilesImpl.java (70%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/files/PublishFileMessageImpl.java (66%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/files/SendFileImpl.java (76%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/files/requiredparambuilder/ChannelFileNameFileIdBuilder.java (82%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/message_actions/AddMessageActionImpl.java (57%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/message_actions/GetMessageActionsImpl.java (60%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/message_actions/RemoveMessageActionImpl.java (64%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/channel/GetAllChannelsMetadataImpl.java (57%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/channel/GetChannelMetadataImpl.java (67%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/channel/RemoveChannelMetadataImpl.java (64%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/channel/SetChannelMetadataImpl.java (77%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/members/GetChannelMembersImpl.java (68%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/members/ManageChannelMembersImpl.java (80%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/members/RemoveChannelMembersImpl.java (71%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/members/SetChannelMembersImpl.java (67%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/memberships/GetMembershipsImpl.java (68%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/memberships/ManageMembershipsImpl.java (77%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/memberships/RemoveMembershipsImpl.java (70%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/memberships/SetMembershipsImpl.java (64%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/uuid/GetAllUUIDMetadataImpl.java (64%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/uuid/GetUUIDMetadataImpl.java (62%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/uuid/RemoveUUIDMetadataImpl.java (63%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/objects_api/uuid/SetUUIDMetadataImpl.java (72%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/presence/GetStateImpl.java (59%) create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/HeartbeatImpl.java rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/presence/HereNowImpl.java (60%) create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/LeaveImpl.java rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/presence/SetStateImpl.java (77%) create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/WhereNowImpl.java rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/pubsub/PublishImpl.java (65%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/pubsub/SignalImpl.java (57%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/push/AddChannelsToPushImpl.java (71%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/push/ListPushProvisionsImpl.java (67%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/push/RemoveAllPushChannelsForDeviceImpl.java (65%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/endpoints/push/RemoveChannelsFromPushImpl.java (70%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{ => java}/v2/PNConfigurationImpl.kt (65%) rename pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/{v2/callbacks/DelegatingEventListener.java => java/v2/callbacks/Converters.java} (58%) create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/DelegatingEventListener.kt create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/DelegatingStatusListener.kt create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/EventEmitterInternal.kt create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelGroupImpl.kt create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelImpl.kt create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelMetadataImpl.kt create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/UserMetadataImpl.kt create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/EmitterHelper.kt create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/SubscriptionImpl.kt create mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/SubscriptionSetImpl.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingStatusListener.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallback.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelGroupImpl.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelImpl.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelMetadataImpl.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/UserMetadataImpl.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/EmitterHelper.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/SubscriptionImpl.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/SubscriptionSetImpl.kt create mode 100644 pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/MigrationGeneratorTest.kt rename pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/{ => java}/endpoints/DelegatingEndpointTest.kt (67%) rename pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/{ => java}/endpoints/DelegatingRemoteActionTest.kt (91%) rename pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/{ => java}/endpoints/DeleteMessagesImplTest.kt (83%) rename pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/{ => java}/endpoints/FetchMessagesImplTest.kt (89%) rename pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/{ => java}/endpoints/access/GrantTokenImplTest.kt (63%) rename pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/{ => java}/v2/PNConfigurationImplTest.kt (92%) rename pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/{ => java}/v2/callbacks/DelegatingEventListenerTest.kt (82%) rename pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/{ => java}/v2/callbacks/DelegatingStatusListenerTest.kt (72%) rename pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/{ => java}/v2/entities/ChannelGroupImplTest.kt (51%) rename pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/{ => java}/v2/entities/ChannelImplTest.kt (58%) create mode 100644 pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/subscription/SubscriptionImplTest.kt create mode 100644 pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/subscription/SubscriptionSetImplTest.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionImplTest.kt delete mode 100644 pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImplTest.kt rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/PubNubError.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/UserId.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/callbacks/Listener.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/enums/PNHeartbeatNotificationOptions.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/enums/PNLogVerbosity.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/enums/PNOperationType.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/enums/PNReconnectionPolicy.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/enums/PNStatusCategory.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/TokenBitmask.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNBoundedPage.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNPublishResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNTimeResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNGrantTokenResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNToken.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/channel_group/PNChannelGroupsResults.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDeleteFileResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadableFile.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFile.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUploadResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUrlResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNListFilesResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNPublishFileMessageResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNDeleteMessagesResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNMessageCountResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNAddMessageActionResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt (60%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNRemoveMessageActionResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNPage.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNEvent.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushAddChannelResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushListProvisionsResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveAllChannelsResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveChannelResult.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadSerializer.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/retry/RetryableEndpointGroup.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt (99%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/utils/SerializedName.kt rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/v2/entities/Subscribable.kt (78%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscribeCapable.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt (54%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonMain/kotlin/com/pubnub/kmp/futures.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jsMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.js.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt (100%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PNConfiguration.kt rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jvmMain/kotlin/com/pubnub/api/crypto/CryptoModule.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jvmMain/kotlin/com/pubnub/api/crypto/cryptor/Cryptor.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedData.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedStreamData.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/ComposableRemoteAction.kt (100%) rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/MappingRemoteAction.kt (100%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/utils/SerializedName.jvm.kt rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt (100%) create mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/internal/endpoints/HasOverridableConfig.kt rename {pubnub-core/pubnub-core-api => pubnub-kotlin/pubnub-kotlin-api}/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/java/com/pubnub/internal/vendor/AppEngineFactory.java (91%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/java/com/pubnub/internal/vendor/Base64.java (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/java/com/pubnub/internal/vendor/Crypto.java (100%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/DelegatingEndpoint.kt create mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/EndpointImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/PubNubRetryableException.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/PubNubUtil.kt (97%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/callbacks/ReconnectionCallback.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/crypto/CryptoModuleImpl.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/crypto/cryptor/AesCbcCryptor.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/crypto/cryptor/CryptorHeader.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/crypto/cryptor/CryptorHeaderVersion.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/crypto/cryptor/HeaderParser.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/crypto/cryptor/InputStreamSeparator.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/crypto/cryptor/LegacyCryptor.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesEndpoint.kt (91%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesEndpoint.kt (97%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/HistoryEndpoint.kt (95%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsEndpoint.kt (93%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/TimeEndpoint.kt (86%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantEndpoint.kt (94%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenEndpoint.kt (86%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenEndpoint.kt (89%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupEndpoint.kt (90%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupEndpoint.kt (88%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupEndpoint.kt (88%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupEndpoint.kt (87%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupEndpoint.kt (89%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileEndpoint.kt (89%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileEndpoint.kt (93%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/files/GenerateUploadUrlEndpoint.kt (96%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlEndpoint.kt (95%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesEndpoint.kt (95%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageEndpoint.kt (93%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileEndpoint.kt (97%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/files/UploadFileEndpoint.kt (98%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionEndpoint.kt (91%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsEndpoint.kt (90%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionEndpoint.kt (90%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataEndpoint.kt (87%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataEndpoint.kt (88%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataEndpoint.kt (82%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataEndpoint.kt (91%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/CollectionQueryParameters.kt (95%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/IncludeQueryParam.kt (90%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersEndpoint.kt (82%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersEndpoint.kt (85%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsEndpoint.kt (82%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsEndpoint.kt (85%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataEndpoint.kt (88%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataEndpoint.kt (84%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataEndpoint.kt (82%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataEndpoint.kt (89%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateEndpoint.kt (93%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/presence/HeartbeatEndpoint.kt (97%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowEndpoint.kt (97%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/presence/LeaveEndpoint.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateEndpoint.kt (93%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowEndpoint.kt (83%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishEndpoint.kt (94%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalEndpoint.kt (88%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SubscribeEndpoint.kt (95%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushEndpoint.kt (93%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsEndpoint.kt (92%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceEndpoint.kt (91%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushEndpoint.kt (93%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/endpoints/remoteaction/RetryingRemoteAction.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/Effect.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/EffectDispatcher.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/EffectFactory.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/EffectInvocation.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/Event.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/EventEngine.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/EventEngineConf.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/EventEngineManager.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/ManagedEffect.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/QueueSinkSource.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/Sink.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/Source.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/State.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/eventengine/Transition.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/extension/Boolean.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/extension/Int.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/extension/JsonElement.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/extension/RetrofitResponse.kt (77%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/extension/ScheduledExecutorService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/extension/String.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/interceptor/SignatureInterceptor.kt (50%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/managers/BasePathManager.kt (90%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/managers/DuplicationManager.kt (85%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/managers/ListenerManager.kt (81%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/managers/PresenceEventEngineManager.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/managers/PublishSequenceManager.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/managers/RetrofitManager.kt (97%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/managers/SubscribeEventEngineManager.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/managers/TokenManager.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/managers/TokenParser.kt (100%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/Converters.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt (55%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/Envelope.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/FetchMessagesEnvelope.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/OriginationMetaData.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/PresenceEnvelope.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/PublishMetaData.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/SubscribeEnvelope.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/SubscribeMessage.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/SubscribeMetaData.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/access_manager/AccessManagerGrantPayload.kt (81%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenRequestBody.kt (87%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenResponse.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/RevokeTokenResponse.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/files/FileUploadNotification.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/files/FileUploadRequestDetails.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/files/FormField.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/files/GenerateUploadUrlPayload.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/files/GeneratedUploadUrlResponse.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/files/ListFilesResult.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/history/ServerFetchMessageItem.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/history/ServerFetchMessagesResult.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/message_actions/MessageActionsResponse.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChangeMemberInput.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChangeMembershipInput.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChannelMetadataInput.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityArrayEnvelope.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityEnvelope.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ServerMemberInput.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ServerMembershipInput.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/objects_api/UUIDMetadataInput.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/models/server/presence/WhereNowPayload.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/Presence.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/PresenceEventEngine.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/data/PresenceData.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/HeartbeatEffect.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/LeaveEffect.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectFactory.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectInvocation.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffect.kt (74%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProvider.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProviderImpl.kt (84%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProvider.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProviderImpl.kt (83%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/event/PresenceEvent.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/presence/eventengine/state/PresenceState.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/retry/RetryableBase.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/retry/RetryableCallback.kt (90%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/retry/RetryableRestCaller.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/AccessManagerService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/ChannelGroupService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/FilesService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/HistoryService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/MessageActionService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/ObjectsService.kt (96%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/PresenceService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/PublishService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/PushService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/S3Service.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/SignalService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/SubscribeService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/services/TimeService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/Subscribe.kt (98%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/SubscribeEventEngine.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/configuration/EventEnginesConf.kt (91%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/data/SubscriptionData.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffect.kt (94%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitStatusEffect.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/HandshakeEffect.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/MessagesConsumer.kt (90%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReceiveMessagesEffect.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReconnectionPolicy.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/StatusConsumer.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectFactory.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectInvocation.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProvider.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProviderImpl.kt (89%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProvider.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProviderImpl.kt (90%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscribeEvent.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscriptionCursor.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/state/SubscribeState.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/utils/PolymorphicDeserializer.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/utils/UnwrapSingleField.kt (100%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListener.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingStatusListener.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallback.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImpl.kt (76%) create mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImpl.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/vendor/FileEncryptionUtil.kt (97%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/main/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessor.kt (95%) create mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/BasePNConfigurationImplTest.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/Keys.kt (100%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/PNConfigurationTest.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/PubNubUtilTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/UserIdTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/crypto/CryptoModuleTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/crypto/algorithm/AesCBCCryptorTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/crypto/algorithm/LegacyCryptorTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/crypto/cryptor/HeaderParserTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/endpoints/access/GrantTokenTest.kt (91%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/endpoints/pubsub/PublishTest.kt (87%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt (75%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt (77%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/DeleteMessagesCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/EndpointCoreTest.kt (96%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/HeartbeatCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/access/GrantEndpointTest.kt (99%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/AddChannelBaseChannelGroupCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/AllChannelsBaseChannelGroupCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/DeleteBaseChannelGroupCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/ListAllBaseChannelGroupCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/RemoveChannelBaseChannelGroupCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/GetFileUrlTest.kt (77%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/SendFileTest.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/TestsWithFiles.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/UploadFileTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/FetchMessagesCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/HistoryCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/MessageCountTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/AddMessageActionCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/GetMessageActionCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/ReceiveMessageActions.kt (89%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/RemoveMessageActionCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/GetStateCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/HereNowCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/LeaveTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/StateSetCoreEndpointEETest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/StateSetCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/WhereNowCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/PublishTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SignalTest.kt (92%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SubscribeCoreEndpointTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/AddChannelsToPushTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/ListPushProvisionsTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/RemoveAllPushChannelsForDeviceTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/RemoveChannelsFromPushTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/CancellableRemoteAction.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/ComposableRemoteActionTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/RetryingRemoteActionTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/TestRemoteAction.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/managers/BasePathManagerTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/managers/PublishSequenceManagerTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/managers/SubscriptionManagerTest.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/legacy/vendor/EncryptDecryptTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/api/retry/RetryConfigurationTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/ContractTestConfig.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/Hooks.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/MockPubnubService.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/RunMainCucumberTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/Utils.kt (88%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/access/parameter/PermissionType.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/access/parameter/ResourceType.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/access/parameter/TTLType.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/access/state/GrantTokenState.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/access/step/GivenSteps.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/access/step/ThenSteps.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/access/step/WhenSteps.kt (78%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/channelmetadata/state/ChannelMetadataState.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/channelmetadata/step/GivenSteps.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/channelmetadata/step/ThenSteps.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/channelmetadata/step/WhenSteps.kt (84%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/crypto/CryptoModuleState.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/crypto/CryptoModuleSteps.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/member/state/MemberState.kt (87%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/member/step/GivenSteps.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/member/step/ThenSteps.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/member/step/WhenSteps.kt (76%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/membership/state/MembershipState.kt (83%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/membership/step/GivenSteps.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/membership/step/ThenSteps.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt (85%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/parameter/SpaceIdType.kt (83%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/presence/eventEngine/step/PresenceEventEngineSteps.kt (89%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/state/World.kt (60%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/step/ErrorMessageAndDetailsStep.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/step/KeysetStep.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/step/ThenSteps.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/EventEngineState.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/TestSinkSource.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/step/EventEngineSteps.kt (81%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/uuidmetadata/state/UUIDMetadataState.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/GivenSteps.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/ThenSteps.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/WhenSteps.kt (76%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/endpoints/DelegatingEndpointTest.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/eventengine/EffectDispatcherTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/eventengine/EventEngineManagerTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/eventengine/EventEngineTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/extension/JsonElementTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/managers/RetrofitManagerTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/managers/TokenParserTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/presence/PresenceTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/HeartbeatEffectTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/LeaveEffectTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectFactoryTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffectTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/presence/eventengine/event/PresenceEventTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatCooldownStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatFailedStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatInactiveStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatStoppedStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatingStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/retry/RetryableCallbackTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/retry/RetryableRestCallerTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/SubscribeTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffectTest.kt (97%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitStatusEffectTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/HandshakeEffectTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReceiveMessagesEffectTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectFactoryTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscribeEventTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/SubscribeEventConsumerWorkerTransitionFunctionTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakeFailedStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakeStoppedStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakingStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceiveFailedStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceiveStoppedStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceivingStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromUnsubscribedStateTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/CoreEndpointTestSuite.kt (98%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/TimeTestSuite.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AddChannelChannelGroupTestSuite.kt (88%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AllChannelsChannelGroupTestSuite.kt (94%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/channel_groups/DeleteChannelGroupTestSuite.kt (88%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/channel_groups/ListAllChannelGroupTestSuite.kt (92%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/channel_groups/RemoveChannelChannelGroupTestSuite.kt (90%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/grant/GrantTestSuite.kt (90%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/history/DeleteMessagesTestSuite.kt (88%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/history/counts/MessageCountsTestSuite.kt (90%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryMetaTestSuite.kt (95%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryTestSuite.kt (94%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesMetaActionsTestSuite.kt (96%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesTestSuite.kt (94%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/message_actions/AddMessageActionTestSuite.kt (92%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsMultipleTestSuite.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsTestSuite.kt (91%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/message_actions/RemoveMessageActionsTestSuite.kt (87%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/presence/GetStateTestSuite.kt (94%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/presence/HeartbeatTestSuite.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/presence/HereNowTestSuite.kt (92%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/presence/LeaveTestSuite.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/presence/StateSetTestSuite.kt (94%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/presence/WhereNowTestSuite.kt (85%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishGetTestSuite.kt (91%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishPostTestSuite.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/pubsub/SignalTestSuite.kt (91%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/pubsub/SubscribeTestSuite.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV1TestSuite.kt (94%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV2TestSuite.kt (91%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV1TestSuite.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV2TestSuite.kt (93%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV1TestSuite.kt (88%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV2TestSuite.kt (88%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV1TestSuite.kt (90%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV2TestSuite.kt (90%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/utils/PolymorphicDeserializerTest.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/utils/UnwrapSingleFieldTest.kt (100%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingStatusListenerTest.kt delete mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImplTest.kt (80%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelGroupImplTest.kt (65%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelImplTest.kt (64%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionImplTest.kt (54%) create mode 100644 pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImplTest.kt rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessorTest.kt (89%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/test/CommonUtils.kt (98%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/test/Extensions.kt (96%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/test/Keys.kt (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/kotlin/com/pubnub/test/SignatureUtils.kt (96%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/resources/entityTooLarge.xml (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/resources/junit-platform.properties (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/resources/logback.xml (100%) rename {pubnub-core/pubnub-core-impl => pubnub-kotlin/pubnub-kotlin-impl}/src/test/resources/special_chars.json (100%) delete mode 100644 pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt diff --git a/.pubnub.yml b/.pubnub.yml index f5bf7ceee..bdd2b955e 100644 --- a/.pubnub.yml +++ b/.pubnub.yml @@ -1,9 +1,9 @@ name: kotlin -version: 9.2.3 +version: 9.2.4 schema: 1 scm: github.com/pubnub/kotlin files: - - build/libs/pubnub-kotlin-9.2.3-all.jar + - build/libs/pubnub-kotlin-9.2.4-all.jar sdks: - type: library @@ -23,8 +23,8 @@ sdks: - distribution-type: library distribution-repository: maven - package-name: pubnub-kotlin-9.2.3 - location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/9.2.3/pubnub-kotlin-9.2.3.jar + package-name: pubnub-kotlin-9.2.4 + location: https://repo.maven.apache.org/maven2/com/pubnub/pubnub-kotlin/9.2.4/pubnub-kotlin-9.2.4.jar supported-platforms: supported-operating-systems: Android: @@ -114,6 +114,11 @@ sdks: license-url: https://www.apache.org/licenses/LICENSE-2.0.txt is-required: Required changelog: + - date: 2024-08-19 + version: v9.2.4 + changes: + - type: bug + text: "Fixes a crash on Android after `PubNub.destroy` is called and there are requests running." - date: 2024-07-29 version: v9.2.3 changes: diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e6c60325..2b1d1f939 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v9.2.4 +August 19 2024 + +#### Fixed +- Fixes a crash on Android after `PubNub.destroy` is called and there are requests running. + ## v9.2.3 July 29 2024 diff --git a/README.md b/README.md index 8de582891..507d780ff 100644 --- a/README.md +++ b/README.md @@ -20,13 +20,13 @@ You will need the publish and subscribe keys to authenticate your app. Get your com.pubnub pubnub-kotlin - 9.2.3 + 9.2.4 ``` * for Gradle, add the following dependency in your `gradle.build`: ```groovy - implementation 'com.pubnub:pubnub-kotlin:9.2.3' + implementation 'com.pubnub:pubnub-kotlin:9.2.4' ``` 2. Configure your keys and create PubNub instance: diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt index 9017fed50..2748525e6 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubJavaLibraryPlugin.kt @@ -3,8 +3,14 @@ package com.pubnub.gradle import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.plugins.JavaLibraryPlugin +import org.gradle.api.plugins.quality.Checkstyle +import org.gradle.api.plugins.quality.CheckstyleExtension +import org.gradle.api.plugins.quality.CheckstylePlugin +import org.gradle.api.tasks.SourceSetContainer import org.gradle.api.tasks.compile.JavaCompile import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.getByType import org.gradle.kotlin.dsl.withType class PubNubJavaLibraryPlugin : Plugin { @@ -12,10 +18,27 @@ class PubNubJavaLibraryPlugin : Plugin { with(target) { apply() apply() + apply() tasks.withType().configureEach { it.options.compilerArgs.add("-parameters") } + + extensions.configure { + toolVersion = "8.14" + configFile = rootProject.file("config/checkstyle/checkstyle.xml") + sourceSets = listOf(extensions.getByType().getByName("main")) + } + + tasks.withType().configureEach { + it.exclude("**/vendor/**", "**/*Test*") + + it.reports { report -> + report.xml.required.set(true) + report.html.required.set(true) + } + } + } } } \ No newline at end of file diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt index c24ed6b89..2daeb8092 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinLibraryPlugin.kt @@ -4,13 +4,9 @@ import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.dependencies -import org.gradle.kotlin.dsl.project import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile -import org.jlleitschuh.gradle.ktlint.KtlintExtension -import org.jlleitschuh.gradle.ktlint.KtlintPlugin class PubNubKotlinLibraryPlugin : Plugin { override fun apply(target: Project) { @@ -26,6 +22,7 @@ class PubNubKotlinLibraryPlugin : Plugin { tasks.named("compileKotlin", KotlinJvmCompile::class.java) { it.compilerOptions { javaParameters.set(true) + freeCompilerArgs.add("-Xjvm-default=all") } } diff --git a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt index 9d075c685..9b1e938e5 100644 --- a/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt +++ b/build-logic/gradle-plugins/src/main/kotlin/com/pubnub/gradle/PubNubKotlinMultiplatformPlugin.kt @@ -54,6 +54,7 @@ class PubNubKotlinMultiplatformPlugin : Plugin { compilation.compileTaskProvider.configure { task -> task.compilerOptions { javaParameters.set(true) + freeCompilerArgs.add("-Xjvm-default=all") } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d8a865f51..638f3bf6c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -59,4 +59,5 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } benmanes-versions = { id = "com.github.ben-manes.versions", version = "0.42.0" } vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktech" } lombok = { id = "io.freefair.lombok", version = "8.6" } -gradle-nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus" } \ No newline at end of file +gradle-nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus" } +codingfeline-buildkonfig = { id = "com.codingfeline.buildkonfig", version = "0.15.1" } \ No newline at end of file diff --git a/migration_utils/replace_in_file.sh b/migration_utils/replace_in_file.sh new file mode 100755 index 000000000..9fd2904a5 --- /dev/null +++ b/migration_utils/replace_in_file.sh @@ -0,0 +1,13 @@ +#!/bin/bash +file="$4" +search="$1" +replace="$2" +dry_run="$3" + +if [[ "$dry_run" == "true" ]]; then + if grep -q "$search" "$file"; then + echo "$file" + fi +else + sed -i '' "s#$search#$replace#g" "$file" +fi diff --git a/migration_utils/replacements.txt b/migration_utils/replacements.txt new file mode 100644 index 000000000..b9728aa69 --- /dev/null +++ b/migration_utils/replacements.txt @@ -0,0 +1,187 @@ +com.pubnub.api.PubNub:com.pubnub.api.java.PubNub +com.pubnub.api.PubNub.Companion:com.pubnub.api.java.PubNub.Companion +com.pubnub.api.PubNubRuntimeException:com.pubnub.api.java.PubNubRuntimeException +com.pubnub.api.PubNubRuntimeException.PubNubRuntimeExceptionBuilder:com.pubnub.api.java.PubNubRuntimeException.PubNubRuntimeExceptionBuilder +com.pubnub.api.SpaceId:com.pubnub.api.java.SpaceId +com.pubnub.api.builder.PresenceBuilder:com.pubnub.api.java.builder.PresenceBuilder +com.pubnub.api.builder.PubNubErrorBuilder:com.pubnub.api.java.builder.PubNubErrorBuilder +com.pubnub.api.builder.PubSubBuilder:com.pubnub.api.java.builder.PubSubBuilder +com.pubnub.api.builder.SubscribeBuilder:com.pubnub.api.java.builder.SubscribeBuilder +com.pubnub.api.builder.UnsubscribeBuilder:com.pubnub.api.java.builder.UnsubscribeBuilder +com.pubnub.api.builder.dto.ChangeTemporaryUnavailableOperation:com.pubnub.api.java.builder.dto.ChangeTemporaryUnavailableOperation +com.pubnub.api.builder.dto.ChangeTemporaryUnavailableOperation.ChangeTemporaryUnavailableOperationBuilder:com.pubnub.api.java.builder.dto.ChangeTemporaryUnavailableOperation.ChangeTemporaryUnavailableOperationBuilder +com.pubnub.api.builder.dto.PresenceOperation:com.pubnub.api.java.builder.dto.PresenceOperation +com.pubnub.api.builder.dto.PresenceOperation.PresenceOperationBuilder:com.pubnub.api.java.builder.dto.PresenceOperation.PresenceOperationBuilder +com.pubnub.api.builder.dto.PubSubOperation:com.pubnub.api.java.builder.dto.PubSubOperation +com.pubnub.api.builder.dto.PubSubOperation.ConnectedStatusAnnouncedOperation:com.pubnub.api.java.builder.dto.PubSubOperation.ConnectedStatusAnnouncedOperation +com.pubnub.api.builder.dto.PubSubOperation.DisconnectOperation:com.pubnub.api.java.builder.dto.PubSubOperation.DisconnectOperation +com.pubnub.api.builder.dto.PubSubOperation.NoOpOperation:com.pubnub.api.java.builder.dto.PubSubOperation.NoOpOperation +com.pubnub.api.builder.dto.PubSubOperation.ReconnectOperation:com.pubnub.api.java.builder.dto.PubSubOperation.ReconnectOperation +com.pubnub.api.builder.dto.StateOperation:com.pubnub.api.java.builder.dto.StateOperation +com.pubnub.api.builder.dto.StateOperation.StateOperationBuilder:com.pubnub.api.java.builder.dto.StateOperation.StateOperationBuilder +com.pubnub.api.builder.dto.TimetokenAndRegionOperation:com.pubnub.api.java.builder.dto.TimetokenAndRegionOperation +com.pubnub.api.builder.dto.UnsubscribeOperation:com.pubnub.api.java.builder.dto.UnsubscribeOperation +com.pubnub.api.builder.dto.UnsubscribeOperation.UnsubscribeOperationBuilder:com.pubnub.api.java.builder.dto.UnsubscribeOperation.UnsubscribeOperationBuilder +com.pubnub.api.callbacks.PNCallback:com.pubnub.api.java.callbacks.PNCallback +com.pubnub.api.callbacks.SubscribeCallback:com.pubnub.api.java.callbacks.SubscribeCallback +com.pubnub.api.callbacks.SubscribeCallback.BaseSubscribeCallback:com.pubnub.api.java.callbacks.SubscribeCallback.BaseSubscribeCallback +com.pubnub.api.endpoints.BuilderSteps:com.pubnub.api.java.endpoints.BuilderSteps +com.pubnub.api.endpoints.BuilderSteps.ChannelStep:com.pubnub.api.java.endpoints.BuilderSteps.ChannelStep +com.pubnub.api.endpoints.DeleteMessages:com.pubnub.api.java.endpoints.DeleteMessages +com.pubnub.api.endpoints.Endpoint:com.pubnub.api.java.endpoints.Endpoint +com.pubnub.api.endpoints.FetchMessages:com.pubnub.api.java.endpoints.FetchMessages +com.pubnub.api.endpoints.History:com.pubnub.api.java.endpoints.History +com.pubnub.api.endpoints.MessageCounts:com.pubnub.api.java.endpoints.MessageCounts +com.pubnub.api.endpoints.access.Grant:com.pubnub.api.java.endpoints.access.Grant +com.pubnub.api.endpoints.access.GrantToken:com.pubnub.api.java.endpoints.access.GrantToken +com.pubnub.api.endpoints.access.RevokeToken:com.pubnub.api.java.endpoints.access.RevokeToken +com.pubnub.api.endpoints.access.builder.AbstractGrantTokenBuilder:com.pubnub.api.java.endpoints.access.builder.AbstractGrantTokenBuilder +com.pubnub.api.endpoints.access.builder.GrantTokenBuilder:com.pubnub.api.java.endpoints.access.builder.GrantTokenBuilder +com.pubnub.api.endpoints.access.builder.GrantTokenEntitiesBuilder:com.pubnub.api.java.endpoints.access.builder.GrantTokenEntitiesBuilder +com.pubnub.api.endpoints.access.builder.GrantTokenObjectsBuilder:com.pubnub.api.java.endpoints.access.builder.GrantTokenObjectsBuilder +com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup:com.pubnub.api.java.endpoints.channel_groups.AddChannelChannelGroup +com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup:com.pubnub.api.java.endpoints.channel_groups.AllChannelsChannelGroup +com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup:com.pubnub.api.java.endpoints.channel_groups.DeleteChannelGroup +com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup:com.pubnub.api.java.endpoints.channel_groups.RemoveChannelChannelGroup +com.pubnub.api.endpoints.files.DeleteFile:com.pubnub.api.java.endpoints.files.DeleteFile +com.pubnub.api.endpoints.files.DeleteFile.Builder:com.pubnub.api.java.endpoints.files.DeleteFile.Builder +com.pubnub.api.endpoints.files.DownloadFile:com.pubnub.api.java.endpoints.files.DownloadFile +com.pubnub.api.endpoints.files.DownloadFile.Builder:com.pubnub.api.java.endpoints.files.DownloadFile.Builder +com.pubnub.api.endpoints.files.GetFileUrl:com.pubnub.api.java.endpoints.files.GetFileUrl +com.pubnub.api.endpoints.files.GetFileUrl.Builder:com.pubnub.api.java.endpoints.files.GetFileUrl.Builder +com.pubnub.api.endpoints.files.ListFiles:com.pubnub.api.java.endpoints.files.ListFiles +com.pubnub.api.endpoints.files.ListFiles.Builder:com.pubnub.api.java.endpoints.files.ListFiles.Builder +com.pubnub.api.endpoints.files.PublishFileMessage:com.pubnub.api.java.endpoints.files.PublishFileMessage +com.pubnub.api.endpoints.files.PublishFileMessage.Builder:com.pubnub.api.java.endpoints.files.PublishFileMessage.Builder +com.pubnub.api.endpoints.files.SendFile:com.pubnub.api.java.endpoints.files.SendFile +com.pubnub.api.endpoints.files.SendFile.Builder:com.pubnub.api.java.endpoints.files.SendFile.Builder +com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps:com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps +com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileIdStep:com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileIdStep +com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileNameStep:com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileNameStep +com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps.InputStreamStep:com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps.InputStreamStep +com.pubnub.api.endpoints.message_actions.AddMessageAction:com.pubnub.api.java.endpoints.message_actions.AddMessageAction +com.pubnub.api.endpoints.message_actions.GetMessageActions:com.pubnub.api.java.endpoints.message_actions.GetMessageActions +com.pubnub.api.endpoints.message_actions.RemoveMessageAction:com.pubnub.api.java.endpoints.message_actions.RemoveMessageAction +com.pubnub.api.endpoints.objects_api.channel.GetAllChannelsMetadata:com.pubnub.api.java.endpoints.objects_api.channel.GetAllChannelsMetadata +com.pubnub.api.endpoints.objects_api.channel.GetChannelMetadata:com.pubnub.api.java.endpoints.objects_api.channel.GetChannelMetadata +com.pubnub.api.endpoints.objects_api.channel.GetChannelMetadata.Builder:com.pubnub.api.java.endpoints.objects_api.channel.GetChannelMetadata.Builder +com.pubnub.api.endpoints.objects_api.channel.RemoveChannelMetadata:com.pubnub.api.java.endpoints.objects_api.channel.RemoveChannelMetadata +com.pubnub.api.endpoints.objects_api.channel.RemoveChannelMetadata.Builder:com.pubnub.api.java.endpoints.objects_api.channel.RemoveChannelMetadata.Builder +com.pubnub.api.endpoints.objects_api.channel.SetChannelMetadata:com.pubnub.api.java.endpoints.objects_api.channel.SetChannelMetadata +com.pubnub.api.endpoints.objects_api.channel.SetChannelMetadata.Builder:com.pubnub.api.java.endpoints.objects_api.channel.SetChannelMetadata.Builder +com.pubnub.api.endpoints.objects_api.members.GetChannelMembers:com.pubnub.api.java.endpoints.objects_api.members.GetChannelMembers +com.pubnub.api.endpoints.objects_api.members.GetChannelMembers.Builder:com.pubnub.api.java.endpoints.objects_api.members.GetChannelMembers.Builder +com.pubnub.api.endpoints.objects_api.members.ManageChannelMembers:com.pubnub.api.java.endpoints.objects_api.members.ManageChannelMembers +com.pubnub.api.endpoints.objects_api.members.ManageChannelMembers.Builder:com.pubnub.api.java.endpoints.objects_api.members.ManageChannelMembers.Builder +com.pubnub.api.endpoints.objects_api.members.RemoveChannelMembers:com.pubnub.api.java.endpoints.objects_api.members.RemoveChannelMembers +com.pubnub.api.endpoints.objects_api.members.RemoveChannelMembers.Builder:com.pubnub.api.java.endpoints.objects_api.members.RemoveChannelMembers.Builder +com.pubnub.api.endpoints.objects_api.members.SetChannelMembers:com.pubnub.api.java.endpoints.objects_api.members.SetChannelMembers +com.pubnub.api.endpoints.objects_api.members.SetChannelMembers.Builder:com.pubnub.api.java.endpoints.objects_api.members.SetChannelMembers.Builder +com.pubnub.api.endpoints.objects_api.memberships.GetMemberships:com.pubnub.api.java.endpoints.objects_api.memberships.GetMemberships +com.pubnub.api.endpoints.objects_api.memberships.ManageMemberships:com.pubnub.api.java.endpoints.objects_api.memberships.ManageMemberships +com.pubnub.api.endpoints.objects_api.memberships.ManageMemberships.Builder:com.pubnub.api.java.endpoints.objects_api.memberships.ManageMemberships.Builder +com.pubnub.api.endpoints.objects_api.memberships.RemoveMemberships:com.pubnub.api.java.endpoints.objects_api.memberships.RemoveMemberships +com.pubnub.api.endpoints.objects_api.memberships.RemoveMemberships.Builder:com.pubnub.api.java.endpoints.objects_api.memberships.RemoveMemberships.Builder +com.pubnub.api.endpoints.objects_api.memberships.SetMemberships:com.pubnub.api.java.endpoints.objects_api.memberships.SetMemberships +com.pubnub.api.endpoints.objects_api.memberships.SetMemberships.Builder:com.pubnub.api.java.endpoints.objects_api.memberships.SetMemberships.Builder +com.pubnub.api.endpoints.objects_api.utils.Include:com.pubnub.api.java.endpoints.objects_api.utils.Include +com.pubnub.api.endpoints.objects_api.utils.Include.PNChannelDetailsLevel:com.pubnub.api.java.endpoints.objects_api.utils.Include.PNChannelDetailsLevel +com.pubnub.api.endpoints.objects_api.utils.Include.PNUUIDDetailsLevel:com.pubnub.api.java.endpoints.objects_api.utils.Include.PNUUIDDetailsLevel +com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps:com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps +com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps.ChannelMembershipsStep:com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps.ChannelMembershipsStep +com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps.RemoveOrSetStep:com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps.RemoveOrSetStep +com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps.RemoveOrSetStep.RemoveStep:com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps.RemoveOrSetStep.RemoveStep +com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps.RemoveOrSetStep.SetStep:com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps.RemoveOrSetStep.SetStep +com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps.UUIDsStep:com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps.UUIDsStep +com.pubnub.api.endpoints.objects_api.utils.PNSortKey:com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey +com.pubnub.api.endpoints.objects_api.utils.PNSortKey.Dir:com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey.Dir +com.pubnub.api.endpoints.objects_api.utils.PNSortKey.Key:com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey.Key +com.pubnub.api.endpoints.objects_api.uuid.GetAllUUIDMetadata:com.pubnub.api.java.endpoints.objects_api.uuid.GetAllUUIDMetadata +com.pubnub.api.endpoints.objects_api.uuid.GetUUIDMetadata:com.pubnub.api.java.endpoints.objects_api.uuid.GetUUIDMetadata +com.pubnub.api.endpoints.objects_api.uuid.RemoveUUIDMetadata:com.pubnub.api.java.endpoints.objects_api.uuid.RemoveUUIDMetadata +com.pubnub.api.endpoints.objects_api.uuid.SetUUIDMetadata:com.pubnub.api.java.endpoints.objects_api.uuid.SetUUIDMetadata +com.pubnub.api.endpoints.presence.GetState:com.pubnub.api.java.endpoints.presence.GetState +com.pubnub.api.endpoints.presence.Heartbeat:com.pubnub.api.java.endpoints.presence.Heartbeat +com.pubnub.api.endpoints.presence.HereNow:com.pubnub.api.java.endpoints.presence.HereNow +com.pubnub.api.endpoints.presence.Leave:com.pubnub.api.java.endpoints.presence.Leave +com.pubnub.api.endpoints.presence.SetState:com.pubnub.api.java.endpoints.presence.SetState +com.pubnub.api.endpoints.presence.WhereNow:com.pubnub.api.java.endpoints.presence.WhereNow +com.pubnub.api.endpoints.pubsub.Publish:com.pubnub.api.java.endpoints.pubsub.Publish +com.pubnub.api.endpoints.pubsub.Signal:com.pubnub.api.java.endpoints.pubsub.Signal +com.pubnub.api.endpoints.push.AddChannelsToPush:com.pubnub.api.java.endpoints.push.AddChannelsToPush +com.pubnub.api.endpoints.push.ListPushProvisions:com.pubnub.api.java.endpoints.push.ListPushProvisions +com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice:com.pubnub.api.java.endpoints.push.RemoveAllPushChannelsForDevice +com.pubnub.api.endpoints.push.RemoveChannelsFromPush:com.pubnub.api.java.endpoints.push.RemoveChannelsFromPush +com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult:com.pubnub.api.java.models.consumer.access_manager.PNAccessManagerGrantResult +com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult.PNAccessManagerGrantResultBuilder:com.pubnub.api.java.models.consumer.access_manager.PNAccessManagerGrantResult.PNAccessManagerGrantResultBuilder +com.pubnub.api.models.consumer.access_manager.PNAccessManagerKeyData:com.pubnub.api.java.models.consumer.access_manager.PNAccessManagerKeyData +com.pubnub.api.models.consumer.access_manager.PNAccessManagerKeyData.PNAccessManagerKeyDataBuilder:com.pubnub.api.java.models.consumer.access_manager.PNAccessManagerKeyData.PNAccessManagerKeyDataBuilder +com.pubnub.api.models.consumer.access_manager.PNAccessManagerKeysData:com.pubnub.api.java.models.consumer.access_manager.PNAccessManagerKeysData +com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions:com.pubnub.api.java.models.consumer.access_manager.sum.SpacePermissions +com.pubnub.api.models.consumer.access_manager.sum.UserPermissions:com.pubnub.api.java.models.consumer.access_manager.sum.UserPermissions +com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant:com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGrant +com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant:com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGroupGrant +com.pubnub.api.models.consumer.access_manager.v3.PNResource:com.pubnub.api.java.models.consumer.access_manager.v3.PNResource +com.pubnub.api.models.consumer.access_manager.v3.PNRevokeTokenResult:com.pubnub.api.java.models.consumer.access_manager.v3.PNRevokeTokenResult +com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant:com.pubnub.api.java.models.consumer.access_manager.v3.UUIDGrant +com.pubnub.api.models.consumer.objects_api.EntityArrayEnvelope:com.pubnub.api.java.models.consumer.objects_api.EntityArrayEnvelope +com.pubnub.api.models.consumer.objects_api.EntityEnvelope:com.pubnub.api.java.models.consumer.objects_api.EntityEnvelope +com.pubnub.api.models.consumer.objects_api.PNObject:com.pubnub.api.java.models.consumer.objects_api.PNObject +com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadata:com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadata +com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult:com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadataResult +com.pubnub.api.models.consumer.objects_api.channel.PNGetAllChannelsMetadataResult:com.pubnub.api.java.models.consumer.objects_api.channel.PNGetAllChannelsMetadataResult +com.pubnub.api.models.consumer.objects_api.channel.PNGetChannelMetadataResult:com.pubnub.api.java.models.consumer.objects_api.channel.PNGetChannelMetadataResult +com.pubnub.api.models.consumer.objects_api.channel.PNRemoveChannelMetadataResult:com.pubnub.api.java.models.consumer.objects_api.channel.PNRemoveChannelMetadataResult +com.pubnub.api.models.consumer.objects_api.channel.PNSetChannelMetadataResult:com.pubnub.api.java.models.consumer.objects_api.channel.PNSetChannelMetadataResult +com.pubnub.api.models.consumer.objects_api.member.PNGetChannelMembersResult:com.pubnub.api.java.models.consumer.objects_api.member.PNGetChannelMembersResult +com.pubnub.api.models.consumer.objects_api.member.PNManageChannelMembersResult:com.pubnub.api.java.models.consumer.objects_api.member.PNManageChannelMembersResult +com.pubnub.api.models.consumer.objects_api.member.PNMembers:com.pubnub.api.java.models.consumer.objects_api.member.PNMembers +com.pubnub.api.models.consumer.objects_api.member.PNRemoveChannelMembersResult:com.pubnub.api.java.models.consumer.objects_api.member.PNRemoveChannelMembersResult +com.pubnub.api.models.consumer.objects_api.member.PNSetChannelMembersResult:com.pubnub.api.java.models.consumer.objects_api.member.PNSetChannelMembersResult +com.pubnub.api.models.consumer.objects_api.member.PNUUID:com.pubnub.api.java.models.consumer.objects_api.member.PNUUID +com.pubnub.api.models.consumer.objects_api.member.PNUUID.UUIDId:com.pubnub.api.java.models.consumer.objects_api.member.PNUUID.UUIDId +com.pubnub.api.models.consumer.objects_api.member.PNUUID.UUIDWithCustom:com.pubnub.api.java.models.consumer.objects_api.member.PNUUID.UUIDWithCustom +com.pubnub.api.models.consumer.objects_api.member.PNUUID.UUIDWithoutCustom:com.pubnub.api.java.models.consumer.objects_api.member.PNUUID.UUIDWithoutCustom +com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership:com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership +com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership.ChannelId:com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership.ChannelId +com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership.ChannelWithCustom:com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership.ChannelWithCustom +com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership.JustChannel:com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership.JustChannel +com.pubnub.api.models.consumer.objects_api.membership.PNGetMembershipsResult:com.pubnub.api.java.models.consumer.objects_api.membership.PNGetMembershipsResult +com.pubnub.api.models.consumer.objects_api.membership.PNManageMembershipResult:com.pubnub.api.java.models.consumer.objects_api.membership.PNManageMembershipResult +com.pubnub.api.models.consumer.objects_api.membership.PNMembership:com.pubnub.api.java.models.consumer.objects_api.membership.PNMembership +com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult:com.pubnub.api.java.models.consumer.objects_api.membership.PNMembershipResult +com.pubnub.api.models.consumer.objects_api.membership.PNRemoveMembershipResult:com.pubnub.api.java.models.consumer.objects_api.membership.PNRemoveMembershipResult +com.pubnub.api.models.consumer.objects_api.membership.PNSetMembershipResult:com.pubnub.api.java.models.consumer.objects_api.membership.PNSetMembershipResult +com.pubnub.api.models.consumer.objects_api.uuid.PNGetAllUUIDMetadataResult:com.pubnub.api.java.models.consumer.objects_api.uuid.PNGetAllUUIDMetadataResult +com.pubnub.api.models.consumer.objects_api.uuid.PNGetUUIDMetadataResult:com.pubnub.api.java.models.consumer.objects_api.uuid.PNGetUUIDMetadataResult +com.pubnub.api.models.consumer.objects_api.uuid.PNRemoveUUIDMetadataResult:com.pubnub.api.java.models.consumer.objects_api.uuid.PNRemoveUUIDMetadataResult +com.pubnub.api.models.consumer.objects_api.uuid.PNSetUUIDMetadataResult:com.pubnub.api.java.models.consumer.objects_api.uuid.PNSetUUIDMetadataResult +com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadata:com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadata +com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult:com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadataResult +com.pubnub.api.v2.PNConfiguration:com.pubnub.api.java.v2.PNConfiguration +com.pubnub.api.v2.PNConfiguration.Builder:com.pubnub.api.java.v2.PNConfiguration.Builder +com.pubnub.api.v2.PNConfiguration.Companion:com.pubnub.api.java.v2.PNConfiguration.Companion +com.pubnub.api.v2.PNConfigurationOverride:com.pubnub.api.java.v2.PNConfigurationOverride +com.pubnub.api.v2.PNConfigurationOverride.Builder:com.pubnub.api.java.v2.PNConfigurationOverride.Builder +com.pubnub.api.v2.PNConfigurationOverride.Companion:com.pubnub.api.java.v2.PNConfigurationOverride.Companion +com.pubnub.api.v2.callbacks.EventEmitter:com.pubnub.api.java.v2.callbacks.EventEmitter +com.pubnub.api.v2.callbacks.EventListener:com.pubnub.api.java.v2.callbacks.EventListener +com.pubnub.api.v2.callbacks.StatusEmitter:com.pubnub.api.java.v2.callbacks.StatusEmitter +com.pubnub.api.v2.callbacks.StatusListener:com.pubnub.api.java.v2.callbacks.StatusListener +com.pubnub.api.v2.callbacks.handlers.OnChannelMetadataHandler:com.pubnub.api.java.v2.callbacks.handlers.OnChannelMetadataHandler +com.pubnub.api.v2.callbacks.handlers.OnFileHandler:com.pubnub.api.java.v2.callbacks.handlers.OnFileHandler +com.pubnub.api.v2.callbacks.handlers.OnMembershipHandler:com.pubnub.api.java.v2.callbacks.handlers.OnMembershipHandler +com.pubnub.api.v2.callbacks.handlers.OnMessageActionHandler:com.pubnub.api.java.v2.callbacks.handlers.OnMessageActionHandler +com.pubnub.api.v2.callbacks.handlers.OnMessageHandler:com.pubnub.api.java.v2.callbacks.handlers.OnMessageHandler +com.pubnub.api.v2.callbacks.handlers.OnPresenceHandler:com.pubnub.api.java.v2.callbacks.handlers.OnPresenceHandler +com.pubnub.api.v2.callbacks.handlers.OnSignalHandler:com.pubnub.api.java.v2.callbacks.handlers.OnSignalHandler +com.pubnub.api.v2.callbacks.handlers.OnUuidMetadataHandler:com.pubnub.api.java.v2.callbacks.handlers.OnUuidMetadataHandler +com.pubnub.api.v2.endpoints.pubsub.PublishBuilder:com.pubnub.api.java.v2.endpoints.pubsub.PublishBuilder +com.pubnub.api.v2.endpoints.pubsub.SignalBuilder:com.pubnub.api.java.v2.endpoints.pubsub.SignalBuilder +com.pubnub.api.v2.entities.Channel:com.pubnub.api.java.v2.entities.Channel +com.pubnub.api.v2.entities.ChannelGroup:com.pubnub.api.java.v2.entities.ChannelGroup +com.pubnub.api.v2.entities.ChannelMetadata:com.pubnub.api.java.v2.entities.ChannelMetadata +com.pubnub.api.v2.entities.Subscribable:com.pubnub.api.java.v2.entities.Subscribable +com.pubnub.api.v2.entities.UserMetadata:com.pubnub.api.java.v2.entities.UserMetadata +com.pubnub.api.v2.subscriptions.Subscription:com.pubnub.api.java.v2.subscriptions.Subscription +com.pubnub.api.v2.subscriptions.SubscriptionSet:com.pubnub.api.java.v2.subscriptions.SubscriptionSet \ No newline at end of file diff --git a/migration_utils/upgrade_v10.sh b/migration_utils/upgrade_v10.sh new file mode 100755 index 000000000..de46a6c2b --- /dev/null +++ b/migration_utils/upgrade_v10.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +# Main script +if [ $# -lt 1 ]; then + echo "Usage: $0 [-d]" + exit 1 +fi + +dry_run=false +replacements_file="replacements.txt" +directory="$1" + +# Check for dry run flag +shift 1 +while [[ $# -gt 0 ]]; do + case "$1" in + -d|--dry-run) + dry_run=true + ;; + *) + echo "Unknown option: $1" + exit 1 + ;; + esac + shift +done + +# Read replacements from file +while IFS= read -r line; do + if [[ $line =~ ^([^:]+):(.+)$ ]]; then + search="${BASH_REMATCH[1]}" + replace="${BASH_REMATCH[2]}" + echo "Replacing '$search' with '$replace'" + + # Find all files and apply the replacement or print + find "$directory" -type f -print0 | xargs -0 -n 1 ./replace_in_file.sh "$search" "$replace" "$dry_run" | sort -u + fi +done < "$replacements_file" \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/build.gradle.kts b/pubnub-core/pubnub-core-api/build.gradle.kts deleted file mode 100644 index 23007352e..000000000 --- a/pubnub-core/pubnub-core-api/build.gradle.kts +++ /dev/null @@ -1,34 +0,0 @@ -plugins { - alias(libs.plugins.benmanes.versions) - id("pubnub.shared") - id("pubnub.dokka") - id("pubnub.multiplatform") - alias(libs.plugins.kotlinx.atomicfu) -} - -kotlin { - sourceSets { - val commonMain by getting { - dependencies { - implementation(libs.kotlinx.atomicfu) - } - } - - val jvmMain by getting { - dependencies { - api(libs.retrofit2) - api(libs.okhttp) - api(libs.okhttp.logging) - api(libs.json) - api(libs.gson) - implementation(libs.slf4j) - } - } - - val commonTest by getting { - dependencies { - implementation(kotlin("test")) - } - } - } -} diff --git a/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml b/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml deleted file mode 100644 index 981420778..000000000 --- a/pubnub-core/pubnub-core-api/config/ktlint/baseline.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/pubnub-core/pubnub-core-api/pubnub_core_api.podspec b/pubnub-core/pubnub-core-api/pubnub_core_api.podspec deleted file mode 100644 index df6fb5bc6..000000000 --- a/pubnub-core/pubnub-core-api/pubnub_core_api.podspec +++ /dev/null @@ -1,54 +0,0 @@ -Pod::Spec.new do |spec| - spec.name = 'pubnub_core_api' - spec.version = '9.2.3' - spec.homepage = '' - spec.source = { :http=> ''} - spec.authors = '' - spec.license = '' - spec.summary = '' - spec.vendored_frameworks = 'build/cocoapods/framework/pubnub_core_api.framework' - spec.libraries = 'c++' - spec.ios.deployment_target = '14' - spec.dependency 'PubNubSwift' - - if !Dir.exist?('build/cocoapods/framework/pubnub_core_api.framework') || Dir.empty?('build/cocoapods/framework/pubnub_core_api.framework') - raise " - - Kotlin framework 'pubnub_core_api' doesn't exist yet, so a proper Xcode project can't be generated. - 'pod install' should be executed after running ':generateDummyFramework' Gradle task: - - ./gradlew :pubnub-core:pubnub-core-api:generateDummyFramework - - Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" - end - - spec.xcconfig = { - 'ENABLE_USER_SCRIPT_SANDBOXING' => 'NO', - } - - spec.pod_target_xcconfig = { - 'KOTLIN_PROJECT_PATH' => ':pubnub-core:pubnub-core-api', - 'PRODUCT_MODULE_NAME' => 'pubnub_core_api', - } - - spec.script_phases = [ - { - :name => 'Build pubnub_core_api', - :execution_position => :before_compile, - :shell_path => '/bin/sh', - :script => <<-SCRIPT - if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then - echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" - exit 0 - fi - set -ev - REPO_ROOT="$PODS_TARGET_SRCROOT" - "$REPO_ROOT/../../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ - -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ - -Pkotlin.native.cocoapods.archs="$ARCHS" \ - -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" - SCRIPT - } - ] - -end \ No newline at end of file diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventListener.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventListener.kt deleted file mode 100644 index 398cfcc6a..000000000 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventListener.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.api.v2.callbacks - -import com.pubnub.api.callbacks.Listener - -interface BaseEventListener : Listener diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusEmitter.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusEmitter.kt deleted file mode 100644 index c873abfd1..000000000 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusEmitter.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.pubnub.api.v2.callbacks - -import com.pubnub.api.callbacks.Listener - -interface BaseStatusEmitter { - /** - * Add a listener. - * - * @param listener The listener to be added. - */ - fun addListener(listener: T) - - /** - * Remove a listener. - * - * @param listener The listener to be removed, previously added with [addListener]. - */ - fun removeListener(listener: Listener) - - /** - * Removes all listeners. - */ - fun removeAllListeners() -} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusListener.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusListener.kt deleted file mode 100644 index b2517ca00..000000000 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseStatusListener.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.api.v2.callbacks - -import com.pubnub.api.callbacks.Listener - -interface BaseStatusListener : Listener diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannel.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannel.kt deleted file mode 100644 index 55381627a..000000000 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannel.kt +++ /dev/null @@ -1,39 +0,0 @@ -package com.pubnub.api.v2.entities - -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.SubscriptionOptions - -/** - * A representation of a PubNub channel identified by its [name]. - * - * You can get a [Subscription] to this channel through [subscription]. - * - * Use the [com.pubnub.api.PubNub.channel] factory method to create instances of this interface. - */ -interface BaseChannel> : Subscribable { - /** - * The name of this channel. Supports wildcards by ending it with ".*" - * - * See more in the [documentation](https://www.pubnub.com/docs/general/channels/overview) - */ - val name: String - - /** - * Returns a [Subscription] that can be used to subscribe to this channel. - * - * Channel subscriptions support passing [com.pubnub.api.v2.subscriptions.SubscriptionOptions.receivePresenceEvents] in - * [options] to enable receiving presence events. - * - * [com.pubnub.api.v2.subscriptions.SubscriptionOptions.filter] can be used to filter events delivered to the subscription. - * - * For example, to create a subscription that only listens to presence events: - * ``` - * channel.subscription(SubscriptionOptions.receivePresenceEvents() + SubscriptionOptions.filter { it is PNPresenceEventResult } ) - * ``` - * - * @param options optional [SubscriptionOptions]. - * @return an inactive [Subscription] to this channel. You must call [Subscription.subscribe] to start receiving events. - */ - override fun subscription(options: SubscriptionOptions): Subscription -} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelMetadata.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelMetadata.kt deleted file mode 100644 index b5e437d91..000000000 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelMetadata.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.pubnub.api.v2.entities - -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.SubscriptionOptions - -interface BaseChannelMetadata> : Subscribable { - /** - * The id for this channel metadata object. - * - * See more in the [documentation](https://www.pubnub.com/docs/general/metadata/channel-metadata) - */ - val id: String - - /** - * Returns a [Subscription] that can be used to subscribe to this channel metadata. - * - * [com.pubnub.api.v2.subscriptions.SubscriptionOptions.filter] can be used to filter events delivered to the subscription. - * - * @param options optional [SubscriptionOptions]. - * @return an inactive [Subscription] to this channel metadata. You must call [Subscription.subscribe] to start receiving events. - */ - override fun subscription(options: SubscriptionOptions): Sub -} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseUserMetadata.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseUserMetadata.kt deleted file mode 100644 index 550a6e1e2..000000000 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseUserMetadata.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.pubnub.api.v2.entities - -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.SubscriptionOptions - -interface BaseUserMetadata> : Subscribable { - /** - * The id for this user metadata object. - * - * See more in the [documentation](https://www.pubnub.com/docs/general/metadata/users-metadata) - */ - val id: String - - /** - * Returns a [Subscription] that can be used to subscribe to this user metadata. - * - * [com.pubnub.api.v2.subscriptions.SubscriptionOptions.filter] can be used to filter events delivered to the subscription. - * - * @param options optional [SubscriptionOptions]. - * @return an inactive [Subscription] to this user metadata. You must call [Subscription.subscribe] to start receiving events. - */ - override fun subscription(options: SubscriptionOptions): Sub -} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt deleted file mode 100644 index e51aeeae0..000000000 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscription.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.pubnub.api.v2.subscriptions - -import com.pubnub.api.v2.callbacks.BaseEventEmitter -import com.pubnub.api.v2.callbacks.BaseEventListener - -/** - * Represents a potential subscription to the PubNub real-time network. - * - * Create objects of this class through the [com.pubnub.api.v2.entities.Subscribable.subscription] method of the - * respective entities, such as [com.pubnub.api.v2.entities.BaseChannel], [com.pubnub.api.v2.entities.BaseChannelGroup], - * [com.pubnub.api.v2.entities.BaseChannelMetadata] and [com.pubnub.api.v2.entities.BaseUserMetadata]. - * - * Created subscriptions are initially inactive, which means you must call [subscribe] to start receiving events. - * - * This class implements the [AutoCloseable] interface to help you release resources by calling [unsubscribe] - * and removing all listeners on [close]. Remember to always call [close] when you no longer need this Subscription. - */ -interface BaseSubscription : BaseEventEmitter, SubscribeCapable, AutoCloseable diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscriptionSet.kt b/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscriptionSet.kt deleted file mode 100644 index 42bc039f3..000000000 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/BaseSubscriptionSet.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.pubnub.api.v2.subscriptions - -import com.pubnub.api.v2.callbacks.BaseEventEmitter -import com.pubnub.api.v2.callbacks.BaseEventListener - -@OptIn(ExperimentalStdlibApi::class) -interface BaseSubscriptionSet< - EvLis : BaseEventListener, - Subscription : BaseSubscription, - > : BaseEventEmitter, SubscribeCapable, AutoCloseable { - /** - * Add a [Subscription] to this set. - * - * Please note that this SubscriptionSet will *not* attempt to ensure all subscriptions match their - * active/inactive state. That is, if you previously called [subscribe] or [unsubscribe] on this set, it will not be - * called on the newly added [subscription] automatically. - * - * @param subscription the [Subscription] to add. - */ - fun add(subscription: Subscription) - - /** - * Remove the [subscription] from this set. - * - * Please note that removing a subscription from the set does not automatically [unsubscribe] or [close] it. - * - * @param subscription the [Subscription] to remove. - */ - fun remove(subscription: Subscription) - - /** - * Returns an immutable copy of the set of subscriptions contained in this [BaseSubscriptionSet]. - */ - val subscriptions: Set -} diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.ios.kt b/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.ios.kt deleted file mode 100644 index f039ced59..000000000 --- a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.ios.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.pubnub.api.models.consumer.message_actions - -import com.pubnub.api.models.consumer.PNBoundedPage - -actual class PNGetMessageActionsResult actual constructor( - actual val actions: List, - actual val page: PNBoundedPage?, -) diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt deleted file mode 100644 index c40011758..000000000 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/BasePubNub.kt +++ /dev/null @@ -1,229 +0,0 @@ -package com.pubnub.api - -import com.pubnub.api.models.consumer.access_manager.v3.PNToken -import com.pubnub.api.v2.callbacks.BaseEventEmitter -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.callbacks.BaseStatusEmitter -import com.pubnub.api.v2.callbacks.BaseStatusListener -import com.pubnub.api.v2.entities.BaseChannel -import com.pubnub.api.v2.entities.BaseChannelGroup -import com.pubnub.api.v2.entities.BaseChannelMetadata -import com.pubnub.api.v2.entities.BaseUserMetadata -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.BaseSubscriptionSet -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import java.io.InputStream - -interface BasePubNub< - EventListener : BaseEventListener, - Subscription : BaseSubscription, - Channel : BaseChannel, - ChannelGroup : BaseChannelGroup, - ChannelMetadata : BaseChannelMetadata, - UserMetadata : BaseUserMetadata, - SubscriptionSet : BaseSubscriptionSet, - StatusListener : BaseStatusListener, - > : BaseEventEmitter, BaseStatusEmitter { - val timestamp: Int - val baseUrl: String - - /** - * The current version of the PubNub SDK. - */ - val version: String - - /** - * Create a handle to a [Channel] that can be used to obtain a [Subscription]. - * - * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server - * state. It is therefore permitted to use this method whenever a representation of a channel is required. - * - * The returned [Channel] holds a reference to this [PubNub] instance internally. - * - * @param name the name of the channel to return. Supports wildcards by ending it with ".*". See more in the - * [documentation](https://www.pubnub.com/docs/general/channels/overview) - * - * @return a [Channel] instance representing the channel with the given [name] - */ - fun channel(name: String): Channel - - /** - * Create a handle to a [ChannelGroup] that can be used to obtain a [Subscription]. - * - * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server - * state. It is therefore permitted to use this method whenever a representation of a channel group is required. - * - * The returned [ChannelGroup] holds a reference to this [PubNub] instance internally. - * - * @param name the name of the channel group to return. See more in the - * [documentation](https://www.pubnub.com/docs/general/channels/subscribe#channel-groups) - * - * @return a [ChannelGroup] instance representing the channel group with the given [name] - */ - fun channelGroup(name: String): ChannelGroup - - /** - * Create a handle to a [ChannelMetadata] object that can be used to obtain a [Subscription] to metadata events. - * - * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server - * state. It is therefore permitted to use this method whenever a representation of a metadata channel is required. - * - * The returned [ChannelMetadata] holds a reference to this [PubNub] instance internally. - * - * @param id the id of the channel metadata to return. See more in the - * [documentation](https://www.pubnub.com/docs/general/metadata/channel-metadata) - * - * @return a [ChannelMetadata] instance representing the channel metadata with the given [id] - */ - fun channelMetadata(id: String): ChannelMetadata - - /** - * Create a handle to a [UserMetadata] object that can be used to obtain a [Subscription] to user metadata events. - * - * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server - * state. It is therefore permitted to use this method whenever a representation of a user metadata is required. - * - * The returned [UserMetadata] holds a reference to this [PubNub] instance internally. - * - * @param id the id of the user. See more in the - * [documentation](https://www.pubnub.com/docs/general/metadata/users-metadata) - * - * @return a [UserMetadata] instance representing the channel metadata with the given [id] - */ - fun userMetadata(id: String): UserMetadata - - /** - * Create a [SubscriptionSet] from the given [subscriptions]. - * - * @param subscriptions the subscriptions that will be added to the returned [SubscriptionSet] - * @return a [SubscriptionSet] containing all [subscriptions] - */ - fun subscriptionSetOf(subscriptions: Set): SubscriptionSet - - /** - * Create a [SubscriptionSet] containing [Subscription] objects for the given sets of [channels] and - * [channelGroups]. - * - * Please note that the subscriptions are not active until you call [SubscriptionSet.subscribe]. - * - * This is a convenience method, and it is equal to calling [PubNub.channel] followed by [Channel.subscription] for - * each channel, then creating a [subscriptionSetOf] using the returned [Subscription] objects (and similarly for - * channel groups). - * - * @param channels the channels to create subscriptions for - * @param channelGroups the channel groups to create subscriptions for - * @param options the [SubscriptionOptions] to pass for each subscription. Refer to supported options in [Channel] and - * [ChannelGroup] documentation. - * @return a [SubscriptionSet] containing subscriptions for the given [channels] and [channelGroups] - */ - fun subscriptionSetOf( - channels: Set, - channelGroups: Set, - options: SubscriptionOptions, - ): SubscriptionSet - - /** - * Perform Cryptographic decryption of an input string using cipher key provided by [PNConfiguration.cipherKey]. - * - * @param inputString String to be decrypted. - * - * @return String containing the decryption of `inputString` using `cipherKey`. - * @throws PubNubException throws exception in case of failed decryption. - */ - @Throws(PubNubException::class) - fun decrypt(inputString: String): String - - /** - * Perform Cryptographic decryption of an input string using a cipher key. - * - * @param inputString String to be decrypted. - * @param cipherKey cipher key to be used for decryption. Default is [PNConfiguration.cipherKey] - * - * @return String containing the decryption of `inputString` using `cipherKey`. - * @throws PubNubException throws exception in case of failed decryption. - */ - @Throws(PubNubException::class) - fun decrypt( - inputString: String, - cipherKey: String? = null, - ): String - - /** - * Perform Cryptographic decryption of an input stream using provided cipher key. - * - * @param inputStream InputStream to be encrypted. - * @param cipherKey Cipher key to be used for decryption. - * - * @return InputStream containing the encryption of `inputStream` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed decryption. - */ - @Throws(PubNubException::class) - fun decryptInputStream( - inputStream: InputStream, - cipherKey: String? = null, - ): InputStream - - /** - * Perform Cryptographic encryption of an input string and a cipher key. - * - * @param inputString String to be encrypted. - * @param cipherKey Cipher key to be used for encryption. Default is [PNConfiguration.cipherKey] - * - * @return String containing the encryption of `inputString` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed encryption. - */ - @Throws(PubNubException::class) - fun encrypt( - inputString: String, - cipherKey: String? = null, - ): String - - /** - * Perform Cryptographic encryption of an input stream using provided cipher key. - * - * @param inputStream InputStream to be encrypted. - * @param cipherKey Cipher key to be used for encryption. - * - * @return InputStream containing the encryption of `inputStream` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed encryption. - */ - @Throws(PubNubException::class) - fun encryptInputStream( - inputStream: InputStream, - cipherKey: String? = null, - ): InputStream - - @Throws(PubNubException::class) - fun parseToken(token: String): PNToken - - fun setToken(token: String?) - - /** - * Force the SDK to try and reach out PubNub. Monitor the results in [SubscribeCallback.status] - * - * @param timetoken optional timetoken to use for the subscriptions on reconnection. - */ - fun reconnect(timetoken: Long = 0L) - - /** - * Cancel any subscribe and heartbeat loops or ongoing re-connections. - * - * Monitor the results in [SubscribeCallback.status] - */ - fun disconnect() - - /** - * Unsubscribe from all channels and all channel groups - */ - fun unsubscribeAll() - - /** - * Frees up threads eventually and allows for a clean exit. - */ - fun destroy() - - /** - * Same as [destroy] but immediately. - */ - fun forceDestroy() -} diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/HasOverridableConfig.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/HasOverridableConfig.kt deleted file mode 100644 index d396500ce..000000000 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/HasOverridableConfig.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.pubnub.api.endpoints - -import com.pubnub.api.v2.BasePNConfiguration - -interface HasOverridableConfig { - fun overrideConfiguration(configuration: BasePNConfiguration) - - val configuration: BasePNConfiguration -} diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.jvm.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.jvm.kt deleted file mode 100644 index b03c50b2d..000000000 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.jvm.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.pubnub.api.models.consumer.message_actions - -import com.google.gson.annotations.SerializedName -import com.pubnub.api.models.consumer.PNBoundedPage - -actual class PNGetMessageActionsResult actual constructor( - @SerializedName("data") - actual val actions: List, - @SerializedName("more") - actual val page: PNBoundedPage?, -) diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfiguration.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfiguration.kt deleted file mode 100644 index a8c08a5f4..000000000 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfiguration.kt +++ /dev/null @@ -1,558 +0,0 @@ -package com.pubnub.api.v2 - -import com.pubnub.api.UserId -import com.pubnub.api.crypto.CryptoModule -import com.pubnub.api.enums.PNHeartbeatNotificationOptions -import com.pubnub.api.enums.PNLogVerbosity -import com.pubnub.api.retry.RetryConfiguration -import okhttp3.Authenticator -import okhttp3.CertificatePinner -import okhttp3.ConnectionSpec -import okhttp3.logging.HttpLoggingInterceptor -import java.net.Proxy -import java.net.ProxySelector -import javax.net.ssl.HostnameVerifier -import javax.net.ssl.SSLSocketFactory -import javax.net.ssl.X509ExtendedTrustManager - -/** - * A storage for user-provided information which describe further PubNub client behaviour. - * Configuration instance contains additional set of properties which - * allow performing precise PubNub client configuration. - * - */ -interface BasePNConfiguration : BasePNConfigurationOverride { - /** - * The user ID that the PubNub client will use. - */ - val userId: UserId - - /** - * The subscribe key from the admin panel. - */ - val subscribeKey: String - - /** - * The publish key from the admin panel (only required if publishing). - */ - val publishKey: String - - /** - * The secret key from the admin panel (only required for modifying/revealing access permissions). - * - * Keep away from Android. - */ - val secretKey: String - - /** - * If Access Manager is utilized, client will use this authKey in all restricted requests. - */ - val authKey: String - - /** - * CryptoModule is responsible for handling encryption and decryption. - * If set, all communications to and from PubNub will be encrypted. - */ - val cryptoModule: CryptoModule? - - /** - * Custom origin if needed. - * - * Defaults to `ps.pndsn.com` - */ - val origin: String - - /** - * If set to `true`, requests will be made over HTTPS. - * - * Deafults to `true`. - */ - val secure: Boolean - - /** - * Set to [PNLogVerbosity.BODY] to enable logging of network traffic, otherwise se to [PNLogVerbosity.NONE]. - */ - val logVerbosity: PNLogVerbosity - - /** - * Set Heartbeat notification options. - * - * By default, the SDK alerts on failed heartbeats (equivalent to [PNHeartbeatNotificationOptions.FAILURES]). - */ - val heartbeatNotificationOptions: PNHeartbeatNotificationOptions - - /** - * Sets the custom presence server timeout. - * - * The value is in seconds, and the minimum value is 20 seconds. - * - * Also sets the value of [heartbeatInterval] - */ - val presenceTimeout: Int - - /** - * How often the client will announce itself to server. - * - * The value is in seconds. - */ - val heartbeatInterval: Int - - /** - * The subscribe request timeout. - * - * The value is in seconds. - * - * Defaults to 310. - */ - val subscribeTimeout: Int - - /** - * How long before the client gives up trying to connect with the server. - * - * The value is in seconds. - * - * Defaults to 5. - */ - val connectTimeout: Int - - /** - * For non subscribe operations (publish, herenow, etc), - * This property relates to a read timeout that is applied from the moment the connection between a client - * and the server has been successfully established. It defines a maximum time of inactivity between two - * data packets when waiting for the server’s response. - * - * The value is in seconds. - * - * Defaults to 10. - */ - @Deprecated( - "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", - replaceWith = ReplaceWith("nonSubscribeReadTimeout") - ) - val nonSubscribeRequestTimeout: Int - get() = nonSubscribeReadTimeout - - /** - * For non subscribe operations (publish, herenow, etc), - * This property relates to a read timeout that is applied from the moment the connection between a client - * and the server has been successfully established. It defines a maximum time of inactivity between two - * data packets when waiting for the server’s response. - * - * The value is in seconds. - * - * Defaults to 10. - */ - val nonSubscribeReadTimeout: Int - - /** - * If operating behind a misbehaving proxy, allow the client to shuffle the subdomains. - * - * Defaults to `false`. - */ - val cacheBusting: Boolean - - /** - * When `true` the SDK doesn't send out the leave requests. - * - * Defaults to `false`. - */ - val suppressLeaveEvents: Boolean - - /** - * When `true` the SDK will resend the last channel state that was set using [PubNub.setPresenceState] - * for the current [userId] with every automatic heartbeat (if [heartbeatInterval] is greater than 0) - * and initial subscribe connection (also after e.g. loss of network). - * - * Defaults to `true`. - * - * Please note that `maintainPresenceState` doesn't apply to state that was set on channel groups. - * It is recommended to disable this option if you set state for channel groups using [PubNub.setPresenceState] - * otherwise that state may be overwritten by individual channel states. - */ - val maintainPresenceState: Boolean - - /** - * Feature to subscribe with a custom filter expression. - */ - val filterExpression: String - - /** - * Whether to include a [PubNubCore.instanceId] with every request. - * - * Defaults to `false`. - */ - val includeInstanceIdentifier: Boolean - - /** - * Whether to include a [PubNubCore.requestId] with every request. - * - * Defaults to `true`. - */ - val includeRequestIdentifier: Boolean - - /** - * @see [okhttp3.Dispatcher.setMaxRequestsPerHost] - */ - val maximumConnections: Int? - - /** - * Enable Google App Engine networking. - * - * Defaults to `false`. - */ - val googleAppEngineNetworking: Boolean - - /** - * Instructs the SDK to use a proxy configuration when communicating with PubNub servers. - * - * @see [Proxy] - */ - val proxy: Proxy? - - /** - * @see [ProxySelector] - */ - val proxySelector: ProxySelector? - - /** - * @see [Authenticator] - */ - val proxyAuthenticator: Authenticator? - - /** - * @see [CertificatePinner] - */ - val certificatePinner: CertificatePinner? - - /** - * Sets a custom [HttpLoggingInterceptor] for logging network traffic. - * - * @see [HttpLoggingInterceptor] - */ - val httpLoggingInterceptor: HttpLoggingInterceptor? - - /** - * @see [SSLSocketFactory] - */ - val sslSocketFactory: SSLSocketFactory? - - /** - * @see [X509ExtendedTrustManager] - */ - val x509ExtendedTrustManager: X509ExtendedTrustManager? - - /** - * @see [okhttp3.ConnectionSpec] - */ - val connectionSpec: ConnectionSpec? - - /** - * @see [javax.net.ssl.HostnameVerifier] - */ - val hostnameVerifier: HostnameVerifier? - - /** - * How many times publishing file message should automatically retry before marking the action as failed - * - * Defaults to `5` - */ - val fileMessagePublishRetryLimit: Int - - val dedupOnSubscribe: Boolean - val maximumMessagesCacheSize: Int - val pnsdkSuffixes: Map - - /** - * Retry configuration for requests. - * Defaults to [RetryConfiguration.None]. - * - * Use [RetryConfiguration.Linear] to set retry with linear delay interval - * Use [RetryConfiguration.Exponential] to set retry with exponential delay interval - * Delay will valy from provided value by random value. - */ - val retryConfiguration: RetryConfiguration - - /** - * Enables explicit presence control. - * When set to true heartbeat calls will contain only channels and groups added explicitly - * using [PubNubCore.presence]. Should be used only with ACL set on the server side. - * For more information please contact PubNub support - * @see PubNubCore.presence - * @see BasePNConfiguration.heartbeatInterval - */ - val managePresenceListManually: Boolean - - @Deprecated( - level = DeprecationLevel.WARNING, - message = """Use UserId instead e.g. config.userId.value""", - replaceWith = ReplaceWith("userId.value"), - ) - val uuid: String - get() = userId.value - - companion object { - fun String.isValid() = isNotBlank() - } - - interface Builder { - /** - * The user ID that the PubNub client will use. - */ - val userId: UserId - - /** - * The subscribe key from the admin panel. - */ - val subscribeKey: String - - /** - * The publish key from the admin panel (only required if publishing). - */ - val publishKey: String - - /** - * The secret key from the admin panel (only required for modifying/revealing access permissions). - * - * Keep away from Android. - */ - val secretKey: String - - /** - * If Access Manager is utilized, client will use this authKey in all restricted requests. - */ - val authKey: String - - /** - * CryptoModule is responsible for handling encryption and decryption. - * If set, all communications to and from PubNub will be encrypted. - */ - val cryptoModule: CryptoModule? - - /** - * Custom origin if needed. - * - * Defaults to `ps.pndsn.com` - */ - val origin: String - - /** - * If set to `true`, requests will be made over HTTPS. - * - * Deafults to `true`. - */ - val secure: Boolean - - /** - * Set to [PNLogVerbosity.BODY] to enable logging of network traffic, otherwise se to [PNLogVerbosity.NONE]. - */ - val logVerbosity: PNLogVerbosity - - /** - * Set Heartbeat notification options. - * - * By default, the SDK alerts on failed heartbeats (equivalent to [PNHeartbeatNotificationOptions.FAILURES]). - */ - val heartbeatNotificationOptions: PNHeartbeatNotificationOptions - - /** - * Sets the custom presence server timeout. - * - * The value is in seconds, and the minimum value is 20 seconds. - * - * Also sets the value of [heartbeatInterval] - */ - val presenceTimeout: Int - - /** - * How often the client will announce itself to server. - * - * The value is in seconds. - */ - val heartbeatInterval: Int - - /** - * The subscribe request timeout. - * - * The value is in seconds. - * - * Defaults to 310. - */ - val subscribeTimeout: Int - - /** - * How long before the client gives up trying to connect with the server. - * - * The value is in seconds. - * - * Defaults to 5. - */ - val connectTimeout: Int - - /** - * For non subscribe operations (publish, herenow, etc), - * This property relates to a read timeout that is applied from the moment the connection between a client - * and the server has been successfully established. It defines a maximum time of inactivity between two - * data packets when waiting for the server’s response. - * - * The value is in seconds. - * - * Defaults to 10. - */ - @Deprecated( - "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", - replaceWith = ReplaceWith("nonSubscribeReadTimeout") - ) - val nonSubscribeRequestTimeout: Int - get() = nonSubscribeReadTimeout - - /** - * For non subscribe operations (publish, herenow, etc), - * This property relates to a read timeout that is applied from the moment the connection between a client - * and the server has been successfully established. It defines a maximum time of inactivity between two - * data packets when waiting for the server’s response. - * - * The value is in seconds. - * - * Defaults to 10. - */ - val nonSubscribeReadTimeout: Int - - /** - * If operating behind a misbehaving proxy, allow the client to shuffle the subdomains. - * - * Defaults to `false`. - */ - val cacheBusting: Boolean - - /** - * When `true` the SDK doesn't send out the leave requests. - * - * Defaults to `false`. - */ - val suppressLeaveEvents: Boolean - - /** - * When `true` the SDK will resend the last channel state that was set using [PubNub.setPresenceState] - * for the current [userId] with every automatic heartbeat (if [heartbeatInterval] is greater than 0) - * and initial subscribe connection (also after e.g. loss of network). - * - * Defaults to `true`. - * - * Please note that `maintainPresenceState` doesn't apply to state that was set on channel groups. - * It is recommended to disable this option if you set state for channel groups using [PubNub.setPresenceState] - * otherwise that state may be overwritten by individual channel states. - */ - val maintainPresenceState: Boolean - - /** - * Feature to subscribe with a custom filter expression. - */ - val filterExpression: String - - /** - * Whether to include a [PubNubCore.instanceId] with every request. - * - * Defaults to `false`. - */ - val includeInstanceIdentifier: Boolean - - /** - * Whether to include a [PubNubCore.requestId] with every request. - * - * Defaults to `true`. - */ - val includeRequestIdentifier: Boolean - - /** - * @see [okhttp3.Dispatcher.setMaxRequestsPerHost] - */ - val maximumConnections: Int? - - /** - * Enable Google App Engine networking. - * - * Defaults to `false`. - */ - val googleAppEngineNetworking: Boolean - - /** - * Instructs the SDK to use a proxy configuration when communicating with PubNub servers. - * - * @see [Proxy] - */ - val proxy: Proxy? - - /** - * @see [ProxySelector] - */ - val proxySelector: ProxySelector? - - /** - * @see [Authenticator] - */ - val proxyAuthenticator: Authenticator? - - /** - * @see [CertificatePinner] - */ - val certificatePinner: CertificatePinner? - - /** - * Sets a custom [HttpLoggingInterceptor] for logging network traffic. - * - * @see [HttpLoggingInterceptor] - */ - val httpLoggingInterceptor: HttpLoggingInterceptor? - - /** - * @see [SSLSocketFactory] - */ - val sslSocketFactory: SSLSocketFactory? - - /** - * @see [X509ExtendedTrustManager] - */ - val x509ExtendedTrustManager: X509ExtendedTrustManager? - - /** - * @see [okhttp3.ConnectionSpec] - */ - val connectionSpec: ConnectionSpec? - - /** - * @see [javax.net.ssl.HostnameVerifier] - */ - val hostnameVerifier: HostnameVerifier? - - /** - * How many times publishing file message should automatically retry before marking the action as failed - * - * Defaults to `5` - */ - val fileMessagePublishRetryLimit: Int - - val dedupOnSubscribe: Boolean - val maximumMessagesCacheSize: Int - val pnsdkSuffixes: Map - - /** - * Retry configuration for requests. - * Defaults to [RetryConfiguration.None]. - * - * Use [RetryConfiguration.Linear] to set retry with linear delay interval - * Use [RetryConfiguration.Exponential] to set retry with exponential delay interval - * Delay will vary from provided value by random value. - */ - val retryConfiguration: RetryConfiguration - - /** - * Enables explicit presence control. - * When set to true heartbeat calls will contain only channels and groups added explicitly - * using [PubNubCore.presence]. Should be used only with ACL set on the server side. - * For more information please contact PubNub support - * @see PubNubCore.presence - * @see BasePNConfiguration.heartbeatInterval - */ - val managePresenceListManually: Boolean - } -} diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfigurationOverride.kt b/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfigurationOverride.kt deleted file mode 100644 index e00a9e6f9..000000000 --- a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/BasePNConfigurationOverride.kt +++ /dev/null @@ -1,87 +0,0 @@ -package com.pubnub.api.v2 - -import com.pubnub.api.UserId -import com.pubnub.api.crypto.CryptoModule -import com.pubnub.api.retry.RetryConfiguration - -interface BasePNConfigurationOverride { - interface Builder { - /** - * The subscribe key from the admin panel. - */ - val subscribeKey: String - - /** - * The publish key from the admin panel (only required if publishing). - */ - val publishKey: String - - /** - * The secret key from the admin panel (only required for modifying/revealing access permissions). - * - * Keep away from Android. - */ - val secretKey: String - - /** - * Retry configuration for requests. - * Defaults to [RetryConfiguration.None]. - * - * Use [RetryConfiguration.Linear] to set retry with linear delay interval - * Use [RetryConfiguration.Exponential] to set retry with exponential delay interval - * Delay will valy from provided value by random value. - */ - val retryConfiguration: RetryConfiguration - - /** - * The user ID that the PubNub client will use. - */ - val userId: UserId - - /** - * Whether to include a [PubNub.instanceId] with every request. - * - * Defaults to `false`. - */ - val includeInstanceIdentifier: Boolean - - /** - * Whether to include a [PubNub.requestId] with every request. - * - * Defaults to `true`. - */ - val includeRequestIdentifier: Boolean - - /** - * If Access Manager is utilized, client will use this authKey in all restricted requests. - */ - val authKey: String - - /** - * CryptoModule is responsible for handling encryption and decryption. - * If set, all communications to and from PubNub will be encrypted. - */ - val cryptoModule: CryptoModule? - - /** - * How long before the client gives up trying to connect with the server. - * - * The value is in seconds. - * - * Defaults to 5. - */ - val connectTimeout: Int - - /** - * For non subscribe operations (publish, herenow, etc), - * This property relates to a read timeout that is applied from the moment the connection between a client - * and the server has been successfully established. It defines a maximum time of inactivity between two - * data packets when waiting for the server’s response. - * - * The value is in seconds. - * - * Defaults to 10. - */ - val nonSubscribeReadTimeout: Int - } -} diff --git a/pubnub-core/pubnub-core-impl/build.gradle.kts b/pubnub-core/pubnub-core-impl/build.gradle.kts deleted file mode 100644 index 8e30fef21..000000000 --- a/pubnub-core/pubnub-core-impl/build.gradle.kts +++ /dev/null @@ -1,59 +0,0 @@ -import com.pubnub.gradle.tasks.GenerateVersionTask - -plugins { - alias(libs.plugins.benmanes.versions) - id("pubnub.java-library") - id("pubnub.kotlin-library") - id("pubnub.test") -} - -val generateVersion = - tasks.register("generateVersion") { - version.set(providers.gradleProperty("VERSION_NAME")) - outputDirectory.set( - layout.buildDirectory.map { - it.dir("generated/sources/generateVersion") - }, - ) - } - -kotlin.sourceSets.getByName("main").kotlin.srcDir(generateVersion) - -dependencies { - api(project(":pubnub-core:pubnub-core-api")) - - implementation(libs.retrofit2) - implementation(libs.retrofit2.converter.gson) - implementation(libs.okhttp) - implementation(libs.okhttp.logging) - - implementation(libs.json) - implementation(libs.gson) - - implementation(libs.slf4j) - implementation(libs.cbor) - - testImplementation(libs.wiremock) - testImplementation(libs.logback.classic) - testImplementation(libs.logback.core) - testImplementation(libs.cucumber.java) - testImplementation(libs.cucumber.junit) - testImplementation(libs.cucumber.picocontainer) - testImplementation(libs.awaitility) - testImplementation(libs.junit4) - testImplementation(libs.junit.jupiter.engine) - testImplementation(libs.junit.vintage.engine) - testImplementation(libs.junit.jupiter) - testImplementation(libs.mockk) - testImplementation(libs.owner) -} - -task("cucumber") { - filter { - // include all tests from package - includeTestsMatching("com.pubnub.contract.*") - } - systemProperty("cucumber.filter.tags", System.getProperty("cucumber.filter.tags")) - systemProperty("cucumber.features", System.getProperty("cucumber.features")) - systemProperty("cucumber.plugins", System.getProperty("cucumber.plugins")) -} diff --git a/pubnub-core/pubnub-core-impl/config/ktlint/baseline.xml b/pubnub-core/pubnub-core-impl/config/ktlint/baseline.xml deleted file mode 100644 index faab705ca..000000000 --- a/pubnub-core/pubnub-core-impl/config/ktlint/baseline.xml +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/BasePubNubImpl.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/BasePubNubImpl.kt deleted file mode 100644 index bd289d053..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/BasePubNubImpl.kt +++ /dev/null @@ -1,143 +0,0 @@ -package com.pubnub.internal - -import com.pubnub.api.BasePubNub -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.models.consumer.access_manager.v3.PNToken -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.callbacks.BaseEventEmitter -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.callbacks.BaseStatusEmitter -import com.pubnub.api.v2.callbacks.BaseStatusListener -import com.pubnub.api.v2.entities.BaseChannel -import com.pubnub.api.v2.entities.BaseChannelGroup -import com.pubnub.api.v2.entities.BaseChannelMetadata -import com.pubnub.api.v2.entities.BaseUserMetadata -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.BaseSubscriptionSet -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.managers.ListenerManager -import com.pubnub.internal.subscribe.eventengine.configuration.EventEnginesConf -import java.util.UUID - -abstract class BasePubNubImpl< - EventListener : BaseEventListener, - Subscription : BaseSubscription, - Channel : BaseChannel, - ChannelGroup : BaseChannelGroup, - ChannelMetadata : BaseChannelMetadata, - UserMetadata : BaseUserMetadata, - SubscriptionSet : BaseSubscriptionSet, - StatusListener : BaseStatusListener, - > internal constructor( - configuration: BasePNConfiguration, - pnsdkName: String, - eventEnginesConf: EventEnginesConf = EventEnginesConf(), -) : BasePubNub, - BaseEventEmitter, - BaseStatusEmitter { - constructor(configuration: BasePNConfiguration, pnsdkName: String) : this(configuration, pnsdkName, EventEnginesConf()) - - val listenerManager: ListenerManager = ListenerManager(this) - val pubNubCore = PubNubCore(configuration, listenerManager, eventEnginesConf, pnsdkName) - - /** - * The current version of the Kotlin SDK. - */ - override val version: String - get() = PubNubCore.SDK_VERSION - - override val timestamp: Int - get() = PubNubCore.timestamp() - - override val baseUrl: String - get() = pubNubCore.baseUrl() - - /** - * Unique id of this PubNub instance. - * - * @see [BasePNConfiguration.includeInstanceIdentifier] - */ - val instanceId: String - get() = pubNubCore.instanceId - - companion object { - /** - * Generates random UUID to use. You should set a unique UUID to identify the user or the device that connects to PubNub. - */ - @JvmStatic - fun generateUUID() = "pn-${UUID.randomUUID()}" - } - - override fun subscriptionSetOf( - channels: Set, - channelGroups: Set, - options: SubscriptionOptions, - ): SubscriptionSet { - val subscriptionSet = subscriptionSetOf(subscriptions = emptySet()) - channels.forEach { - subscriptionSet.add(channel(it).subscription(options)) - } - channelGroups.forEach { - subscriptionSet.add(channelGroup(it).subscription(options)) - } - return subscriptionSet - } - - /** - * Remove a listener. - * - * @param listener The listener to be removed. - */ - override fun removeListener(listener: Listener) { - listenerManager.removeListener(listener) - } - - /** - * Removes all status and event listeners. - */ - override fun removeAllListeners() { - listenerManager.removeAllListeners() - } - - /** - * Force destroy the SDK to evict the connection pools and close executors. - */ - override fun forceDestroy() { - pubNubCore.forceDestroy() - } - - /** - * Destroy the SDK to cancel all ongoing requests and stop heartbeat timer. - */ - override fun destroy() { - pubNubCore.destroy() - } - - override fun reconnect(timetoken: Long) { - pubNubCore.reconnect(timetoken) - } - - override fun parseToken(token: String): PNToken { - return pubNubCore.parseToken(token) - } - - override fun setToken(token: String?) { - pubNubCore.setToken(token) - } - - /** - * Cancel any subscribe and heartbeat loops or ongoing re-connections. - * - * Monitor the results in [SubscribeCallback.status] - */ - override fun disconnect() { - pubNubCore.disconnect() - } - - /** - * Unsubscribe from all channels and all channel groups - */ - override fun unsubscribeAll() { - pubNubCore.unsubscribeAll() - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt deleted file mode 100644 index f4dd224ce..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt +++ /dev/null @@ -1,446 +0,0 @@ -package com.pubnub.internal - -import com.google.gson.JsonElement -import com.pubnub.api.PubNubError -import com.pubnub.api.PubNubException -import com.pubnub.api.retry.RetryableEndpointGroup -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.BasePNConfiguration.Companion.isValid -import com.pubnub.api.v2.callbacks.Consumer -import com.pubnub.api.v2.callbacks.Result -import com.pubnub.internal.managers.RetrofitManager -import com.pubnub.internal.retry.RetryableBase -import com.pubnub.internal.retry.RetryableCallback -import com.pubnub.internal.retry.RetryableRestCaller -import org.slf4j.LoggerFactory -import retrofit2.Call -import retrofit2.Response -import java.io.IOException -import java.net.ConnectException -import java.net.SocketTimeoutException -import java.net.UnknownHostException - -/** - * Base class for all PubNub API operation implementations. - * - * @param Input Server's response. - * @param Output Parsed and encapsulated response for endusers. - * @property pubnub The client instance. - */ -abstract class EndpointCore protected constructor(protected val pubnub: PubNubCore) : - EndpointInterface { - private var configOverride: BasePNConfiguration? = null - final override val configuration: BasePNConfiguration - get() = configOverride ?: pubnub.configuration - - protected val retrofitManager: RetrofitManager - get() = configOverride?.let { configOverrideNonNull -> - RetrofitManager(pubnub.retrofitManager, configOverrideNonNull) - } ?: pubnub.retrofitManager - - private val log = LoggerFactory.getLogger(this.javaClass.simpleName) - - private lateinit var cachedCallback: Consumer> - private lateinit var call: Call - private var silenceFailures = false - private val retryableRestCaller by lazy { - RetryableRestCaller( - configuration.retryConfiguration, - getEndpointGroupName(), - isEndpointRetryable(), - ) - } - - /** - * Key-value object to pass with every PubNub API operation. Used for debugging purposes. - * todo: it should be removed! - */ - val queryParam: MutableMap = mutableMapOf() - - /** - * Executes the call synchronously. This function blocks the thread. - * - * @return A parsed and encapsulated response if the request has been successful, `null` otherwise. - * - * @throws [PubNubException] if anything goes wrong with the request. - */ - override fun sync(): Output { - validateParams() - call = doWork(createBaseParams()) - val response = retryableRestCaller.execute(call) - return handleResponse(response) - } - - private fun handleResponse(response: Response): Output { - when { - response.isSuccessful -> { - return checkAndCreateResponse(response) - } - - else -> { - val (errorString, errorJson) = extractErrorBody(response) - throw createException(response, errorString, errorJson) - } - } - } - - /** - * Executes the call asynchronously. This function does not block the thread. - * - * @param callback The callback to receive the response in. - */ - override fun async(callback: Consumer>) { - cachedCallback = callback - - try { - validateParams() - call = doWork(createBaseParams()) - } catch (pubnubException: PubNubException) { - callback.accept(Result.failure(pubnubException)) - return - } - - call.enqueue( - object : RetryableCallback( - call = call, - retryConfiguration = configuration.retryConfiguration, - endpointGroupName = getEndpointGroupName(), - isEndpointRetryable = isEndpointRetryable(), - executorService = pubnub.executorService, - ) { - override fun onFinalResponse( - call: Call, - response: Response, - ) { - when { - response.isSuccessful -> { - // query params - try { - Result.success(checkAndCreateResponse(response)) - } catch (e: PubNubException) { - Result.failure(e) - }.let { result -> - callback.accept(result) - } - } - - else -> { - val (errorString, errorJson) = extractErrorBody(response) - - callback.accept( - Result.failure( - createException( - response, - errorString, - errorJson, - ), - ), - ) - } - } - } - - override fun onFinalFailure( - call: Call, - t: Throwable, - ) { - if (silenceFailures) { - return - } - - val error: PubNubError = - when (t) { - is UnknownHostException, is ConnectException -> { - PubNubError.CONNECT_EXCEPTION - } - - is SocketTimeoutException -> { - PubNubError.SUBSCRIBE_TIMEOUT - } - - is IOException -> { - PubNubError.PARSING_ERROR - } - - is IllegalStateException -> { - PubNubError.PARSING_ERROR - } - - else -> { - PubNubError.HTTP_ERROR - } - } - - val pubnubException = - PubNubException( - errorMessage = t.toString(), - pubnubError = error, - cause = t, - remoteAction = this@EndpointCore, - ) - callback.accept(Result.failure(pubnubException)) - } - }, - ) - } - - protected fun createBaseParams(): HashMap { - val map = hashMapOf() - - map += queryParam - - map["pnsdk"] = pubnub.generatePnsdk() - map["uuid"] = configuration.userId.value - - if (configuration.includeInstanceIdentifier) { - map["instanceid"] = pubnub.instanceId - } - - if (configuration.includeRequestIdentifier) { - map["requestid"] = pubnub.requestId() - } - - if (isAuthRequired()) { - val token = pubnub.tokenManager.getToken() - if (token != null) { - map["auth"] = token - } else if (configuration.authKey.isValid()) { - map["auth"] = configuration.authKey - } - } - return map - } - - /** - * Cancel the operation but do not alert anybody, useful for restarting the heartbeats and subscribe loops. - */ - override fun silentCancel() { - if (::call.isInitialized) { - if (!call.isCanceled) { - silenceFailures = true - call.cancel() - } - } - } - - private fun createException( - response: Response, - errorString: String? = null, - errorBody: JsonElement? = null, - ): PubNubException { - val errorChannels = mutableListOf() - val errorGroups = mutableListOf() - - if (errorBody != null) { - if (pubnub.mapper.isJsonObject(errorBody) && - pubnub.mapper.hasField( - errorBody, - "payload", - ) - ) { - val payloadBody = pubnub.mapper.getField(errorBody, "payload")!! - - if (pubnub.mapper.hasField(payloadBody, "channels")) { - val iterator = pubnub.mapper.getArrayIterator(payloadBody, "channels") - while (iterator.hasNext()) { - errorChannels.add(pubnub.mapper.elementToString(iterator.next())!!) - } - } - - if (pubnub.mapper.hasField(payloadBody, "channel-groups")) { - val iterator = pubnub.mapper.getArrayIterator(payloadBody, "channel-groups") - while (iterator.hasNext()) { - val node = iterator.next() - - val channelGroupName = - pubnub.mapper.elementToString(node)!!.let { - if (it.first().toString() == ":") { - it.substring(1) - } else { - it - } - } - - errorGroups.add(channelGroupName) - } - } - } - } - - val affectedChannels = - errorChannels.ifEmpty { - try { - getAffectedChannels() - } catch (e: UninitializedPropertyAccessException) { - emptyList() - } - } - - val affectedChannelGroups = - errorGroups.ifEmpty { - try { - getAffectedChannelGroups() - } catch (e: UninitializedPropertyAccessException) { - emptyList() - } - } - - return PubNubException( - pubnubError = PubNubError.HTTP_ERROR, - errorMessage = errorString, - jso = errorBody?.toString(), - statusCode = response.code(), - affectedCall = call, - retryAfterHeaderValue = response.headers()[RetryableBase.RETRY_AFTER_HEADER_NAME]?.toIntOrNull(), - affectedChannels = affectedChannels, - affectedChannelGroups = affectedChannelGroups, - requestInfo = - PubNubException.RequestInfo( - tlsEnabled = response.raw().request.url.isHttps, - origin = response.raw().request.url.host, - uuid = response.raw().request.url.queryParameter("uuid"), - authKey = response.raw().request.url.queryParameter("auth"), - clientRequest = response.raw().request, - ), - remoteAction = this, - ) - } - - override fun retry() { - silenceFailures = false - async(cachedCallback) - } - - private fun extractErrorBody(response: Response): Pair { - val errorBodyString = - try { - response.errorBody()?.string() - } catch (e: IOException) { - "N/A" - } - - val errorBodyJson = - try { - pubnub.mapper.fromJson(errorBodyString, JsonElement::class.java) - } catch (e: PubNubException) { - null - } - - return errorBodyString to errorBodyJson - } - - private fun checkAndCreateResponse(input: Response): Output { - try { - return createResponse(input) - } catch (pubnubException: PubNubException) { - throw pubnubException.copy( - statusCode = input.code(), - jso = pubnub.mapper.toJson(input.body()), - affectedCall = call, - ) - } catch (e: KotlinNullPointerException) { - throw PubNubException( - pubnubError = PubNubError.PARSING_ERROR, - errorMessage = e.toString(), - affectedCall = call, - statusCode = input.code(), - jso = pubnub.mapper.toJson(input.body()), - cause = e, - ) - } catch (e: IllegalStateException) { - throw PubNubException( - pubnubError = PubNubError.PARSING_ERROR, - errorMessage = e.toString(), - affectedCall = call, - statusCode = input.code(), - jso = pubnub.mapper.toJson(input.body()), - cause = e, - ) - } catch (e: IndexOutOfBoundsException) { - throw PubNubException( - pubnubError = PubNubError.PARSING_ERROR, - errorMessage = e.toString(), - affectedCall = call, - statusCode = input.code(), - jso = pubnub.mapper.toJson(input.body()), - cause = e, - ) - } catch (e: NullPointerException) { - throw PubNubException( - pubnubError = PubNubError.PARSING_ERROR, - errorMessage = e.toString(), - affectedCall = call, - statusCode = input.code(), - jso = pubnub.mapper.toJson(input.body()), - cause = e, - ) - } catch (e: IllegalArgumentException) { - throw PubNubException( - pubnubError = PubNubError.PARSING_ERROR, - errorMessage = e.toString(), - affectedCall = call, - statusCode = input.code(), - jso = pubnub.mapper.toJson(input.body()), - cause = e, - ) - } catch (e: TypeCastException) { - throw PubNubException( - pubnubError = PubNubError.PARSING_ERROR, - errorMessage = e.toString(), - affectedCall = call, - statusCode = input.code(), - jso = pubnub.mapper.toJson(input.body()), - cause = e, - ) - } catch (e: ClassCastException) { - throw PubNubException( - pubnubError = PubNubError.PARSING_ERROR, - errorMessage = e.toString(), - affectedCall = call, - statusCode = input.code(), - jso = pubnub.mapper.toJson(input.body()), - cause = e, - ) - } catch (e: UninitializedPropertyAccessException) { - throw PubNubException( - pubnubError = PubNubError.PARSING_ERROR, - errorMessage = e.toString(), - affectedCall = call, - statusCode = input.code(), - jso = pubnub.mapper.toJson(input.body()), - cause = e, - ) - } - } - - protected open fun getAffectedChannels() = emptyList() - - protected open fun getAffectedChannelGroups(): List = emptyList() - - protected open fun validateParams() { - if (isSubKeyRequired() && !configuration.subscribeKey.isValid()) { - throw PubNubException(PubNubError.SUBSCRIBE_KEY_MISSING) - } - if (isPubKeyRequired() && !configuration.publishKey.isValid()) { - throw PubNubException(PubNubError.PUBLISH_KEY_MISSING) - } - } - - override fun overrideConfiguration(configuration: BasePNConfiguration) { - this.configOverride = configuration - } - - protected abstract fun doWork(queryParams: HashMap): Call - - protected abstract fun createResponse(input: Response): Output - - protected open fun isSubKeyRequired() = true - - protected open fun isPubKeyRequired() = false - - protected open fun isAuthRequired() = true - - protected abstract fun getEndpointGroupName(): RetryableEndpointGroup - - protected open fun isEndpointRetryable(): Boolean = true - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointInterface.kt deleted file mode 100644 index 031dfd1fe..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/EndpointInterface.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal - -import com.pubnub.api.endpoints.HasOverridableConfig -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction - -interface EndpointInterface : ExtendedRemoteAction, HasOverridableConfig diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt deleted file mode 100644 index b6a4b4751..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubCore.kt +++ /dev/null @@ -1,2382 +0,0 @@ -package com.pubnub.internal - -import com.pubnub.api.PubNubException -import com.pubnub.api.UserId -import com.pubnub.api.crypto.CryptoModule -import com.pubnub.api.enums.PNPushEnvironment -import com.pubnub.api.enums.PNPushType -import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.access_manager.v3.PNToken -import com.pubnub.api.models.consumer.history.PNHistoryResult -import com.pubnub.api.models.consumer.message_actions.PNMessageAction -import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.EmptyOptions -import com.pubnub.api.v2.subscriptions.SubscriptionCursor -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.crypto.decryptString -import com.pubnub.internal.crypto.encryptString -import com.pubnub.internal.endpoints.DeleteMessagesEndpoint -import com.pubnub.internal.endpoints.FetchMessagesEndpoint -import com.pubnub.internal.endpoints.HistoryEndpoint -import com.pubnub.internal.endpoints.MessageCountsEndpoint -import com.pubnub.internal.endpoints.TimeEndpoint -import com.pubnub.internal.endpoints.access.GrantEndpoint -import com.pubnub.internal.endpoints.access.GrantTokenEndpoint -import com.pubnub.internal.endpoints.access.RevokeTokenEndpoint -import com.pubnub.internal.endpoints.channel_groups.AddChannelChannelGroupEndpoint -import com.pubnub.internal.endpoints.channel_groups.AllChannelsChannelGroupEndpoint -import com.pubnub.internal.endpoints.channel_groups.DeleteChannelGroupEndpoint -import com.pubnub.internal.endpoints.channel_groups.ListAllChannelGroupEndpoint -import com.pubnub.internal.endpoints.channel_groups.RemoveChannelChannelGroupEndpoint -import com.pubnub.internal.endpoints.files.DeleteFileEndpoint -import com.pubnub.internal.endpoints.files.DownloadFileEndpoint -import com.pubnub.internal.endpoints.files.GenerateUploadUrlEndpoint -import com.pubnub.internal.endpoints.files.GetFileUrlEndpoint -import com.pubnub.internal.endpoints.files.ListFilesEndpoint -import com.pubnub.internal.endpoints.files.PublishFileMessageEndpoint -import com.pubnub.internal.endpoints.files.SendFileEndpoint -import com.pubnub.internal.endpoints.files.UploadFileEndpoint -import com.pubnub.internal.endpoints.message_actions.AddMessageActionEndpoint -import com.pubnub.internal.endpoints.message_actions.GetMessageActionsEndpoint -import com.pubnub.internal.endpoints.message_actions.RemoveMessageActionEndpoint -import com.pubnub.internal.endpoints.objects.channel.GetAllChannelMetadataEndpoint -import com.pubnub.internal.endpoints.objects.channel.GetChannelMetadataEndpoint -import com.pubnub.internal.endpoints.objects.channel.RemoveChannelMetadataEndpoint -import com.pubnub.internal.endpoints.objects.channel.SetChannelMetadataEndpoint -import com.pubnub.internal.endpoints.objects.internal.CollectionQueryParameters -import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam -import com.pubnub.internal.endpoints.objects.member.GetChannelMembersEndpoint -import com.pubnub.internal.endpoints.objects.member.ManageChannelMembersEndpoint -import com.pubnub.internal.endpoints.objects.membership.GetMembershipsEndpoint -import com.pubnub.internal.endpoints.objects.membership.ManageMembershipsEndpoint -import com.pubnub.internal.endpoints.objects.uuid.GetAllUUIDMetadataEndpoint -import com.pubnub.internal.endpoints.objects.uuid.GetUUIDMetadataEndpoint -import com.pubnub.internal.endpoints.objects.uuid.RemoveUUIDMetadataEndpoint -import com.pubnub.internal.endpoints.objects.uuid.SetUUIDMetadataEndpoint -import com.pubnub.internal.endpoints.presence.GetStateEndpoint -import com.pubnub.internal.endpoints.presence.HereNowEndpoint -import com.pubnub.internal.endpoints.presence.SetStateEndpoint -import com.pubnub.internal.endpoints.presence.WhereNowEndpoint -import com.pubnub.internal.endpoints.pubsub.PublishEndpoint -import com.pubnub.internal.endpoints.pubsub.SignalEndpoint -import com.pubnub.internal.endpoints.push.AddChannelsToPushEndpoint -import com.pubnub.internal.endpoints.push.ListPushProvisionsEndpoint -import com.pubnub.internal.endpoints.push.RemoveAllPushChannelsForDeviceEndpoint -import com.pubnub.internal.endpoints.push.RemoveChannelsFromPushEndpoint -import com.pubnub.internal.managers.BasePathManager -import com.pubnub.internal.managers.DuplicationManager -import com.pubnub.internal.managers.ListenerManager -import com.pubnub.internal.managers.MapperManager -import com.pubnub.internal.managers.PublishSequenceManager -import com.pubnub.internal.managers.RetrofitManager -import com.pubnub.internal.managers.TokenManager -import com.pubnub.internal.managers.TokenParser -import com.pubnub.internal.models.consumer.access_manager.sum.SpacePermissions -import com.pubnub.internal.models.consumer.access_manager.sum.UserPermissions -import com.pubnub.internal.models.consumer.access_manager.sum.toChannelGrant -import com.pubnub.internal.models.consumer.access_manager.sum.toUuidGrant -import com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant -import com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant -import com.pubnub.internal.models.consumer.objects.PNKey -import com.pubnub.internal.models.consumer.objects.PNMemberKey -import com.pubnub.internal.models.consumer.objects.PNMembershipKey -import com.pubnub.internal.models.consumer.objects.PNSortKey -import com.pubnub.internal.models.consumer.objects.member.MemberInput -import com.pubnub.internal.models.consumer.objects.member.PNUUIDDetailsLevel -import com.pubnub.internal.models.consumer.objects.membership.ChannelMembershipInput -import com.pubnub.internal.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.internal.presence.Presence -import com.pubnub.internal.presence.eventengine.data.PresenceData -import com.pubnub.internal.presence.eventengine.effect.effectprovider.HeartbeatProviderImpl -import com.pubnub.internal.presence.eventengine.effect.effectprovider.LeaveProviderImpl -import com.pubnub.internal.subscribe.PRESENCE_CHANNEL_SUFFIX -import com.pubnub.internal.subscribe.Subscribe -import com.pubnub.internal.subscribe.eventengine.configuration.EventEnginesConf -import com.pubnub.internal.v2.entities.BaseChannelGroupImpl -import com.pubnub.internal.v2.entities.BaseChannelImpl -import com.pubnub.internal.v2.entities.ChannelGroupName -import com.pubnub.internal.v2.entities.ChannelName -import com.pubnub.internal.v2.subscription.BaseSubscriptionImpl -import com.pubnub.internal.workers.SubscribeMessageProcessor -import java.io.InputStream -import java.util.Date -import java.util.UUID -import java.util.concurrent.Executors -import java.util.concurrent.ScheduledExecutorService -import kotlin.time.Duration.Companion.seconds - -class PubNubCore internal constructor( - val configuration: BasePNConfiguration, - val listenerManager: ListenerManager, - eventEnginesConf: EventEnginesConf = EventEnginesConf(), - private val pnsdkName: String, -) { - companion object { - internal const val TIMESTAMP_DIVIDER = 1000 - internal const val SDK_VERSION = PUBNUB_VERSION - internal const val MAX_SEQUENCE = 65535 - - @JvmStatic - fun timestamp() = (Date().time / TIMESTAMP_DIVIDER).toInt() - } - - private val subscriptionFactory: SubscriptionFactory> = - { channels, channelGroups, options -> - object : BaseSubscriptionImpl(this, channels, channelGroups, options) { - override fun addListener(listener: BaseEventListener) { - // not used - } - } - } - - //region Managers - - /** - * Manage and parse JSON - */ - val mapper = MapperManager() - - private val numberOfThreadsInPool = Integer.min(Runtime.getRuntime().availableProcessors(), 8) - internal val executorService: ScheduledExecutorService = Executors.newScheduledThreadPool(numberOfThreadsInPool) - - private val basePathManager = BasePathManager(configuration) - internal val retrofitManager = RetrofitManager(this, configuration) - internal val publishSequenceManager = PublishSequenceManager(MAX_SEQUENCE) - internal val tokenManager: TokenManager = TokenManager() - private val tokenParser: TokenParser = TokenParser() - private val presenceData = PresenceData() - private val subscribe = - Subscribe.create( - this, - listenerManager, - eventEnginesConf, - SubscribeMessageProcessor(this, DuplicationManager(configuration)), - presenceData, - configuration.maintainPresenceState, - ) - - private val presence = - Presence.create( - heartbeatProvider = HeartbeatProviderImpl(this), - leaveProvider = LeaveProviderImpl(this), - heartbeatInterval = configuration.heartbeatInterval.seconds, - suppressLeaveEvents = configuration.suppressLeaveEvents, - heartbeatNotificationOptions = configuration.heartbeatNotificationOptions, - listenerManager = listenerManager, - eventEngineConf = eventEnginesConf.presence, - presenceData = presenceData, - sendStateWithHeartbeat = configuration.maintainPresenceState, - executorService = executorService, - ) - - //endregion - - /** - * Unique id of this PubNub instance. - * - * @see [BasePNConfiguration.includeInstanceIdentifier] - */ - val instanceId = UUID.randomUUID().toString() - - //region Internal - internal fun baseUrl() = basePathManager.basePath() - - internal fun requestId() = UUID.randomUUID().toString() - //endregion - - fun generatePnsdk(): String { - val joinedSuffixes = configuration.pnsdkSuffixes.toSortedMap().values.joinToString(" ") - return "$pnsdkName/$SDK_VERSION" + - if (joinedSuffixes.isNotBlank()) { - " $joinedSuffixes" - } else { - "" - } - } - - //region Publish - - /** - * Send a message to all subscribers of a channel. - * - * To publish a message you must first specify a valid [BasePNConfiguration.publishKey]. - * A successfully published message is replicated across the PubNub Real-Time Network and sent - * simultaneously to all subscribed clients on a channel. - * - * Messages in transit can be secured from potential eavesdroppers with SSL/TLS by setting - * [BasePNConfiguration.secure] to `true` during initialization. - * - * **Publish Anytime** - * - * - * It is not required to be subscribed to a channel in order to publish to that channel. - * - * **Message Data:** - * - * - * The message argument can contain any JSON serializable data, including: Objects, Arrays, Integers and Strings. - * Data should not contain special Java/Kotlin classes or functions as these will not serialize. - * String content can include any single-byte or multi-byte UTF-8 character. - * - * - * @param message The payload. - * **Warning:** It is important to note that you should not serialize JSON - * when sending signals/messages via PubNub. - * Why? Because the serialization is done for you automatically. - * Instead just pass the full object as the message payload. - * PubNub takes care of everything for you. - * @param channel Destination of the message. - * @param meta Metadata object which can be used with the filtering ability. - * @param shouldStore Store in history. - * If not specified, then the history configuration of the key is used. - * @param usePost Use HTTP POST to publish. Default is `false` - * @param replicate Replicate the message. Is set to `true` by default. - * @param ttl Set a per message time to live in storage. - * - If `shouldStore = true`, and `ttl = 0`, the message is stored - * with no expiry time. - * - If `shouldStore = true` and `ttl = X` (`X` is an Integer value), - * the message is stored with an expiry time of `X` hours. - * - If `shouldStore = false`, the `ttl` parameter is ignored. - * - If ttl isn't specified, then expiration of the message defaults - * back to the expiry value for the key. - */ - fun publish( - channel: String, - message: Any, - meta: Any? = null, - shouldStore: Boolean? = null, - usePost: Boolean = false, - replicate: Boolean = true, - ttl: Int? = null, - ) = PublishEndpoint( - pubnub = this, - channel = channel, - message = message, - meta = meta, - shouldStore = shouldStore, - usePost = usePost, - replicate = replicate, - ttl = ttl, - ) - - /** - * Send a message to PubNub Functions Event Handlers. - * - * These messages will go directly to any Event Handlers registered on the channel that you fire to - * and will trigger their execution. The content of the fired request will be available for processing - * within the Event Handler. - * - * The message sent via `fire()` isn't replicated, and so won't be received by any subscribers to the channel. - * The message is also not stored in history. - * - * - * @param message The payload. - * **Warning:** It is important to note that you should not serialize JSON - * when sending signals/messages via PubNub. - * Why? Because the serialization is done for you automatically. - * Instead just pass the full object as the message payload. - * PubNub takes care of everything for you. - * @param channel Destination of the message. - * @param meta Metadata object which can be used with the filtering ability. - * If not specified, then the history configuration of the key is used. - * @param usePost Use HTTP POST to publish. Default is `false` - * @param ttl Set a per message time to live in storage. - * - If `shouldStore = true`, and `ttl = 0`, the message is stored - * with no expiry time. - * - If `shouldStore = true` and `ttl = X` (`X` is an Integer value), - * the message is stored with an expiry time of `X` hours. - * - If `shouldStore = false`, the `ttl` parameter is ignored. - * - If ttl isn't specified, then expiration of the message defaults - * back to the expiry value for the key. - */ - fun fire( - channel: String, - message: Any, - meta: Any? = null, - usePost: Boolean = false, - ) = publish( - channel = channel, - message = message, - meta = meta, - shouldStore = false, - usePost = usePost, - replicate = false, - ) - - /** - * Send a signal to all subscribers of a channel. - * - * By default, signals are limited to a message payload size of 30 bytes. - * This limit applies only to the payload, and not to the URI or headers. - * If you require a larger payload size, please [contact support](mailto:support@pubnub.com). - * - * @param channel The channel which the signal will be sent to. - * @param message The payload which will be serialized and sent. - */ - fun signal( - channel: String, - message: Any, - ) = SignalEndpoint(pubnub = this, channel = channel, message = message) - //endregion - - private fun subscribeInternal( - channels: List = emptyList(), - channelGroups: List = emptyList(), - withPresence: Boolean = false, - withTimetoken: Long = 0L, - ) { - subscribe.subscribe(channels.toSet(), channelGroups.toSet(), withPresence, withTimetoken) - if (!configuration.managePresenceListManually) { - presence.joined( - channels.filterNot { it.endsWith(PRESENCE_CHANNEL_SUFFIX) }.toSet(), - channelGroups.filterNot { it.endsWith(PRESENCE_CHANNEL_SUFFIX) }.toSet(), - ) - } - } - - private fun unsubscribeInternal( - channels: List = emptyList(), - channelGroups: List = emptyList(), - ) { - val channelSetWithoutPresence = channels.filter { !it.endsWith(PRESENCE_CHANNEL_SUFFIX) }.toSet() - val groupSetWithoutPresence = channelGroups.filter { !it.endsWith(PRESENCE_CHANNEL_SUFFIX) }.toSet() - subscribe.unsubscribe(channelSetWithoutPresence, groupSetWithoutPresence) - if (!configuration.managePresenceListManually) { - presence.left(channelSetWithoutPresence, groupSetWithoutPresence) - } - } - - /** - * Unsubscribe from all channels and all channel groups - */ - @Synchronized - fun unsubscribeAll() { - synchronized(lockChannelsAndGroups) { - channelSubscriptions.clear() - channelGroupSubscriptions.clear() - subscribe.unsubscribeAll() - presence.leftAll() - } - } - - /** - * Queries the local subscribe loop for channels currently in the mix. - * - * @return A list of channels the client is currently subscribed to. - */ - fun getSubscribedChannels() = subscribe.getSubscribedChannels() - - /** - * Queries the local subscribe loop for channel groups currently in the mix. - * - * @return A list of channel groups the client is currently subscribed to. - */ - fun getSubscribedChannelGroups() = subscribe.getSubscribedChannelGroups() - - //endregion - - //region MobilePush - - /** - * Enable push notifications on provided set of channels. - * - * @param pushType Accepted values: FCM, APNS, MPNS, APNS2. - * @see [PNPushType] - * @param channels Channels to add push notifications to. - * @param deviceId The device ID (token) to associate with push notifications. - * @param environment Environment within which device should manage list of channels with enabled notifications - * (works only if [pushType] set to [PNPushType.APNS2]). - * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). - * Required only if pushType set to [PNPushType.APNS2]. - */ - fun addPushNotificationsOnChannels( - pushType: PNPushType, - channels: List, - deviceId: String, - topic: String? = null, - environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, - ) = AddChannelsToPushEndpoint( - pubnub = this, - pushType = pushType, - channels = channels, - deviceId = deviceId, - topic = topic, - environment = environment, - ) - - /** - * Request a list of all channels on which push notifications have been enabled using specified [ListPushProvisionsEndpoint.deviceId]. - * - * @param pushType Accepted values: FCM, APNS, MPNS, APNS2. @see [PNPushType] - * @param deviceId The device ID (token) to associate with push notifications. - * @param environment Environment within which device should manage list of channels with enabled notifications - * (works only if [pushType] set to [PNPushType.APNS2]). - * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). - * Required only if pushType set to [PNPushType.APNS2]. - */ - fun auditPushChannelProvisions( - pushType: PNPushType, - deviceId: String, - topic: String? = null, - environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, - ) = ListPushProvisionsEndpoint( - pubnub = this, - pushType = pushType, - deviceId = deviceId, - topic = topic, - environment = environment, - ) - - /** - * Disable push notifications on provided set of channels. - * - * @param pushType Accepted values: FCM, APNS, MPNS, APNS2. @see [PNPushType] - * @param channels Channels to remove push notifications from. - * @param deviceId The device ID (token) associated with push notifications. - * @param environment Environment within which device should manage list of channels with enabled notifications - * (works only if [pushType] set to [PNPushType.APNS2]). - * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). - * Required only if pushType set to [PNPushType.APNS2]. - */ - fun removePushNotificationsFromChannels( - pushType: PNPushType, - channels: List, - deviceId: String, - topic: String? = null, - environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, - ) = RemoveChannelsFromPushEndpoint( - pubnub = this, - pushType = pushType, - channels = channels, - deviceId = deviceId, - topic = topic, - environment = environment, - ) - - /** - * Disable push notifications from all channels registered with the specified [RemoveAllPushChannelsForDeviceEndpoint.deviceId]. - * - * @param pushType Accepted values: FCM, APNS, MPNS, APNS2. @see [PNPushType] - * @param deviceId The device ID (token) to associate with push notifications. - * @param environment Environment within which device should manage list of channels with enabled notifications - * (works only if [pushType] set to [PNPushType.APNS2]). - * @param topic Notifications topic name (usually it is bundle identifier of application for Apple platform). - * Required only if pushType set to [PNPushType.APNS2]. - */ - fun removeAllPushNotificationsFromDeviceWithPushToken( - pushType: PNPushType, - deviceId: String, - topic: String? = null, - environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, - ) = RemoveAllPushChannelsForDeviceEndpoint( - pubnub = this, - pushType = pushType, - deviceId = deviceId, - topic = topic, - environment = environment, - ) - //endregion - - //region StoragePlayback - - /** - * Fetch historical messages of a channel. - * - * It is possible to control how messages are returned and in what order, for example you can: - * - Search for messages starting on the newest end of the timeline (default behavior - `reverse = false`) - * - Search for messages from the oldest end of the timeline by setting `reverse` to `true`. - * - Page through results by providing a `start` OR `end` timetoken. - * - Retrieve a slice of the time line by providing both a `start` AND `end` timetoken. - * - Limit the number of messages to a specific quantity using the `count` parameter. - * - * **Start & End parameter usage clarity:** - * - If only the `start` parameter is specified (without `end`), - * you will receive messages that are older than and up to that `start` timetoken value. - * - If only the `end` parameter is specified (without `start`) - * you will receive messages that match that end timetoken value and newer. - * - Specifying values for both start and end parameters - * will return messages between those timetoken values (inclusive on the `end` value) - * - Keep in mind that you will still receive a maximum of 100 messages - * even if there are more messages that meet the timetoken values. - * Iterative calls to history adjusting the start timetoken is necessary to page through the full set of results - * if more than 100 messages meet the timetoken values. - * - * @param channel Channel to return history messages from. - * @param start Timetoken delimiting the start of time slice (exclusive) to pull messages from. - * @param end Timetoken delimiting the end of time slice (inclusive) to pull messages from. - * @param count Specifies the number of historical messages to return. - * Default and maximum value is `100`. - * @param reverse Whether to traverse the time ine in reverse starting with the oldest message first. - * Default is `false`. - * @param includeTimetoken Whether to include message timetokens in the response. - * Defaults to `false`. - * @param includeMeta Whether to include message metadata in response. - * Defaults to `false`. - */ - fun history( - channel: String, - start: Long? = null, - end: Long? = null, - count: Int = PNHistoryResult.MAX_COUNT, - reverse: Boolean = false, - includeTimetoken: Boolean = false, - includeMeta: Boolean = false, - ) = HistoryEndpoint( - pubnub = this, - channel = channel, - start = start, - end = end, - count = count, - reverse = reverse, - includeTimetoken = includeTimetoken, - includeMeta = includeMeta, - ) - - /** - * Fetch historical messages from multiple channels. - * The `includeMessageActions` flag also allows you to fetch message actions along with the messages. - * - * It's possible to control how messages are returned and in what order. For example, you can: - * - Search for messages starting on the newest end of the timeline. - * - Search for messages from the oldest end of the timeline. - * - Page through results by providing a `start` OR `end` time token. - * - Retrieve a slice of the time line by providing both a `start` AND `end` time token. - * - Limit the number of messages to a specific quantity using the `count` parameter. - * - Batch history returns up to 25 messages per channel, on a maximum of 500 channels. - * Use the start and end timestamps to page through the next batch of messages. - * - * **Start & End parameter usage clarity:** - * - If you specify only the `start` parameter (without `end`), - * you will receive messages that are older than and up to that `start` timetoken. - * - If you specify only the `end` parameter (without `start`), - * you will receive messages from that `end` timetoken and newer. - * - Specify values for both `start` and `end` parameters to retrieve messages between those timetokens - * (inclusive of the `end` value). - * - Keep in mind that you will still receive a maximum of 25 messages - * even if there are more messages that meet the timetoken values. - * - Iterative calls to history adjusting the start timetoken is necessary to page through the full set of results - * if more than 25 messages meet the timetoken values. - * - * @param channels Channels to return history messages from. - * @param maximumPerChannel Specifies the number of historical messages to return per channel. - * If [includeMessageActions] is `false`, then `1` is the default (and maximum) value. - * Otherwise it's `25`. - * @param start Timetoken delimiting the start of time slice (exclusive) to pull messages from. - * @param end Time token delimiting the end of time slice (inclusive) to pull messages from. - * @param includeMeta Whether to include message metadata in response. - * Defaults to `false`. - * @param includeMessageActions Whether to include message actions in response. - * Defaults to `false`. - */ - @Deprecated( - replaceWith = - ReplaceWith( - "fetchMessages(channels = channels, page = PNBoundedPage(start = start, end = end, " + - "limit = maximumPerChannel),includeMeta = includeMeta, " + - "includeMessageActions = includeMessageActions, includeMessageType = includeMessageType)", - "com.pubnub.api.models.consumer.PNBoundedPage", - ), - level = DeprecationLevel.WARNING, - message = "Use fetchMessages(String, PNBoundedPage, Boolean, Boolean, Boolean) instead", - ) - fun fetchMessages( - channels: List, - maximumPerChannel: Int = 0, - start: Long? = null, - end: Long? = null, - includeMeta: Boolean = false, - includeMessageActions: Boolean = false, - includeMessageType: Boolean = true, - ): FetchMessagesEndpoint = - fetchMessages( - channels = channels, - page = PNBoundedPage(start = start, end = end, limit = maximumPerChannel), - includeMeta = includeMeta, - includeMessageActions = includeMessageActions, - includeMessageType = includeMessageType, - ) - - /** - * Fetch historical messages from multiple channels. - * The `includeMessageActions` flag also allows you to fetch message actions along with the messages. - * - * It's possible to control how messages are returned and in what order. For example, you can: - * - Search for messages starting on the newest end of the timeline. - * - Search for messages from the oldest end of the timeline. - * - Page through results by providing a `start` OR `end` time token. - * - Retrieve a slice of the time line by providing both a `start` AND `end` time token. - * - Limit the number of messages to a specific quantity using the `limit` parameter. - * - Batch history returns up to 25 messages per channel, on a maximum of 500 channels. - * Use the start and end timestamps to page through the next batch of messages. - * - * **Start & End parameter usage clarity:** - * - If you specify only the `start` parameter (without `end`), - * you will receive messages that are older than and up to that `start` timetoken. - * - If you specify only the `end` parameter (without `start`), - * you will receive messages from that `end` timetoken and newer. - * - Specify values for both `start` and `end` parameters to retrieve messages between those timetokens - * (inclusive of the `end` value). - * - Keep in mind that you will still receive a maximum of 25 messages - * even if there are more messages that meet the timetoken values. - * - Iterative calls to history adjusting the start timetoken is necessary to page through the full set of results - * if more than 25 messages meet the timetoken values. - * - * @param channels Channels to return history messages from. - * @param page The paging object used for pagination. @see [PNBoundedPage] - * @param includeUUID Whether to include publisher uuid with each history message. Defaults to `true`. - * @param includeMeta Whether to include message metadata in response. - * Defaults to `false`. - * @param includeMessageActions Whether to include message actions in response. - * Defaults to `false`. - * @param includeMessageType Whether to include message type in response. - * Defaults to `false`. - */ - fun fetchMessages( - channels: List, - page: PNBoundedPage = PNBoundedPage(), - includeUUID: Boolean = true, - includeMeta: Boolean = false, - includeMessageActions: Boolean = false, - includeMessageType: Boolean = true, - ) = FetchMessagesEndpoint( - pubnub = this, - channels = channels, - page = page, - includeUUID = includeUUID, - includeMeta = includeMeta, - includeMessageActions = includeMessageActions, - includeMessageType = includeMessageType, - ) - - /** - * Removes messages from the history of a specific channel. - * - * NOTE: There is a setting to accept delete from history requests for a key, - * which you must enable by checking the Enable `Delete-From-History` checkbox - * in the key settings for your key in the Administration Portal. - * - * Requires Initialization with secret key. - * - * @param channels Channels to delete history messages from. - * @param start Timetoken delimiting the start of time slice (exclusive) to delete messages from. - * @param end Time token delimiting the end of time slice (inclusive) to delete messages from. - */ - fun deleteMessages( - channels: List, - start: Long? = null, - end: Long? = null, - ) = DeleteMessagesEndpoint(pubnub = this, channels = channels, start = start, end = end) - - /** - * Fetches the number of messages published on one or more channels since a given time. - * The count returned is the number of messages in history with a timetoken value greater - * than the passed value in the [MessageCountsEndpoint.channelsTimetoken] parameter. - * - * @param channels Channels to fetch the message count from. - * @param channelsTimetoken List of timetokens, in order of the channels list. - * Specify a single timetoken to apply it to all channels. - * Otherwise, the list of timetokens must be the same length as the list of channels. - */ - fun messageCounts( - channels: List, - channelsTimetoken: List, - ) = MessageCountsEndpoint(pubnub = this, channels = channels, channelsTimetoken = channelsTimetoken) - //endregion - - //region Presence - - /** - * Obtain information about the current state of a channel including a list of unique user IDs - * currently subscribed to the channel and the total occupancy count of the channel. - * - * @param channels The channels to get the 'here now' details of. - * Leave empty for a 'global her now'. - * @param channelGroups The channel groups to get the 'here now' details of. - * Leave empty for a 'global her now'. - * @param includeState Whether the response should include presence state information, if available. - * Defaults to `false`. - * @param includeUUIDs Whether the response should include UUIDs od connected clients. - * Defaults to `true`. - */ - fun hereNow( - channels: List = emptyList(), - channelGroups: List = emptyList(), - includeState: Boolean = false, - includeUUIDs: Boolean = true, - ) = HereNowEndpoint( - pubnub = this, - channels = channels, - channelGroups = channelGroups, - includeState = includeState, - includeUUIDs = includeUUIDs, - ) - - /** - * Obtain information about the current list of channels to which a UUID is subscribed to. - * - * @param uuid UUID of the user to get its current channel subscriptions. Defaults to the UUID of the client. - * @see [BasePNConfiguration.uuid] - */ - fun whereNow(uuid: String = configuration.userId.value) = WhereNowEndpoint(pubnub = this, uuid = uuid) - - /** - * Set state information specific to a subscriber UUID. - * - * State information is supplied as a JSON object of key/value pairs. - * - * If [BasePNConfiguration.maintainPresenceState] is `true`, and the `uuid` matches [BasePNConfiguration.uuid], the state - * for channels will be saved in the PubNub client and resent with every heartbeat and initial subscribe request. - * In that case, it's not recommended to mix setting state through channels *and* channel groups, as state set - * through the channel group will be overwritten after the next heartbeat or subscribe reconnection (e.g. after loss - * of network). - * - * @param channels Channels to set the state to. - * @param channelGroups Channel groups to set the state to. - * @param state The actual state object to set. - * NOTE: Presence state must be expressed as a JsonObject. - * When calling [PubNub.setPresenceState], be sure to supply an initialized JsonObject - * or POJO which can be serialized to a JsonObject. - * @param uuid UUID of the user to set the state for. Defaults to the UUID of the client. - * @see [PNConfiguration.uuid] - */ - fun setPresenceState( - channels: List = listOf(), - channelGroups: List = listOf(), - state: Any, - uuid: String = configuration.userId.value, - ): SetStateEndpoint = - SetStateEndpoint( - pubnub = this, - channels = channels, - channelGroups = channelGroups, - state = state, - uuid = uuid, - presenceData = presenceData, - ) - - /** - * Retrieve state information specific to a subscriber UUID. - * - * State information is supplied as a JSON object of key/value pairs. - * - * @param channels Channels to get the state from. - * @param channelGroups Channel groups to get the state from. - * @param uuid UUID of the user to get the state from. Defaults to the UUID of the client. - * @see [PNConfiguration.uuid] - */ - fun getPresenceState( - channels: List = listOf(), - channelGroups: List = listOf(), - uuid: String = configuration.userId.value, - ) = GetStateEndpoint(pubnub = this, channels = channels, channelGroups = channelGroups, uuid = uuid) - - /** - * Track the online and offline status of users and devices in real time and store custom state information. - * When you have Presence enabled, PubNub automatically creates a presence channel for each channel. - * - * Subscribing to a presence channel or presence channel group will only return presence events - * - * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. - * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. - */ - fun presence( - channels: List = emptyList(), - channelGroups: List = emptyList(), - connected: Boolean = false, - ) = presence.presence( - channels = channels.toSet(), - channelGroups = channelGroups.toSet(), - connected = connected, - ) - - //endregion - - //region MessageActions - - /** - * Add an action on a published message. Returns the added action in the response. - * - * @param channel Channel to publish message actions to. - * @param messageAction The message action object containing the message action's type, - * value and the publish timetoken of the original message. - */ - fun addMessageAction( - channel: String, - messageAction: PNMessageAction, - ) = AddMessageActionEndpoint(pubnub = this, channel = channel, messageAction = messageAction) - - /** - * Remove a previously added action on a published message. Returns an empty response. - * - * @param channel Channel to remove message actions from. - * @param messageTimetoken The publish timetoken of the original message. - * @param actionTimetoken The publish timetoken of the message action to be removed. - */ - fun removeMessageAction( - channel: String, - messageTimetoken: Long, - actionTimetoken: Long, - ) = RemoveMessageActionEndpoint( - pubnub = this, - channel = channel, - messageTimetoken = messageTimetoken, - actionTimetoken = actionTimetoken, - ) - - /** - * Get a list of message actions in a channel. Returns a list of actions in the response. - * - * @param channel Channel to fetch message actions from. - * @param start Message Action timetoken denoting the start of the range requested - * (return values will be less than start). - * @param end Message Action timetoken denoting the end of the range requested - * (return values will be greater than or equal to end). - * @param limit Specifies the number of message actions to return in response. - */ - @Deprecated( - replaceWith = - ReplaceWith( - "getMessageActions(channel = channel, page = PNBoundedPage(start = start, end = end, limit = limit))", - "com.pubnub.api.models.consumer.PNBoundedPage", - ), - level = DeprecationLevel.WARNING, - message = "Use getMessageActions(String, PNBoundedPage) instead", - ) - fun getMessageActions( - channel: String, - start: Long? = null, - end: Long? = null, - limit: Int? = null, - ) = getMessageActions(channel = channel, page = PNBoundedPage(start = start, end = end, limit = limit)) - - /** - * Get a list of message actions in a channel. Returns a list of actions in the response. - * - * @param channel Channel to fetch message actions from. - * @param page The paging object used for pagination. @see [PNBoundedPage] - */ - fun getMessageActions( - channel: String, - page: PNBoundedPage = PNBoundedPage(), - ) = GetMessageActionsEndpoint(pubnub = this, channel = channel, page = page) - //endregion - - //region ChannelGroups - - /** - * Adds a channel to a channel group. - * - * @param channels The channels to add to the channel group. - * @param channelGroup The channel group to add the channels to. - */ - fun addChannelsToChannelGroup( - channels: List, - channelGroup: String, - ) = AddChannelChannelGroupEndpoint(pubnub = this, channels = channels, channelGroup = channelGroup) - - /** - * Lists all the channels of the channel group. - * - * @param channelGroup Channel group to fetch the belonging channels. - */ - fun listChannelsForChannelGroup(channelGroup: String) = AllChannelsChannelGroupEndpoint(pubnub = this, channelGroup = channelGroup) - - /** - * Removes channels from a channel group. - * - * @param channelGroup The channel group to remove channels from - * @param channels The channels to remove from the channel group. - */ - fun removeChannelsFromChannelGroup( - channels: List, - channelGroup: String, - ) = RemoveChannelChannelGroupEndpoint(pubnub = this, channels = channels, channelGroup = channelGroup) - - /** - * Lists all registered channel groups for the subscribe key. - */ - fun listAllChannelGroups() = ListAllChannelGroupEndpoint(this) - - /** - * Removes the channel group. - * - * @param channelGroup The channel group to remove. - */ - fun deleteChannelGroup(channelGroup: String) = DeleteChannelGroupEndpoint(pubnub = this, channelGroup = channelGroup) - //endregion - - //region PAM - - /** - * This function establishes access permissions for PubNub Access Manager (PAM) by setting the `read` or `write` - * attribute to `true`. - * A grant with `read` or `write` set to `false` (or not included) will revoke any previous grants - * with `read` or `write` set to `true`. - * - * Permissions can be applied to any one of three levels: - * - Application level privileges are based on `subscribeKey` applying to all associated channels. - * - Channel level privileges are based on a combination of `subscribeKey` and `channel` name. - * - User level privileges are based on the combination of `subscribeKey`, `channel`, and `auth_key`. - * - * @param read Set to `true` to request the *read* permission. Defaults to `false`. - * @param write Set to `true` to request the *write* permission. Defaults to `false`. - * @param manage Set to `true` to request the *read* permission. Defaults to `false`. - * @param delete Set to `true` to request the *delete* permission. Defaults to `false`. - * @param ttl Time in minutes for which granted permissions are valid. - * Setting ttl to `0` will apply the grant indefinitely, which is also the default behavior. - * - * @param authKeys Specifies authKey to grant permissions to. It's possible to specify multiple auth keys. - * You can also grant access to a single authKey for multiple channels at the same time. - * @param channels Specifies the channels on which to grant permissions. - * If no channels/channelGroups are specified, then the grant applies to all channels/channelGroups - * that have been or will be created for that publish/subscribe key set. - * - * Furthermore, any existing or future grants on specific channels are ignored, - * until the all channels grant is revoked. - * - * It's possible to grant permissions to multiple channels simultaneously. - * Wildcard notation like a.* can be used to grant access on channels. You can grant one level deep. - * - `a.*` - you can grant on this. - * - `a.b.*` - grant won't work on this. If you grant on `a.b.*`, - * the grant will treat `a.b.*` as a single channel with name `a.b.*`. - * @param channelGroups Specifies the channel groups to grant permissions to. - * If no [channels] or [channelGroups] are specified, then the grant applies to all channels/channelGroups - * that have been or will be created for that publish/subscribe key set. - * - * Furthermore, any existing or future grants on specific [channelGroups] are ignored, - * until the all [channelGroups] grant is revoked. - * - * It's possible to grant permissions to multiple [channelGroups] simultaneously. - */ - fun grant( - read: Boolean = false, - write: Boolean = false, - manage: Boolean = false, - delete: Boolean = false, - ttl: Int = -1, - authKeys: List = emptyList(), - channels: List = emptyList(), - channelGroups: List = emptyList(), - uuids: List = emptyList(), - ) = GrantEndpoint( - pubnub = this, - read = read, - write = write, - manage = manage, - delete = delete, - ttl = ttl, - authKeys = authKeys, - channels = channels, - channelGroups = channelGroups, - uuids = uuids, - ) - - /** - * See [grant] - */ - fun grant( - read: Boolean = false, - write: Boolean = false, - manage: Boolean = false, - delete: Boolean = false, - get: Boolean = false, - update: Boolean = false, - join: Boolean = false, - ttl: Int = -1, - authKeys: List = emptyList(), - channels: List = emptyList(), - channelGroups: List = emptyList(), - uuids: List = emptyList(), - ) = GrantEndpoint( - pubnub = this, - read = read, - write = write, - manage = manage, - delete = delete, - get = get, - update = update, - join = join, - ttl = ttl, - authKeys = authKeys, - channels = channels, - channelGroups = channelGroups, - uuids = uuids, - ) - - /** - * This function generates a grant token for PubNub Access Manager (PAM). - * - * Permissions can be applied to any of the three type of resources: - * - channels - * - channel groups - * - uuid - metadata associated with particular UUID - * - * Each type of resource have different set of permissions. To know what's possible for each of them - * check ChannelGrant, ChannelGroupGrant and UUIDGrant. - * - * @param ttl Time in minutes for which granted permissions are valid. - * @param meta Additional metadata - * @param authorizedUUID Single uuid which is authorized to use the token to make API requests to PubNub - * @param channels List of all channel grants - * @param channelGroups List of all channel group grants - * @param uuids List of all uuid grants - */ - - fun grantToken( - ttl: Int, - meta: Any? = null, - authorizedUUID: String? = null, - channels: List = emptyList(), - channelGroups: List = emptyList(), - uuids: List = emptyList(), - ): GrantTokenEndpoint { - return GrantTokenEndpoint( - pubnub = this, - ttl = ttl, - meta = meta, - authorizedUUID = authorizedUUID, - channels = channels, - channelGroups = channelGroups, - uuids = uuids, - ) - } - - /** - * This function generates a grant token for PubNub Access Manager (PAM). - * - * Permissions can be applied to any of the two type of resources: - * - spacePermissions - * - userPermissions - * - * Each type of resource have different set of permissions. To know what's possible for each of them - * check SpacePermissions and UserPermissions. - * - * @param ttl Time in minutes for which granted permissions are valid. - * @param meta Additional metadata - * @param authorizedUserId Single userId which is authorized to use the token to make API requests to PubNub - * @param spacesPermissions List of all space grants - * @param usersPermissions List of all userId grants - */ - fun grantToken( - ttl: Int, - meta: Any? = null, - authorizedUserId: UserId? = null, - spacesPermissions: List = emptyList(), - usersPermissions: List = emptyList(), - ): GrantTokenEndpoint { - return GrantTokenEndpoint( - pubnub = this, - ttl = ttl, - meta = meta, - authorizedUUID = authorizedUserId?.value, - channels = spacesPermissions.map { spacePermissions -> spacePermissions.toChannelGrant() }, - channelGroups = emptyList(), - uuids = usersPermissions.map { userPermissions -> userPermissions.toUuidGrant() }, - ) - } - - /** - * This method allows you to disable an existing token and revoke all permissions embedded within. - * - * @param token Existing token with embedded permissions. - */ - fun revokeToken(token: String): RevokeTokenEndpoint { - return RevokeTokenEndpoint( - pubnub = this, - token = token, - ) - } - //endregion - - //region Miscellaneous - - /** - * Returns a 17 digit precision Unix epoch from the server. - */ - fun time() = TimeEndpoint(this) - //endregion - - //region ObjectsAPI - - /** - * Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each. - * - * @param limit Number of objects to return in the response. - * Default is 100, which is also the maximum value. - * Set limit to 0 (zero) and includeCount to true if you want to retrieve only a result count. - * @param page Use for pagination. - * - [PNNext] : Previously-returned cursor bookmark for fetching the next page. - * - [PNPrev] : Previously-returned cursor bookmark for fetching the previous page. - * Ignored if you also supply the start parameter. - * @param filter Expression used to filter the results. Only objects whose properties satisfy the given - * expression are returned. - * @param sort List of properties to sort by. Available options are id, name, and updated. - * @see [PNAsc], [PNDesc] - * @param includeCount Request totalCount to be included in paginated response. By default, totalCount is omitted. - * Default is `false`. - * @param includeCustom Include respective additional fields in the response. - */ - fun getAllChannelMetadata( - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - ) = GetAllChannelMetadataEndpoint( - pubnub = this, - collectionQueryParameters = - CollectionQueryParameters( - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - ), - includeQueryParam = IncludeQueryParam(includeCustom = includeCustom), - ) - - /** - * Returns metadata for the specified Channel, optionally including the custom data object for each. - * - * @param channel Channel name. - * @param includeCustom Include respective additional fields in the response. - */ - fun getChannelMetadata( - channel: String, - includeCustom: Boolean = false, - ) = GetChannelMetadataEndpoint( - pubnub = this, - channel = channel, - includeQueryParam = IncludeQueryParam(includeCustom = includeCustom), - ) - - /** - * Set metadata for a Channel in the database, optionally including the custom data object for each. - * - * @param channel Channel name. - * @param name Name of a channel. - * @param description Description of a channel. - * @param custom Object with supported data types. - * @param includeCustom Include respective additional fields in the response. - */ - fun setChannelMetadata( - channel: String, - name: String? = null, - description: String? = null, - custom: Any? = null, - includeCustom: Boolean = false, - type: String? = null, - status: String? = null, - ) = SetChannelMetadataEndpoint( - pubnub = this, - channel = channel, - name = name, - description = description, - custom = custom, - includeQueryParam = IncludeQueryParam(includeCustom = includeCustom), - type = type, - status = status, - ) - - /** - * Removes the metadata from a specified channel. - * - * @param channel Channel name. - */ - fun removeChannelMetadata(channel: String) = RemoveChannelMetadataEndpoint(this, channel = channel) - - /** - * Returns a paginated list of UUID Metadata objects, optionally including the custom data object for each. - * - * @param limit Number of objects to return in the response. - * Default is 100, which is also the maximum value. - * Set limit to 0 (zero) and includeCount to true if you want to retrieve only a result count. - * @param page Use for pagination. - * - [PNNext] : Previously-returned cursor bookmark for fetching the next page. - * - [PNPrev] : Previously-returned cursor bookmark for fetching the previous page. - * Ignored if you also supply the start parameter. - * @param filter Expression used to filter the results. Only objects whose properties satisfy the given - * expression are returned. - * @param sort List of properties to sort by. Available options are id, name, and updated. - * @see [PNAsc], [PNDesc] - * @param includeCount Request totalCount to be included in paginated response. By default, totalCount is omitted. - * Default is `false`. - * @param includeCustom Include respective additional fields in the response. - */ - fun getAllUUIDMetadata( - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - ) = GetAllUUIDMetadataEndpoint( - pubnub = this, - collectionQueryParameters = - CollectionQueryParameters( - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - ), - withInclude = IncludeQueryParam(includeCustom = includeCustom), - ) - - /** - * Returns metadata for the specified UUID, optionally including the custom data object for each. - * - * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. - * @param includeCustom Include respective additional fields in the response. - */ - fun getUUIDMetadata( - uuid: String? = null, - includeCustom: Boolean = false, - ) = GetUUIDMetadataEndpoint( - pubnub = this, - uuid = uuid ?: configuration.userId.value, - includeQueryParam = IncludeQueryParam(includeCustom = includeCustom), - ) - - /** - * Set metadata for a UUID in the database, optionally including the custom data object for each. - * - * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. - * @param name Display name for the user. Maximum 200 characters. - * @param externalId User's identifier in an external system - * @param profileUrl The URL of the user's profile picture - * @param email The user's email address. Maximum 80 characters. - * @param custom Object with supported data types. - * @param includeCustom Include respective additional fields in the response. - */ - fun setUUIDMetadata( - uuid: String? = null, - name: String? = null, - externalId: String? = null, - profileUrl: String? = null, - email: String? = null, - custom: Any? = null, - includeCustom: Boolean = false, - type: String? = null, - status: String? = null, - ) = SetUUIDMetadataEndpoint( - pubnub = this, - uuid = uuid, - name = name, - externalId = externalId, - profileUrl = profileUrl, - email = email, - custom = custom, - withInclude = IncludeQueryParam(includeCustom = includeCustom), - type = type, - status = status, - ) - - /** - * Removes the metadata from a specified UUID. - * - * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. - */ - fun removeUUIDMetadata(uuid: String? = null) = RemoveUUIDMetadataEndpoint(pubnub = this, uuid = uuid) - - /** - * The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions. - * - * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. - * @param limit Number of objects to return in the response. - * Default is 100, which is also the maximum value. - * Set limit to 0 (zero) and includeCount to true if you want to retrieve only a result count. - * @param page Use for pagination. - * - [PNNext] : Previously-returned cursor bookmark for fetching the next page. - * - [PNPrev] : Previously-returned cursor bookmark for fetching the previous page. - * Ignored if you also supply the start parameter. - * @param filter Expression used to filter the results. Only objects whose properties satisfy the given - * expression are returned. - * @param sort List of properties to sort by. Available options are id, name, and updated. - * @see [PNAsc], [PNDesc] - * @param includeCount Request totalCount to be included in paginated response. By default, totalCount is omitted. - * Default is `false`. - * @param includeCustom Include respective additional fields in the response. - * @param includeChannelDetails Include custom fields for channels metadata. - */ - fun getMemberships( - uuid: String? = null, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeChannelDetails: PNChannelDetailsLevel? = null, - includeType: Boolean = false, - ) = GetMembershipsEndpoint( - pubnub = this, - uuid = uuid ?: configuration.userId.value, - collectionQueryParameters = - CollectionQueryParameters( - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - ), - includeQueryParam = - IncludeQueryParam( - includeCustom = includeCustom, - includeChannelDetails = includeChannelDetails, - includeChannelType = includeType, - ), - ) - - /** - * @see [PubNubCore.setMemberships] - */ - @Deprecated( - replaceWith = - ReplaceWith( - "setMemberships(channels = channels, uuid = uuid, limit = limit, " + - "page = page, filter = filter, sort = sort, includeCount = includeCount, includeCustom = includeCustom," + - "includeChannelDetails = includeChannelDetails)", - ), - level = DeprecationLevel.WARNING, - message = "Use setMemberships instead", - ) - fun addMemberships( - channels: List, - uuid: String? = null, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeChannelDetails: PNChannelDetailsLevel? = null, - ) = setMemberships( - channels = channels, - uuid = uuid ?: configuration.userId.value, - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - includeCustom = includeCustom, - includeChannelDetails = includeChannelDetails, - ) - - /** - * Set channel memberships for a UUID. - * - * @param channels List of channels to add to membership. List can contain strings (channel-name only) - * or objects (which can include custom data). @see [PNChannelWithCustom] - * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. - * @param limit Number of objects to return in the response. - * Default is 100, which is also the maximum value. - * Set limit to 0 (zero) and includeCount to true if you want to retrieve only a result count. - * @param page Use for pagination. - * - [PNNext] : Previously-returned cursor bookmark for fetching the next page. - * - [PNPrev] : Previously-returned cursor bookmark for fetching the previous page. - * Ignored if you also supply the start parameter. - * @param filter Expression used to filter the results. Only objects whose properties satisfy the given - * expression are returned. - * @param sort List of properties to sort by. Available options are id, name, and updated. - * @see [PNAsc], [PNDesc] - * @param includeCount Request totalCount to be included in paginated response. By default, totalCount is omitted. - * Default is `false`. - * @param includeCustom Include respective additional fields in the response. - * @param includeChannelDetails Include custom fields for channels metadata. - */ - fun setMemberships( - channels: List, - uuid: String? = null, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeChannelDetails: PNChannelDetailsLevel? = null, - includeType: Boolean = false - ) = manageMemberships( - channelsToSet = channels, - channelsToRemove = listOf(), - uuid = uuid ?: configuration.userId.value, - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - includeCustom = includeCustom, - includeChannelDetails = includeChannelDetails, - includeType = includeType - ) - - /** - * Remove channel memberships for a UUID. - * - * @param channels Channels to remove from membership. - * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. - * @param limit Number of objects to return in the response. - * Default is 100, which is also the maximum value. - * Set limit to 0 (zero) and includeCount to true if you want to retrieve only a result count. - * @param page Use for pagination. - * - [PNNext] : Previously-returned cursor bookmark for fetching the next page. - * - [PNPrev] : Previously-returned cursor bookmark for fetching the previous page. - * Ignored if you also supply the start parameter. - * @param filter Expression used to filter the results. Only objects whose properties satisfy the given - * expression are returned. - * @param sort List of properties to sort by. Available options are id, name, and updated. - * @see [PNAsc], [PNDesc] - * @param includeCount Request totalCount to be included in paginated response. By default, totalCount is omitted. - * Default is `false`. - * @param includeCustom Include respective additional fields in the response. - * @param includeChannelDetails Include custom fields for channels metadata. - */ - fun removeMemberships( - channels: List, - uuid: String? = null, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeChannelDetails: PNChannelDetailsLevel? = null, - includeType: Boolean = false, - ) = manageMemberships( - channelsToSet = listOf(), - channelsToRemove = channels, - uuid = uuid ?: configuration.userId.value, - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - includeCustom = includeCustom, - includeChannelDetails = includeChannelDetails, - includeType = includeType, - ) - - /** - * Add and remove channel memberships for a UUID. - * - * @param channelsToSet Collection of channels to add to membership. @see [com.pubnub.api.models.consumer.objects.membership.PNChannelMembership.Partial] - * @param channelsToRemove Channels to remove from membership. - * @param uuid Unique user identifier. If not supplied then current user’s uuid is used. - * @param limit Number of objects to return in the response. - * Default is 100, which is also the maximum value. - * Set limit to 0 (zero) and includeCount to true if you want to retrieve only a result count. - * @param page Use for pagination. - * - [PNNext] : Previously-returned cursor bookmark for fetching the next page. - * - [PNPrev] : Previously-returned cursor bookmark for fetching the previous page. - * Ignored if you also supply the start parameter. - * @param filter Expression used to filter the results. Only objects whose properties satisfy the given - * expression are returned. - * @param sort List of properties to sort by. Available options are id, name, and updated. - * @see [PNAsc], [PNDesc] - * @param includeCount Request totalCount to be included in paginated response. By default, totalCount is omitted. - * Default is `false`. - * @param includeCustom Include respective additional fields in the response. - * @param includeChannelDetails Include custom fields for channels metadata. - */ - fun manageMemberships( - channelsToSet: List, - channelsToRemove: List, - uuid: String? = null, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeChannelDetails: PNChannelDetailsLevel? = null, - includeType: Boolean = false, - ) = ManageMembershipsEndpoint( - pubnub = this, - channelsToSet = channelsToSet, - channelsToRemove = channelsToRemove, - uuid = uuid ?: configuration.userId.value, - collectionQueryParameters = - CollectionQueryParameters( - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - ), - includeQueryParam = - IncludeQueryParam( - includeCustom = includeCustom, - includeChannelDetails = includeChannelDetails, - includeChannelType = includeType, - ), - ) - - /** - * @see [PubNub.getChannelMembers] - */ - @Deprecated( - replaceWith = - ReplaceWith( - "getChannelMembers(channel = channel, limit = limit, " + - "page = page, filter = filter, sort = sort, includeCount = includeCount, includeCustom = includeCustom," + - "includeUUIDDetails = includeUUIDDetails)", - ), - level = DeprecationLevel.WARNING, - message = "Use getChannelMembers instead", - ) - fun getMembers( - channel: String, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, - ) = getChannelMembers( - channel = channel, - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - includeCustom = includeCustom, - includeUUIDDetails = includeUUIDDetails, - ) - - /** - * The method returns a list of members in a channel. The list will include user metadata for members - * that have additional metadata stored in the database. - * - * @param channel Channel name - * @param limit Number of objects to return in the response. - * Default is 100, which is also the maximum value. - * Set limit to 0 (zero) and includeCount to true if you want to retrieve only a result count. - * @param page Use for pagination. - * - [PNNext] : Previously-returned cursor bookmark for fetching the next page. - * - [PNPrev] : Previously-returned cursor bookmark for fetching the previous page. - * Ignored if you also supply the start parameter. - * @param filter Expression used to filter the results. Only objects whose properties satisfy the given - * expression are returned. - * @param sort List of properties to sort by. Available options are id, name, and updated. - * @see [PNAsc], [PNDesc] - * @param includeCount Request totalCount to be included in paginated response. By default, totalCount is omitted. - * Default is `false`. - * @param includeCustom Include respective additional fields in the response. - * @param includeUUIDDetails Include custom fields for UUIDs metadata. - */ - fun getChannelMembers( - channel: String, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, - includeType: Boolean = false, - ) = GetChannelMembersEndpoint( - pubnub = this, - channel = channel, - collectionQueryParameters = - CollectionQueryParameters( - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - ), - includeQueryParam = - IncludeQueryParam( - includeCustom = includeCustom, - includeUUIDDetails = includeUUIDDetails, - includeUuidType = includeType, - ), - ) - - /** - * @see [PubNub.setChannelMembers] - */ - @Deprecated( - replaceWith = - ReplaceWith( - "setChannelMembers(channel = channel, uuids = uuids, limit = limit, " + - "page = page, filter = filter, sort = sort, includeCount = includeCount, includeCustom = includeCustom," + - "includeUUIDDetails = includeUUIDDetails)", - ), - level = DeprecationLevel.WARNING, - message = "Use setChannelMembers instead", - ) - fun addMembers( - channel: String, - uuids: List, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, - ) = setChannelMembers( - channel = channel, - uuids = uuids, - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - includeCustom = includeCustom, - includeUUIDDetails = includeUUIDDetails, - ) - - /** - * This method sets members in a channel. - * - * @param channel Channel name - * @param uuids List of members to add to the channel. List can contain strings (uuid only) - * or objects (which can include custom data). @see [PNMember.Partial] - * @param limit Number of objects to return in the response. - * Default is 100, which is also the maximum value. - * Set limit to 0 (zero) and includeCount to true if you want to retrieve only a result count. - * @param page Use for pagination. - * - [PNNext] : Previously-returned cursor bookmark for fetching the next page. - * - [PNPrev] : Previously-returned cursor bookmark for fetching the previous page. - * Ignored if you also supply the start parameter. - * @param filter Expression used to filter the results. Only objects whose properties satisfy the given - * expression are returned. - * @param sort List of properties to sort by. Available options are id, name, and updated. - * @see [PNAsc], [PNDesc] - * @param includeCount Request totalCount to be included in paginated response. By default, totalCount is omitted. - * Default is `false`. - * @param includeCustom Include respective additional fields in the response. - * @param includeUUIDDetails Include custom fields for UUIDs metadata. - */ - fun setChannelMembers( - channel: String, - uuids: List, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, - includeType: Boolean = false, - ) = manageChannelMembers( - channel = channel, - uuidsToSet = uuids, - uuidsToRemove = listOf(), - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - includeCustom = includeCustom, - includeUUIDDetails = includeUUIDDetails, - includeType = includeType - ) - - /** - * @see [PubNub.removeChannelMembers] - */ - @Deprecated( - replaceWith = - ReplaceWith( - "removeChannelMembers(channel = channel, uuids = uuids, limit = limit, " + - "page = page, filter = filter, sort = sort, includeCount = includeCount, includeCustom = includeCustom," + - "includeUUIDDetails = includeUUIDDetails)", - ), - level = DeprecationLevel.WARNING, - message = "Use removeChannelMembers instead", - ) - fun removeMembers( - channel: String, - uuids: List, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, - ) = removeChannelMembers( - channel = channel, - uuids = uuids, - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - includeCustom = includeCustom, - includeUUIDDetails = includeUUIDDetails, - ) - - /** - * Remove members from a Channel. - * - * @param channel Channel name - * @param uuids Members to remove from channel. - * @param limit Number of objects to return in the response. - * Default is 100, which is also the maximum value. - * Set limit to 0 (zero) and includeCount to true if you want to retrieve only a result count. - * @param page Use for pagination. - * - [PNNext] : Previously-returned cursor bookmark for fetching the next page. - * - [PNPrev] : Previously-returned cursor bookmark for fetching the previous page. - * Ignored if you also supply the start parameter. - * @param filter Expression used to filter the results. Only objects whose properties satisfy the given - * expression are returned. - * @param sort List of properties to sort by. Available options are id, name, and updated. - * @see [PNAsc], [PNDesc] - * @param includeCount Request totalCount to be included in paginated response. By default, totalCount is omitted. - * Default is `false`. - * @param includeCustom Include respective additional fields in the response. - * @param includeUUIDDetails Include custom fields for UUIDs metadata. - */ - fun removeChannelMembers( - channel: String, - uuids: List, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, - includeType: Boolean = false, - ) = manageChannelMembers( - channel = channel, - uuidsToSet = listOf(), - uuidsToRemove = uuids, - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - includeCustom = includeCustom, - includeUUIDDetails = includeUUIDDetails, - includeType = includeType, - ) - - /** - * Set or remove members in a channel. - * - * @param channel Channel name - * @param uuidsToSet Collection of members to add to the channel. @see [com.pubnub.api.models.consumer.objects.member.PNMember.Partial] - * @param uuidsToRemove Members to remove from channel. - * @param limit Number of objects to return in the response. - * Default is 100, which is also the maximum value. - * Set limit to 0 (zero) and includeCount to true if you want to retrieve only a result count. - * @param page Use for pagination. - * - [PNNext] : Previously-returned cursor bookmark for fetching the next page. - * - [PNPrev] : Previously-returned cursor bookmark for fetching the previous page. - * Ignored if you also supply the start parameter. - * @param filter Expression used to filter the results. Only objects whose properties satisfy the given - * expression are returned. - * @param sort List of properties to sort by. Available options are id, name, and updated. - * @see [PNAsc], [PNDesc] - * @param includeCount Request totalCount to be included in paginated response. By default, totalCount is omitted. - * Default is `false`. - * @param includeCustom Include respective additional fields in the response. - * @param includeUUIDDetails Include custom fields for UUIDs metadata. - */ - fun manageChannelMembers( - channel: String, - uuidsToSet: Collection, - uuidsToRemove: Collection, - limit: Int? = null, - page: PNPage? = null, - filter: String? = null, - sort: Collection> = listOf(), - includeCount: Boolean = false, - includeCustom: Boolean = false, - includeUUIDDetails: PNUUIDDetailsLevel? = null, - includeType: Boolean = false, - ) = ManageChannelMembersEndpoint( - pubnub = this, - channel = channel, - uuidsToSet = uuidsToSet, - uuidsToRemove = uuidsToRemove, - collectionQueryParameters = - CollectionQueryParameters( - limit = limit, - page = page, - filter = filter, - sort = sort, - includeCount = includeCount, - ), - includeQueryParam = - IncludeQueryParam( - includeCustom = includeCustom, - includeUUIDDetails = includeUUIDDetails, - includeUuidType = includeType, - ), - ) - - //endregion ObjectsAPI - - //region files - - /** - * Upload file / data to specified Channel. - * - * @param channel Channel name - * @param fileName Name of the file to send. - * @param inputStream Input stream with file content. The inputStream will be depleted after the call. - * @param message The payload. - * **Warning:** It is important to note that you should not serialize JSON - * when sending signals/messages via PubNub. - * Why? Because the serialization is done for you automatically. - * Instead just pass the full object as the message payload. - * PubNub takes care of everything for you. - * @param meta Metadata object which can be used with the filtering ability. - * @param ttl Set a per message time to live in storage. - * - If `shouldStore = true`, and `ttl = 0`, the message is stored - * with no expiry time. - * - If `shouldStore = true` and `ttl = X` (`X` is an Integer value), - * the message is stored with an expiry time of `X` hours. - * - If `shouldStore = false`, the `ttl` parameter is ignored. - * - If ttl isn't specified, then expiration of the message defaults - * back to the expiry value for the key. - * @param shouldStore Store in history. - * If not specified, then the history configuration of the key is used. - * @param cipherKey Key to be used to encrypt uploaded data. - */ - fun sendFile( - channel: String, - fileName: String, - inputStream: InputStream, - message: Any? = null, - meta: Any? = null, - ttl: Int? = null, - shouldStore: Boolean? = null, - cipherKey: String? = null, - ): SendFileEndpoint { - val cryptoModule = - if (cipherKey != null) { - CryptoModule.createLegacyCryptoModule(cipherKey) - } else { - configuration.cryptoModule - } - - return SendFileEndpoint( - channel = channel, - fileName = fileName, - inputStream = inputStream, - message = message, - meta = meta, - ttl = ttl, - shouldStore = shouldStore, - executorService = - retrofitManager.getTransactionClientExecutorService() - ?: Executors.newSingleThreadExecutor(), - fileMessagePublishRetryLimit = configuration.fileMessagePublishRetryLimit, - generateUploadUrlFactory = GenerateUploadUrlEndpoint.Factory(this), - publishFileMessageFactory = PublishFileMessageEndpoint.Factory(this), - sendFileToS3Factory = UploadFileEndpoint.Factory(this), - cryptoModule = cryptoModule, - ) - } - - /** - * Retrieve list of files uploaded to Channel. - * - * @param channel Channel name - * @param limit Number of files to return. Minimum value is 1, and maximum is 100. Default value is 100. - * @param next Previously-returned cursor bookmark for fetching the next page. @see [PNPage.PNNext] - */ - fun listFiles( - channel: String, - limit: Int? = null, - next: PNPage.PNNext? = null, - ): ListFilesEndpoint { - return ListFilesEndpoint( - pubNub = this, - channel = channel, - limit = limit, - next = next, - ) - } - - /** - * Generate URL which can be used to download file from target Channel. - * - * @param channel Name of channel to which the file has been uploaded. - * @param fileName Name under which the uploaded file is stored. - * @param fileId Unique identifier for the file, assigned during upload. - */ - fun getFileUrl( - channel: String, - fileName: String, - fileId: String, - ): GetFileUrlEndpoint { - return GetFileUrlEndpoint( - pubNub = this, - channel = channel, - fileName = fileName, - fileId = fileId, - ) - } - - /** - * Download file from specified Channel. - * - * @param channel Name of channel to which the file has been uploaded. - * @param fileName Name under which the uploaded file is stored. - * @param fileId Unique identifier for the file, assigned during upload. - * @param cipherKey Key to be used to decrypt downloaded data. If a key is not provided, - * the SDK uses the cipherKey from the @see [PNConfiguration]. - */ - fun downloadFile( - channel: String, - fileName: String, - fileId: String, - cipherKey: String? = null, - ): DownloadFileEndpoint { - val cryptoModule = - if (cipherKey != null) { - CryptoModule.createLegacyCryptoModule(cipherKey) - } else { - configuration.cryptoModule - } - - return DownloadFileEndpoint( - pubNub = this, - channel = channel, - fileName = fileName, - fileId = fileId, - cryptoModule = cryptoModule, - ) - } - - /** - * Delete file from specified Channel. - * - * @param channel Name of channel to which the file has been uploaded. - * @param fileName Name under which the uploaded file is stored. - * @param fileId Unique identifier for the file, assigned during upload. - */ - fun deleteFile( - channel: String, - fileName: String, - fileId: String, - ): DeleteFileEndpoint { - return DeleteFileEndpoint( - pubNub = this, - channel = channel, - fileName = fileName, - fileId = fileId, - ) - } - - /** - * Publish file message from specified Channel. - * @param channel Name of channel to which the file has been uploaded. - * @param fileName Name under which the uploaded file is stored. - * @param fileId Unique identifier for the file, assigned during upload. - * @param message The payload. - * **Warning:** It is important to note that you should not serialize JSON - * when sending signals/messages via PubNub. - * Why? Because the serialization is done for you automatically. - * Instead just pass the full object as the message payload. - * PubNub takes care of everything for you. - * @param meta Metadata object which can be used with the filtering ability. - * @param ttl Set a per message time to live in storage. - * - If `shouldStore = true`, and `ttl = 0`, the message is stored - * with no expiry time. - * - If `shouldStore = true` and `ttl = X` (`X` is an Integer value), - * the message is stored with an expiry time of `X` hours. - * - If `shouldStore = false`, the `ttl` parameter is ignored. - * - If ttl isn't specified, then expiration of the message defaults - * back to the expiry value for the key. - * @param shouldStore Store in history. - * If not specified, then the history configuration of the key is used. - * - */ - fun publishFileMessage( - channel: String, - fileName: String, - fileId: String, - message: Any? = null, - meta: Any? = null, - ttl: Int? = null, - shouldStore: Boolean? = null, - ): PublishFileMessageEndpoint { - return PublishFileMessageEndpoint( - pubNub = this, - channel = channel, - fileName = fileName, - fileId = fileId, - message = message, - meta = meta, - ttl = ttl, - shouldStore = shouldStore, - ) - } - //endregion - - //region Encryption - - /** - * Perform Cryptographic decryption of an input string using cipher key provided by [BasePNConfiguration.cipherKey]. - * - * @param inputString String to be decrypted. - * - * @return String containing the decryption of `inputString` using `cipherKey`. - * @throws PubNubException throws exception in case of failed decryption. - */ - @Throws(PubNubException::class) - fun decrypt(inputString: String): String = decrypt(inputString, null) - - /** - * Perform Cryptographic decryption of an input string using a cipher key. - * - * @param inputString String to be decrypted. - * @param cipherKey cipher key to be used for decryption. Default is [BasePNConfiguration.cipherKey] - * - * @return String containing the decryption of `inputString` using `cipherKey`. - * @throws PubNubException throws exception in case of failed decryption. - */ - @Throws(PubNubException::class) - fun decrypt( - inputString: String, - cryptoModule: CryptoModule? = null, - ): String = getCryptoModuleOrThrow(cryptoModule).decryptString(inputString) - - /** - * Perform Cryptographic decryption of an input stream using provided cipher key. - * - * @param inputStream InputStream to be encrypted. - * @param cipherKey Cipher key to be used for decryption. - * - * @return InputStream containing the encryption of `inputStream` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed decryption. - */ - @Throws(PubNubException::class) - fun decryptInputStream( - inputStream: InputStream, - cryptoModule: CryptoModule? = null, - ): InputStream = getCryptoModuleOrThrow(cryptoModule).decryptStream(inputStream) - - /** - * Perform Cryptographic encryption of an input string and a cipher key. - * - * @param inputString String to be encrypted. - * @param cipherKey Cipher key to be used for encryption. Default is [BasePNConfiguration.cipherKey] - * - * @return String containing the encryption of `inputString` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed encryption. - */ - @Throws(PubNubException::class) - fun encrypt( - inputString: String, - cryptoModule: CryptoModule? = null, - ): String = getCryptoModuleOrThrow(cryptoModule).encryptString(inputString) - - /** - * Perform Cryptographic encryption of an input stream using provided cipher key. - * - * @param inputStream InputStream to be encrypted. - * @param cipherKey Cipher key to be used for encryption. - * - * @return InputStream containing the encryption of `inputStream` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed encryption. - */ - @Throws(PubNubException::class) - fun encryptInputStream( - inputStream: InputStream, - cryptoModule: CryptoModule? = null, - ): InputStream = getCryptoModuleOrThrow(cryptoModule).encryptStream(inputStream) - - @Throws(PubNubException::class) - private fun getCryptoModuleOrThrow(cryptoModule: CryptoModule? = null): CryptoModule { - return cryptoModule ?: configuration.cryptoModule ?: throw PubNubException("Crypto module is not initialized") - } - //endregion - - /** - * Force the SDK to try and reach out PubNub. Monitor the results in [SubscribeCallback.status] - * - * @param timetoken optional timetoken to use for the subscriptions on reconnection. - */ - fun reconnect(timetoken: Long = 0L) { - subscribe.reconnect(timetoken) - presence.reconnect() - } - - /** - * Cancel any subscribe and heartbeat loops or ongoing re-connections. - * - * Monitor the results in [SubscribeCallback.status] - */ - fun disconnect() { - subscribe.disconnect() - presence.disconnect() - } - - /** - * Frees up threads and allows for a clean exit. - */ - fun destroy() { - subscribe.destroy() - presence.destroy() - - retrofitManager.destroy() - executorService.shutdown() - } - - /** - * Same as [destroy] but immediately. - */ - fun forceDestroy() { - subscribe.destroy() - presence.destroy() - - retrofitManager.destroy(true) - executorService.shutdownNow() - } - - fun parseToken(token: String): PNToken { - return tokenParser.unwrapToken(token) - } - - fun setToken(token: String?) { - return tokenManager.setToken(token) - } - - // internal - private val lockChannelsAndGroups = Any() - private val channelSubscriptions = mutableMapOf>>() - private val channelGroupSubscriptions = mutableMapOf>>() - - internal fun subscribe( - vararg subscriptions: BaseSubscriptionImpl<*>, - cursor: SubscriptionCursor, - ) { - synchronized(lockChannelsAndGroups) { - val channelsToSubscribe = mutableSetOf() - subscriptions.forEach { subscription -> - subscription.channels.forEach { channelName -> - channelSubscriptions.computeIfAbsent(channelName) { mutableSetOf() } - .also { set -> set.add(subscription) } - channelsToSubscribe.add(channelName) - } - } - val groupsToSubscribe = mutableSetOf() - subscriptions.forEach { subscription -> - subscription.channelGroups.forEach { channelGroupName -> - channelGroupSubscriptions.computeIfAbsent(channelGroupName) { mutableSetOf() } - .also { set -> set.add(subscription) } - groupsToSubscribe.add(channelGroupName) - } - } - - val (channelsWithPresence, channelsNoPresence) = - channelsToSubscribe.filter { !it.isPresence } - .partition { - channelsToSubscribe.contains(it.withPresence) - } - val (groupsWithPresence, groupsNoPresence) = - groupsToSubscribe.filter { !it.isPresence }.partition { - groupsToSubscribe.contains(it.withPresence) - } - if (channelsWithPresence.isNotEmpty() || groupsWithPresence.isNotEmpty()) { - subscribeInternal( - channels = channelsWithPresence.map(ChannelName::id), - channelGroups = groupsWithPresence.map(ChannelGroupName::id), - withPresence = true, - withTimetoken = cursor.timetoken, - ) - } - if (channelsNoPresence.isNotEmpty() || groupsNoPresence.isNotEmpty()) { - subscribeInternal( - channels = channelsNoPresence.map(ChannelName::id), - channelGroups = groupsNoPresence.map(ChannelGroupName::id), - withPresence = false, - withTimetoken = cursor.timetoken, - ) - } - } - } - - internal fun unsubscribe(vararg subscriptions: BaseSubscriptionImpl<*>) { - synchronized(lockChannelsAndGroups) { - val channelsToUnsubscribe = mutableSetOf() - subscriptions.forEach { subscription -> - subscription.channels.forEach { channelName -> - val set = channelSubscriptions[channelName] - set?.remove(subscription) - if (set != null && set.isEmpty()) { // there were mappings but there none now - channelsToUnsubscribe += channelName - channelSubscriptions.remove(channelName) - } - } - } - - val groupsToUnsubscribe = mutableSetOf() - subscriptions.forEach { subscription -> - subscription.channelGroups.forEach { channelGroupName -> - val set = channelGroupSubscriptions[channelGroupName] - set?.remove(subscription) - if (set != null && set.isEmpty()) { - groupsToUnsubscribe += channelGroupName - channelGroupSubscriptions.remove(channelGroupName) - } - } - } - if (channelsToUnsubscribe.isNotEmpty() || groupsToUnsubscribe.isNotEmpty()) { - unsubscribeInternal( - channels = channelsToUnsubscribe.map(ChannelName::id), - channelGroups = groupsToUnsubscribe.map(ChannelGroupName::id), - ) - } - } - } - - private val channelSubscriptionMap = mutableMapOf>() - private val channelGroupSubscriptionMap = mutableMapOf>() - - //region Subscribe - - /** - * Causes the client to create an open TCP socket to the PubNub Real-Time Network and begin listening for messages - * on a specified channel. - * - * To subscribe to a channel the client must send the appropriate [BasePNConfiguration.subscribeKey] at initialization. - * - * By default, a newly subscribed client will only receive messages published to the channel - * after the `subscribe()` call completes. - * - * If a client gets disconnected from a channel, it can automatically attempt to reconnect to that channel - * and retrieve any available messages that were missed during that period. - * This can be achieved by setting [BasePNConfiguration.retryConfiguration] when - * initializing the client. - * - * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. - * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. - * @param withPresence Also subscribe to related presence channel. - * @param withTimetoken A timetoken to start the subscribe loop from. - */ - @Synchronized - fun subscribe( - channels: List = emptyList(), - channelGroups: List = emptyList(), - withPresence: Boolean = false, - withTimetoken: Long = 0L, - ) { - val toSubscribe = mutableSetOf>() - channels.filter { it.isNotEmpty() }.map { ChannelName(it) }.forEach { channelName -> - // if we are adding a NEW subscriptions in this step, this var will contain it: - var subscription: BaseSubscriptionImpl<*>? = null - channelSubscriptionMap.computeIfAbsent(channelName) { newChannelName -> - val channel = - BaseChannelImpl( - this, - newChannelName, - subscriptionFactory, - ) - val options = - if (withPresence) { - SubscriptionOptions.receivePresenceEvents() - } else { - EmptyOptions - } - channel.subscription(options).also { sub -> - toSubscribe.add(sub) - subscription = sub - } - } - // make sure we are also subscribed and tracking the -pnpres channel if withPresence==true - if (withPresence) { - channelSubscriptionMap.computeIfAbsent(channelName.withPresence) { presenceChannelName -> - // this will either be the subscriptions we just created in the previous step, - // or if we were already subscribed to the channel WITHOUT presence, we need to create a new one - subscription ?: BaseChannelImpl( - this, - presenceChannelName, - subscriptionFactory, - ).subscription().also { sub -> - toSubscribe.add(sub) - } - } - } - } - channelGroups.filter { it.isNotEmpty() }.map { ChannelGroupName(it) }.forEach { channelGroupName -> - var subscription: BaseSubscriptionImpl<*>? = null - - channelGroupSubscriptionMap.computeIfAbsent(channelGroupName) { newChannelGroupName -> - val channelGroup = BaseChannelGroupImpl(this, newChannelGroupName, subscriptionFactory) - val options = - if (withPresence) { - SubscriptionOptions.receivePresenceEvents() - } else { - EmptyOptions - } - channelGroup.subscription(options).also { sub -> - toSubscribe.add(sub) - subscription = sub - } - } - // make sure we are also subscribed and tracking the -pnpres channel if withPresence==true - if (withPresence) { - channelGroupSubscriptionMap.computeIfAbsent(channelGroupName.withPresence) { presenceGroupName -> - // this will either be the subscriptions we just created in the previous step, - // or if we were already subscribed to the channel WITHOUT presence, we need to create a new one - subscription ?: BaseChannelGroupImpl(this, presenceGroupName, subscriptionFactory) - .subscription().also { sub -> - toSubscribe.add(sub) - } - } - } - } - - // actually subscribe to all subscriptions created in this function and added to the set - subscribe(*toSubscribe.toTypedArray(), cursor = SubscriptionCursor(withTimetoken)) - } - - /** - * When subscribed to a single channel, this function causes the client to issue a leave from the channel - * and close any open socket to the PubNub Network. - * - * For multiplexed channels, the specified channel(s) will be removed and the socket remains open - * until there are no more channels remaining in the list. - * - * * **WARNING** - * Unsubscribing from all the channel(s) and then subscribing to a new channel Y isn't the same as - * Subscribing to channel Y and then unsubscribing from the previously subscribed channel(s). - * - * Unsubscribing from all the channels resets the timetoken and thus, - * there could be some gaps in the subscriptions that may lead to a message loss. - * - * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. - * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. - */ - @Synchronized - fun unsubscribe( - channels: List = emptyList(), - channelGroups: List = emptyList(), - ) { - val toUnsubscribe: MutableSet> = mutableSetOf() - channels.filter { it.isNotEmpty() }.map { ChannelName(it) }.forEach { channelName -> - channelSubscriptionMap.remove(channelName)?.let { sub -> - toUnsubscribe.add(sub) - } - channelSubscriptionMap.remove(channelName.withPresence)?.let { sub -> - toUnsubscribe.add(sub) - } - } - channelGroups.filter { it.isNotEmpty() }.map { ChannelGroupName(it) }.forEach { groupName -> - channelGroupSubscriptionMap.remove(groupName)?.let { sub -> - toUnsubscribe.add(sub) - } - channelGroupSubscriptionMap.remove(groupName.withPresence)?.let { sub -> - toUnsubscribe.add(sub) - } - } - unsubscribe(*toUnsubscribe.toTypedArray()) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/SpaceId.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/SpaceId.kt deleted file mode 100644 index 5d1cdf33d..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/SpaceId.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.pubnub.internal - -data class SpaceId(val value: String) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/SubscriptionFactory.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/SubscriptionFactory.kt deleted file mode 100644 index a14068837..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/SubscriptionFactory.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.pubnub.internal - -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.v2.entities.ChannelGroupName -import com.pubnub.internal.v2.entities.ChannelName - -typealias SubscriptionFactory = ( - channels: Set, - channelGroups: Set, - options: SubscriptionOptions, -) -> T diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/callbacks/SubscribeCallback.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/callbacks/SubscribeCallback.kt deleted file mode 100644 index f825b52c7..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/callbacks/SubscribeCallback.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.callbacks - -import com.pubnub.internal.v2.callbacks.EventListenerCore -import com.pubnub.internal.v2.callbacks.StatusListenerCore - -interface SubscribeCallback : StatusListenerCore, EventListenerCore diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesInterface.kt deleted file mode 100644 index 9cfff1fd1..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesInterface.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.pubnub.internal.endpoints - -import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult -import com.pubnub.internal.EndpointInterface - -interface DeleteMessagesInterface : EndpointInterface { - val channels: List - val start: Long? - val end: Long? -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesInterface.kt deleted file mode 100644 index 6496cc65a..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesInterface.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints - -import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.history.PNFetchMessagesResult -import com.pubnub.internal.EndpointInterface - -interface FetchMessagesInterface : EndpointInterface { - val channels: List - val page: PNBoundedPage - val includeUUID: Boolean - val includeMeta: Boolean - val includeMessageActions: Boolean - val includeMessageType: Boolean -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryInterface.kt deleted file mode 100644 index ebca40da1..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryInterface.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints - -import com.pubnub.api.models.consumer.history.PNHistoryResult -import com.pubnub.internal.EndpointInterface - -interface HistoryInterface : EndpointInterface { - val channel: String - val start: Long? - val end: Long? - val count: Int - val reverse: Boolean - val includeTimetoken: Boolean - val includeMeta: Boolean -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsInterface.kt deleted file mode 100644 index 41f831278..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsInterface.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.pubnub.internal.endpoints - -import com.pubnub.api.models.consumer.history.PNMessageCountResult -import com.pubnub.internal.EndpointInterface - -interface MessageCountsInterface : EndpointInterface { - val channels: List - val channelsTimetoken: List -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeInterface.kt deleted file mode 100644 index 71d8c835a..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeInterface.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.endpoints - -import com.pubnub.api.models.consumer.PNTimeResult -import com.pubnub.internal.EndpointInterface - -interface TimeInterface : EndpointInterface diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantInterface.kt deleted file mode 100644 index 83edc23f1..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantInterface.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.pubnub.internal.endpoints.access - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface GrantInterface : HasOverridableConfig { - val read: Boolean - val write: Boolean - val manage: Boolean - val delete: Boolean - val get: Boolean - val update: Boolean - val join: Boolean - val ttl: Int - val authKeys: List - val channels: List - val channelGroups: List - val uuids: List -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenInterface.kt deleted file mode 100644 index c30ba255d..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenInterface.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.pubnub.internal.endpoints.access - -import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult -import com.pubnub.internal.EndpointInterface - -interface GrantTokenInterface : EndpointInterface { - val ttl: Int -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenInterface.kt deleted file mode 100644 index e7a41a5d5..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenInterface.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.internal.endpoints.access - -import com.pubnub.internal.EndpointInterface - -interface RevokeTokenInterface : EndpointInterface diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupInterface.kt deleted file mode 100644 index c171e0bc2..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupInterface.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups - -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult -import com.pubnub.internal.EndpointInterface - -interface AddChannelChannelGroupInterface : EndpointInterface { - val channelGroup: String - val channels: List -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupInterface.kt deleted file mode 100644 index 57d14dd9d..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupInterface.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups - -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult -import com.pubnub.internal.EndpointInterface - -interface AllChannelsChannelGroupInterface : EndpointInterface { - val channelGroup: String -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupInterface.kt deleted file mode 100644 index 16e5e8d8c..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupInterface.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups - -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult -import com.pubnub.internal.EndpointInterface - -interface DeleteChannelGroupInterface : EndpointInterface { - val channelGroup: String -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupInterface.kt deleted file mode 100644 index 087995974..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupInterface.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups - -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult -import com.pubnub.internal.EndpointInterface - -interface ListAllChannelGroupInterface : EndpointInterface diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupInterface.kt deleted file mode 100644 index a59877e5e..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupInterface.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups - -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult -import com.pubnub.internal.EndpointInterface - -interface RemoveChannelChannelGroupInterface : EndpointInterface { - val channelGroup: String - val channels: List -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileInterface.kt deleted file mode 100644 index a9210aca9..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileInterface.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.models.consumer.files.PNDeleteFileResult -import com.pubnub.internal.EndpointInterface - -interface DeleteFileInterface : EndpointInterface diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileInterface.kt deleted file mode 100644 index 1546b9b52..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileInterface.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.models.consumer.files.PNDownloadFileResult -import com.pubnub.internal.EndpointInterface - -interface DownloadFileInterface : EndpointInterface diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlInterface.kt deleted file mode 100644 index c1e85bf35..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlInterface.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.models.consumer.files.PNFileUrlResult -import com.pubnub.internal.EndpointInterface - -interface GetFileUrlInterface : EndpointInterface diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesInterface.kt deleted file mode 100644 index 9c494bf8a..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesInterface.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.models.consumer.files.PNListFilesResult -import com.pubnub.internal.EndpointInterface - -interface ListFilesInterface : EndpointInterface diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageInterface.kt deleted file mode 100644 index 6387d0438..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageInterface.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult -import com.pubnub.internal.EndpointInterface - -interface PublishFileMessageInterface : EndpointInterface diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileInterface.kt deleted file mode 100644 index f1e7d5400..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileInterface.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.models.consumer.files.PNFileUploadResult - -interface SendFileInterface : ExtendedRemoteAction diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionInterface.kt deleted file mode 100644 index 7490f1f1b..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionInterface.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.pubnub.internal.endpoints.message_actions - -import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult -import com.pubnub.api.models.consumer.message_actions.PNMessageAction -import com.pubnub.internal.EndpointInterface - -interface AddMessageActionInterface : EndpointInterface { - val channel: String - val messageAction: PNMessageAction -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsInterface.kt deleted file mode 100644 index d2cd6c963..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsInterface.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.pubnub.internal.endpoints.message_actions - -import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult -import com.pubnub.internal.EndpointInterface - -interface GetMessageActionsInterface : EndpointInterface { - val channel: String - val page: PNBoundedPage -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionInterface.kt deleted file mode 100644 index 2776899f9..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionInterface.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.pubnub.internal.endpoints.message_actions - -import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult -import com.pubnub.internal.EndpointInterface - -interface RemoveMessageActionInterface : EndpointInterface { - val channel: String - val messageTimetoken: Long - val actionTimetoken: Long -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataInterface.kt deleted file mode 100644 index 46587a98b..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataInterface.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.internal.endpoints.objects.channel - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface GetAllChannelMetadataInterface : HasOverridableConfig diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataInterface.kt deleted file mode 100644 index 5e5939d37..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataInterface.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.endpoints.objects.channel - -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult -import com.pubnub.internal.EndpointInterface - -interface GetChannelMetadataInterface : EndpointInterface diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataInterface.kt deleted file mode 100644 index 7aea3a02b..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataInterface.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.internal.endpoints.objects.channel - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface RemoveChannelMetadataInterface : HasOverridableConfig diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataInterface.kt deleted file mode 100644 index c0b56bec2..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataInterface.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.endpoints.objects.channel - -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult -import com.pubnub.internal.EndpointInterface - -interface SetChannelMetadataInterface : EndpointInterface diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersInterface.kt deleted file mode 100644 index a95e0dbbe..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersInterface.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.internal.endpoints.objects.member - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface GetChannelMembersInterface : HasOverridableConfig diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersInterface.kt deleted file mode 100644 index 7084a1009..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersInterface.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.internal.endpoints.objects.member - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface ManageChannelMembersInterface : HasOverridableConfig diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsInterface.kt deleted file mode 100644 index a37e4533c..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsInterface.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.internal.endpoints.objects.membership - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface GetMembershipsInterface : HasOverridableConfig diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsInterface.kt deleted file mode 100644 index fa99607d1..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsInterface.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.internal.endpoints.objects.membership - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface ManageMembershipsInterface : HasOverridableConfig diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataInterface.kt deleted file mode 100644 index e9ff2dea0..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataInterface.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.internal.endpoints.objects.uuid - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface GetAllUUIDMetadataInterface : HasOverridableConfig diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataInterface.kt deleted file mode 100644 index a04a60d73..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataInterface.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.pubnub.internal.endpoints.objects.uuid - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface GetUUIDMetadataInterface : HasOverridableConfig { - val uuid: String -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataInterface.kt deleted file mode 100644 index 4f46938de..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataInterface.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.pubnub.internal.endpoints.objects.uuid - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface RemoveUUIDMetadataInterface : HasOverridableConfig { - val uuid: String? -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataInterface.kt deleted file mode 100644 index c88e849e7..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataInterface.kt +++ /dev/null @@ -1,5 +0,0 @@ -package com.pubnub.internal.endpoints.objects.uuid - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface SetUUIDMetadataInterface : HasOverridableConfig diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateInterface.kt deleted file mode 100644 index 2fb61e6ef..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateInterface.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.pubnub.internal.endpoints.presence - -import com.pubnub.api.models.consumer.presence.PNGetStateResult -import com.pubnub.internal.EndpointInterface - -interface GetStateInterface : EndpointInterface { - val channels: List - val channelGroups: List - val uuid: String -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowInterface.kt deleted file mode 100644 index 27f911c2e..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowInterface.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.pubnub.internal.endpoints.presence - -import com.pubnub.api.models.consumer.presence.PNHereNowResult -import com.pubnub.internal.EndpointInterface - -interface HereNowInterface : EndpointInterface { - val channels: List - val channelGroups: List - val includeState: Boolean - val includeUUIDs: Boolean -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateInterface.kt deleted file mode 100644 index 902e3a0a2..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateInterface.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.pubnub.internal.endpoints.presence - -import com.pubnub.api.models.consumer.presence.PNSetStateResult -import com.pubnub.internal.EndpointInterface - -interface SetStateInterface : EndpointInterface { - val channels: List - val channelGroups: List - val state: Any - val uuid: String -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowInterface.kt deleted file mode 100644 index 8149fe028..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowInterface.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.pubnub.internal.endpoints.presence - -import com.pubnub.api.endpoints.HasOverridableConfig - -interface WhereNowInterface : HasOverridableConfig { - val uuid: String -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishInterface.kt deleted file mode 100644 index f73a4492b..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishInterface.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.pubsub - -import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.internal.EndpointInterface - -interface PublishInterface : EndpointInterface { - val message: Any - val channel: String - val meta: Any? - val shouldStore: Boolean? - val usePost: Boolean - val replicate: Boolean - val ttl: Int? -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalInterface.kt deleted file mode 100644 index ac91db29c..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalInterface.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.pubnub.internal.endpoints.pubsub - -import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.internal.EndpointInterface - -interface SignalInterface : EndpointInterface { - val channel: String - val message: Any -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushInterface.kt deleted file mode 100644 index 8a336e867..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushInterface.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.push - -import com.pubnub.api.enums.PNPushEnvironment -import com.pubnub.api.enums.PNPushType -import com.pubnub.api.models.consumer.push.PNPushAddChannelResult -import com.pubnub.internal.EndpointInterface - -interface AddChannelsToPushInterface : EndpointInterface { - val pushType: PNPushType - val channels: List - val deviceId: String - val topic: String? - val environment: PNPushEnvironment -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsInterface.kt deleted file mode 100644 index bc70f6cab..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsInterface.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.pubnub.internal.endpoints.push - -import com.pubnub.api.enums.PNPushEnvironment -import com.pubnub.api.enums.PNPushType -import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult -import com.pubnub.internal.EndpointInterface - -interface ListPushProvisionsInterface : EndpointInterface { - val pushType: PNPushType - val deviceId: String - val topic: String? - val environment: PNPushEnvironment -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceInterface.kt deleted file mode 100644 index a9a421c69..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceInterface.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.pubnub.internal.endpoints.push - -import com.pubnub.api.enums.PNPushEnvironment -import com.pubnub.api.enums.PNPushType -import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult -import com.pubnub.internal.EndpointInterface - -interface RemoveAllPushChannelsForDeviceInterface : EndpointInterface { - val pushType: PNPushType - val deviceId: String - val environment: PNPushEnvironment - val topic: String? -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushInterface.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushInterface.kt deleted file mode 100644 index 433e635d7..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushInterface.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.push - -import com.pubnub.api.enums.PNPushEnvironment -import com.pubnub.api.enums.PNPushType -import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult -import com.pubnub.internal.EndpointInterface - -interface RemoveChannelsFromPushInterface : EndpointInterface { - val pushType: PNPushType - val channels: List - val deviceId: String - val topic: String? - val environment: PNPushEnvironment -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/PNAccessManagerGrantResults.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/PNAccessManagerGrantResults.kt deleted file mode 100644 index fba6a1bd2..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/PNAccessManagerGrantResults.kt +++ /dev/null @@ -1,63 +0,0 @@ -package com.pubnub.internal.models.consumer.access_manager - -import com.google.gson.annotations.SerializedName -import com.pubnub.internal.PubNubCore - -/** - * Result of the [PubNubCore.grant] operation - * - * @property level Permissions level, one of `subkey`, `subkey+auth`, `channel`, `channel-group`, - * `channel-group+auth` level. - * @property ttl Time in minutes for which granted permissions are valid. Value of `0` means indefinite. - * @property subscribeKey The subscribe key. - * @property channels Access rights per channel. - * @property channelGroups Access rights per channel group. - */ -class PNAccessManagerGrantResult( - val level: String, - val ttl: Int, - val subscribeKey: String, - val channels: Map?>, - val channelGroups: Map?>, - val uuids: Map?>, -) - -open class PNAccessManagerKeyData { - /** - * Is `true` if *read* rights are granted. - */ - @SerializedName("r") - var readEnabled: Boolean = false - - /** - * Is `true` if *write* rights are granted. - */ - @SerializedName("w") - var writeEnabled: Boolean = false - - /** - * Is `true` if *manage* rights are granted. - */ - @SerializedName("m") - var manageEnabled: Boolean = false - - /** - * Is `true` if *delete* rights are granted. - */ - @SerializedName("d") - var deleteEnabled: Boolean = false - - @SerializedName("g") - var getEnabled: Boolean = false - - @SerializedName("u") - var updateEnabled: Boolean = false - - @SerializedName("j") - var joinEnabled: Boolean = false -} - -class PNAccessManagerKeysData { - @SerializedName("auths") - val authKeys: Map? = null -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/sum/SpacePermissions.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/sum/SpacePermissions.kt deleted file mode 100644 index 1492dec28..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/sum/SpacePermissions.kt +++ /dev/null @@ -1,65 +0,0 @@ -package com.pubnub.internal.models.consumer.access_manager.sum - -import com.pubnub.api.PubNubError -import com.pubnub.api.PubNubException -import com.pubnub.internal.SpaceId -import com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNChannelPatternGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNChannelResourceGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNSpacePatternPermissionsGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNSpacePermissionsGrant - -interface SpacePermissions : PNGrant { - companion object { - fun id( - spaceId: SpaceId, - read: Boolean = false, - write: Boolean = false, - manage: Boolean = false, - delete: Boolean = false, - get: Boolean = false, - join: Boolean = false, - update: Boolean = false, - ): SpacePermissions = - PNSpacePermissionsGrant( - id = spaceId.value, - read = read, - write = write, - manage = manage, - delete = delete, - get = get, - join = join, - update = update, - ) - - fun pattern( - pattern: String, - read: Boolean = false, - write: Boolean = false, - manage: Boolean = false, - delete: Boolean = false, - get: Boolean = false, - join: Boolean = false, - update: Boolean = false, - ): SpacePermissions = - PNSpacePatternPermissionsGrant( - id = pattern, - read = read, - write = write, - manage = manage, - delete = delete, - get = get, - join = join, - update = update, - ) - } -} - -fun SpacePermissions.toChannelGrant(): ChannelGrant { - return when (this) { - is PNSpacePermissionsGrant -> PNChannelResourceGrant(spacePermissions = this) - is PNSpacePatternPermissionsGrant -> PNChannelPatternGrant(spacePermissions = this) - else -> throw PubNubException(pubnubError = PubNubError.INVALID_ARGUMENTS) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/sum/UserPermissions.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/sum/UserPermissions.kt deleted file mode 100644 index c36b8be73..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/sum/UserPermissions.kt +++ /dev/null @@ -1,49 +0,0 @@ -package com.pubnub.internal.models.consumer.access_manager.sum - -import com.pubnub.api.PubNubError -import com.pubnub.api.PubNubException -import com.pubnub.api.UserId -import com.pubnub.internal.models.consumer.access_manager.v3.PNGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNUUIDPatternGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNUUIDResourceGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNUserPatternPermissionsGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNUserPermissionsGrant -import com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant - -interface UserPermissions : PNGrant { - companion object { - fun id( - userId: UserId, - get: Boolean = false, - update: Boolean = false, - delete: Boolean = false, - ): UserPermissions = - PNUserPermissionsGrant( - id = userId.value, - delete = delete, - get = get, - update = update, - ) - - fun pattern( - pattern: String, - get: Boolean = false, - update: Boolean = false, - delete: Boolean = false, - ): UserPermissions = - PNUserPatternPermissionsGrant( - id = pattern, - delete = delete, - get = get, - update = update, - ) - } -} - -fun UserPermissions.toUuidGrant(): UUIDGrant { - return when (this) { - is PNUserPermissionsGrant -> PNUUIDResourceGrant(userPermissions = this) - is PNUserPatternPermissionsGrant -> PNUUIDPatternGrant(userPermissions = this) - else -> throw PubNubException(pubnubError = PubNubError.INVALID_ARGUMENTS) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/ChannelGrant.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/ChannelGrant.kt deleted file mode 100644 index b69eeb321..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/ChannelGrant.kt +++ /dev/null @@ -1,51 +0,0 @@ -package com.pubnub.internal.models.consumer.access_manager.v3 - -interface ChannelGrant : PNGrant { - companion object { - fun name( - name: String, - read: Boolean = false, - write: Boolean = false, - manage: Boolean = false, - delete: Boolean = false, - create: Boolean = false, - get: Boolean = false, - join: Boolean = false, - update: Boolean = false, - ): ChannelGrant = - PNChannelResourceGrant( - id = name, - read = read, - write = write, - manage = manage, - delete = delete, - create = create, - get = get, - join = join, - update = update, - ) - - fun pattern( - pattern: String, - read: Boolean = false, - write: Boolean = false, - manage: Boolean = false, - delete: Boolean = false, - create: Boolean = false, - get: Boolean = false, - join: Boolean = false, - update: Boolean = false, - ): ChannelGrant = - PNChannelPatternGrant( - id = pattern, - read = read, - write = write, - manage = manage, - delete = delete, - create = create, - get = get, - join = join, - update = update, - ) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/ChannelGroupGrant.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/ChannelGroupGrant.kt deleted file mode 100644 index 4f27392e1..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/ChannelGroupGrant.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.pubnub.internal.models.consumer.access_manager.v3 - -interface ChannelGroupGrant : PNGrant { - companion object { - fun id( - id: String, - read: Boolean = false, - manage: Boolean = false, - ): ChannelGroupGrant = - PNChannelGroupResourceGrant( - id = id, - read = read, - manage = manage, - ) - - fun pattern( - pattern: String, - read: Boolean = false, - manage: Boolean = false, - ): ChannelGroupGrant = - PNChannelGroupPatternGrant( - id = pattern, - read = read, - manage = manage, - ) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/Grants.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/Grants.kt deleted file mode 100644 index 973227ae1..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/Grants.kt +++ /dev/null @@ -1,155 +0,0 @@ -package com.pubnub.internal.models.consumer.access_manager.v3 - -import com.pubnub.internal.models.consumer.access_manager.sum.SpacePermissions -import com.pubnub.internal.models.consumer.access_manager.sum.UserPermissions - -interface PNGrant { - val read: Boolean - val write: Boolean - val manage: Boolean - val delete: Boolean - val create: Boolean - val get: Boolean - val join: Boolean - val update: Boolean - val id: String -} - -internal sealed class PNAbstractGrant( - override val read: Boolean = false, - override val write: Boolean = false, - override val manage: Boolean = false, - override val delete: Boolean = false, - override val create: Boolean = false, - override val get: Boolean = false, - override val join: Boolean = false, - override val update: Boolean = false, -) : PNGrant - -internal sealed class PNResourceGrant : PNAbstractGrant() - -internal sealed class PNPatternGrant : PNAbstractGrant() - -internal data class PNChannelResourceGrant( - override val id: String, - override val read: Boolean = false, - override val write: Boolean = false, - override val manage: Boolean = false, - override val delete: Boolean = false, - override val create: Boolean = false, - override val get: Boolean = false, - override val join: Boolean = false, - override val update: Boolean = false, -) : PNResourceGrant(), ChannelGrant { - constructor(spacePermissions: SpacePermissions) : this( - id = spacePermissions.id, - read = spacePermissions.read, - write = spacePermissions.write, - manage = spacePermissions.manage, - delete = spacePermissions.delete, - create = false, - get = spacePermissions.get, - join = spacePermissions.join, - update = spacePermissions.update, - ) -} - -internal data class PNSpacePermissionsGrant( - override val id: String, - override val read: Boolean = false, - override val write: Boolean = false, - override val manage: Boolean = false, - override val delete: Boolean = false, - override val get: Boolean = false, - override val join: Boolean = false, - override val update: Boolean = false, -) : PNResourceGrant(), SpacePermissions - -internal data class PNChannelPatternGrant( - override val id: String, - override val read: Boolean = false, - override val write: Boolean = false, - override val manage: Boolean = false, - override val delete: Boolean = false, - override val create: Boolean = false, - override val get: Boolean = false, - override val join: Boolean = false, - override val update: Boolean = false, -) : PNPatternGrant(), ChannelGrant { - constructor(spacePermissions: SpacePermissions) : this( - id = spacePermissions.id, - read = spacePermissions.read, - write = spacePermissions.write, - manage = spacePermissions.manage, - delete = spacePermissions.delete, - create = false, - get = spacePermissions.get, - join = spacePermissions.join, - update = spacePermissions.update, - ) -} - -internal data class PNSpacePatternPermissionsGrant( - override val id: String, - override val read: Boolean = false, - override val write: Boolean = false, - override val manage: Boolean = false, - override val delete: Boolean = false, - override val get: Boolean = false, - override val join: Boolean = false, - override val update: Boolean = false, -) : PNPatternGrant(), SpacePermissions - -internal data class PNChannelGroupResourceGrant( - override val id: String, - override val read: Boolean = false, - override val manage: Boolean = false, -) : PNResourceGrant(), ChannelGroupGrant - -internal data class PNChannelGroupPatternGrant( - override val id: String, - override val read: Boolean = false, - override val manage: Boolean = false, -) : PNPatternGrant(), ChannelGroupGrant - -internal data class PNUUIDResourceGrant( - override val id: String, - override val get: Boolean = false, - override val update: Boolean = false, - override val delete: Boolean = false, -) : PNResourceGrant(), UUIDGrant { - constructor(userPermissions: UserPermissions) : this( - id = userPermissions.id, - get = userPermissions.get, - update = userPermissions.update, - delete = userPermissions.delete, - ) -} - -internal data class PNUserPermissionsGrant( - override val id: String, - override val get: Boolean = false, - override val update: Boolean = false, - override val delete: Boolean = false, -) : PNResourceGrant(), UserPermissions - -internal data class PNUUIDPatternGrant( - override val id: String, - override val get: Boolean = false, - override val update: Boolean = false, - override val delete: Boolean = false, -) : PNPatternGrant(), UUIDGrant { - constructor(userPermissions: UserPermissions) : this( - id = userPermissions.id, - get = userPermissions.get, - update = userPermissions.update, - delete = userPermissions.delete, - ) -} - -internal data class PNUserPatternPermissionsGrant( - override val id: String, - override val get: Boolean = false, - override val update: Boolean = false, - override val delete: Boolean = false, -) : PNPatternGrant(), UserPermissions diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/UUIDGrant.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/UUIDGrant.kt deleted file mode 100644 index f580f823a..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/access_manager/v3/UUIDGrant.kt +++ /dev/null @@ -1,31 +0,0 @@ -package com.pubnub.internal.models.consumer.access_manager.v3 - -interface UUIDGrant : PNGrant { - companion object { - fun id( - id: String, - get: Boolean = false, - update: Boolean = false, - delete: Boolean = false, - ): UUIDGrant = - PNUUIDResourceGrant( - id = id, - delete = delete, - get = get, - update = update, - ) - - fun pattern( - pattern: String, - get: Boolean = false, - update: Boolean = false, - delete: Boolean = false, - ): UUIDGrant = - PNUUIDPatternGrant( - id = pattern, - delete = delete, - get = get, - update = update, - ) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/PNRemoveMetadataResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/PNRemoveMetadataResult.kt deleted file mode 100644 index 5200664ff..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/PNRemoveMetadataResult.kt +++ /dev/null @@ -1,3 +0,0 @@ -package com.pubnub.internal.models.consumer.objects - -data class PNRemoveMetadataResult(val status: Int) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/PNSortKey.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/PNSortKey.kt deleted file mode 100644 index abd2e56f9..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/PNSortKey.kt +++ /dev/null @@ -1,50 +0,0 @@ -package com.pubnub.internal.models.consumer.objects - -interface SortField { - val fieldName: String -} - -enum class PNKey(override val fieldName: String) : SortField { - ID("id"), - NAME("name"), - UPDATED("updated"), - TYPE("type"), - STATUS("status"), -} - -enum class PNMembershipKey(override val fieldName: String) : SortField { - CHANNEL_ID("channel.id"), - CHANNEL_NAME("channel.name"), - CHANNEL_UPDATED("channel.updated"), - UPDATED("updated"), -} - -enum class PNMemberKey(override val fieldName: String) : SortField { - UUID_ID("uuid.id"), - UUID_NAME("uuid.name"), - UUID_UPDATED("uuid.updated"), - UPDATED("updated"), -} - -sealed class PNSortKey( - internal val key: T, - internal val dir: String = "asc", -) { - class PNAsc(key: T) : PNSortKey(key = key, dir = "asc") - - class PNDesc(key: T) : PNSortKey(key = key, dir = "desc") - - fun toSortParameter(): String { - return key.fieldName + ":" + dir - } - - companion object { - fun asc(key: PNKey): PNSortKey { - return PNAsc(key) - } - - fun desc(key: PNKey): PNSortKey { - return PNDesc(key) - } - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/ResultSortKey.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/ResultSortKey.kt deleted file mode 100644 index 741a99ed2..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/ResultSortKey.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.pubnub.internal.models.consumer.objects - -interface SortableKey - -sealed class ResultSortKey( - val key: T, - internal val dir: String = "asc", -) { - class Asc(key: T) : ResultSortKey(key = key, dir = "asc") - - class Desc(key: T) : ResultSortKey(key = key, dir = "desc") -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt deleted file mode 100644 index 2acd86375..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.channel - -import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult - -data class PNChannelMetadataArrayResult( - val status: Int, - val data: Collection, - val totalCount: Int?, - val next: PNPage.PNNext?, - val prev: PNPage.PNPrev?, -) { - fun toApi(): PNChannelMetadataArrayResult { - return PNChannelMetadataArrayResult( - status, - data, - totalCount, - next, - prev, - ) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/MemberInput.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/MemberInput.kt deleted file mode 100644 index db17c4f11..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/MemberInput.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.member - -interface MemberInput { - val uuid: String - val custom: Any? - val status: String? -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt deleted file mode 100644 index 049e31a09..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMember.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.member - -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -import com.pubnub.api.utils.PatchValue - -data class PNMember( - val uuid: PNUUIDMetadata, - val custom: PatchValue?>? = null, - val updated: String, - val eTag: String, - val status: PatchValue? = null, -) { - data class Partial( - val uuidId: String, - override val custom: Any? = null, - override val status: String? = null, - ) : MemberInput { - override val uuid: String = uuidId - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMemberArrayResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMemberArrayResult.kt deleted file mode 100644 index 51f9b4b9e..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNMemberArrayResult.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.member - -import com.pubnub.api.models.consumer.objects.PNPage - -data class PNMemberArrayResult( - val status: Int, - val data: Collection, - val totalCount: Int?, - val next: PNPage.PNNext?, - val prev: PNPage.PNPrev?, -) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNUUIDDetailsLevel.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNUUIDDetailsLevel.kt deleted file mode 100644 index 132588b7a..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNUUIDDetailsLevel.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.member - -enum class PNUUIDDetailsLevel { - UUID, - UUID_WITH_CUSTOM, -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNUUIDWithCustom.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNUUIDWithCustom.kt deleted file mode 100644 index 674e23d72..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/member/PNUUIDWithCustom.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.member - -@Deprecated( - message = "Use PNMember.Partial", - level = DeprecationLevel.WARNING, - replaceWith = - ReplaceWith( - "PNMember.Partial(uuidId = uuid, custom = custom)", - "com.pubnub.internal.models.consumer.objects.member.PNMember", - ), -) -data class PNUUIDWithCustom( - override val uuid: String, - override val custom: Any? = null, -) : MemberInput { - companion object { - @Deprecated( - message = "Use PNMember.Partial", - level = DeprecationLevel.ERROR, - replaceWith = - ReplaceWith( - "PNMember.Partial(uuidId = uuid, custom = custom)", - "com.pubnub.internal.models.consumer.objects.member.PNMember", - ), - ) - fun of( - uuid: String, - custom: Any? = null, - ) = PNMember.Partial(uuidId = uuid, custom = custom) - } - - override val status: String? = null -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/ChannelMembershipInput.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/ChannelMembershipInput.kt deleted file mode 100644 index 76235f9e0..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/ChannelMembershipInput.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.membership - -interface ChannelMembershipInput { - val channel: String - val custom: Any? - val status: String? -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelDetailsLevel.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelDetailsLevel.kt deleted file mode 100644 index 4577ca873..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelDetailsLevel.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.membership - -enum class PNChannelDetailsLevel { - CHANNEL, - CHANNEL_WITH_CUSTOM, -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt deleted file mode 100644 index ea3e52fc1..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembership.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.membership - -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata -import com.pubnub.api.utils.PatchValue - -data class PNChannelMembership( - val channel: PNChannelMetadata, - val custom: PatchValue?>? = null, - val updated: String, - val eTag: String, - val status: PatchValue? = null, -) { - data class Partial( - val channelId: String, - override val custom: Any? = null, - override val status: String? = null, - ) : ChannelMembershipInput { - override val channel: String = channelId - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembershipArrayResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembershipArrayResult.kt deleted file mode 100644 index 76e5840b5..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelMembershipArrayResult.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.membership - -import com.pubnub.api.models.consumer.objects.PNPage - -data class PNChannelMembershipArrayResult( - val status: Int, - val data: Collection, - val totalCount: Int?, - val next: PNPage.PNNext?, - val prev: PNPage.PNPrev?, -) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelWithCustom.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelWithCustom.kt deleted file mode 100644 index 3314a0c7a..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/membership/PNChannelWithCustom.kt +++ /dev/null @@ -1,33 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.membership - -@Deprecated( - message = "Use PNChannelMembership.Partial", - level = DeprecationLevel.WARNING, - replaceWith = - ReplaceWith( - "PNChannelMembership.Partial(channelId = channel, custom = custom)", - "com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership", - ), -) -data class PNChannelWithCustom( - override val channel: String, - override val custom: Any? = null, -) : ChannelMembershipInput { - override val status: String? = null - - companion object { - @Deprecated( - message = "Use PNChannelMembership.Partial", - level = DeprecationLevel.ERROR, - replaceWith = - ReplaceWith( - "PNChannelMembership.Partial(channelId = channel, custom = custom)", - "com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership", - ), - ) - fun of( - channel: String, - custom: Any? = null, - ) = PNChannelMembership.Partial(channelId = channel, custom = custom) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt deleted file mode 100644 index d61833096..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataArrayResult.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.uuid - -import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata - -data class PNUUIDMetadataArrayResult( - val status: Int, - val data: Collection, - val totalCount: Int?, - val next: PNPage.PNNext?, - val prev: PNPage.PNPrev?, -) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt deleted file mode 100644 index d743391e2..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/objects/uuid/PNUUIDMetadataResult.kt +++ /dev/null @@ -1,8 +0,0 @@ -package com.pubnub.internal.models.consumer.objects.uuid - -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata - -data class PNUUIDMetadataResult( - val status: Int, - val data: PNUUIDMetadata, -) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/presence/PNWhereNowResult.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/presence/PNWhereNowResult.kt deleted file mode 100644 index 1adbf5c81..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/presence/PNWhereNowResult.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.pubnub.internal.models.consumer.presence - -import com.pubnub.internal.PubNubCore - -/** - * Result of the [PubNubCore.whereNow] operation. - * - * @property channels List of channels where a UUID is present. - */ -class PNWhereNowResult internal constructor( - val channels: List, -) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/BasePNConfigurationImpl.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/BasePNConfigurationImpl.kt deleted file mode 100644 index 295f62953..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/BasePNConfigurationImpl.kt +++ /dev/null @@ -1,154 +0,0 @@ -package com.pubnub.internal.v2 - -import com.pubnub.api.UserId -import com.pubnub.api.crypto.CryptoModule -import com.pubnub.api.enums.PNHeartbeatNotificationOptions -import com.pubnub.api.enums.PNLogVerbosity -import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.BasePNConfigurationOverride -import okhttp3.Authenticator -import okhttp3.CertificatePinner -import okhttp3.ConnectionSpec -import okhttp3.logging.HttpLoggingInterceptor -import java.net.Proxy -import java.net.ProxySelector -import javax.net.ssl.HostnameVerifier -import javax.net.ssl.SSLSocketFactory -import javax.net.ssl.X509ExtendedTrustManager - -/** - * A storage for user-provided information which describe further PubNub client behaviour. - * Configuration instance contains additional set of properties which - * allow performing precise PubNub client configuration. - * - */ -open class BasePNConfigurationImpl internal constructor( - override val userId: UserId, - override val subscribeKey: String = "", - override val publishKey: String = "", - override val secretKey: String = "", - override val authKey: String = "", - override val cryptoModule: CryptoModule? = null, - override val origin: String = "", - override val secure: Boolean = true, - override val logVerbosity: PNLogVerbosity = PNLogVerbosity.NONE, - override val heartbeatNotificationOptions: PNHeartbeatNotificationOptions = PNHeartbeatNotificationOptions.FAILURES, - override val presenceTimeout: Int = PRESENCE_TIMEOUT, - override val heartbeatInterval: Int = 0, - override val subscribeTimeout: Int = SUBSCRIBE_TIMEOUT, - override val connectTimeout: Int = CONNECT_TIMEOUT, - override val nonSubscribeReadTimeout: Int = NON_SUBSCRIBE_REQUEST_TIMEOUT, - override val cacheBusting: Boolean = false, - override val suppressLeaveEvents: Boolean = false, - override val maintainPresenceState: Boolean = true, - override val filterExpression: String = "", - override val includeInstanceIdentifier: Boolean = false, - override val includeRequestIdentifier: Boolean = true, - override val maximumConnections: Int? = null, - override val googleAppEngineNetworking: Boolean = false, - override val proxy: Proxy? = null, - override val proxySelector: ProxySelector? = null, - override val proxyAuthenticator: Authenticator? = null, - override val certificatePinner: CertificatePinner? = null, - override val httpLoggingInterceptor: HttpLoggingInterceptor? = null, - override val sslSocketFactory: SSLSocketFactory? = null, - override val x509ExtendedTrustManager: X509ExtendedTrustManager? = null, - override val connectionSpec: ConnectionSpec? = null, - override val hostnameVerifier: HostnameVerifier? = null, - override val fileMessagePublishRetryLimit: Int = 5, - override val dedupOnSubscribe: Boolean = false, - override val maximumMessagesCacheSize: Int = DEFAULT_DEDUPE_SIZE, - override val pnsdkSuffixes: Map = emptyMap(), - override val retryConfiguration: RetryConfiguration = RetryConfiguration.None, - override val managePresenceListManually: Boolean = false, -) : BasePNConfiguration { - companion object { - const val DEFAULT_DEDUPE_SIZE = 100 - const val PRESENCE_TIMEOUT = 300 - const val MINIMUM_PRESENCE_TIMEOUT = 20 - const val NON_SUBSCRIBE_REQUEST_TIMEOUT = 10 - const val SUBSCRIBE_TIMEOUT = 310 - const val CONNECT_TIMEOUT = 5 - } - - constructor( - userId: UserId, - ) : this(userId, "") - - abstract class Builder(defaultConfiguration: BasePNConfiguration) : BasePNConfiguration.Builder, BasePNConfigurationOverride.Builder { - override val userId: UserId = defaultConfiguration.userId - - override val subscribeKey: String = defaultConfiguration.subscribeKey - - override val publishKey: String = defaultConfiguration.publishKey - - override val secretKey: String = defaultConfiguration.secretKey - - override val authKey: String = defaultConfiguration.authKey - - override val cryptoModule: CryptoModule? = defaultConfiguration.cryptoModule - - override val origin: String = defaultConfiguration.origin - - override val secure: Boolean = defaultConfiguration.secure - - override val logVerbosity: PNLogVerbosity = defaultConfiguration.logVerbosity - - override val heartbeatNotificationOptions: PNHeartbeatNotificationOptions = - defaultConfiguration.heartbeatNotificationOptions - - override val presenceTimeout: Int = defaultConfiguration.presenceTimeout - - override val heartbeatInterval: Int = defaultConfiguration.heartbeatInterval - - override val subscribeTimeout: Int = defaultConfiguration.subscribeTimeout - - override val connectTimeout: Int = defaultConfiguration.connectTimeout - - override val nonSubscribeReadTimeout: Int = defaultConfiguration.nonSubscribeReadTimeout - - override val cacheBusting: Boolean = defaultConfiguration.cacheBusting - - override val suppressLeaveEvents: Boolean = defaultConfiguration.suppressLeaveEvents - - override val maintainPresenceState: Boolean = defaultConfiguration.maintainPresenceState - - override val filterExpression: String = defaultConfiguration.filterExpression - - override val includeInstanceIdentifier: Boolean = defaultConfiguration.includeInstanceIdentifier - - override val includeRequestIdentifier: Boolean = defaultConfiguration.includeRequestIdentifier - - override val maximumConnections: Int? = defaultConfiguration.maximumConnections - - override val googleAppEngineNetworking: Boolean = defaultConfiguration.googleAppEngineNetworking - - override val proxy: Proxy? = defaultConfiguration.proxy - - override val proxySelector: ProxySelector? = defaultConfiguration.proxySelector - - override val proxyAuthenticator: Authenticator? = defaultConfiguration.proxyAuthenticator - - override val certificatePinner: CertificatePinner? = defaultConfiguration.certificatePinner - - override val httpLoggingInterceptor: HttpLoggingInterceptor? = defaultConfiguration.httpLoggingInterceptor - - override val sslSocketFactory: SSLSocketFactory? = defaultConfiguration.sslSocketFactory - - override val x509ExtendedTrustManager: X509ExtendedTrustManager? = defaultConfiguration.x509ExtendedTrustManager - - override val connectionSpec: ConnectionSpec? = defaultConfiguration.connectionSpec - - override val hostnameVerifier: HostnameVerifier? = defaultConfiguration.hostnameVerifier - - override val fileMessagePublishRetryLimit: Int = defaultConfiguration.fileMessagePublishRetryLimit - override val dedupOnSubscribe: Boolean = defaultConfiguration.dedupOnSubscribe - override val maximumMessagesCacheSize: Int = defaultConfiguration.maximumMessagesCacheSize - override val pnsdkSuffixes: Map = defaultConfiguration.pnsdkSuffixes - - override val retryConfiguration: RetryConfiguration = defaultConfiguration.retryConfiguration - - override val managePresenceListManually: Boolean = defaultConfiguration.managePresenceListManually - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/EventListenerCore.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/EventListenerCore.kt deleted file mode 100644 index 4b348aa48..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/EventListenerCore.kt +++ /dev/null @@ -1,84 +0,0 @@ -package com.pubnub.internal.v2.callbacks - -import com.pubnub.api.BasePubNub -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -import com.pubnub.api.models.consumer.pubsub.PNSignalResult -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult - -interface EventListenerCore : Listener { - /** - * Receive messages at subscribed channels. - * - * @see [PubNub.subscribe] - * - * @param pubnub The client instance which has this listener attached. - * @param event Wrapper around the actual message content. - */ - fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNMessageResult, - ) {} - - /** - * Receive presence events for channels subscribed with presence enabled via - * passing [com.pubnub.api.v2.subscriptions.SubscriptionOptions.receivePresenceEvents] - * in [com.pubnub.api.v2.entities.BaseChannel.subscription]. - * - * @param pubnub The client instance which has this listener attached. - * @param event Wrapper around a presence event. - */ - fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNPresenceEventResult, - ) {} - - /** - * Receive signals at subscribed channels. - * - * @see [PubNub.signal] - * - * @param pubnub The client instance which has this listener attached. - * @param event Wrapper around a signal event. - */ - fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNSignalResult, - ) {} - - /** - * Receive message actions for messages in subscribed channels. - * - * @param pubnub The client instance which has this listener attached. - * @param event Wrapper around a message action event. - */ - fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNMessageActionResult, - ) {} - - /** - * Receive channel metadata and UUID metadata events in subscribed channels. - * - * @param pubnub The client instance which has this listener attached. - * @param event Wrapper around the object event. - */ - fun objects( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNObjectEventResult, - ) {} - - /** - * Receive file events in subscribed channels. - * - * @param pubnub The client instance which has this listener attached. - * @param event Wrapper around the file event. - */ - fun file( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNFileEventResult, - ) {} -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/StatusListenerCore.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/StatusListenerCore.kt deleted file mode 100644 index 02587574a..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/StatusListenerCore.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.pubnub.internal.v2.callbacks - -import com.pubnub.api.BasePubNub -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.models.consumer.PNStatus - -interface StatusListenerCore : Listener { - /** - * Receive status updates from the PubNub client. - * - * @see [PNStatus] - * - * @param pubnub The client instance which has this listener attached. - * @param status Wrapper around the actual message content. - */ - fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - status: PNStatus, - ) -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelGroupImpl.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelGroupImpl.kt deleted file mode 100644 index 1e7044fd1..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelGroupImpl.kt +++ /dev/null @@ -1,65 +0,0 @@ -package com.pubnub.internal.v2.entities - -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.entities.BaseChannelGroup -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.ReceivePresenceEventsImpl -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.SubscriptionFactory -import com.pubnub.internal.subscribe.PRESENCE_CHANNEL_SUFFIX - -open class BaseChannelGroupImpl>( - internal val pubNub: PubNubCore, - private val channelGroupName: ChannelGroupName, - private val subscriptionFactory: SubscriptionFactory, -) : BaseChannelGroup { - override val name: String = channelGroupName.id - - override fun subscription(options: SubscriptionOptions): Sub { - val channelGroups = - buildSet { - add(channelGroupName) - if (options.allOptions.filterIsInstance().isNotEmpty()) { - add(channelGroupName.withPresence) - } - } - return subscriptionFactory( - emptySet(), - channelGroups, - SubscriptionOptions.filter { result -> - channelGroups.any { it.id == result.subscription } - } + options, - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - if (other !is BaseChannelGroupImpl<*, *>) { - return false - } - - if (pubNub != other.pubNub) { - return false - } - if (name != other.name) { - return false - } - - return true - } - - override fun hashCode(): Int { - var result = pubNub.hashCode() - result = 31 * result + name.hashCode() - return result - } -} - -@JvmInline -value class ChannelGroupName(val id: String) { - val withPresence get() = ChannelGroupName("${this.id}$PRESENCE_CHANNEL_SUFFIX") - val isPresence get() = id.endsWith(PRESENCE_CHANNEL_SUFFIX) -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelImpl.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelImpl.kt deleted file mode 100644 index 239e22d90..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelImpl.kt +++ /dev/null @@ -1,79 +0,0 @@ -package com.pubnub.internal.v2.entities - -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.entities.BaseChannel -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.ReceivePresenceEventsImpl -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.SubscriptionFactory -import com.pubnub.internal.subscribe.PRESENCE_CHANNEL_SUFFIX - -open class BaseChannelImpl>( - protected val pubnub: PubNubCore, - protected val channelName: ChannelName, - private val subscriptionFactory: SubscriptionFactory, -) : BaseChannel { - override val name: String = channelName.id - - override fun subscription(options: SubscriptionOptions): Sub { - val channels = - buildSet { - add(channelName) - if (options.allOptions.filterIsInstance().isNotEmpty()) { - add(channelName.withPresence) - } - } - return subscriptionFactory( - channels, - emptySet(), - SubscriptionOptions.filter { result -> - // simple channel name or presence channel - if (channels.any { it.id == result.channel }) { - return@filter true - } - - // wildcard channels - if (name.endsWith(".*") && - ( - result.subscription == name || - result.channel.startsWith(name.substringBeforeLast("*")) - ) - ) { - return@filter true - } - return@filter false - } + options, - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - if (other !is BaseChannelImpl<*, *>) { - return false - } - - if (pubnub != other.pubnub) { - return false - } - if (name != other.name) { - return false - } - - return true - } - - override fun hashCode(): Int { - var result = pubnub.hashCode() - result = 31 * result + name.hashCode() - return result - } -} - -@JvmInline -value class ChannelName(val id: String) { - val withPresence get() = ChannelName("${this.id}$PRESENCE_CHANNEL_SUFFIX") - val isPresence get() = id.endsWith(PRESENCE_CHANNEL_SUFFIX) -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelMetadataImpl.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelMetadataImpl.kt deleted file mode 100644 index c5522b846..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseChannelMetadataImpl.kt +++ /dev/null @@ -1,52 +0,0 @@ -package com.pubnub.internal.v2.entities - -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.entities.BaseChannelMetadata -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.SubscriptionFactory - -open class BaseChannelMetadataImpl>( - internal val pubnub: PubNubCore, - val channelName: ChannelName, - private val subscriptionFactory: SubscriptionFactory, -) : BaseChannelMetadata { - override val id: String = channelName.id - - override fun subscription(options: SubscriptionOptions): Sub { - val channels = setOf(channelName) - return subscriptionFactory( - channels, - emptySet(), - SubscriptionOptions.filter { result -> - // simple channel name or presence channel - channels.any { it.id == result.channel } - } + options, - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - if (other !is BaseChannelMetadataImpl<*, *>) { - return false - } - - if (pubnub != other.pubnub) { - return false - } - if (id != other.id) { - return false - } - - return true - } - - override fun hashCode(): Int { - var result = pubnub.hashCode() - result = 31 * result + id.hashCode() - return result - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseUserMetadataImpl.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseUserMetadataImpl.kt deleted file mode 100644 index 6852e3c35..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/entities/BaseUserMetadataImpl.kt +++ /dev/null @@ -1,52 +0,0 @@ -package com.pubnub.internal.v2.entities - -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.entities.BaseUserMetadata -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.SubscriptionFactory - -open class BaseUserMetadataImpl>( - internal val pubnub: PubNubCore, - val channelName: ChannelName, - private val subscriptionFactory: SubscriptionFactory, -) : BaseUserMetadata { - override val id: String = channelName.id - - override fun subscription(options: SubscriptionOptions): Sub { - val channels = setOf(channelName) - return subscriptionFactory( - channels, - emptySet(), - SubscriptionOptions.filter { result -> - // simple channel name or presence channel - channels.any { it.id == result.channel } - } + options, - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - if (other !is BaseUserMetadataImpl<*, *>) { - return false - } - - if (pubnub != other.pubnub) { - return false - } - if (id != other.id) { - return false - } - - return true - } - - override fun hashCode(): Int { - var result = pubnub.hashCode() - result = 31 * result + id.hashCode() - return result - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionImpl.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionImpl.kt deleted file mode 100644 index d1333b711..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionImpl.kt +++ /dev/null @@ -1,109 +0,0 @@ -package com.pubnub.internal.v2.subscription - -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.models.consumer.pubsub.PNEvent -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.FilterImpl -import com.pubnub.api.v2.subscriptions.SubscriptionCursor -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.managers.AnnouncementCallback -import com.pubnub.internal.managers.AnnouncementEnvelope -import com.pubnub.internal.v2.callbacks.EventEmitterImpl -import com.pubnub.internal.v2.callbacks.EventListenerCore -import com.pubnub.internal.v2.entities.ChannelGroupName -import com.pubnub.internal.v2.entities.ChannelName - -abstract class BaseSubscriptionImpl( - internal val pubnub: PubNubCore, - channels: Set = emptySet(), - channelGroups: Set = emptySet(), - options: SubscriptionOptions? = null, - eventEmitterFactory: (BaseSubscriptionImpl) -> EventEmitterImpl = { baseSubscriptionImpl -> - EventEmitterImpl(AnnouncementCallback.Phase.SUBSCRIPTION, baseSubscriptionImpl::accepts) - }, -) : BaseSubscription { - @Volatile - var isActive = false - @Synchronized - set(newValue) { - if (!field && newValue) { // wasn't active && is now active - pubnub.listenerManager.addAnnouncementCallback(eventEmitter) - } else if (field && !newValue) { // was active && no longer active - pubnub.listenerManager.removeAnnouncementCallback(eventEmitter) - } - field = newValue - } - - internal val channels = channels.toSet() - internal val channelGroups = channelGroups.toSet() - - private val filters: List = options?.allOptions?.filterIsInstance() ?: emptyList() - - /** - * To ensure that events are delivered with timestamps growing monotonically, - * we will set this to the highest received timestamp and compare incoming messages against it. - * - * This will be reset on subscribe(cursor) with the value from the SubscriptionCursor. - */ - private var lastTimetoken: Long = 0L - - protected val eventEmitter = eventEmitterFactory(this) - - fun accepts(envelope: AnnouncementEnvelope): Boolean { - val event = envelope.event - val accepted = isActive && filters.all { filter -> filter.predicate(event) } && checkAndUpdateTimetoken(event) - if (accepted) { - envelope.acceptedBy += this@BaseSubscriptionImpl - } - return accepted - } - - private fun checkAndUpdateTimetoken(result: PNEvent): Boolean { - result.timetoken?.let { resultTimetoken -> - if (resultTimetoken <= lastTimetoken) { - return false - } else { - lastTimetoken = resultTimetoken - return true - } - } ?: return false - } - - override fun subscribe(cursor: SubscriptionCursor) { - onSubscriptionActive(cursor) - pubnub.subscribe(this, cursor = cursor) - } - - internal fun onSubscriptionActive(cursor: SubscriptionCursor) { - lastTimetoken = cursor.timetoken - isActive = true - } - - override fun unsubscribe() { - onSubscriptionInactive() - pubnub.unsubscribe(this) - } - - internal fun onSubscriptionInactive() { - lastTimetoken = 0L - isActive = false - } - - override fun close() { - unsubscribe() - } - - protected fun addListener(listener: EventListenerCore) { - eventEmitter.addListener(listener) - } - - override fun removeListener(listener: Listener) { - eventEmitter.removeListener(listener) - } - - override fun removeAllListeners() { - eventEmitter.removeAllListeners() - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImpl.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImpl.kt deleted file mode 100644 index 029713fad..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImpl.kt +++ /dev/null @@ -1,73 +0,0 @@ -package com.pubnub.internal.v2.subscription - -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.BaseSubscriptionSet -import com.pubnub.api.v2.subscriptions.SubscriptionCursor -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.managers.AnnouncementCallback -import com.pubnub.internal.managers.AnnouncementEnvelope -import com.pubnub.internal.v2.callbacks.EventEmitterImpl -import com.pubnub.internal.v2.callbacks.EventListenerCore -import java.util.concurrent.CopyOnWriteArraySet - -private const val ERROR_SUBSCRIPTION_WRONG_CLASS = - "Only Subscriptions returned from objects created" + - "through the PubNub instance and their methods, such as channel(...).subscriptions() are supported." -private const val ERROR_WRONG_PUBNUB_INSTANCE = - "Adding Subscriptions from another PubNub instance to a SubscriptionSet is not allowed." - -abstract class BaseSubscriptionSetImpl>( - private val pubnub: PubNubCore, - initialSubscriptions: Set> = emptySet(), -) : BaseSubscriptionSet { - private val _subscriptions: CopyOnWriteArraySet> = CopyOnWriteArraySet() - override val subscriptions: Set get() = _subscriptions.toSet() as Set - protected val eventEmitter = EventEmitterImpl(AnnouncementCallback.Phase.SET, ::accepts) - - private fun accepts(envelope: AnnouncementEnvelope<*>) = subscriptions.any { subscription -> subscription in envelope.acceptedBy } - - init { - require(initialSubscriptions.all { it.pubnub == pubnub }) { ERROR_WRONG_PUBNUB_INSTANCE } - _subscriptions.addAll(initialSubscriptions) - pubnub.listenerManager.addAnnouncementCallback(eventEmitter) - } - - override fun add(subscription: Sub) { // todo check this - require(subscription is BaseSubscriptionImpl<*>) { ERROR_SUBSCRIPTION_WRONG_CLASS } - require(subscription.pubnub == pubnub) { ERROR_WRONG_PUBNUB_INSTANCE } - _subscriptions.add(subscription as BaseSubscriptionImpl) - } - - override fun remove(subscription: Sub) { - _subscriptions.remove(subscription as BaseSubscriptionImpl<*>) - } - - override fun subscribe(cursor: SubscriptionCursor) { - _subscriptions.forEach { it.onSubscriptionActive(cursor) } - pubnub.subscribe(*_subscriptions.toTypedArray(), cursor = cursor) - } - - override fun unsubscribe() { - _subscriptions.forEach { it.onSubscriptionInactive() } - pubnub.unsubscribe(*_subscriptions.toTypedArray()) - } - - override fun close() { - unsubscribe() - pubnub.listenerManager.removeAnnouncementCallback(eventEmitter) - } - - protected fun addListener(listener: EventListenerCore) { - eventEmitter.addListener(listener) - } - - override fun removeListener(listener: Listener) { - eventEmitter.removeListener(listener) - } - - override fun removeAllListeners() { - eventEmitter.removeAllListeners() - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/workers/SubscribeMessageWorker.kt b/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/workers/SubscribeMessageWorker.kt deleted file mode 100644 index 187ba6d07..000000000 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/workers/SubscribeMessageWorker.kt +++ /dev/null @@ -1,54 +0,0 @@ -package com.pubnub.internal.workers - -import com.pubnub.api.PubNubException -import com.pubnub.api.enums.PNStatusCategory -import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -import com.pubnub.api.models.consumer.pubsub.PNSignalResult -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.managers.DuplicationManager -import com.pubnub.internal.managers.ListenerManager -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.internal.models.server.SubscribeMessage -import org.slf4j.LoggerFactory -import java.util.concurrent.LinkedBlockingQueue - -internal class SubscribeMessageWorker( - pubnub: PubNubCore, - val listenerManager: ListenerManager, - private val queue: LinkedBlockingQueue, - duplicationManager: DuplicationManager, - private val messageProcessor: SubscribeMessageProcessor = SubscribeMessageProcessor(pubnub, duplicationManager), -) : Runnable { - private val log = LoggerFactory.getLogger("SubscribeMessageWorker") - - override fun run() { - takeMessage() - } - - private fun takeMessage() { - while (!Thread.interrupted()) { - try { - when (val event = messageProcessor.processIncomingPayload(queue.take())) { - is PNMessageResult -> listenerManager.announce(event) - is PNPresenceEventResult -> listenerManager.announce(event) - is PNSignalResult -> listenerManager.announce(event) - is PNMessageActionResult -> listenerManager.announce(event) - is PNObjectEventResult -> listenerManager.announce(event) - is PNFileEventResult -> listenerManager.announce(event) - } - } catch (e: PubNubException) { - listenerManager.announce(PNStatus(PNStatusCategory.PNMalformedResponseCategory, e)) - } catch (e: InterruptedException) { - Thread.currentThread().interrupt() - log.trace("take message interrupted!", e) - } catch (e: Exception) { - // don't crash the thread on malformed messages - log.warn("Unexpected message processing error", e) - } - } - } -} diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/BasePNConfigurationImplTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/BasePNConfigurationImplTest.kt deleted file mode 100644 index bba619f3a..000000000 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/BasePNConfigurationImplTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.pubnub.api - -import com.pubnub.internal.BasePubNubImpl -import com.pubnub.internal.TestPubNub -import com.pubnub.internal.v2.BasePNConfigurationImpl -import org.junit.Assert.assertEquals -import org.junit.Test - -class BasePNConfigurationImplTest { - @Test - fun testDefaultTimeoutValues() { - val p = TestPubNub(BasePNConfigurationImpl(userId = UserId(BasePubNubImpl.generateUUID()))) - assertEquals(300, p.pubNubCore.configuration.presenceTimeout) - assertEquals(0, p.pubNubCore.configuration.heartbeatInterval) - p.forceDestroy() - } -} diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/TestPubNub.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/TestPubNub.kt deleted file mode 100644 index d60f69405..000000000 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/TestPubNub.kt +++ /dev/null @@ -1,179 +0,0 @@ -package com.pubnub.internal - -import com.pubnub.api.models.consumer.access_manager.v3.PNToken -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.callbacks.BaseStatusListener -import com.pubnub.internal.callbacks.SubscribeCallback -import com.pubnub.internal.subscribe.eventengine.configuration.EventEnginesConf -import com.pubnub.internal.v2.entities.BaseChannelGroupImpl -import com.pubnub.internal.v2.entities.BaseChannelImpl -import com.pubnub.internal.v2.entities.BaseChannelMetadataImpl -import com.pubnub.internal.v2.entities.BaseUserMetadataImpl -import com.pubnub.internal.v2.subscription.BaseSubscriptionImpl -import com.pubnub.internal.v2.subscription.BaseSubscriptionSetImpl -import java.io.InputStream - -class TestPubNub internal constructor( - configuration: BasePNConfiguration, - eventEnginesConf: EventEnginesConf = EventEnginesConf(), -) : - BasePubNubImpl< - BaseEventListener, - BaseSubscriptionImpl, - BaseChannelImpl>, - BaseChannelGroupImpl>, - BaseChannelMetadataImpl>, - BaseUserMetadataImpl>, - BaseSubscriptionSetImpl>, - BaseStatusListener, - >(configuration, "PubNub-Test", eventEnginesConf) { - override fun channel(name: String): BaseChannelImpl> { - TODO("Not yet implemented") - } - - override fun channelGroup(name: String): BaseChannelGroupImpl> { - TODO("Not yet implemented") - } - - override fun channelMetadata(id: String): BaseChannelMetadataImpl> { - TODO("Not yet implemented") - } - - override fun userMetadata(id: String): BaseUserMetadataImpl> { - TODO("Not yet implemented") - } - - /** - * Perform Cryptographic decryption of an input string using cipher key provided by [PNConfiguration.cipherKey]. - * - * @param inputString String to be decrypted. - * - * @return String containing the decryption of `inputString` using `cipherKey`. - * @throws PubNubException throws exception in case of failed decryption. - */ - override fun decrypt(inputString: String): String { - TODO("Not yet implemented") - } - - /** - * Perform Cryptographic decryption of an input string using a cipher key. - * - * @param inputString String to be decrypted. - * @param cipherKey cipher key to be used for decryption. Default is [PNConfiguration.cipherKey] - * - * @return String containing the decryption of `inputString` using `cipherKey`. - * @throws PubNubException throws exception in case of failed decryption. - */ - override fun decrypt( - inputString: String, - cipherKey: String?, - ): String { - TODO("Not yet implemented") - } - - /** - * Perform Cryptographic decryption of an input stream using provided cipher key. - * - * @param inputStream InputStream to be encrypted. - * @param cipherKey Cipher key to be used for decryption. - * - * @return InputStream containing the encryption of `inputStream` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed decryption. - */ - override fun decryptInputStream( - inputStream: InputStream, - cipherKey: String?, - ): InputStream { - TODO("Not yet implemented") - } - - /** - * Perform Cryptographic encryption of an input string and a cipher key. - * - * @param inputString String to be encrypted. - * @param cipherKey Cipher key to be used for encryption. Default is [PNConfiguration.cipherKey] - * - * @return String containing the encryption of `inputString` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed encryption. - */ - override fun encrypt( - inputString: String, - cipherKey: String?, - ): String { - TODO("Not yet implemented") - } - - /** - * Perform Cryptographic encryption of an input stream using provided cipher key. - * - * @param inputStream InputStream to be encrypted. - * @param cipherKey Cipher key to be used for encryption. - * - * @return InputStream containing the encryption of `inputStream` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed encryption. - */ - override fun encryptInputStream( - inputStream: InputStream, - cipherKey: String?, - ): InputStream { - TODO("Not yet implemented") - } - - override fun parseToken(token: String): PNToken { - TODO("Not yet implemented") - } - - override fun setToken(token: String?) { - TODO("Not yet implemented") - } - - /** - * Cancel any subscribe and heartbeat loops or ongoing re-connections. - * - * Monitor the results in [SubscribeCallback.status] - */ - override fun disconnect() { - TODO("Not yet implemented") - } - - /** - * Unsubscribe from all channels and all channel groups - */ - override fun unsubscribeAll() { - TODO("Not yet implemented") - } - - override fun subscriptionSetOf( - subscriptions: Set>, - ): BaseSubscriptionSetImpl> { - TODO("Not yet implemented") - } - - fun addListener(listener: SubscribeCallback) { - listenerManager.addListener(listener) - } - - /** - * Add a listener. - * - * @param listener The listener to be added. - */ - override fun addListener(listener: BaseEventListener) { - TODO("Not yet implemented") - } - - /** - * Add a listener. - * - * @param listener The listener to be added. - */ - override fun addListener(listener: BaseStatusListener) { - TODO("Not yet implemented") - } - } - -fun interface TestEventListener : BaseEventListener { - fun message(message: PNMessageResult) -} diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImplTest.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImplTest.kt deleted file mode 100644 index 693a7149e..000000000 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImplTest.kt +++ /dev/null @@ -1,146 +0,0 @@ -package com.pubnub.internal.v2.subscriptions - -import com.google.gson.JsonNull -import com.pubnub.api.BasePubNub -import com.pubnub.api.UserId -import com.pubnub.api.models.consumer.pubsub.BasePubSubResult -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.internal.TestEventListener -import com.pubnub.internal.TestPubNub -import com.pubnub.internal.v2.BasePNConfigurationImpl -import com.pubnub.internal.v2.callbacks.EventListenerCore -import com.pubnub.internal.v2.entities.ChannelName -import com.pubnub.internal.v2.subscription.BaseSubscriptionImpl -import com.pubnub.internal.v2.subscription.BaseSubscriptionSetImpl -import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertFalse -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class BaseSubscriptionSetImplTest { - private lateinit var pubnub: TestPubNub - private lateinit var subscriptionSet: BaseSubscriptionSetImpl> - private lateinit var anotherSubscription: BaseSubscriptionImpl - private val channelName = "myChannel" - - @BeforeEach - fun setUp() { - pubnub = TestPubNub(BasePNConfigurationImpl(UserId("uuid"))) - subscriptionSet = - object : - BaseSubscriptionSetImpl>(pubnub.pubNubCore) { - override fun addListener(listener: TestEventListener) { - addListener( - object : EventListenerCore { - override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNMessageResult, - ) { - listener.message(event) - } - }, - ) - } - } - - subscriptionSet.add( - object : BaseSubscriptionImpl(pubnub.pubNubCore, setOf(ChannelName(channelName))) { - override fun addListener(listener: TestEventListener) { - TODO("Not yet implemented") - } - }, - ) - - anotherSubscription = - object : BaseSubscriptionImpl(pubnub.pubNubCore, setOf(ChannelName("anotherChannel"))) { - override fun addListener(listener: TestEventListener) { - TODO("Not yet implemented") - } - } - } - - @AfterEach - fun teardown() { - subscriptionSet.close() - anotherSubscription.close() - pubnub.destroy() - } - - @Test - fun add() { - // given - - // when - subscriptionSet.add(anotherSubscription) - subscriptionSet.subscribe() - - // then - assertTrue(subscriptionSet.subscriptions.contains(anotherSubscription)) - assertEquals(setOf(channelName, "anotherChannel"), pubnub.pubNubCore.getSubscribedChannels().toSet()) - } - - @Test - fun remove() { - // given - subscriptionSet.add(anotherSubscription) - - // when - subscriptionSet.remove(anotherSubscription) - subscriptionSet.subscribe() - - // then - assertFalse(subscriptionSet.subscriptions.contains(anotherSubscription)) - assertEquals(setOf(channelName), pubnub.pubNubCore.getSubscribedChannels().toSet()) - } - - @Test - fun subscribe() { - // when - subscriptionSet.subscribe() - - // then - assertEquals(setOf(channelName), pubnub.pubNubCore.getSubscribedChannels().toSet()) - } - - @Test - fun unsubscribe() { - // given - subscriptionSet.subscribe() - - // when - subscriptionSet.unsubscribe() - - // then - assertEquals(emptyList(), pubnub.pubNubCore.getSubscribedChannels()) - } - - @Test - fun close() { - // given - subscriptionSet.subscribe() - subscriptionSet.addListener( - object : TestEventListener { - override fun message(message: PNMessageResult) { - throw IllegalStateException("We should not get a message after close!") - } - }, - ) - - // when - subscriptionSet.close() - - pubnub.listenerManager.announce( - PNMessageResult( - BasePubSubResult(channelName, null, null, null, null), - JsonNull.INSTANCE, - ), - ) - - // then - // no exception from listener - assertEquals(emptyList(), pubnub.pubNubCore.getSubscribedChannels()) - assertEquals(emptyList(), pubnub.pubNubCore.getSubscribedChannelGroups()) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/TestPNConfigurationImpl.kt b/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/TestPNConfigurationImpl.kt deleted file mode 100644 index 20aa73beb..000000000 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/TestPNConfigurationImpl.kt +++ /dev/null @@ -1,348 +0,0 @@ -package com.pubnub.test - -import com.pubnub.api.UserId -import com.pubnub.api.crypto.CryptoModule -import com.pubnub.api.enums.PNHeartbeatNotificationOptions -import com.pubnub.api.enums.PNLogVerbosity -import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.internal.v2.BasePNConfigurationImpl -import okhttp3.Authenticator -import okhttp3.CertificatePinner -import okhttp3.ConnectionSpec -import okhttp3.logging.HttpLoggingInterceptor -import java.net.Proxy -import java.net.ProxySelector -import javax.net.ssl.HostnameVerifier -import javax.net.ssl.SSLSocketFactory -import javax.net.ssl.X509ExtendedTrustManager - -class TestPNConfigurationImpl( - override val userId: UserId, - override val subscribeKey: String, - override val publishKey: String, - override val secretKey: String, - override val authKey: String, - override val cryptoModule: CryptoModule?, - override val origin: String, - override val secure: Boolean, - override val logVerbosity: PNLogVerbosity, - override val heartbeatNotificationOptions: PNHeartbeatNotificationOptions, - override val presenceTimeout: Int, - override val heartbeatInterval: Int, - override val subscribeTimeout: Int, - override val connectTimeout: Int, - override val nonSubscribeReadTimeout: Int, - override val cacheBusting: Boolean, - override val suppressLeaveEvents: Boolean, - override val maintainPresenceState: Boolean, - override val filterExpression: String, - override val includeInstanceIdentifier: Boolean, - override val includeRequestIdentifier: Boolean, - override val maximumConnections: Int?, - override val googleAppEngineNetworking: Boolean, - override val proxy: Proxy?, - override val proxySelector: ProxySelector?, - override val proxyAuthenticator: Authenticator?, - override val certificatePinner: CertificatePinner?, - override val httpLoggingInterceptor: HttpLoggingInterceptor?, - override val sslSocketFactory: SSLSocketFactory?, - override val x509ExtendedTrustManager: X509ExtendedTrustManager?, - override val connectionSpec: ConnectionSpec?, - override val hostnameVerifier: HostnameVerifier?, - override val fileMessagePublishRetryLimit: Int, - override val dedupOnSubscribe: Boolean, - override val maximumMessagesCacheSize: Int, - override val pnsdkSuffixes: Map, - override val retryConfiguration: RetryConfiguration, - override val managePresenceListManually: Boolean, -) : BasePNConfigurationImpl(userId) { - class Builder internal constructor(override var userId: UserId) : - BasePNConfigurationImpl.Builder(BasePNConfigurationImpl(userId)) { - /** - * The subscribe key from the admin panel. - */ - override var subscribeKey: String = super.subscribeKey - - /** - * The publish key from the admin panel (only required if publishing). - */ - override var publishKey: String = super.publishKey - - /** - * The secret key from the admin panel (only required for modifying/revealing access permissions). - * - * Keep away from Android. - */ - override var secretKey: String = super.secretKey - - /** - * If Access Manager is utilized, client will use this authKey in all restricted requests. - */ - override var authKey: String = super.authKey - - /** - * CryptoModule is responsible for handling encryption and decryption. - * If set, all communications to and from PubNub will be encrypted. - */ - override var cryptoModule: CryptoModule? = super.cryptoModule - - /** - * Custom origin if needed. - * - * Defaults to `ps.pndsn.com` - */ - override var origin: String = super.origin - - /** - * If set to `true`, requests will be made over HTTPS. - * - * Deafults to `true`. - */ - override var secure: Boolean = super.secure - - /** - * Set to [PNLogVerbosity.BODY] to enable logging of network traffic, otherwise se to [PNLogVerbosity.NONE]. - */ - override var logVerbosity: PNLogVerbosity = super.logVerbosity - - /** - * Set Heartbeat notification options. - * - * By default, the SDK alerts on failed heartbeats (equivalent to [PNHeartbeatNotificationOptions.FAILURES]). - */ - override var heartbeatNotificationOptions: PNHeartbeatNotificationOptions = super.heartbeatNotificationOptions - - /** - * Sets the custom presence server timeout. - * - * The value is in seconds, and the minimum value is 20 seconds. - * - * Also sets the value of [heartbeatInterval] - */ - override var presenceTimeout: Int = super.presenceTimeout - set(value) { - field = - if (value < MINIMUM_PRESENCE_TIMEOUT) { - MINIMUM_PRESENCE_TIMEOUT - } else { - value - } - heartbeatInterval = (presenceTimeout / 2) - 1 - } - - /** - * How often the client will announce itself to server. - * - * The value is in seconds. - */ - override var heartbeatInterval: Int = super.heartbeatInterval - - /** - * The subscribe request timeout. - * - * The value is in seconds. - * - * Defaults to 310. - */ - override var subscribeTimeout: Int = super.subscribeTimeout - - /** - * How long before the client gives up trying to connect with a subscribe call. - * - * The value is in seconds. - * - * Defaults to 5. - */ - override var connectTimeout: Int = super.connectTimeout - - /** - * For non subscribe operations (publish, herenow, etc) - * how long to wait to connect to PubNub before giving up with a connection timeout error. - * - * The value is in seconds. - * - * Defaults to 10. - */ - override var nonSubscribeRequestTimeout: Int = super.nonSubscribeRequestTimeout - - /** - * If operating behind a misbehaving proxy, allow the client to shuffle the subdomains. - * - * Defaults to `false`. - */ - override var cacheBusting: Boolean = super.cacheBusting - - /** - * When `true` the SDK doesn't send out the leave requests. - * - * Defaults to `false`. - */ - override var suppressLeaveEvents: Boolean = super.suppressLeaveEvents - - /** - * When `true` the SDK will resend the last channel state that was set using [PubNub.setPresenceState] - * for the current [userId] with every automatic heartbeat (if [heartbeatInterval] is greater than 0) - * and initial subscribe connection (also after e.g. loss of network). - * - * Defaults to `true`. - * - * Please note that `maintainPresenceState` doesn't apply to state that was set on channel groups. - * It is recommended to disable this option if you set state for channel groups using [PubNub.setPresenceState] - * otherwise that state may be overwritten by individual channel states. - */ - override var maintainPresenceState: Boolean = super.maintainPresenceState - - /** - * Feature to subscribe with a custom filter expression. - */ - override var filterExpression: String = super.filterExpression - - /** - * Whether to include a [PubNubCore.instanceId] with every request. - * - * Defaults to `false`. - */ - override var includeInstanceIdentifier: Boolean = super.includeInstanceIdentifier - - /** - * Whether to include a [PubNubCore.requestId] with every request. - * - * Defaults to `true`. - */ - override var includeRequestIdentifier: Boolean = super.includeRequestIdentifier - - /** - * @see [okhttp3.Dispatcher.setMaxRequestsPerHost] - */ - override var maximumConnections: Int? = super.maximumConnections - - /** - * Enable Google App Engine networking. - * - * Defaults to `false`. - */ - override var googleAppEngineNetworking: Boolean = super.googleAppEngineNetworking - - /** - * Instructs the SDK to use a proxy configuration when communicating with PubNub servers. - * - * @see [Proxy] - */ - override var proxy: Proxy? = super.proxy - - /** - * @see [ProxySelector] - */ - override var proxySelector: ProxySelector? = super.proxySelector - - /** - * @see [Authenticator] - */ - override var proxyAuthenticator: Authenticator? = super.proxyAuthenticator - - /** - * @see [CertificatePinner] - */ - override var certificatePinner: CertificatePinner? = super.certificatePinner - - /** - * Sets a custom [HttpLoggingInterceptor] for logging network traffic. - * - * @see [HttpLoggingInterceptor] - */ - override var httpLoggingInterceptor: HttpLoggingInterceptor? = super.httpLoggingInterceptor - - /** - * @see [SSLSocketFactory] - */ - override var sslSocketFactory: SSLSocketFactory? = super.sslSocketFactory - - /** - * @see [X509ExtendedTrustManager] - */ - override var x509ExtendedTrustManager: X509ExtendedTrustManager? = super.x509ExtendedTrustManager - - /** - * @see [okhttp3.ConnectionSpec] - */ - override var connectionSpec: ConnectionSpec? = super.connectionSpec - - /** - * @see [javax.net.ssl.HostnameVerifier] - */ - override var hostnameVerifier: HostnameVerifier? = super.hostnameVerifier - - /** - * How many times publishing file message should automatically retry before marking the action as failed - * - * Defaults to `5` - */ - override var fileMessagePublishRetryLimit: Int = super.fileMessagePublishRetryLimit - override var dedupOnSubscribe: Boolean = super.dedupOnSubscribe - override var maximumMessagesCacheSize: Int = super.maximumMessagesCacheSize - override var pnsdkSuffixes: Map = super.pnsdkSuffixes - - /** - * Retry configuration for requests. - * Defaults to [RetryConfiguration.None]. - * - * Use [RetryConfiguration.Linear] to set retry with linear delay interval - * Use [RetryConfiguration.Exponential] to set retry with exponential delay interval - * Delay will valy from provided value by random value. - */ - override var retryConfiguration: RetryConfiguration = super.retryConfiguration - - /** - * Enables explicit presence control. - * When set to true heartbeat calls will contain only channels and groups added explicitly - * using [PubNubCore.presence]. Should be used only with ACL set on the server side. - * For more information please contact PubNub support - * @see PubNubCore.presence - * @see BasePNConfigurationImpl.heartbeatInterval - */ - override var managePresenceListManually: Boolean = super.managePresenceListManually - - fun build(): BasePNConfigurationImpl { - return TestPNConfigurationImpl( - userId = userId, - subscribeKey = subscribeKey, - publishKey = publishKey, - secretKey = secretKey, - authKey = authKey, - cryptoModule = cryptoModule, - origin = origin, - secure = secure, - logVerbosity = logVerbosity, - heartbeatNotificationOptions = heartbeatNotificationOptions, - presenceTimeout = presenceTimeout, - heartbeatInterval = heartbeatInterval, - subscribeTimeout = subscribeTimeout, - connectTimeout = connectTimeout, - nonSubscribeReadTimeout = nonSubscribeReadTimeout, - cacheBusting = cacheBusting, - suppressLeaveEvents = suppressLeaveEvents, - maintainPresenceState = maintainPresenceState, - filterExpression = filterExpression, - includeInstanceIdentifier = includeInstanceIdentifier, - includeRequestIdentifier = includeRequestIdentifier, - maximumConnections = maximumConnections, - googleAppEngineNetworking = googleAppEngineNetworking, - proxy = proxy, - proxySelector = proxySelector, - proxyAuthenticator = proxyAuthenticator, - certificatePinner = certificatePinner, - httpLoggingInterceptor = httpLoggingInterceptor, - sslSocketFactory = sslSocketFactory, - x509ExtendedTrustManager = x509ExtendedTrustManager, - connectionSpec = connectionSpec, - hostnameVerifier = hostnameVerifier, - fileMessagePublishRetryLimit = fileMessagePublishRetryLimit, - dedupOnSubscribe = dedupOnSubscribe, - maximumMessagesCacheSize = maximumMessagesCacheSize, - pnsdkSuffixes = pnsdkSuffixes, - retryConfiguration = retryConfiguration, - managePresenceListManually = managePresenceListManually, - ) - } - } -} diff --git a/pubnub-gson/build.gradle.kts b/pubnub-gson/build.gradle.kts index 4b8dd2eee..8d6adc4fe 100644 --- a/pubnub-gson/build.gradle.kts +++ b/pubnub-gson/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - checkstyle alias(libs.plugins.benmanes.versions) alias(libs.plugins.lombok) id("pubnub.java-library") @@ -7,23 +6,6 @@ plugins { } dependencies { - api(project(":pubnub-core:pubnub-core-api")) api(project(":pubnub-gson:pubnub-gson-api")) - implementation(project(":pubnub-core:pubnub-core-impl")) implementation(project(":pubnub-gson:pubnub-gson-impl")) } - -checkstyle { - toolVersion = "8.14" - configFile = rootProject.file("config/checkstyle/checkstyle.xml") - sourceSets = listOf(project.sourceSets.getByName("main")) -} - -tasks.withType().configureEach { - exclude("**/vendor/**", "**/*Test*") - - reports { - xml.required = true - html.required = true - } -} diff --git a/pubnub-gson/pubnub-gson-api/build.gradle.kts b/pubnub-gson/pubnub-gson-api/build.gradle.kts index 1e2c29c06..26b655734 100644 --- a/pubnub-gson/pubnub-gson-api/build.gradle.kts +++ b/pubnub-gson/pubnub-gson-api/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - checkstyle alias(libs.plugins.benmanes.versions) alias(libs.plugins.lombok) id("pubnub.java-library") @@ -8,24 +7,7 @@ plugins { } dependencies { - api(project(":pubnub-core:pubnub-core-api")) - implementation(project(":pubnub-core:pubnub-core-impl")) - + api(project(":pubnub-kotlin:pubnub-kotlin-api")) implementation(libs.slf4j) implementation(libs.jetbrains.annotations) } - -checkstyle { - toolVersion = "8.14" - configFile = rootProject.file("config/checkstyle/checkstyle.xml") - sourceSets = listOf(project.sourceSets.getByName("main")) -} - -tasks.withType().configureEach { - exclude("**/vendor/**", "**/*Test*") - - reports { - xml.required = true - html.required = true - } -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/PNConfiguration.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/PNConfiguration.kt deleted file mode 100644 index 8ad0a1dc7..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/PNConfiguration.kt +++ /dev/null @@ -1,700 +0,0 @@ -package com.pubnub.api - -import com.pubnub.api.crypto.CryptoModule -import com.pubnub.api.enums.PNHeartbeatNotificationOptions -import com.pubnub.api.enums.PNLogVerbosity -import com.pubnub.api.enums.PNReconnectionPolicy -import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.internal.v2.BasePNConfigurationImpl -import okhttp3.Authenticator -import okhttp3.CertificatePinner -import okhttp3.ConnectionSpec -import okhttp3.logging.HttpLoggingInterceptor -import org.slf4j.LoggerFactory -import java.net.Proxy -import java.net.ProxySelector -import javax.net.ssl.HostnameVerifier -import javax.net.ssl.SSLSocketFactory -import javax.net.ssl.X509ExtendedTrustManager - -@Deprecated( - message = "Use `com.pubnub.api.v2.PNConfiguration.builder()` instead.", - replaceWith = ReplaceWith("PNConfiguration.builder(userId, subscribeKey = )", "com.pubnub.api.v2.PNConfiguration"), -) -class PNConfiguration(userId: UserId) : BasePNConfiguration { - @Deprecated( - replaceWith = ReplaceWith( - "PNConfiguration(userId = UserId(uuid))", - "com.pubnub.api.PNConfiguration", - ), - level = DeprecationLevel.WARNING, - message = "Use PNConfiguration(UserId) instead.", - ) - @Throws(PubNubException::class) - constructor(uuid: String) : this(UserId(uuid)) - - private val defaultConfiguration = BasePNConfigurationImpl(userId) - - override var userId: UserId = userId - private set - - fun setUserId(userId: UserId): PNConfiguration { - this.userId = userId - return this - } - - @Deprecated( - "Use UserId instead e.g. config.userId.value", - replaceWith = ReplaceWith("userId.value"), - level = DeprecationLevel.WARNING, - ) - override val uuid - get() = userId.value - - @Throws(PubNubException::class) - fun setUuid(uuid: String) { - userId = UserId(uuid) - } - - /** - * The subscribe key from the admin panel. - */ - fun setSubscribeKey(subscribeKey: String): PNConfiguration { - this.subscribeKey = subscribeKey - return this - } - - override var subscribeKey: String = defaultConfiguration.subscribeKey - private set - - /** - * The publish key from the admin panel (only required if publishing). - */ - fun setPublishKey(publishKey: String): PNConfiguration { - this.publishKey = publishKey - return this - } - - override var publishKey: String = defaultConfiguration.publishKey - private set - - /** - * The secret key from the admin panel (only required for modifying/revealing access permissions). - * - * Keep away from Android. - */ - fun setSecretKey(secretKey: String): PNConfiguration { - this.secretKey = secretKey - return this - } - - override var secretKey: String = defaultConfiguration.secretKey - private set - - /** - * If Access Manager is utilized, client will use this authKey in all restricted requests. - */ - fun setAuthKey(authKey: String): PNConfiguration { - this.authKey = authKey - return this - } - - override var authKey: String = defaultConfiguration.authKey - private set - - /** - * If set, all communications to and from PubNub will be encrypted. - */ - @Deprecated( - """Instead of cipherKey and useRandomInitializationVector use CryptoModule instead - e.g. config.cryptoModule = CryptoModule.createLegacyCryptoModule(cipherKey = cipherKey, randomIv = true) - or config.cryptoModule = CryptoModule.createAesCbcCryptoModule(cipherKey = cipherKey, randomIv = true)""", - level = DeprecationLevel.WARNING, - ) - var cipherKey: String? = null - private set - - /** - * If set, all communications to and from PubNub will be encrypted. - */ - fun setCipherKey(cipherKey: String?): PNConfiguration { - this.cipherKey = cipherKey - return this - } - - /** - * Should initialization vector for encrypted messages be random. - * - * Defaults to `true`. - */ - @Deprecated( - """Instead of cipherKey and useRandomInitializationVector use CryptoModule instead - e.g. config.cryptoModule = CryptoModule.createLegacyCryptoModule(cipherKey = cipherKey, randomIv = true) - or config.cryptoModule = CryptoModule.createAesCbcCryptoModule(cipherKey = cipherKey, randomIv = true)""", - level = DeprecationLevel.WARNING, - ) - var useRandomInitializationVector: Boolean = true - private set - - /** - * Should initialization vector for encrypted messages be random. - * - * Defaults to `true`. - */ - fun setUseRandomInitializationVector(useRandomInitializationVector: Boolean): PNConfiguration { - this.useRandomInitializationVector = useRandomInitializationVector - return this - } - - /** - * CryptoModule is responsible for handling encryption and decryption. - * If set, all communications to and from PubNub will be encrypted. - */ - fun setCryptoModule(cryptoModule: CryptoModule?): PNConfiguration { - this.cryptoModule = cryptoModule - return this - } - - override var cryptoModule: CryptoModule? = defaultConfiguration.cryptoModule - get() = field ?: cipherKey?.let { cipherKey -> - if (cipherKey.isNotBlank()) { - log.warn("cipherKey is deprecated. Use CryptoModule instead") - field = - CryptoModule.createLegacyCryptoModule( - cipherKey = cipherKey, - randomIv = useRandomInitializationVector, - ) - field - } else { - null - } - } - private set - - /** - * Custom origin if needed. - * - * Defaults to `ps.pndsn.com` - */ - fun setOrigin(origin: String): PNConfiguration { - this.origin = origin - return this - } - - override var origin: String = defaultConfiguration.origin - private set - - /** - * If set to `true`, requests will be made over HTTPS. - * - * Deafults to `true`. - */ - fun setSecure(secure: Boolean): PNConfiguration { - this.secure = secure - return this - } - - override var secure: Boolean = defaultConfiguration.secure - private set - - /** - * Set to [PNLogVerbosity.BODY] to enable logging of network traffic, otherwise se to [PNLogVerbosity.NONE]. - */ - fun setLogVerbosity(logVerbosity: PNLogVerbosity): PNConfiguration { - this.logVerbosity = logVerbosity - return this - } - - override var logVerbosity: PNLogVerbosity = defaultConfiguration.logVerbosity - private set - - /** - * Set Heartbeat notification options. - * - * By default, the SDK alerts on failed heartbeats (equivalent to [PNHeartbeatNotificationOptions.FAILURES]). - */ - fun setHeartbeatNotificationOptions(heartbeatNotificationOptions: PNHeartbeatNotificationOptions): PNConfiguration { - this.heartbeatNotificationOptions = heartbeatNotificationOptions - return this - } - - override var heartbeatNotificationOptions: PNHeartbeatNotificationOptions = - defaultConfiguration.heartbeatNotificationOptions - private set - - /** - * Sets the custom presence server timeout. - * - * The value is in seconds, and the minimum value is 20 seconds. - * - * Also sets the value of [heartbeatInterval] - */ - fun setPresenceTimeout(presenceTimeout: Int): PNConfiguration { - val timeout = validatePresenceTimeout(presenceTimeout) - setPresenceTimeoutWithCustomInterval(timeout, (timeout / 2) - 1) - return this - } - - /** - * Set presence configurations for timeout and announce interval. - * - * @param timeout presence timeout; how long before the server considers this client to be gone. - * @param interval presence announce interval, how often the client should announce itself. - * @return returns itself. - */ - fun setPresenceTimeoutWithCustomInterval( - timeout: Int, - interval: Int, - ): PNConfiguration { - val newTimeout = validatePresenceTimeout(timeout) - presenceTimeout = newTimeout - heartbeatInterval = interval - return this - } - - override var presenceTimeout: Int = defaultConfiguration.presenceTimeout - private set - - /** - * How often the client will announce itself to server. - * - * The value is in seconds. - */ - fun setHeartbeatInterval(heartbeatInterval: Int): PNConfiguration { - this.heartbeatInterval = heartbeatInterval - return this - } - - override var heartbeatInterval: Int = defaultConfiguration.heartbeatInterval - private set - - /** - * The subscribe request timeout. - * - * The value is in seconds. - * - * Defaults to 310. - */ - fun setSubscribeTimeout(subscribeTimeout: Int): PNConfiguration { - this.subscribeTimeout = subscribeTimeout - return this - } - - override var subscribeTimeout: Int = defaultConfiguration.subscribeTimeout - private set - - /** - * How long before the client gives up trying to connect with the server. - * - * The value is in seconds. - * - * Defaults to 5. - */ - fun setConnectTimeout(connectTimeout: Int): PNConfiguration { - this.connectTimeout = connectTimeout - return this - } - - override var connectTimeout: Int = defaultConfiguration.connectTimeout - private set - - override var nonSubscribeReadTimeout: Int = defaultConfiguration.nonSubscribeReadTimeout - private set - - /** - * For non subscribe operations (publish, herenow, etc), - * This property relates to a read timeout that is applied from the moment the connection between a client - * and the server has been successfully established. It defines a maximum time of inactivity between two - * data packets when waiting for the server’s response. - * - * The value is in seconds. - * - * Defaults to 10. - */ - fun setNonSubscribeReadTimeout(nonSubscribeReadTimeout: Int): PNConfiguration { - this.nonSubscribeReadTimeout = nonSubscribeReadTimeout - return this - } - - /** - * For non subscribe operations (publish, herenow, etc), - * This property relates to a read timeout that is applied from the moment the connection between a client - * and the server has been successfully established. It defines a maximum time of inactivity between two - * data packets when waiting for the server’s response. - * - * The value is in seconds. - * - * Defaults to 10. - */ - @Deprecated( - "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", - replaceWith = ReplaceWith("nonSubscribeReadTimeout") - ) - fun setNonSubscribeRequestTimeout(nonSubscribeRequestTimeout: Int): PNConfiguration { - return this.setNonSubscribeReadTimeout(nonSubscribeRequestTimeout) - } - - /** - * If operating behind a misbehaving proxy, allow the client to shuffle the subdomains. - * - * Defaults to `false`. - */ - fun setCacheBusting(cacheBusting: Boolean): PNConfiguration { - this.cacheBusting = cacheBusting - return this - } - - override var cacheBusting: Boolean = defaultConfiguration.cacheBusting - private set - - /** - * When `true` the SDK doesn't send out the leave requests. - * - * Defaults to `false`. - */ - fun setSuppressLeaveEvents(suppressLeaveEvents: Boolean): PNConfiguration { - this.suppressLeaveEvents = suppressLeaveEvents - return this - } - - override var suppressLeaveEvents: Boolean = defaultConfiguration.suppressLeaveEvents - private set - - /** - * When `true` the SDK will resend the last channel state that was set using [PubNub.setPresenceState] - * for the current [userId] with every automatic heartbeat (if [heartbeatInterval] is greater than 0) - * and initial subscribe connection (also after e.g. loss of network). - * - * Defaults to `true`. - * - * Please note that `maintainPresenceState` doesn't apply to state that was set on channel groups. - * It is recommended to disable this option if you set state for channel groups using [PubNub.setPresenceState] - * otherwise that state may be overwritten by individual channel states. - */ - fun setMaintainPresenceState(maintainPresenceState: Boolean): PNConfiguration { - this.maintainPresenceState = maintainPresenceState - return this - } - - override var maintainPresenceState: Boolean = defaultConfiguration.maintainPresenceState - private set - - /** - * Feature to subscribe with a custom filter expression. - */ - fun setFilterExpression(filterExpression: String): PNConfiguration { - this.filterExpression = filterExpression - return this - } - - override var filterExpression: String = defaultConfiguration.filterExpression - private set - - /** - * Whether to include a [PubNubCore.instanceId] with every request. - * - * Defaults to `false`. - */ - fun setIncludeInstanceIdentifier(includeInstanceIdentifier: Boolean): PNConfiguration { - this.includeInstanceIdentifier = includeInstanceIdentifier - return this - } - - override var includeInstanceIdentifier: Boolean = defaultConfiguration.includeInstanceIdentifier - private set - - /** - * Whether to include a [PubNubCore.requestId] with every request. - * - * Defaults to `true`. - */ - fun setIncludeRequestIdentifier(includeRequestIdentifier: Boolean): PNConfiguration { - this.includeRequestIdentifier = includeRequestIdentifier - return this - } - - override var includeRequestIdentifier: Boolean = defaultConfiguration.includeRequestIdentifier - private set - - /** - * @see [okhttp3.Dispatcher.setMaxRequestsPerHost] - */ - fun setMaximumConnections(maximumConnections: Int?): PNConfiguration { - this.maximumConnections = maximumConnections - return this - } - - override var maximumConnections: Int? = defaultConfiguration.maximumConnections - private set - - /** - * Enable Google App Engine networking. - * - * Defaults to `false`. - */ - fun setGoogleAppEngineNetworking(googleAppEngineNetworking: Boolean): PNConfiguration { - this.googleAppEngineNetworking = googleAppEngineNetworking - return this - } - - override var googleAppEngineNetworking: Boolean = defaultConfiguration.googleAppEngineNetworking - private set - - /** - * Instructs the SDK to use a proxy configuration when communicating with PubNub servers. - * - * @see [Proxy] - */ - fun setProxy(proxy: Proxy?): PNConfiguration { - this.proxy = proxy - return this - } - - override var proxy: Proxy? = defaultConfiguration.proxy - private set - - /** - * @see [ProxySelector] - */ - fun setProxySelector(proxySelector: ProxySelector?): PNConfiguration { - this.proxySelector = proxySelector - return this - } - - override var proxySelector: ProxySelector? = defaultConfiguration.proxySelector - private set - - /** - * @see [Authenticator] - */ - fun setProxyAuthenticator(proxyAuthenticator: Authenticator?): PNConfiguration { - this.proxyAuthenticator = proxyAuthenticator - return this - } - - override var proxyAuthenticator: Authenticator? = defaultConfiguration.proxyAuthenticator - private set - - /** - * @see [CertificatePinner] - */ - fun setCertificatePinner(certificatePinner: CertificatePinner?): PNConfiguration { - this.certificatePinner = certificatePinner - return this - } - - override var certificatePinner: CertificatePinner? = defaultConfiguration.certificatePinner - private set - - /** - * Sets a custom [HttpLoggingInterceptor] for logging network traffic. - * - * @see [HttpLoggingInterceptor] - */ - fun setHttpLoggingInterceptor(httpLoggingInterceptor: HttpLoggingInterceptor?): PNConfiguration { - this.httpLoggingInterceptor = httpLoggingInterceptor - return this - } - - override var httpLoggingInterceptor: HttpLoggingInterceptor? = defaultConfiguration.httpLoggingInterceptor - private set - - /** - * @see [SSLSocketFactory] - */ - fun setSslSocketFactory(sslSocketFactory: SSLSocketFactory?): PNConfiguration { - this.sslSocketFactory = sslSocketFactory - return this - } - - override var sslSocketFactory: SSLSocketFactory? = defaultConfiguration.sslSocketFactory - private set - - /** - * @see [X509ExtendedTrustManager] - */ - fun setX509ExtendedTrustManager(x509ExtendedTrustManager: X509ExtendedTrustManager?): PNConfiguration { - this.x509ExtendedTrustManager = x509ExtendedTrustManager - return this - } - - override var x509ExtendedTrustManager: X509ExtendedTrustManager? = defaultConfiguration.x509ExtendedTrustManager - private set - - /** - * @see [okhttp3.ConnectionSpec] - */ - fun setConnectionSpec(connectionSpec: ConnectionSpec?): PNConfiguration { - this.connectionSpec = connectionSpec - return this - } - - override var connectionSpec: ConnectionSpec? = defaultConfiguration.connectionSpec - private set - - /** - * @see [javax.net.ssl.HostnameVerifier] - */ - fun setHostnameVerifier(hostnameVerifier: HostnameVerifier?): PNConfiguration { - this.hostnameVerifier = hostnameVerifier - return this - } - - override var hostnameVerifier: HostnameVerifier? = defaultConfiguration.hostnameVerifier - private set - - /** - * How many times publishing file message should automatically retry before marking the action as failed - * - * Defaults to `5` - */ - fun setFileMessagePublishRetryLimit(fileMessagePublishRetryLimit: Int): PNConfiguration { - this.fileMessagePublishRetryLimit = fileMessagePublishRetryLimit - return this - } - - override var fileMessagePublishRetryLimit: Int = defaultConfiguration.fileMessagePublishRetryLimit - private set - - fun setDedupOnSubscribe(dedupOnSubscribe: Boolean): PNConfiguration { - this.dedupOnSubscribe = dedupOnSubscribe - return this - } - - override var dedupOnSubscribe: Boolean = defaultConfiguration.dedupOnSubscribe - private set - - fun setMaximumMessagesCacheSize(maximumMessagesCacheSize: Int): PNConfiguration { - this.maximumMessagesCacheSize = maximumMessagesCacheSize - return this - } - - override var maximumMessagesCacheSize: Int = defaultConfiguration.maximumMessagesCacheSize - private set - - fun setPnsdkSuffixes(pnSdkSuffixes: Map): PNConfiguration { - this.pnsdkSuffixes = pnSdkSuffixes - return this - } - - override var pnsdkSuffixes: Map = defaultConfiguration.pnsdkSuffixes - private set - - /** - * Retry configuration for requests. - * Defaults to [RetryConfiguration.None]. - * - * Use [RetryConfiguration.Linear] to set retry with linear delay interval - * Use [RetryConfiguration.Exponential] to set retry with exponential delay interval - * Delay will valy from provided value by random value. - */ - fun setRetryConfiguration(retryConfiguration: RetryConfiguration): PNConfiguration { - this.retryConfiguration = retryConfiguration - return this - } - - override var retryConfiguration: RetryConfiguration = defaultConfiguration.retryConfiguration - private set - - /** - * Enables explicit presence control. - * When set to true heartbeat calls will contain only channels and groups added explicitly - * using [PubNubCore.presence]. Should be used only with ACL set on the server side. - * For more information please contact PubNub support - * @see PubNubCore.presence - * @see BasePNConfigurationImpl.heartbeatInterval - */ - fun setManagePresenceListManually(managePresenceListManually: Boolean): PNConfiguration { - this.managePresenceListManually = managePresenceListManually - return this - } - - override var managePresenceListManually: Boolean = defaultConfiguration.managePresenceListManually - private set - - /** - * Set to [PNReconnectionPolicy.LINEAR] for automatic reconnects. - * - * Use [PNReconnectionPolicy.NONE] to disable automatic reconnects. - * - * Use [PNReconnectionPolicy.EXPONENTIAL] to set exponential retry interval. - * - * Defaults to [PNReconnectionPolicy.NONE]. - */ - @Deprecated( - """Instead of reconnectionPolicy and maximumReconnectionRetries use retryConfiguration - e.g. config.retryConfiguration = RetryConfiguration.Linear(delayInSec = 3, maxRetryNumber = 5) - or config.retryConfiguration = RetryConfiguration.Exponential(minDelayInSec = 3, maxDelayInSec = 10, maxRetryNumber = 5)""", - level = DeprecationLevel.WARNING, - ) - var reconnectionPolicy: PNReconnectionPolicy = PNReconnectionPolicy.NONE - private set - - fun setReconnectionPolicy(reconnectionPolicy: PNReconnectionPolicy): PNConfiguration { - this.reconnectionPolicy = reconnectionPolicy - calculateRetryConfiguration() - return this - } - - private fun calculateRetryConfiguration() { - retryConfiguration = when (reconnectionPolicy) { - PNReconnectionPolicy.NONE -> RetryConfiguration.None - PNReconnectionPolicy.LINEAR -> RetryConfiguration.Linear( - maxRetryNumber = getMaximumReconnectionRetriesFor(reconnectionPolicy), - ) - - PNReconnectionPolicy.EXPONENTIAL -> RetryConfiguration.Exponential( - maxRetryNumber = getMaximumReconnectionRetriesFor(reconnectionPolicy), - ) - } - } - - private fun getMaximumReconnectionRetriesFor(reconnectionPolicy: PNReconnectionPolicy): Int { - val maxRetryNumber = if (reconnectionPolicy == PNReconnectionPolicy.LINEAR) { - RetryConfiguration.Linear.MAX_RETRIES - } else { - RetryConfiguration.Exponential.MAX_RETRIES - } - return when { - maximumReconnectionRetries <= -1 -> maxRetryNumber - maximumReconnectionRetries > maxRetryNumber -> maxRetryNumber - else -> maximumReconnectionRetries - } - } - - /** - * Sets how many times to retry to reconnect before giving up. - * Must be used in combination with [reconnectionPolicy]. - * - * The default value is `-1` which means unlimited retries. - */ - @Deprecated( - """Instead of reconnectionPolicy and maximumReconnectionRetries use retryConfiguration - e.g. config.retryConfiguration = RetryConfiguration.Linear(delayInSec = 3, maxRetryNumber = 5) - or config.retryConfiguration = RetryConfiguration.Exponential(minDelayInSec = 3, maxDelayInSec = 10, maxRetryNumber = 5)""", - level = DeprecationLevel.WARNING, - ) - var maximumReconnectionRetries = -1 - private set - - fun setMaximumReconnectionRetries(maximumReconnectionRetries: Int): PNConfiguration { - this.maximumReconnectionRetries = maximumReconnectionRetries - calculateRetryConfiguration() - return this - } - - companion object { - private const val MINIMUM_PRESENCE_TIMEOUT = 20 - private val log = LoggerFactory.getLogger("PNConfiguration") - - private fun validatePresenceTimeout(timeout: Int): Int { - var validTimeout = timeout - if (timeout < MINIMUM_PRESENCE_TIMEOUT) { - validTimeout = MINIMUM_PRESENCE_TIMEOUT - log.warn("Presence timeout is too low. Defaulting to: " + MINIMUM_PRESENCE_TIMEOUT) - } - return validTimeout - } - } -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/callbacks/SubscribeCallback.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/callbacks/SubscribeCallback.java deleted file mode 100644 index 420a2d092..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/callbacks/SubscribeCallback.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.pubnub.api.callbacks; - -import com.pubnub.api.PubNub; -import com.pubnub.api.models.consumer.PNStatus; -import com.pubnub.api.v2.callbacks.EventListener; -import com.pubnub.api.v2.callbacks.StatusListener; -import org.jetbrains.annotations.NotNull; - -public abstract class SubscribeCallback implements StatusListener, EventListener { - public static class BaseSubscribeCallback extends SubscribeCallback { - @Override - public void status(@NotNull PubNub pubnub, @NotNull PNStatus pnStatus) { - } - } -} \ No newline at end of file diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/Endpoint.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/Endpoint.java deleted file mode 100644 index b23af8dd6..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/Endpoint.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.pubnub.api.endpoints; - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; -import com.pubnub.api.v2.PNConfiguration; - -public interface Endpoint extends ExtendedRemoteAction { - /** - * Allows to override certain configuration options (see {@link com.pubnub.api.v2.BasePNConfigurationOverride.Builder}) for this request only. - *

- * {@link com.pubnub.api.v2.PNConfigurationOverride#from(com.pubnub.api.v2.BasePNConfiguration)} should be used to obtain a PNConfigurationOverride.Builder. - * Only options present in PNConfigurationOverride.Builder will be used for the override. - *

- * Example: - *

-     * configOverride = PNConfigurationOverride.from(pubnub.configuration)
-     * configOverride.userId(UserId("example"))
-     * endpoint.overrideConfiguration(configOverride.build()).sync()
-     * 
- * - * @return Returns the same instance for convenience, so {@link Endpoint#sync()} or {@link Endpoint#async(java.util.function.Consumer)} can be called next. - */ - Endpoint overrideConfiguration(PNConfiguration configuration); -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/Time.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/Time.java deleted file mode 100644 index 9a779b2ea..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/Time.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.pubnub.api.endpoints; - -import com.pubnub.api.models.consumer.PNTimeResult; - -public interface Time extends Endpoint { -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/GrantToken.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/GrantToken.java deleted file mode 100644 index 5e57ed551..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/GrantToken.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.pubnub.api.endpoints.access; - -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult; - -public interface GrantToken extends Endpoint { - GrantToken ttl(Integer ttl); - - GrantToken meta(Object meta); - - GrantToken authorizedUUID(String authorizedUUID); - - GrantToken channels(java.util.List channels); - - GrantToken channelGroups(java.util.List channelGroups); - - GrantToken uuids(java.util.List uuids); -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.java deleted file mode 100644 index b3da30e3c..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/ListAllChannelGroup.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.pubnub.api.endpoints.channel_groups; - -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult; - -public interface ListAllChannelGroup extends Endpoint { -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/GetMemberships.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/GetMemberships.java deleted file mode 100644 index 14a2af650..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/GetMemberships.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.pubnub.api.endpoints.objects_api.memberships; - -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.objects_api.membership.PNGetMembershipsResult; - -public interface GetMemberships extends Endpoint { - GetMemberships uuid(String uuid); - - GetMemberships limit(Integer limit); - - GetMemberships page(com.pubnub.api.models.consumer.objects.PNPage page); - - GetMemberships filter(String filter); - - GetMemberships sort(java.util.Collection sort); - - GetMemberships includeTotalCount(boolean includeTotalCount); - - GetMemberships includeCustom(boolean includeCustom); - - GetMemberships includeChannel(com.pubnub.api.endpoints.objects_api.utils.Include.PNChannelDetailsLevel includeChannel); -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/GetUUIDMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/GetUUIDMetadata.java deleted file mode 100644 index 83751738d..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/GetUUIDMetadata.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.pubnub.api.endpoints.objects_api.uuid; - -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.objects_api.uuid.PNGetUUIDMetadataResult; - -public interface GetUUIDMetadata extends Endpoint { - GetUUIDMetadata uuid(String uuid); - - GetUUIDMetadata includeCustom(boolean includeCustom); -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/RemoveUUIDMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/RemoveUUIDMetadata.java deleted file mode 100644 index 9e382af6e..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/RemoveUUIDMetadata.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.pubnub.api.endpoints.objects_api.uuid; - -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.objects_api.uuid.PNRemoveUUIDMetadataResult; - -public interface RemoveUUIDMetadata extends Endpoint { - RemoveUUIDMetadata uuid(String uuid); -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/WhereNow.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/WhereNow.java deleted file mode 100644 index 5072fcf59..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/WhereNow.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.pubnub.api.endpoints.presence; - -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.internal.models.consumer.presence.PNWhereNowResult; - -public interface WhereNow extends Endpoint { - WhereNow uuid(String uuid); -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/PubNub.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/PubNub.kt similarity index 72% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/PubNub.kt rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/PubNub.kt index 242f0c00c..7b66b54f0 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/PubNub.kt +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/PubNub.kt @@ -1,87 +1,86 @@ -package com.pubnub.api - -import com.pubnub.api.builder.PresenceBuilder -import com.pubnub.api.builder.SubscribeBuilder -import com.pubnub.api.builder.UnsubscribeBuilder -import com.pubnub.api.callbacks.SubscribeCallback -import com.pubnub.api.endpoints.DeleteMessages -import com.pubnub.api.endpoints.FetchMessages -import com.pubnub.api.endpoints.History -import com.pubnub.api.endpoints.MessageCounts +package com.pubnub.api.java + +import com.pubnub.api.PubNubException import com.pubnub.api.endpoints.Time -import com.pubnub.api.endpoints.access.Grant -import com.pubnub.api.endpoints.access.RevokeToken -import com.pubnub.api.endpoints.access.builder.GrantTokenBuilder -import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup -import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup -import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup -import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup -import com.pubnub.api.endpoints.files.DeleteFile -import com.pubnub.api.endpoints.files.DownloadFile -import com.pubnub.api.endpoints.files.GetFileUrl -import com.pubnub.api.endpoints.files.ListFiles -import com.pubnub.api.endpoints.files.PublishFileMessage -import com.pubnub.api.endpoints.files.SendFile -import com.pubnub.api.endpoints.message_actions.AddMessageAction -import com.pubnub.api.endpoints.message_actions.GetMessageActions -import com.pubnub.api.endpoints.message_actions.RemoveMessageAction -import com.pubnub.api.endpoints.objects_api.channel.GetAllChannelsMetadata -import com.pubnub.api.endpoints.objects_api.channel.GetChannelMetadata -import com.pubnub.api.endpoints.objects_api.channel.RemoveChannelMetadata -import com.pubnub.api.endpoints.objects_api.channel.SetChannelMetadata -import com.pubnub.api.endpoints.objects_api.members.GetChannelMembers -import com.pubnub.api.endpoints.objects_api.members.ManageChannelMembers -import com.pubnub.api.endpoints.objects_api.members.RemoveChannelMembers -import com.pubnub.api.endpoints.objects_api.members.SetChannelMembers -import com.pubnub.api.endpoints.objects_api.memberships.GetMemberships -import com.pubnub.api.endpoints.objects_api.memberships.ManageMemberships -import com.pubnub.api.endpoints.objects_api.memberships.RemoveMemberships -import com.pubnub.api.endpoints.objects_api.memberships.SetMemberships -import com.pubnub.api.endpoints.objects_api.uuid.GetAllUUIDMetadata -import com.pubnub.api.endpoints.objects_api.uuid.GetUUIDMetadata -import com.pubnub.api.endpoints.objects_api.uuid.RemoveUUIDMetadata -import com.pubnub.api.endpoints.objects_api.uuid.SetUUIDMetadata -import com.pubnub.api.endpoints.presence.GetState -import com.pubnub.api.endpoints.presence.HereNow -import com.pubnub.api.endpoints.presence.SetState -import com.pubnub.api.endpoints.presence.WhereNow -import com.pubnub.api.endpoints.pubsub.Publish -import com.pubnub.api.endpoints.push.AddChannelsToPush -import com.pubnub.api.endpoints.push.ListPushProvisions -import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice -import com.pubnub.api.endpoints.push.RemoveChannelsFromPush -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.api.v2.endpoints.pubsub.PublishBuilder -import com.pubnub.api.v2.endpoints.pubsub.SignalBuilder -import com.pubnub.api.v2.entities.Channel -import com.pubnub.api.v2.entities.ChannelGroup -import com.pubnub.api.v2.entities.ChannelMetadata -import com.pubnub.api.v2.entities.UserMetadata -import com.pubnub.api.v2.subscriptions.Subscription -import com.pubnub.api.v2.subscriptions.SubscriptionSet -import com.pubnub.internal.BasePubNubImpl +import com.pubnub.api.java.builder.PresenceBuilder +import com.pubnub.api.java.builder.SubscribeBuilder +import com.pubnub.api.java.builder.UnsubscribeBuilder +import com.pubnub.api.java.callbacks.SubscribeCallback +import com.pubnub.api.java.endpoints.DeleteMessages +import com.pubnub.api.java.endpoints.FetchMessages +import com.pubnub.api.java.endpoints.History +import com.pubnub.api.java.endpoints.MessageCounts +import com.pubnub.api.java.endpoints.access.Grant +import com.pubnub.api.java.endpoints.access.RevokeToken +import com.pubnub.api.java.endpoints.access.builder.GrantTokenBuilder +import com.pubnub.api.java.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.java.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.java.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.java.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.java.endpoints.files.DeleteFile +import com.pubnub.api.java.endpoints.files.DownloadFile +import com.pubnub.api.java.endpoints.files.GetFileUrl +import com.pubnub.api.java.endpoints.files.ListFiles +import com.pubnub.api.java.endpoints.files.PublishFileMessage +import com.pubnub.api.java.endpoints.files.SendFile +import com.pubnub.api.java.endpoints.message_actions.AddMessageAction +import com.pubnub.api.java.endpoints.message_actions.GetMessageActions +import com.pubnub.api.java.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.java.endpoints.objects_api.channel.GetAllChannelsMetadata +import com.pubnub.api.java.endpoints.objects_api.channel.GetChannelMetadata +import com.pubnub.api.java.endpoints.objects_api.channel.RemoveChannelMetadata +import com.pubnub.api.java.endpoints.objects_api.channel.SetChannelMetadata +import com.pubnub.api.java.endpoints.objects_api.members.GetChannelMembers +import com.pubnub.api.java.endpoints.objects_api.members.ManageChannelMembers +import com.pubnub.api.java.endpoints.objects_api.members.RemoveChannelMembers +import com.pubnub.api.java.endpoints.objects_api.members.SetChannelMembers +import com.pubnub.api.java.endpoints.objects_api.memberships.GetMemberships +import com.pubnub.api.java.endpoints.objects_api.memberships.ManageMemberships +import com.pubnub.api.java.endpoints.objects_api.memberships.RemoveMemberships +import com.pubnub.api.java.endpoints.objects_api.memberships.SetMemberships +import com.pubnub.api.java.endpoints.objects_api.uuid.GetAllUUIDMetadata +import com.pubnub.api.java.endpoints.objects_api.uuid.GetUUIDMetadata +import com.pubnub.api.java.endpoints.objects_api.uuid.RemoveUUIDMetadata +import com.pubnub.api.java.endpoints.objects_api.uuid.SetUUIDMetadata +import com.pubnub.api.java.endpoints.presence.GetState +import com.pubnub.api.java.endpoints.presence.HereNow +import com.pubnub.api.java.endpoints.presence.SetState +import com.pubnub.api.java.endpoints.presence.WhereNow +import com.pubnub.api.java.endpoints.pubsub.Publish +import com.pubnub.api.java.endpoints.pubsub.Signal +import com.pubnub.api.java.endpoints.push.AddChannelsToPush +import com.pubnub.api.java.endpoints.push.ListPushProvisions +import com.pubnub.api.java.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.java.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.java.v2.PNConfiguration +import com.pubnub.api.java.v2.callbacks.EventEmitter +import com.pubnub.api.java.v2.callbacks.StatusEmitter +import com.pubnub.api.java.v2.endpoints.pubsub.PublishBuilder +import com.pubnub.api.java.v2.entities.Channel +import com.pubnub.api.java.v2.entities.ChannelGroup +import com.pubnub.api.java.v2.entities.ChannelMetadata +import com.pubnub.api.java.v2.entities.UserMetadata +import com.pubnub.api.java.v2.subscriptions.Subscription +import com.pubnub.api.java.v2.subscriptions.SubscriptionSet +import com.pubnub.api.models.consumer.access_manager.v3.PNToken import java.io.InputStream -interface PubNub : - BasePubNub< - EventListener, - Subscription, - Channel, - ChannelGroup, - ChannelMetadata, - UserMetadata, - SubscriptionSet, - StatusListener, - > { +interface PubNub : EventEmitter, StatusEmitter { + val timestamp: Int + val baseUrl: String + + /** + * The current version of the PubNub SDK. + */ + val version: String + /** * Get the configuration that was used to initialize this PubNub instance. * Modifying the values in this configuration is not advised, as it may lead * to undefined behavior. */ - val configuration: BasePNConfiguration + val configuration: com.pubnub.api.v2.PNConfiguration /** * Causes the client to create an open TCP socket to the PubNub Real-Time Network and begin listening for messages @@ -361,7 +360,7 @@ interface PubNub : * This limit applies only to the payload, and not to the URI or headers. * If you require a larger payload size, please [contact support](mailto:support@pubnub.com). */ - fun signal(message: Any, channel: String): SignalBuilder + fun signal(message: Any, channel: String): com.pubnub.api.endpoints.pubsub.Signal /** * Send a signal to all subscribers of a channel. @@ -378,7 +377,7 @@ interface PubNub : level = DeprecationLevel.WARNING, message = "Use signal(Object, String) instead", ) - fun signal(): com.pubnub.api.endpoints.pubsub.Signal + fun signal(): Signal /** * Lists all registered channel groups for the subscribe key. @@ -534,6 +533,13 @@ interface PubNub : fun reconnect() + /** + * Force the SDK to try and reach out PubNub. Monitor the results in [SubscribeCallback.status] + * + * @param timetoken optional timetoken to use for the subscriptions on reconnection. + */ + fun reconnect(timetoken: Long = 0L) + /** * Send a message to PubNub Functions Event Handlers. * @@ -580,15 +586,15 @@ interface PubNub : */ fun getSubscribedChannelGroups(): List - override fun channel(name: String): Channel + fun channel(name: String): Channel - override fun channelGroup(name: String): ChannelGroup + fun channelGroup(name: String): ChannelGroup - override fun channelMetadata(id: String): ChannelMetadata + fun channelMetadata(id: String): ChannelMetadata - override fun userMetadata(id: String): UserMetadata + fun userMetadata(id: String): UserMetadata - override fun subscriptionSetOf(subscriptions: Set): SubscriptionSet + fun subscriptionSetOf(subscriptions: Set): SubscriptionSet /** * Add a legacy listener for both client status and events. @@ -598,6 +604,32 @@ interface PubNub : */ fun addListener(listener: SubscribeCallback) + /** + * Perform Cryptographic decryption of an input string using cipher key provided by [PNConfiguration.cipherKey]. + * + * @param inputString String to be decrypted. + * + * @return String containing the decryption of `inputString` using `cipherKey`. + * @throws PubNubException throws exception in case of failed decryption. + */ + @Throws(PubNubException::class) + fun decrypt(inputString: String): String + + /** + * Perform Cryptographic decryption of an input string using a cipher key. + * + * @param inputString String to be decrypted. + * @param cipherKey cipher key to be used for decryption. Default is [PNConfiguration.cipherKey] + * + * @return String containing the decryption of `inputString` using `cipherKey`. + * @throws PubNubException throws exception in case of failed decryption. + */ + @Throws(PubNubException::class) + fun decrypt( + inputString: String, + cipherKey: String?, + ): String + /** * Perform Cryptographic decryption of an input stream using provided cipher key. * @@ -609,6 +641,36 @@ interface PubNub : @Throws(PubNubException::class) fun decryptInputStream(inputStream: InputStream): InputStream + /** + * Perform Cryptographic decryption of an input stream using provided cipher key. + * + * @param inputStream InputStream to be encrypted. + * @param cipherKey Cipher key to be used for decryption. + * + * @return InputStream containing the encryption of `inputStream` using `cipherKey`. + * @throws PubNubException Throws exception in case of failed decryption. + */ + @Throws(PubNubException::class) + fun decryptInputStream( + inputStream: InputStream, + cipherKey: String?, + ): InputStream + + /** + * Perform Cryptographic encryption of an input string and a cipher key. + * + * @param inputString String to be encrypted. + * @param cipherKey Cipher key to be used for encryption. Default is [PNConfiguration.cipherKey] + * + * @return String containing the encryption of `inputString` using `cipherKey`. + * @throws PubNubException Throws exception in case of failed encryption. + */ + @Throws(PubNubException::class) + fun encrypt( + inputString: String, + cipherKey: String?, + ): String + /** * Perform Cryptographic encryption of an input string and a cipher key. * @@ -632,6 +694,48 @@ interface PubNub : @Throws(PubNubException::class) fun encryptInputStream(inputStream: InputStream): InputStream + /** + * Perform Cryptographic encryption of an input stream using provided cipher key. + * + * @param inputStream InputStream to be encrypted. + * @param cipherKey Cipher key to be used for encryption. + * + * @return InputStream containing the encryption of `inputStream` using `cipherKey`. + * @throws PubNubException Throws exception in case of failed encryption. + */ + @Throws(PubNubException::class) + fun encryptInputStream( + inputStream: InputStream, + cipherKey: String?, + ): InputStream + + @Throws(PubNubException::class) + fun parseToken(token: String): PNToken + + fun setToken(token: String?) + + /** + * Cancel any subscribe and heartbeat loops or ongoing re-connections. + * + * Monitor the results in [SubscribeCallback.status] + */ + fun disconnect() + + /** + * Unsubscribe from all channels and all channel groups + */ + fun unsubscribeAll() + + /** + * Frees up threads eventually and allows for a clean exit. + */ + fun destroy() + + /** + * Same as [destroy] but immediately. + */ + fun forceDestroy() + companion object { /** * Initialize and return an instance of the PubNub client. @@ -639,10 +743,10 @@ interface PubNub : * @return the PubNub client */ @JvmStatic - fun create(configuration: BasePNConfiguration): PubNub { + fun create(configuration: PNConfiguration): PubNub { return Class.forName( - "com.pubnub.internal.PubNubImpl", - ).getConstructor(BasePNConfiguration::class.java).newInstance(configuration) as PubNub + "com.pubnub.internal.java.PubNubForJavaImpl", + ).getConstructor(PNConfiguration::class.java).newInstance(configuration) as PubNub } /** @@ -650,6 +754,6 @@ interface PubNub : * that connects to PubNub. */ @JvmStatic - fun generateUUID(): String = BasePubNubImpl.generateUUID() + fun generateUUID(): String = com.pubnub.api.PubNub.generateUUID() } } diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/PubNubRuntimeException.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/PubNubRuntimeException.java similarity index 95% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/PubNubRuntimeException.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/PubNubRuntimeException.java index 0cefc1255..e08695497 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/PubNubRuntimeException.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/PubNubRuntimeException.java @@ -1,6 +1,7 @@ -package com.pubnub.api; +package com.pubnub.api.java; import com.google.gson.JsonElement; +import com.pubnub.api.PubNubError; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/SpaceId.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/SpaceId.java similarity index 92% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/SpaceId.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/SpaceId.java index 83551fbb2..dc3dbcde4 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/SpaceId.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/SpaceId.java @@ -1,4 +1,4 @@ -package com.pubnub.api; +package com.pubnub.api.java; import kotlin.text.StringsKt; import lombok.Getter; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/PresenceBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/PresenceBuilder.java similarity index 86% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/PresenceBuilder.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/PresenceBuilder.java index 7590e9ca4..e9bf036f8 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/PresenceBuilder.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/PresenceBuilder.java @@ -1,6 +1,6 @@ -package com.pubnub.api.builder; +package com.pubnub.api.java.builder; -import com.pubnub.internal.PubNubCore; +import com.pubnub.api.PubNub; import lombok.AccessLevel; import lombok.Setter; import lombok.experimental.Accessors; @@ -14,7 +14,7 @@ public class PresenceBuilder extends PubSubBuilder { @Setter(AccessLevel.PUBLIC) private boolean connected; - public PresenceBuilder(PubNubCore pubnub) { + public PresenceBuilder(PubNub pubnub) { super(pubnub); } diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/PubNubErrorBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/PubNubErrorBuilder.java similarity index 99% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/PubNubErrorBuilder.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/PubNubErrorBuilder.java index ca251aba8..6ecc816d0 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/PubNubErrorBuilder.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/PubNubErrorBuilder.java @@ -1,4 +1,4 @@ -package com.pubnub.api.builder; +package com.pubnub.api.java.builder; import com.pubnub.api.PubNubError; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/PubSubBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/PubSubBuilder.java similarity index 86% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/PubSubBuilder.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/PubSubBuilder.java index 59de3e476..0b91bf31a 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/PubSubBuilder.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/PubSubBuilder.java @@ -1,7 +1,7 @@ -package com.pubnub.api.builder; +package com.pubnub.api.java.builder; -import com.pubnub.internal.PubNubCore; +import com.pubnub.api.PubNub; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; @@ -21,9 +21,9 @@ public abstract class PubSubBuilder { @Getter(AccessLevel.PROTECTED) @Setter(AccessLevel.PROTECTED) - private PubNubCore pubnub; + private PubNub pubnub; - public PubSubBuilder(PubNubCore pubnub) { + public PubSubBuilder(PubNub pubnub) { this.pubnub = pubnub; this.channelSubscriptions = new ArrayList<>(); this.channelGroupSubscriptions = new ArrayList<>(); diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/SubscribeBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/SubscribeBuilder.java similarity index 92% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/SubscribeBuilder.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/SubscribeBuilder.java index 7954d2224..b69c6bd9c 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/SubscribeBuilder.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/SubscribeBuilder.java @@ -1,6 +1,6 @@ -package com.pubnub.api.builder; +package com.pubnub.api.java.builder; -import com.pubnub.internal.PubNubCore; +import com.pubnub.api.PubNub; import lombok.AccessLevel; import lombok.Setter; import lombok.experimental.Accessors; @@ -23,7 +23,7 @@ public class SubscribeBuilder extends PubSubBuilder { @Setter(AccessLevel.NONE) private Long timetoken = 0L; - public SubscribeBuilder(PubNubCore pubnub) { + public SubscribeBuilder(PubNub pubnub) { super(pubnub); } diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/UnsubscribeBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/UnsubscribeBuilder.java similarity index 69% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/UnsubscribeBuilder.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/UnsubscribeBuilder.java index 4d05f8947..6340fb11b 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/UnsubscribeBuilder.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/UnsubscribeBuilder.java @@ -1,13 +1,13 @@ -package com.pubnub.api.builder; +package com.pubnub.api.java.builder; -import com.pubnub.internal.PubNubCore; +import com.pubnub.api.PubNub; import lombok.Getter; import lombok.Setter; @Getter @Setter public class UnsubscribeBuilder extends PubSubBuilder { - public UnsubscribeBuilder(PubNubCore pubnub) { + public UnsubscribeBuilder(PubNub pubnub) { super(pubnub); } diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/ChangeTemporaryUnavailableOperation.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/ChangeTemporaryUnavailableOperation.java similarity index 91% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/ChangeTemporaryUnavailableOperation.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/ChangeTemporaryUnavailableOperation.java index 67a7045b4..80ff24695 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/ChangeTemporaryUnavailableOperation.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/ChangeTemporaryUnavailableOperation.java @@ -1,4 +1,4 @@ -package com.pubnub.api.builder.dto; +package com.pubnub.api.java.builder.dto; import lombok.Builder; import lombok.Data; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/PresenceOperation.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/PresenceOperation.java similarity index 90% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/PresenceOperation.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/PresenceOperation.java index 788c979fd..f136b66db 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/PresenceOperation.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/PresenceOperation.java @@ -1,4 +1,4 @@ -package com.pubnub.api.builder.dto; +package com.pubnub.api.java.builder.dto; import lombok.Builder; import lombok.Data; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/PubSubOperation.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/PubSubOperation.java similarity index 95% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/PubSubOperation.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/PubSubOperation.java index 19ac04f2b..78518b1f1 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/PubSubOperation.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/PubSubOperation.java @@ -1,4 +1,4 @@ -package com.pubnub.api.builder.dto; +package com.pubnub.api.java.builder.dto; import lombok.Data; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/StateOperation.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/StateOperation.java similarity index 90% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/StateOperation.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/StateOperation.java index e2e1e948c..23e5fbf39 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/StateOperation.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/StateOperation.java @@ -1,4 +1,4 @@ -package com.pubnub.api.builder.dto; +package com.pubnub.api.java.builder.dto; import lombok.Builder; import lombok.Data; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/TimetokenAndRegionOperation.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/TimetokenAndRegionOperation.java similarity index 80% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/TimetokenAndRegionOperation.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/TimetokenAndRegionOperation.java index 0693431c3..ab9da5b08 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/TimetokenAndRegionOperation.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/TimetokenAndRegionOperation.java @@ -1,4 +1,4 @@ -package com.pubnub.api.builder.dto; +package com.pubnub.api.java.builder.dto; import lombok.Data; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/UnsubscribeOperation.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/UnsubscribeOperation.java similarity index 85% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/UnsubscribeOperation.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/UnsubscribeOperation.java index f29b23261..df9ff4460 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/builder/dto/UnsubscribeOperation.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/builder/dto/UnsubscribeOperation.java @@ -1,4 +1,4 @@ -package com.pubnub.api.builder.dto; +package com.pubnub.api.java.builder.dto; import lombok.Builder; import lombok.Data; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/callbacks/PNCallback.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/callbacks/PNCallback.java similarity index 91% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/callbacks/PNCallback.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/callbacks/PNCallback.java index 088f40207..101d1eb8c 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/callbacks/PNCallback.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/callbacks/PNCallback.java @@ -1,4 +1,4 @@ -package com.pubnub.api.callbacks; +package com.pubnub.api.java.callbacks; import com.pubnub.api.PubNubException; import com.pubnub.api.v2.callbacks.Result; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/callbacks/SubscribeCallback.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/callbacks/SubscribeCallback.kt new file mode 100644 index 000000000..8ffc3dd89 --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/callbacks/SubscribeCallback.kt @@ -0,0 +1,13 @@ +package com.pubnub.api.java.callbacks + +import com.pubnub.api.java.PubNub +import com.pubnub.api.java.v2.callbacks.EventListener +import com.pubnub.api.java.v2.callbacks.StatusListener +import com.pubnub.api.models.consumer.PNStatus + +abstract class SubscribeCallback : StatusListener, EventListener { + open class BaseSubscribeCallback : SubscribeCallback(), EventListener { + override fun status(pubnub: PubNub, pnStatus: PNStatus) { + } + } +} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/BuilderSteps.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/BuilderSteps.java similarity index 73% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/BuilderSteps.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/BuilderSteps.java index e3110c176..9cc3e025a 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/BuilderSteps.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/BuilderSteps.java @@ -1,4 +1,4 @@ -package com.pubnub.api.endpoints; +package com.pubnub.api.java.endpoints; public interface BuilderSteps { interface ChannelStep { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/DeleteMessages.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/DeleteMessages.java similarity index 88% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/DeleteMessages.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/DeleteMessages.java index 297eec06b..bce32f4ec 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/DeleteMessages.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/DeleteMessages.java @@ -1,4 +1,4 @@ -package com.pubnub.api.endpoints; +package com.pubnub.api.java.endpoints; import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/Endpoint.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/Endpoint.kt new file mode 100644 index 000000000..0500cc522 --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/Endpoint.kt @@ -0,0 +1,25 @@ +package com.pubnub.api.java.endpoints + +import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction +import com.pubnub.api.v2.PNConfiguration + +interface Endpoint : ExtendedRemoteAction { + /** + * Allows to override certain configuration options (see [com.pubnub.api.v2.PNConfigurationOverride.Builder]) for this request only. + * + * + * [com.pubnub.api.java.v2.PNConfigurationOverride.from] should be used to obtain a `PNConfigurationOverride.Builder`. + * Only options present in `PNConfigurationOverride.Builder` will be used for the override. + * + * + * Example: + *
+     * configOverride = PNConfigurationOverride.from(pubnub.configuration)
+     * configOverride.userId(UserId("example"))
+     * endpoint.overrideConfiguration(configOverride.build()).sync()
+     
* + * + * @return Returns the same instance for convenience, so [Endpoint.sync] or [Endpoint.async] can be called next. + */ + fun overrideConfiguration(configuration: PNConfiguration): Endpoint +} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/FetchMessages.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/FetchMessages.java similarity index 93% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/FetchMessages.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/FetchMessages.java index 00632253f..a577a20c4 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/FetchMessages.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/FetchMessages.java @@ -1,4 +1,4 @@ -package com.pubnub.api.endpoints; +package com.pubnub.api.java.endpoints; import com.pubnub.api.models.consumer.history.PNFetchMessagesResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/History.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/History.java similarity index 91% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/History.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/History.java index 0fde7f6fc..27ca180ce 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/History.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/History.java @@ -1,4 +1,4 @@ -package com.pubnub.api.endpoints; +package com.pubnub.api.java.endpoints; import com.pubnub.api.models.consumer.history.PNHistoryResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/MessageCounts.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/MessageCounts.java similarity index 87% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/MessageCounts.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/MessageCounts.java index db0d04465..d3220b59f 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/MessageCounts.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/MessageCounts.java @@ -1,4 +1,4 @@ -package com.pubnub.api.endpoints; +package com.pubnub.api.java.endpoints; import com.pubnub.api.models.consumer.history.PNMessageCountResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/Grant.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/Grant.java similarity index 75% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/Grant.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/Grant.java index 564de45b3..c24b1fb17 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/Grant.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/Grant.java @@ -1,7 +1,7 @@ -package com.pubnub.api.endpoints.access; +package com.pubnub.api.java.endpoints.access; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.models.consumer.access_manager.PNAccessManagerGrantResult; public interface Grant extends Endpoint { Grant read(boolean read); diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/GrantToken.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/GrantToken.java new file mode 100644 index 000000000..03a12630d --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/GrantToken.java @@ -0,0 +1,23 @@ +package com.pubnub.api.java.endpoints.access; + +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGrant; +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGroupGrant; +import com.pubnub.api.java.models.consumer.access_manager.v3.UUIDGrant; +import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult; + +import java.util.List; + +public interface GrantToken extends Endpoint { + GrantToken ttl(Integer ttl); + + GrantToken meta(Object meta); + + GrantToken authorizedUUID(String authorizedUUID); + + GrantToken channels(List channels); + + GrantToken channelGroups(List channelGroups); + + GrantToken uuids(List uuids); +} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/RevokeToken.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/RevokeToken.java similarity index 55% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/RevokeToken.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/RevokeToken.java index 7ff61634c..7fd729eda 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/RevokeToken.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/RevokeToken.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.access; +package com.pubnub.api.java.endpoints.access; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import kotlin.Unit; public interface RevokeToken extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/AbstractGrantTokenBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/AbstractGrantTokenBuilder.java similarity index 62% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/AbstractGrantTokenBuilder.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/AbstractGrantTokenBuilder.java index 2b1edcdd7..448eec18d 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/AbstractGrantTokenBuilder.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/AbstractGrantTokenBuilder.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.access.builder; +package com.pubnub.api.java.endpoints.access.builder; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult; public interface AbstractGrantTokenBuilder extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/GrantTokenBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/GrantTokenBuilder.java similarity index 61% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/GrantTokenBuilder.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/GrantTokenBuilder.java index 86cf3c5f8..4944ddc2c 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/GrantTokenBuilder.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/GrantTokenBuilder.java @@ -1,13 +1,13 @@ -package com.pubnub.api.endpoints.access.builder; +package com.pubnub.api.java.endpoints.access.builder; import com.pubnub.api.UserId; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions; -import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions; -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant; -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.models.consumer.access_manager.sum.SpacePermissions; +import com.pubnub.api.java.models.consumer.access_manager.sum.UserPermissions; +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGrant; +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGroupGrant; import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult; -import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant; +import com.pubnub.api.java.models.consumer.access_manager.v3.UUIDGrant; import java.util.List; @@ -15,7 +15,7 @@ public interface GrantTokenBuilder extends Endpoint { /** * @param ttl * @return instance of this builder - * @deprecated Use {@link com.pubnub.api.PubNub#grantToken(Integer)} instead. + * @deprecated Use {@link com.pubnub.api.java.PubNub#grantToken(int)} instead. */ @Deprecated GrantTokenBuilder ttl(Integer ttl); diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/GrantTokenEntitiesBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/GrantTokenEntitiesBuilder.java similarity index 66% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/GrantTokenEntitiesBuilder.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/GrantTokenEntitiesBuilder.java index 4d05fc5dd..d5b539df5 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/GrantTokenEntitiesBuilder.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/GrantTokenEntitiesBuilder.java @@ -1,9 +1,9 @@ -package com.pubnub.api.endpoints.access.builder; +package com.pubnub.api.java.endpoints.access.builder; import com.pubnub.api.UserId; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions; -import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.models.consumer.access_manager.sum.SpacePermissions; +import com.pubnub.api.java.models.consumer.access_manager.sum.UserPermissions; import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult; import java.util.List; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/GrantTokenObjectsBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/GrantTokenObjectsBuilder.java similarity index 60% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/GrantTokenObjectsBuilder.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/GrantTokenObjectsBuilder.java index 841ce4f67..0812f2901 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/access/builder/GrantTokenObjectsBuilder.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/access/builder/GrantTokenObjectsBuilder.java @@ -1,10 +1,10 @@ -package com.pubnub.api.endpoints.access.builder; +package com.pubnub.api.java.endpoints.access.builder; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant; -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGrant; +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGroupGrant; import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult; -import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant; +import com.pubnub.api.java.models.consumer.access_manager.v3.UUIDGrant; import java.util.List; @@ -13,7 +13,7 @@ public interface GrantTokenObjectsBuilder extends Endpoint { /** * @param ttl * @return instance of this builder - * @deprecated Use {@link com.pubnub.api.PubNub#grantToken(int)}} instead. + * @deprecated Use {@link com.pubnub.api.java.PubNub#grantToken(int)}} instead. */ GrantTokenObjectsBuilder ttl(Integer ttl); diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/AddChannelChannelGroup.java similarity index 75% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/AddChannelChannelGroup.java index 381262b9c..8cbd5619c 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/AddChannelChannelGroup.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/AddChannelChannelGroup.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.channel_groups; +package com.pubnub.api.java.endpoints.channel_groups; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult; public interface AddChannelChannelGroup extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/AllChannelsChannelGroup.java similarity index 70% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/AllChannelsChannelGroup.java index e9a7718fb..c5b4532db 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/AllChannelsChannelGroup.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/AllChannelsChannelGroup.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.channel_groups; +package com.pubnub.api.java.endpoints.channel_groups; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult; public interface AllChannelsChannelGroup extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/DeleteChannelGroup.java similarity index 70% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/DeleteChannelGroup.java index 988a7c24b..aa457d103 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/DeleteChannelGroup.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/DeleteChannelGroup.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.channel_groups; +package com.pubnub.api.java.endpoints.channel_groups; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult; public interface DeleteChannelGroup extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/RemoveChannelChannelGroup.java similarity index 76% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/RemoveChannelChannelGroup.java index bca1fbc09..9186cab4a 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/channel_groups/RemoveChannelChannelGroup.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/channel_groups/RemoveChannelChannelGroup.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.channel_groups; +package com.pubnub.api.java.endpoints.channel_groups; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult; public interface RemoveChannelChannelGroup extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/DeleteFile.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/DeleteFile.java similarity index 54% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/DeleteFile.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/DeleteFile.java index ff7d02ed3..b54785f40 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/DeleteFile.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/DeleteFile.java @@ -1,8 +1,8 @@ -package com.pubnub.api.endpoints.files; +package com.pubnub.api.java.endpoints.files; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps; import com.pubnub.api.models.consumer.files.PNDeleteFileResult; public interface DeleteFile extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/DownloadFile.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/DownloadFile.java similarity index 59% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/DownloadFile.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/DownloadFile.java index bd871ea23..717b03e3f 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/DownloadFile.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/DownloadFile.java @@ -1,8 +1,8 @@ -package com.pubnub.api.endpoints.files; +package com.pubnub.api.java.endpoints.files; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps; import com.pubnub.api.models.consumer.files.PNDownloadFileResult; public interface DownloadFile extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/GetFileUrl.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/GetFileUrl.java similarity index 54% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/GetFileUrl.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/GetFileUrl.java index 510d3a1c4..a31933ca0 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/GetFileUrl.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/GetFileUrl.java @@ -1,8 +1,8 @@ -package com.pubnub.api.endpoints.files; +package com.pubnub.api.java.endpoints.files; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps; import com.pubnub.api.models.consumer.files.PNFileUrlResult; public interface GetFileUrl extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/ListFiles.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/ListFiles.java similarity index 69% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/ListFiles.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/ListFiles.java index c02cb1593..17f820028 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/ListFiles.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/ListFiles.java @@ -1,7 +1,7 @@ -package com.pubnub.api.endpoints.files; +package com.pubnub.api.java.endpoints.files; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.files.PNListFilesResult; public interface ListFiles extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/PublishFileMessage.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/PublishFileMessage.java similarity index 68% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/PublishFileMessage.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/PublishFileMessage.java index 49e5a5b65..2cb4e8852 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/PublishFileMessage.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/PublishFileMessage.java @@ -1,8 +1,8 @@ -package com.pubnub.api.endpoints.files; +package com.pubnub.api.java.endpoints.files; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps; import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult; public interface PublishFileMessage extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/SendFile.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/SendFile.java similarity index 75% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/SendFile.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/SendFile.java index 6219fbca2..3c8cb048a 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/SendFile.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/SendFile.java @@ -1,8 +1,8 @@ -package com.pubnub.api.endpoints.files; +package com.pubnub.api.java.endpoints.files; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps; import com.pubnub.api.models.consumer.files.PNFileUploadResult; public interface SendFile extends ExtendedRemoteAction { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/requiredparambuilder/FilesBuilderSteps.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/requiredparambuilder/FilesBuilderSteps.java similarity index 76% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/requiredparambuilder/FilesBuilderSteps.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/requiredparambuilder/FilesBuilderSteps.java index f8fcb8cbd..a7406383e 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/files/requiredparambuilder/FilesBuilderSteps.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/files/requiredparambuilder/FilesBuilderSteps.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.files.requiredparambuilder; +package com.pubnub.api.java.endpoints.files.requiredparambuilder; -import com.pubnub.api.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.BuilderSteps; import java.io.IOException; import java.io.InputStream; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/message_actions/AddMessageAction.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/message_actions/AddMessageAction.java similarity index 77% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/message_actions/AddMessageAction.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/message_actions/AddMessageAction.java index e7bb83948..103675547 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/message_actions/AddMessageAction.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/message_actions/AddMessageAction.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.message_actions; +package com.pubnub.api.java.endpoints.message_actions; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult; import com.pubnub.api.models.consumer.message_actions.PNMessageAction; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/message_actions/GetMessageActions.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/message_actions/GetMessageActions.java similarity index 76% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/message_actions/GetMessageActions.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/message_actions/GetMessageActions.java index 2c603a36c..b757ea8d5 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/message_actions/GetMessageActions.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/message_actions/GetMessageActions.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.message_actions; +package com.pubnub.api.java.endpoints.message_actions; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult; public interface GetMessageActions extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/message_actions/RemoveMessageAction.java similarity index 77% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/message_actions/RemoveMessageAction.java index 113d2f0e6..a2c085ba2 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/message_actions/RemoveMessageAction.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/message_actions/RemoveMessageAction.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.message_actions; +package com.pubnub.api.java.endpoints.message_actions; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult; public interface RemoveMessageAction extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/GetAllChannelsMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/GetAllChannelsMetadata.java similarity index 57% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/GetAllChannelsMetadata.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/GetAllChannelsMetadata.java index b4df9aebe..1622a9b59 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/GetAllChannelsMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/GetAllChannelsMetadata.java @@ -1,7 +1,8 @@ -package com.pubnub.api.endpoints.objects_api.channel; +package com.pubnub.api.java.endpoints.objects_api.channel; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.objects_api.channel.PNGetAllChannelsMetadataResult; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNGetAllChannelsMetadataResult; import java.util.Collection; @@ -12,7 +13,7 @@ public interface GetAllChannelsMetadata extends Endpoint sort); + GetAllChannelsMetadata sort(Collection sort); GetAllChannelsMetadata includeTotalCount(boolean includeTotalCount); diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/GetChannelMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/GetChannelMetadata.java similarity index 54% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/GetChannelMetadata.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/GetChannelMetadata.java index d492a7c0d..e0479fca4 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/GetChannelMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/GetChannelMetadata.java @@ -1,8 +1,8 @@ -package com.pubnub.api.endpoints.objects_api.channel; +package com.pubnub.api.java.endpoints.objects_api.channel; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.objects_api.channel.PNGetChannelMetadataResult; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNGetChannelMetadataResult; public interface GetChannelMetadata extends Endpoint { GetChannelMetadata includeCustom(boolean includeCustom); diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/RemoveChannelMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/RemoveChannelMetadata.java similarity index 50% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/RemoveChannelMetadata.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/RemoveChannelMetadata.java index b64b17b52..e13477eef 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/RemoveChannelMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/RemoveChannelMetadata.java @@ -1,8 +1,8 @@ -package com.pubnub.api.endpoints.objects_api.channel; +package com.pubnub.api.java.endpoints.objects_api.channel; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.objects_api.channel.PNRemoveChannelMetadataResult; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNRemoveChannelMetadataResult; public interface RemoveChannelMetadata extends Endpoint { interface Builder extends BuilderSteps.ChannelStep { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/SetChannelMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/SetChannelMetadata.java similarity index 69% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/SetChannelMetadata.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/SetChannelMetadata.java index 62c187861..22ebe63fe 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/channel/SetChannelMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/channel/SetChannelMetadata.java @@ -1,8 +1,8 @@ -package com.pubnub.api.endpoints.objects_api.channel; +package com.pubnub.api.java.endpoints.objects_api.channel; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.objects_api.channel.PNSetChannelMetadataResult; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNSetChannelMetadataResult; import java.util.Map; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/GetChannelMembers.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/GetChannelMembers.java similarity index 51% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/GetChannelMembers.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/GetChannelMembers.java index 1790546b5..d1709cdd0 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/GetChannelMembers.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/GetChannelMembers.java @@ -1,8 +1,10 @@ -package com.pubnub.api.endpoints.objects_api.members; +package com.pubnub.api.java.endpoints.objects_api.members; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.objects_api.member.PNGetChannelMembersResult; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.member.PNGetChannelMembersResult; public interface GetChannelMembers extends Endpoint { GetChannelMembers limit(Integer limit); @@ -11,13 +13,13 @@ public interface GetChannelMembers extends Endpoint { GetChannelMembers filter(String filter); - GetChannelMembers sort(java.util.Collection sort); + GetChannelMembers sort(java.util.Collection sort); GetChannelMembers includeTotalCount(boolean includeTotalCount); GetChannelMembers includeCustom(boolean includeCustom); - GetChannelMembers includeUUID(com.pubnub.api.endpoints.objects_api.utils.Include.PNUUIDDetailsLevel includeUUID); + GetChannelMembers includeUUID(Include.PNUUIDDetailsLevel includeUUID); interface Builder extends BuilderSteps.ChannelStep { @Override diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/ManageChannelMembers.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/ManageChannelMembers.java similarity index 53% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/ManageChannelMembers.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/ManageChannelMembers.java index 571100fa2..d1ba01434 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/ManageChannelMembers.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/ManageChannelMembers.java @@ -1,9 +1,11 @@ -package com.pubnub.api.endpoints.objects_api.members; +package com.pubnub.api.java.endpoints.objects_api.members; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps; -import com.pubnub.api.models.consumer.objects_api.member.PNManageChannelMembersResult; -import com.pubnub.api.models.consumer.objects_api.member.PNUUID; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.member.PNManageChannelMembersResult; +import com.pubnub.api.java.models.consumer.objects_api.member.PNUUID; import java.util.Collection; @@ -14,13 +16,13 @@ public interface ManageChannelMembers extends Endpoint sort); + ManageChannelMembers sort(Collection sort); ManageChannelMembers includeTotalCount(boolean includeTotalCount); ManageChannelMembers includeCustom(boolean includeCustom); - ManageChannelMembers includeUUID(com.pubnub.api.endpoints.objects_api.utils.Include.PNUUIDDetailsLevel includeUUID); + ManageChannelMembers includeUUID(Include.PNUUIDDetailsLevel includeUUID); interface Builder extends ObjectsBuilderSteps.ChannelStep> { @Override diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/RemoveChannelMembers.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/RemoveChannelMembers.java similarity index 52% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/RemoveChannelMembers.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/RemoveChannelMembers.java index 3169c66a6..a8b7e6eb9 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/RemoveChannelMembers.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/RemoveChannelMembers.java @@ -1,9 +1,11 @@ -package com.pubnub.api.endpoints.objects_api.members; +package com.pubnub.api.java.endpoints.objects_api.members; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps; -import com.pubnub.api.models.consumer.objects_api.member.PNRemoveChannelMembersResult; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.member.PNRemoveChannelMembersResult; import java.util.Collection; @@ -15,13 +17,13 @@ public interface RemoveChannelMembers extends Endpoint sort); + RemoveChannelMembers sort(Collection sort); RemoveChannelMembers includeTotalCount(boolean includeTotalCount); RemoveChannelMembers includeCustom(boolean includeCustom); - RemoveChannelMembers includeUUID(com.pubnub.api.endpoints.objects_api.utils.Include.PNUUIDDetailsLevel includeUUID); + RemoveChannelMembers includeUUID(Include.PNUUIDDetailsLevel includeUUID); interface Builder extends BuilderSteps.ChannelStep> { @Override diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/SetChannelMembers.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/SetChannelMembers.java similarity index 52% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/SetChannelMembers.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/SetChannelMembers.java index 06b63f099..0d6d8457a 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/members/SetChannelMembers.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/members/SetChannelMembers.java @@ -1,9 +1,11 @@ -package com.pubnub.api.endpoints.objects_api.members; +package com.pubnub.api.java.endpoints.objects_api.members; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps; -import com.pubnub.api.models.consumer.objects_api.member.PNSetChannelMembersResult; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.member.PNSetChannelMembersResult; import java.util.Collection; @@ -15,13 +17,13 @@ public interface SetChannelMembers extends Endpoint { SetChannelMembers filter(String filter); - SetChannelMembers sort(Collection sort); + SetChannelMembers sort(Collection sort); SetChannelMembers includeTotalCount(boolean includeTotalCount); SetChannelMembers includeCustom(boolean includeCustom); - SetChannelMembers includeUUID(com.pubnub.api.endpoints.objects_api.utils.Include.PNUUIDDetailsLevel includeUUID); + SetChannelMembers includeUUID(Include.PNUUIDDetailsLevel includeUUID); interface Builder extends BuilderSteps.ChannelStep> { @Override diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/GetMemberships.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/GetMemberships.java new file mode 100644 index 000000000..b6c705794 --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/GetMemberships.java @@ -0,0 +1,24 @@ +package com.pubnub.api.java.endpoints.objects_api.memberships; + +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNGetMembershipsResult; + +public interface GetMemberships extends Endpoint { + GetMemberships uuid(String uuid); + + GetMemberships limit(Integer limit); + + GetMemberships page(com.pubnub.api.models.consumer.objects.PNPage page); + + GetMemberships filter(String filter); + + GetMemberships sort(java.util.Collection sort); + + GetMemberships includeTotalCount(boolean includeTotalCount); + + GetMemberships includeCustom(boolean includeCustom); + + GetMemberships includeChannel(Include.PNChannelDetailsLevel includeChannel); +} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/ManageMemberships.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/ManageMemberships.java similarity index 50% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/ManageMemberships.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/ManageMemberships.java index d4fca915b..7c934331e 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/ManageMemberships.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/ManageMemberships.java @@ -1,17 +1,19 @@ -package com.pubnub.api.endpoints.objects_api.memberships; +package com.pubnub.api.java.endpoints.objects_api.memberships; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps; -import com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNManageMembershipResult; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNManageMembershipResult; import java.util.Collection; public interface ManageMemberships extends Endpoint { - ManageMemberships set(java.util.Collection set); + ManageMemberships set(Collection set); - ManageMemberships remove(java.util.Collection remove); + ManageMemberships remove(Collection remove); ManageMemberships uuid(String uuid); @@ -21,13 +23,13 @@ public interface ManageMemberships extends Endpoint { ManageMemberships filter(String filter); - ManageMemberships sort(java.util.Collection sort); + ManageMemberships sort(Collection sort); ManageMemberships includeTotalCount(boolean includeTotalCount); ManageMemberships includeCustom(boolean includeCustom); - ManageMemberships includeChannel(com.pubnub.api.endpoints.objects_api.utils.Include.PNChannelDetailsLevel includeChannel); + ManageMemberships includeChannel(Include.PNChannelDetailsLevel includeChannel); interface Builder extends ObjectsBuilderSteps.RemoveOrSetStep { @Override diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/RemoveMemberships.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/RemoveMemberships.java similarity index 53% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/RemoveMemberships.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/RemoveMemberships.java index 3d5a0c8ca..a87341614 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/RemoveMemberships.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/RemoveMemberships.java @@ -1,9 +1,11 @@ -package com.pubnub.api.endpoints.objects_api.memberships; - -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps; -import com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNRemoveMembershipResult; +package com.pubnub.api.java.endpoints.objects_api.memberships; + +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNRemoveMembershipResult; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -18,13 +20,13 @@ public interface RemoveMemberships extends Endpoint { RemoveMemberships filter(String filter); - RemoveMemberships sort(java.util.Collection sort); + RemoveMemberships sort(Collection sort); RemoveMemberships includeTotalCount(boolean includeTotalCount); RemoveMemberships includeCustom(boolean includeCustom); - RemoveMemberships includeChannel(com.pubnub.api.endpoints.objects_api.utils.Include.PNChannelDetailsLevel includeChannel); + RemoveMemberships includeChannel(Include.PNChannelDetailsLevel includeChannel); interface Builder extends ObjectsBuilderSteps.ChannelMembershipsStep { @Override diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/SetMemberships.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/SetMemberships.java similarity index 52% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/SetMemberships.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/SetMemberships.java index 8a8f8e998..a5b9c4442 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/memberships/SetMemberships.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/memberships/SetMemberships.java @@ -1,8 +1,10 @@ -package com.pubnub.api.endpoints.objects_api.memberships; +package com.pubnub.api.java.endpoints.objects_api.memberships; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNSetMembershipResult; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNSetMembershipResult; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -16,13 +18,13 @@ public interface SetMemberships extends Endpoint { SetMemberships filter(String filter); - SetMemberships sort(java.util.Collection sort); + SetMemberships sort(Collection sort); SetMemberships includeTotalCount(boolean includeTotalCount); SetMemberships includeCustom(boolean includeCustom); - SetMemberships includeChannel(com.pubnub.api.endpoints.objects_api.utils.Include.PNChannelDetailsLevel includeChannel); + SetMemberships includeChannel(Include.PNChannelDetailsLevel includeChannel); interface Builder { SetMemberships channelMemberships(@NotNull Collection channelMemberships); diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/utils/Include.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/utils/Include.java similarity index 94% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/utils/Include.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/utils/Include.java index d5d4a3437..7711cf43a 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/utils/Include.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/utils/Include.java @@ -1,4 +1,4 @@ -package com.pubnub.api.endpoints.objects_api.utils; +package com.pubnub.api.java.endpoints.objects_api.utils; public class Include { static final String INCLUDE_CHANNEL_PARAM_VALUE = "channel"; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/utils/ObjectsBuilderSteps.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/utils/ObjectsBuilderSteps.java similarity index 73% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/utils/ObjectsBuilderSteps.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/utils/ObjectsBuilderSteps.java index 1f794f88b..eb44307fe 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/utils/ObjectsBuilderSteps.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/utils/ObjectsBuilderSteps.java @@ -1,8 +1,8 @@ -package com.pubnub.api.endpoints.objects_api.utils; +package com.pubnub.api.java.endpoints.objects_api.utils; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.models.consumer.objects_api.member.PNUUID; -import com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.models.consumer.objects_api.member.PNUUID; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership; import org.jetbrains.annotations.NotNull; import java.util.Collection; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/utils/PNSortKey.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/utils/PNSortKey.java similarity index 84% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/utils/PNSortKey.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/utils/PNSortKey.java index e2ec76daf..28d751013 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/utils/PNSortKey.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/utils/PNSortKey.java @@ -1,10 +1,10 @@ -package com.pubnub.api.endpoints.objects_api.utils; +package com.pubnub.api.java.endpoints.objects_api.utils; import lombok.AccessLevel; import lombok.Getter; -import static com.pubnub.api.endpoints.objects_api.utils.PNSortKey.Dir.ASC; -import static com.pubnub.api.endpoints.objects_api.utils.PNSortKey.Dir.DESC; +import static com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey.Dir.ASC; +import static com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey.Dir.DESC; public final class PNSortKey { public enum Dir { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/GetAllUUIDMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/GetAllUUIDMetadata.java similarity index 54% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/GetAllUUIDMetadata.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/GetAllUUIDMetadata.java index 37b246879..e9415f462 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/GetAllUUIDMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/GetAllUUIDMetadata.java @@ -1,7 +1,8 @@ -package com.pubnub.api.endpoints.objects_api.uuid; +package com.pubnub.api.java.endpoints.objects_api.uuid; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.objects_api.uuid.PNGetAllUUIDMetadataResult; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNGetAllUUIDMetadataResult; public interface GetAllUUIDMetadata extends Endpoint { GetAllUUIDMetadata includeCustom(boolean includeCustom); @@ -14,5 +15,5 @@ public interface GetAllUUIDMetadata extends Endpoint GetAllUUIDMetadata filter(String filter); - GetAllUUIDMetadata sort(java.util.Collection sort); + GetAllUUIDMetadata sort(java.util.Collection sort); } diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/GetUUIDMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/GetUUIDMetadata.java new file mode 100644 index 000000000..f607e392f --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/GetUUIDMetadata.java @@ -0,0 +1,10 @@ +package com.pubnub.api.java.endpoints.objects_api.uuid; + +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNGetUUIDMetadataResult; + +public interface GetUUIDMetadata extends Endpoint { + GetUUIDMetadata uuid(String uuid); + + GetUUIDMetadata includeCustom(boolean includeCustom); +} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/RemoveUUIDMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/RemoveUUIDMetadata.java new file mode 100644 index 000000000..f9f884934 --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/RemoveUUIDMetadata.java @@ -0,0 +1,8 @@ +package com.pubnub.api.java.endpoints.objects_api.uuid; + +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNRemoveUUIDMetadataResult; + +public interface RemoveUUIDMetadata extends Endpoint { + RemoveUUIDMetadata uuid(String uuid); +} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/SetUUIDMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/SetUUIDMetadata.java similarity index 73% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/SetUUIDMetadata.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/SetUUIDMetadata.java index d5b8841c1..7e4520ef1 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/objects_api/uuid/SetUUIDMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/objects_api/uuid/SetUUIDMetadata.java @@ -1,7 +1,7 @@ -package com.pubnub.api.endpoints.objects_api.uuid; +package com.pubnub.api.java.endpoints.objects_api.uuid; -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.objects_api.uuid.PNSetUUIDMetadataResult; +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNSetUUIDMetadataResult; import java.util.Map; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/GetState.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/GetState.java similarity index 75% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/GetState.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/GetState.java index c32a2b778..39679938f 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/GetState.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/GetState.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.presence; +package com.pubnub.api.java.endpoints.presence; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.presence.PNGetStateResult; public interface GetState extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/Heartbeat.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/Heartbeat.java similarity index 69% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/Heartbeat.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/Heartbeat.java index 63812d7a6..a377c96ad 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/Heartbeat.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/Heartbeat.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.presence; +package com.pubnub.api.java.endpoints.presence; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; public interface Heartbeat extends Endpoint { Heartbeat channels(java.util.List channels); diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/HereNow.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/HereNow.java similarity index 78% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/HereNow.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/HereNow.java index 385921019..b44f67387 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/HereNow.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/HereNow.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.presence; +package com.pubnub.api.java.endpoints.presence; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.presence.PNHereNowResult; public interface HereNow extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/Leave.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/Leave.java similarity index 64% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/Leave.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/Leave.java index 6b1897e0f..4c2a8538b 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/Leave.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/Leave.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.presence; +package com.pubnub.api.java.endpoints.presence; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; public interface Leave extends Endpoint { Leave channels(java.util.List channels); diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/SetState.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/SetState.java similarity index 79% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/SetState.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/SetState.java index 4019da73a..bed6bd7db 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/presence/SetState.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/SetState.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.presence; +package com.pubnub.api.java.endpoints.presence; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.presence.PNSetStateResult; public interface SetState extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/WhereNow.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/WhereNow.java new file mode 100644 index 000000000..645bb45e4 --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/presence/WhereNow.java @@ -0,0 +1,8 @@ +package com.pubnub.api.java.endpoints.presence; + +import com.pubnub.api.java.endpoints.Endpoint; +import com.pubnub.api.models.consumer.presence.PNWhereNowResult; + +public interface WhereNow extends Endpoint { + WhereNow uuid(String uuid); +} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/pubsub/Publish.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/pubsub/Publish.java similarity index 80% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/pubsub/Publish.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/pubsub/Publish.java index 66148b2b3..cbd0fafec 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/pubsub/Publish.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/pubsub/Publish.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.pubsub; +package com.pubnub.api.java.endpoints.pubsub; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.PNPublishResult; public interface Publish extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/pubsub/Signal.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/pubsub/Signal.java similarity index 67% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/pubsub/Signal.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/pubsub/Signal.java index 17d210cba..3f45e3af0 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/pubsub/Signal.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/pubsub/Signal.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.pubsub; +package com.pubnub.api.java.endpoints.pubsub; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.PNPublishResult; public interface Signal extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/AddChannelsToPush.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/AddChannelsToPush.java similarity index 83% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/AddChannelsToPush.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/AddChannelsToPush.java index 032ba71f0..34348aa45 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/AddChannelsToPush.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/AddChannelsToPush.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.push; +package com.pubnub.api.java.endpoints.push; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.push.PNPushAddChannelResult; public interface AddChannelsToPush extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/ListPushProvisions.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/ListPushProvisions.java similarity index 82% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/ListPushProvisions.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/ListPushProvisions.java index ae0d43ff8..85ca3e001 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/ListPushProvisions.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/ListPushProvisions.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.push; +package com.pubnub.api.java.endpoints.push; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult; public interface ListPushProvisions extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/RemoveAllPushChannelsForDevice.java similarity index 84% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/RemoveAllPushChannelsForDevice.java index 4a6a622eb..c12135616 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/RemoveAllPushChannelsForDevice.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.push; +package com.pubnub.api.java.endpoints.push; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult; public interface RemoveAllPushChannelsForDevice extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/RemoveChannelsFromPush.java similarity index 84% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/RemoveChannelsFromPush.java index 5604cd30a..3e86860de 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/endpoints/push/RemoveChannelsFromPush.java @@ -1,6 +1,6 @@ -package com.pubnub.api.endpoints.push; +package com.pubnub.api.java.endpoints.push; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult; public interface RemoveChannelsFromPush extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/PNAccessManagerGrantResult.java similarity index 68% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/PNAccessManagerGrantResult.java index b67a021c8..a9ab93397 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/PNAccessManagerGrantResult.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.access_manager; +package com.pubnub.api.java.models.consumer.access_manager; import lombok.Builder; import lombok.Data; @@ -24,7 +24,7 @@ public class PNAccessManagerGrantResult { private Map> uuids; - public static PNAccessManagerGrantResult from(com.pubnub.internal.models.consumer.access_manager.PNAccessManagerGrantResult data) { + public static PNAccessManagerGrantResult from(com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult data) { return PNAccessManagerGrantResult.builder() .level(data.getLevel()) @@ -36,11 +36,11 @@ public static PNAccessManagerGrantResult from(com.pubnub.internal.models.consume .build(); } - private static Map> from(Map> data) { + private static Map> from(Map> data) { Map> newMap = new HashMap<>(data.size()); - for (Map.Entry> stringMapEntry : data.entrySet()) { + for (Map.Entry> stringMapEntry : data.entrySet()) { Map innerMap = new HashMap<>(stringMapEntry.getValue().size()); - for (Map.Entry innerEntry : stringMapEntry.getValue().entrySet()) { + for (Map.Entry innerEntry : stringMapEntry.getValue().entrySet()) { innerMap.put(innerEntry.getKey(), PNAccessManagerKeyData.from(innerEntry.getValue())); } newMap.put(stringMapEntry.getKey(), innerMap); diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerKeyData.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/PNAccessManagerKeyData.java similarity index 85% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerKeyData.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/PNAccessManagerKeyData.java index 9d1ff8678..8d889cbd1 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerKeyData.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/PNAccessManagerKeyData.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.access_manager; +package com.pubnub.api.java.models.consumer.access_manager; import com.google.gson.annotations.SerializedName; import lombok.Builder; @@ -29,7 +29,7 @@ public class PNAccessManagerKeyData { @SerializedName("j") private boolean joinEnabled; - static PNAccessManagerKeyData from(com.pubnub.internal.models.consumer.access_manager.PNAccessManagerKeyData data) { + static PNAccessManagerKeyData from(com.pubnub.api.models.consumer.access_manager.PNAccessManagerKeyData data) { return PNAccessManagerKeyData.builder() .readEnabled(data.getReadEnabled()) .writeEnabled(data.getWriteEnabled()) diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerKeysData.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/PNAccessManagerKeysData.java similarity index 81% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerKeysData.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/PNAccessManagerKeysData.java index 8a2b9465e..5cea4cdfd 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/PNAccessManagerKeysData.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/PNAccessManagerKeysData.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.access_manager; +package com.pubnub.api.java.models.consumer.access_manager; import com.google.gson.annotations.SerializedName; import lombok.Getter; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/sum/SpacePermissions.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/sum/SpacePermissions.java similarity index 87% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/sum/SpacePermissions.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/sum/SpacePermissions.java index b9c16a66e..90afe626c 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/sum/SpacePermissions.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/sum/SpacePermissions.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.access_manager.sum; +package com.pubnub.api.java.models.consumer.access_manager.sum; -import com.pubnub.api.SpaceId; -import com.pubnub.api.models.consumer.access_manager.v3.PNResource; +import com.pubnub.api.java.SpaceId; +import com.pubnub.api.java.models.consumer.access_manager.v3.PNResource; public class SpacePermissions extends PNResource { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/sum/UserPermissions.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/sum/UserPermissions.java similarity index 86% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/sum/UserPermissions.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/sum/UserPermissions.java index 8b2bee413..0438448c2 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/sum/UserPermissions.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/sum/UserPermissions.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.access_manager.sum; +package com.pubnub.api.java.models.consumer.access_manager.sum; import com.pubnub.api.UserId; -import com.pubnub.api.models.consumer.access_manager.v3.PNResource; +import com.pubnub.api.java.models.consumer.access_manager.v3.PNResource; public class UserPermissions extends PNResource { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/ChannelGrant.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/ChannelGrant.java similarity index 94% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/ChannelGrant.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/ChannelGrant.java index 37f5b41fd..ada397f50 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/ChannelGrant.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/ChannelGrant.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.access_manager.v3; +package com.pubnub.api.java.models.consumer.access_manager.v3; public class ChannelGrant extends PNResource { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/ChannelGroupGrant.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/ChannelGroupGrant.java similarity index 92% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/ChannelGroupGrant.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/ChannelGroupGrant.java index edde89f27..bd8e78cfe 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/ChannelGroupGrant.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/ChannelGroupGrant.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.access_manager.v3; +package com.pubnub.api.java.models.consumer.access_manager.v3; public class ChannelGroupGrant extends PNResource { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/PNResource.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/PNResource.java similarity index 95% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/PNResource.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/PNResource.java index 9d9261722..3166a1d6d 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/PNResource.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/PNResource.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.access_manager.v3; +package com.pubnub.api.java.models.consumer.access_manager.v3; import lombok.AccessLevel; import lombok.Getter; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/PNRevokeTokenResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/PNRevokeTokenResult.java similarity index 50% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/PNRevokeTokenResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/PNRevokeTokenResult.java index 5eb636b39..d7f92e242 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/PNRevokeTokenResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/PNRevokeTokenResult.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.access_manager.v3; +package com.pubnub.api.java.models.consumer.access_manager.v3; import lombok.Data; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/UUIDGrant.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/UUIDGrant.java similarity index 91% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/UUIDGrant.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/UUIDGrant.java index c6055f1d9..04cd8d196 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/access_manager/v3/UUIDGrant.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/access_manager/v3/UUIDGrant.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.access_manager.v3; +package com.pubnub.api.java.models.consumer.access_manager.v3; public class UUIDGrant extends PNResource { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/EntityArrayEnvelope.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/EntityArrayEnvelope.java similarity index 89% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/EntityArrayEnvelope.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/EntityArrayEnvelope.java index 69ce2aadc..665f2af7c 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/EntityArrayEnvelope.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/EntityArrayEnvelope.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.objects_api; +package com.pubnub.api.java.models.consumer.objects_api; import com.pubnub.api.models.consumer.objects.PNPage; import lombok.Getter; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/EntityEnvelope.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/EntityEnvelope.java similarity index 69% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/EntityEnvelope.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/EntityEnvelope.java index fd93d6ca6..f2b459370 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/EntityEnvelope.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/EntityEnvelope.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.objects_api; +package com.pubnub.api.java.models.consumer.objects_api; import lombok.Getter; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/PNObject.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/PNObject.java similarity index 90% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/PNObject.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/PNObject.java index 9f6aa6a7f..3038a46a5 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/PNObject.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/PNObject.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.objects_api; +package com.pubnub.api.java.models.consumer.objects_api; import lombok.EqualsAndHashCode; import lombok.Getter; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNChannelMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNChannelMetadata.java similarity index 94% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNChannelMetadata.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNChannelMetadata.java index 84d7f77be..5b775dc36 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNChannelMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNChannelMetadata.java @@ -1,6 +1,6 @@ -package com.pubnub.api.models.consumer.objects_api.channel; +package com.pubnub.api.java.models.consumer.objects_api.channel; -import com.pubnub.api.models.consumer.objects_api.PNObject; +import com.pubnub.api.java.models.consumer.objects_api.PNObject; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNChannelMetadataResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNChannelMetadataResult.java similarity index 93% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNChannelMetadataResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNChannelMetadataResult.java index 3a9215be1..c4c730cef 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNChannelMetadataResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNChannelMetadataResult.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.objects_api.channel; +package com.pubnub.api.java.models.consumer.objects_api.channel; import com.google.gson.JsonElement; import com.pubnub.api.models.consumer.pubsub.PubSubResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNGetAllChannelsMetadataResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNGetAllChannelsMetadataResult.java similarity index 84% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNGetAllChannelsMetadataResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNGetAllChannelsMetadataResult.java index b42d9f8f6..1b2a1624a 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNGetAllChannelsMetadataResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNGetAllChannelsMetadataResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.channel; +package com.pubnub.api.java.models.consumer.objects_api.channel; -import com.pubnub.api.models.consumer.objects_api.EntityArrayEnvelope; -import com.pubnub.internal.models.consumer.objects.channel.PNChannelMetadataArrayResult; +import com.pubnub.api.java.models.consumer.objects_api.EntityArrayEnvelope; +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNGetChannelMetadataResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNGetChannelMetadataResult.java similarity index 71% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNGetChannelMetadataResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNGetChannelMetadataResult.java index bdb589687..aec499073 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNGetChannelMetadataResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNGetChannelMetadataResult.java @@ -1,6 +1,6 @@ -package com.pubnub.api.models.consumer.objects_api.channel; +package com.pubnub.api.java.models.consumer.objects_api.channel; -import com.pubnub.api.models.consumer.objects_api.EntityEnvelope; +import com.pubnub.api.java.models.consumer.objects_api.EntityEnvelope; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNRemoveChannelMetadataResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNRemoveChannelMetadataResult.java similarity index 75% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNRemoveChannelMetadataResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNRemoveChannelMetadataResult.java index 2323855f1..7772cdd22 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNRemoveChannelMetadataResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNRemoveChannelMetadataResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.channel; +package com.pubnub.api.java.models.consumer.objects_api.channel; import com.google.gson.JsonElement; -import com.pubnub.api.models.consumer.objects_api.EntityEnvelope; +import com.pubnub.api.java.models.consumer.objects_api.EntityEnvelope; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNSetChannelMetadataResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNSetChannelMetadataResult.java similarity index 71% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNSetChannelMetadataResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNSetChannelMetadataResult.java index 96debf136..cb700ced3 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/channel/PNSetChannelMetadataResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNSetChannelMetadataResult.java @@ -1,6 +1,6 @@ -package com.pubnub.api.models.consumer.objects_api.channel; +package com.pubnub.api.java.models.consumer.objects_api.channel; -import com.pubnub.api.models.consumer.objects_api.EntityEnvelope; +import com.pubnub.api.java.models.consumer.objects_api.EntityEnvelope; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNGetChannelMembersResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNGetChannelMembersResult.java similarity index 84% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNGetChannelMembersResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNGetChannelMembersResult.java index 1efee3539..a22e73250 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNGetChannelMembersResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNGetChannelMembersResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.member; +package com.pubnub.api.java.models.consumer.objects_api.member; -import com.pubnub.api.models.consumer.objects_api.EntityArrayEnvelope; -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult; +import com.pubnub.api.java.models.consumer.objects_api.EntityArrayEnvelope; +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNManageChannelMembersResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNManageChannelMembersResult.java similarity index 85% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNManageChannelMembersResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNManageChannelMembersResult.java index de490bbef..e4062619c 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNManageChannelMembersResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNManageChannelMembersResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.member; +package com.pubnub.api.java.models.consumer.objects_api.member; -import com.pubnub.api.models.consumer.objects_api.EntityArrayEnvelope; -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult; +import com.pubnub.api.java.models.consumer.objects_api.EntityArrayEnvelope; +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNMembers.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNMembers.java similarity index 86% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNMembers.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNMembers.java index 23403bb6a..c4c9bc2ef 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNMembers.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNMembers.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.member; +package com.pubnub.api.java.models.consumer.objects_api.member; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadata; -import com.pubnub.internal.models.consumer.objects.member.PNMember; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadata; +import com.pubnub.api.models.consumer.objects.member.PNMember; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNRemoveChannelMembersResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNRemoveChannelMembersResult.java similarity index 85% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNRemoveChannelMembersResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNRemoveChannelMembersResult.java index 6052cbd22..31bc80b11 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNRemoveChannelMembersResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNRemoveChannelMembersResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.member; +package com.pubnub.api.java.models.consumer.objects_api.member; -import com.pubnub.api.models.consumer.objects_api.EntityArrayEnvelope; -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult; +import com.pubnub.api.java.models.consumer.objects_api.EntityArrayEnvelope; +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNSetChannelMembersResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNSetChannelMembersResult.java similarity index 84% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNSetChannelMembersResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNSetChannelMembersResult.java index 2dda4fa57..18a68104c 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNSetChannelMembersResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNSetChannelMembersResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.member; +package com.pubnub.api.java.models.consumer.objects_api.member; -import com.pubnub.api.models.consumer.objects_api.EntityArrayEnvelope; -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult; +import com.pubnub.api.java.models.consumer.objects_api.EntityArrayEnvelope; +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.ToString; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNUUID.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNUUID.java similarity index 96% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNUUID.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNUUID.java index 680db20f1..e13bbf7ac 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/member/PNUUID.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNUUID.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.objects_api.member; +package com.pubnub.api.java.models.consumer.objects_api.member; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNChannelMembership.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNChannelMembership.java similarity index 95% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNChannelMembership.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNChannelMembership.java index 049ec5db4..14c52ae7d 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNChannelMembership.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNChannelMembership.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.objects_api.membership; +package com.pubnub.api.java.models.consumer.objects_api.membership; import lombok.AllArgsConstructor; import lombok.EqualsAndHashCode; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNGetMembershipsResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNGetMembershipsResult.java similarity index 84% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNGetMembershipsResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNGetMembershipsResult.java index 482ad7cb4..1639c1399 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNGetMembershipsResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNGetMembershipsResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.membership; +package com.pubnub.api.java.models.consumer.objects_api.membership; -import com.pubnub.api.models.consumer.objects_api.EntityArrayEnvelope; -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult; +import com.pubnub.api.java.models.consumer.objects_api.EntityArrayEnvelope; +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNManageMembershipResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNManageMembershipResult.java similarity index 85% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNManageMembershipResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNManageMembershipResult.java index 8ff7af681..966f4cd6f 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNManageMembershipResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNManageMembershipResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.membership; +package com.pubnub.api.java.models.consumer.objects_api.membership; -import com.pubnub.api.models.consumer.objects_api.EntityArrayEnvelope; -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult; +import com.pubnub.api.java.models.consumer.objects_api.EntityArrayEnvelope; +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembership.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNMembership.java similarity index 79% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembership.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNMembership.java index 0427f1a57..eb11e37df 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembership.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNMembership.java @@ -1,11 +1,11 @@ -package com.pubnub.api.models.consumer.objects_api.membership; +package com.pubnub.api.java.models.consumer.objects_api.membership; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadata; -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadata; +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership; import lombok.Data; import lombok.NonNull; -import lombok.RequiredArgsConstructor; import lombok.experimental.Accessors; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.ArrayList; @@ -14,8 +14,10 @@ @Data @Accessors(chain = true) -@RequiredArgsConstructor public class PNMembership { + public PNMembership(@NotNull PNChannelMetadata channel) { + this.channel = channel; + } @NonNull private PNChannelMetadata channel; private Object custom; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembershipResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNMembershipResult.java similarity index 93% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembershipResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNMembershipResult.java index 345b36329..357cbf67a 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNMembershipResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNMembershipResult.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.objects_api.membership; +package com.pubnub.api.java.models.consumer.objects_api.membership; import com.google.gson.JsonElement; import com.pubnub.api.models.consumer.pubsub.PubSubResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNRemoveMembershipResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNRemoveMembershipResult.java similarity index 82% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNRemoveMembershipResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNRemoveMembershipResult.java index 07e0ebcee..4ac51efc8 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNRemoveMembershipResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNRemoveMembershipResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.membership; +package com.pubnub.api.java.models.consumer.objects_api.membership; -import com.pubnub.api.models.consumer.objects_api.EntityArrayEnvelope; -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult; +import com.pubnub.api.java.models.consumer.objects_api.EntityArrayEnvelope; +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNSetMembershipResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNSetMembershipResult.java similarity index 85% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNSetMembershipResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNSetMembershipResult.java index 4bfb1c6ab..f444614aa 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/membership/PNSetMembershipResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNSetMembershipResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.membership; +package com.pubnub.api.java.models.consumer.objects_api.membership; -import com.pubnub.api.models.consumer.objects_api.EntityArrayEnvelope; -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult; +import com.pubnub.api.java.models.consumer.objects_api.EntityArrayEnvelope; +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNGetAllUUIDMetadataResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNGetAllUUIDMetadataResult.java similarity index 86% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNGetAllUUIDMetadataResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNGetAllUUIDMetadataResult.java index 160898a17..53a93efb5 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNGetAllUUIDMetadataResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNGetAllUUIDMetadataResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.uuid; +package com.pubnub.api.java.models.consumer.objects_api.uuid; -import com.pubnub.api.models.consumer.objects_api.EntityArrayEnvelope; -import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataArrayResult; +import com.pubnub.api.java.models.consumer.objects_api.EntityArrayEnvelope; +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNGetUUIDMetadataResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNGetUUIDMetadataResult.java similarity index 81% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNGetUUIDMetadataResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNGetUUIDMetadataResult.java index 812ebcd9c..8fac5b3ae 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNGetUUIDMetadataResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNGetUUIDMetadataResult.java @@ -1,6 +1,6 @@ -package com.pubnub.api.models.consumer.objects_api.uuid; +package com.pubnub.api.java.models.consumer.objects_api.uuid; -import com.pubnub.api.models.consumer.objects_api.EntityEnvelope; +import com.pubnub.api.java.models.consumer.objects_api.EntityEnvelope; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNRemoveUUIDMetadataResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNRemoveUUIDMetadataResult.java similarity index 81% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNRemoveUUIDMetadataResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNRemoveUUIDMetadataResult.java index 43be6ce1a..262f4bdb5 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNRemoveUUIDMetadataResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNRemoveUUIDMetadataResult.java @@ -1,7 +1,7 @@ -package com.pubnub.api.models.consumer.objects_api.uuid; +package com.pubnub.api.java.models.consumer.objects_api.uuid; import com.google.gson.JsonElement; -import com.pubnub.api.models.consumer.objects_api.EntityEnvelope; +import com.pubnub.api.java.models.consumer.objects_api.EntityEnvelope; import lombok.AccessLevel; import lombok.Getter; import lombok.Setter; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNSetUUIDMetadataResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNSetUUIDMetadataResult.java similarity index 81% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNSetUUIDMetadataResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNSetUUIDMetadataResult.java index daa979bcb..e7185a1a2 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNSetUUIDMetadataResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNSetUUIDMetadataResult.java @@ -1,6 +1,6 @@ -package com.pubnub.api.models.consumer.objects_api.uuid; +package com.pubnub.api.java.models.consumer.objects_api.uuid; -import com.pubnub.api.models.consumer.objects_api.EntityEnvelope; +import com.pubnub.api.java.models.consumer.objects_api.EntityEnvelope; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNUUIDMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNUUIDMetadata.java similarity index 94% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNUUIDMetadata.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNUUIDMetadata.java index 409eab008..cec764261 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNUUIDMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNUUIDMetadata.java @@ -1,6 +1,6 @@ -package com.pubnub.api.models.consumer.objects_api.uuid; +package com.pubnub.api.java.models.consumer.objects_api.uuid; -import com.pubnub.api.models.consumer.objects_api.PNObject; +import com.pubnub.api.java.models.consumer.objects_api.PNObject; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNUUIDMetadataResult.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNUUIDMetadataResult.java similarity index 93% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNUUIDMetadataResult.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNUUIDMetadataResult.java index ea8d4a552..b62781583 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/models/consumer/objects_api/uuid/PNUUIDMetadataResult.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNUUIDMetadataResult.java @@ -1,4 +1,4 @@ -package com.pubnub.api.models.consumer.objects_api.uuid; +package com.pubnub.api.java.models.consumer.objects_api.uuid; import com.google.gson.JsonElement; import com.pubnub.api.models.consumer.pubsub.PubSubResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/PNConfiguration.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/PNConfiguration.kt similarity index 54% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/PNConfiguration.kt rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/PNConfiguration.kt index 664b4bcfb..99b5a3c62 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/PNConfiguration.kt +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/PNConfiguration.kt @@ -1,12 +1,11 @@ -package com.pubnub.api.v2 +package com.pubnub.api.java.v2 import com.pubnub.api.UserId import com.pubnub.api.crypto.CryptoModule import com.pubnub.api.enums.PNHeartbeatNotificationOptions import com.pubnub.api.enums.PNLogVerbosity +import com.pubnub.api.java.v2.PNConfiguration.Builder import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.api.v2.PNConfiguration.Builder -import com.pubnub.internal.v2.BasePNConfigurationImpl import okhttp3.Authenticator import okhttp3.CertificatePinner import okhttp3.ConnectionSpec @@ -17,22 +16,287 @@ import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509ExtendedTrustManager -interface PNConfiguration : BasePNConfiguration, PNConfigurationOverride { +interface PNConfiguration : com.pubnub.api.v2.PNConfiguration { companion object { @JvmStatic fun builder( userId: UserId, subscribeKey: String, ): Builder { - return Class.forName("com.pubnub.internal.v2.PNConfigurationImpl\$Builder") - .getConstructor(BasePNConfiguration::class.java) - .newInstance(object : BasePNConfigurationImpl(userId) { - override val subscribeKey: String = subscribeKey - }) as Builder + return Class.forName("com.pubnub.internal.java.v2.PNConfigurationImpl\$Builder") + .getConstructor(UserId::class.java, subscribeKey::class.java) + .newInstance(userId, subscribeKey) as Builder + } + + @JvmStatic + fun builder(initialConfiguration: com.pubnub.api.v2.PNConfiguration): Builder { + return Class.forName("com.pubnub.internal.java.v2.PNConfigurationImpl\$Builder") + .getConstructor(com.pubnub.api.v2.PNConfiguration::class.java) + .newInstance(initialConfiguration) as Builder } } - interface Builder : BasePNConfiguration.Builder, PNConfigurationOverride.Builder { + interface Builder : PNConfigurationOverride.Builder { + /** + * The user ID that the PubNub client will use. + */ + val userId: UserId + + /** + * The subscribe key from the admin panel. + */ + val subscribeKey: String + + /** + * The publish key from the admin panel (only required if publishing). + */ + val publishKey: String + + /** + * The secret key from the admin panel (only required for modifying/revealing access permissions). + * + * Keep away from Android. + */ + val secretKey: String + + /** + * If Access Manager is utilized, client will use this authKey in all restricted requests. + */ + val authKey: String + + /** + * CryptoModule is responsible for handling encryption and decryption. + * If set, all communications to and from PubNub will be encrypted. + */ + val cryptoModule: CryptoModule? + + /** + * Custom origin if needed. + * + * Defaults to `ps.pndsn.com` + */ + val origin: String + + /** + * If set to `true`, requests will be made over HTTPS. + * + * Deafults to `true`. + */ + val secure: Boolean + + /** + * Set to [PNLogVerbosity.BODY] to enable logging of network traffic, otherwise se to [PNLogVerbosity.NONE]. + */ + val logVerbosity: PNLogVerbosity + + /** + * Set Heartbeat notification options. + * + * By default, the SDK alerts on failed heartbeats (equivalent to [PNHeartbeatNotificationOptions.FAILURES]). + */ + val heartbeatNotificationOptions: PNHeartbeatNotificationOptions + + /** + * Sets the custom presence server timeout. + * + * The value is in seconds, and the minimum value is 20 seconds. + * + * Also sets the value of [heartbeatInterval] + */ + val presenceTimeout: Int + + /** + * How often the client will announce itself to server. + * + * The value is in seconds. + */ + val heartbeatInterval: Int + + /** + * The subscribe request timeout. + * + * The value is in seconds. + * + * Defaults to 310. + */ + val subscribeTimeout: Int + + /** + * How long before the client gives up trying to connect with the server. + * + * The value is in seconds. + * + * Defaults to 5. + */ + val connectTimeout: Int + + /** + * For non subscribe operations (publish, herenow, etc), + * This property relates to a read timeout that is applied from the moment the connection between a client + * and the server has been successfully established. It defines a maximum time of inactivity between two + * data packets when waiting for the server’s response. + * + * The value is in seconds. + * + * Defaults to 10. + */ + @Deprecated( + "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", + replaceWith = ReplaceWith("nonSubscribeReadTimeout") + ) + val nonSubscribeRequestTimeout: Int + get() = nonSubscribeReadTimeout + + /** + * For non subscribe operations (publish, herenow, etc), + * This property relates to a read timeout that is applied from the moment the connection between a client + * and the server has been successfully established. It defines a maximum time of inactivity between two + * data packets when waiting for the server’s response. + * + * The value is in seconds. + * + * Defaults to 10. + */ + val nonSubscribeReadTimeout: Int + + /** + * If operating behind a misbehaving proxy, allow the client to shuffle the subdomains. + * + * Defaults to `false`. + */ + val cacheBusting: Boolean + + /** + * When `true` the SDK doesn't send out the leave requests. + * + * Defaults to `false`. + */ + val suppressLeaveEvents: Boolean + + /** + * When `true` the SDK will resend the last channel state that was set using [PubNub.setPresenceState] + * for the current [userId] with every automatic heartbeat (if [heartbeatInterval] is greater than 0) + * and initial subscribe connection (also after e.g. loss of network). + * + * Defaults to `true`. + * + * Please note that `maintainPresenceState` doesn't apply to state that was set on channel groups. + * It is recommended to disable this option if you set state for channel groups using [PubNub.setPresenceState] + * otherwise that state may be overwritten by individual channel states. + */ + val maintainPresenceState: Boolean + + /** + * Feature to subscribe with a custom filter expression. + */ + val filterExpression: String + + /** + * Whether to include a `instanceId` with every request. + * + * Defaults to `false`. + */ + val includeInstanceIdentifier: Boolean + + /** + * Whether to include a `requestId` with every request. + * + * Defaults to `true`. + */ + val includeRequestIdentifier: Boolean + + /** + * @see [okhttp3.Dispatcher.setMaxRequestsPerHost] + */ + val maximumConnections: Int? + + /** + * Enable Google App Engine networking. + * + * Defaults to `false`. + */ + val googleAppEngineNetworking: Boolean + + /** + * Instructs the SDK to use a proxy configuration when communicating with PubNub servers. + * + * @see [Proxy] + */ + val proxy: Proxy? + + /** + * @see [ProxySelector] + */ + val proxySelector: ProxySelector? + + /** + * @see [Authenticator] + */ + val proxyAuthenticator: Authenticator? + + /** + * @see [CertificatePinner] + */ + val certificatePinner: CertificatePinner? + + /** + * Sets a custom [HttpLoggingInterceptor] for logging network traffic. + * + * @see [HttpLoggingInterceptor] + */ + val httpLoggingInterceptor: HttpLoggingInterceptor? + + /** + * @see [SSLSocketFactory] + */ + val sslSocketFactory: SSLSocketFactory? + + /** + * @see [X509ExtendedTrustManager] + */ + val x509ExtendedTrustManager: X509ExtendedTrustManager? + + /** + * @see [okhttp3.ConnectionSpec] + */ + val connectionSpec: ConnectionSpec? + + /** + * @see [javax.net.ssl.HostnameVerifier] + */ + val hostnameVerifier: HostnameVerifier? + + /** + * How many times publishing file message should automatically retry before marking the action as failed + * + * Defaults to `5` + */ + val fileMessagePublishRetryLimit: Int + + val dedupOnSubscribe: Boolean + val maximumMessagesCacheSize: Int + val pnsdkSuffixes: Map + + /** + * Retry configuration for requests. + * Defaults to [RetryConfiguration.None]. + * + * Use [RetryConfiguration.Linear] to set retry with linear delay interval + * Use [RetryConfiguration.Exponential] to set retry with exponential delay interval + * Delay will valy from provided value by random value. + */ + val retryConfiguration: RetryConfiguration + + /** + * Enables explicit presence control. + * When set to true heartbeat calls will contain only channels and groups added explicitly + * using [PubNubCore.presence]. Should be used only with ACL set on the server side. + * For more information please contact PubNub support + * @see PubNubCore.presence + * @see PNConfiguration.heartbeatInterval + */ + val managePresenceListManually: Boolean + override fun build(): PNConfiguration override fun setUserId(userId: UserId): Builder @@ -114,7 +378,10 @@ interface PNConfiguration : BasePNConfiguration, PNConfigurationOverride { "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", replaceWith = ReplaceWith("nonSubscribeReadTimeout") ) - fun nonSubscribeRequestTimeout(nonSubscribeRequestTimeout: Int): Builder + fun nonSubscribeRequestTimeout(nonSubscribeRequestTimeout: Int): Builder { + nonSubscribeReadTimeout(nonSubscribeRequestTimeout) + return this + } override fun nonSubscribeReadTimeout(nonSubscribeReadTimeout: Int): Builder @@ -254,23 +521,23 @@ interface PNConfiguration : BasePNConfiguration, PNConfigurationOverride { * using [PubNubCore.presence]. Should be used only with ACL set on the server side. * For more information please contact PubNub support * @see PubNubCore.presence - * @see BasePNConfigurationImpl.heartbeatInterval + * @see PNConfigurationImpl.heartbeatInterval */ fun managePresenceListManually(managePresenceListManually: Boolean): Builder } } -interface PNConfigurationOverride : BasePNConfigurationOverride { +interface PNConfigurationOverride : com.pubnub.api.v2.PNConfigurationOverride { companion object { @JvmStatic - fun from(configuration: BasePNConfiguration): Builder { - return Class.forName("com.pubnub.internal.v2.PNConfigurationImpl\$Builder") - .getConstructor(BasePNConfiguration::class.java) + fun from(configuration: com.pubnub.api.v2.PNConfiguration): Builder { + return Class.forName("com.pubnub.internal.java.v2.PNConfigurationImpl\$Builder") + .getConstructor(com.pubnub.api.v2.PNConfiguration::class.java) .newInstance(configuration) as Builder } } - interface Builder : BasePNConfigurationOverride.Builder { + interface Builder { fun setUserId(userId: UserId): Builder fun subscribeKey(subscribeKey: String): Builder diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/EventEmitter.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/EventEmitter.kt new file mode 100644 index 000000000..970528c16 --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/EventEmitter.kt @@ -0,0 +1,243 @@ +package com.pubnub.api.java.v2.callbacks + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.java.v2.callbacks.handlers.OnChannelMetadataHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnFileHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnMembershipHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnMessageActionHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnMessageHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnPresenceHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnSignalHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnUuidMetadataHandler + +/** + * Interface implemented by objects that are the source of real time events from the PubNub network. + */ +interface EventEmitter { + /** + * Add a listener. + * + * @param listener The listener to be added. + */ + fun addListener(listener: EventListener) + + /** + * Remove a listener. + * + * @param listener The listener to be removed, previously added with [addListener]. + */ + fun removeListener(listener: Listener) + + /** + * Removes all listeners. + */ + fun removeAllListeners() + + /** + * Sets the handler for incoming message events. + * This method allows the assignment of an [OnMessageHandler] implementation or lambda expression to handle + * incoming messages. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to message events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`setOnMessage(pnMessageResult -> System.out.println("Received: " + pnMessageResult.getMessage()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`setOnMessage(null);
+     `
* + * + * @param onMessageHandler An implementation of [OnMessageHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + fun setOnMessage(onMessageHandler: OnMessageHandler?) + + /** + * Sets the handler for incoming signal events. + * This method allows the assignment of an [OnSignalHandler] implementation or lambda expression to handle + * incoming signals. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to signal events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`setOnSignal(pnSignalResult -> System.out.println("Received: " + pnSignalResult.getMessage()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`setOnSignal(null);
+     `
* + * + * @param onSignalHandler An implementation of [OnSignalHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + fun setOnSignal(onSignalHandler: OnSignalHandler?) + + /** + * Sets the handler for incoming presence events. + * This method allows the assignment of an [OnPresenceHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to presence events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onPresenceHandler(pnPresenceEventResult -> System.out.println("Received: " + pnPresenceEventResult.getEvent()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onPresenceHandler(null);
+     `
* + * + * @param onPresenceHandler An implementation of [OnPresenceHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + fun setOnPresence(onPresenceHandler: OnPresenceHandler?) + + /** + * Sets the handler for incoming messageAction events. + * This method allows the assignment of an [OnMessageActionHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to messageAction events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onMessageActionHandler(pnMessageActionResult -> System.out.println("Received: " + pnMessageActionResult.getMessageAction()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onMessageActionHandler(null);
+     `
* + * + * @param onMessageActionHandler An implementation of [OnMessageActionHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + fun setOnMessageAction(onMessageActionHandler: OnMessageActionHandler?) + + /** + * Sets the handler for incoming uuidMetadata events. + * This method allows the assignment of an [OnUuidMetadataHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to uuidMetadata events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onUuidMetadataHandler(pnUUIDMetadataResult -> System.out.println("Received: " + pnUUIDMetadataResult.getData()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onUuidMetadataHandler(null);
+     `
* + * + * @param onUuidMetadataHandler An implementation of [OnUuidMetadataHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + fun setOnUuidMetadata(onUuidMetadataHandler: OnUuidMetadataHandler?) + + /** + * Sets the handler for incoming channelMetadata events. + * This method allows the assignment of an [OnChannelMetadataHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to channelMetadata events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onChannelMetadataHandler(pnChannelMetadataResult -> System.out.println("Received: " +  pnChannelMetadataResult.getEvent()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onChannelMetadataHandler(null);
+     `
* + * + * @param onChannelMetadataHandler An implementation of [OnChannelMetadataHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + fun setOnChannelMetadata(onChannelMetadataHandler: OnChannelMetadataHandler?) + + /** + * Sets the handler for incoming membership events. + * This method allows the assignment of an [OnMembershipHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to membership events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onMembershipHandler(pnMembershipResult -> System.out.println("Received: " +  pnMembershipResult.getEvent()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onMembershipHandler(null);
+     `
* + * + * @param onMembershipHandler An implementation of [OnMembershipHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + fun setOnMembership(onMembershipHandler: OnMembershipHandler?) + + /** + * Sets the handler for incoming file events. + * This method allows the assignment of an [OnFileHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to file events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onFileHandler(pnFileEventResult -> System.out.println("Received: " +  pnFileEventResult.getMessage()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onFileHandler(null);
+     `
* + * + * @param onFileHandler An implementation of [OnFileHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + fun setOnFile(onFileHandler: OnFileHandler?) +} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/EventListener.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/EventListener.kt new file mode 100644 index 000000000..51d77d724 --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/EventListener.kt @@ -0,0 +1,46 @@ +package com.pubnub.api.java.v2.callbacks + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.java.PubNub +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadataResult +import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembershipResult +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadataResult +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult + +/** + * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time + * network. + */ +interface EventListener : Listener { + fun message(pubnub: PubNub, result: PNMessageResult) {} + + fun presence( + pubnub: PubNub, + result: PNPresenceEventResult, + ) {} + + fun signal(pubnub: PubNub, result: PNSignalResult) {} + + fun messageAction( + pubNub: PubNub, + result: PNMessageActionResult, + ) {} + + fun file( + pubnub: PubNub, + result: PNFileEventResult, + ) {} + + fun uuid(pubnub: PubNub, pnUUIDMetadataResult: PNUUIDMetadataResult) { + } + + fun channel(pubnub: PubNub, pnChannelMetadataResult: PNChannelMetadataResult) { + } + + fun membership(pubnub: PubNub, pnMembershipResult: PNMembershipResult) { + } +} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventEmitter.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/StatusEmitter.kt similarity index 59% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventEmitter.kt rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/StatusEmitter.kt index c83d24768..751e6dcab 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/BaseEventEmitter.kt +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/StatusEmitter.kt @@ -1,14 +1,18 @@ -package com.pubnub.api.v2.callbacks +package com.pubnub.api.java.v2.callbacks import com.pubnub.api.callbacks.Listener -interface BaseEventEmitter { +/** + * Interface implemented by objects that manage the subscription connection to the PubNub network and can be monitored + * for connection state changes. + */ +interface StatusEmitter { /** * Add a listener. * * @param listener The listener to be added. */ - fun addListener(listener: T) + fun addListener(listener: StatusListener) /** * Remove a listener. diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/StatusListener.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/StatusListener.kt new file mode 100644 index 000000000..359e96c53 --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/StatusListener.kt @@ -0,0 +1,22 @@ +package com.pubnub.api.java.v2.callbacks + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.java.PubNub +import com.pubnub.api.models.consumer.PNStatus + +fun interface StatusListener : Listener { + /** + * Receive status updates from the PubNub client, such as: + * * [com.pubnub.api.enums.PNStatusCategory.PNConnectedCategory], + * * [com.pubnub.api.enums.PNStatusCategory.PNDisconnectedCategory], + * * [com.pubnub.api.enums.PNStatusCategory.PNSubscriptionChanged] + * * [com.pubnub.api.enums.PNStatusCategory.PNConnectionError], + * * [com.pubnub.api.enums.PNStatusCategory.PNUnexpectedDisconnectCategory], + * + * @see [PNStatus] + * + * @param pubnub The client instance which has this listener attached. + * @param status Wrapper around the actual message content. + */ + fun status(pubnub: PubNub, status: PNStatus) +} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnChannelMetadataHandler.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnChannelMetadataHandler.java similarity index 86% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnChannelMetadataHandler.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnChannelMetadataHandler.java index a134324f4..67c578961 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnChannelMetadataHandler.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnChannelMetadataHandler.java @@ -1,6 +1,6 @@ -package com.pubnub.api.v2.callbacks.handlers; +package com.pubnub.api.java.v2.callbacks.handlers; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadataResult; @FunctionalInterface public interface OnChannelMetadataHandler { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnFileHandler.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnFileHandler.java similarity index 94% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnFileHandler.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnFileHandler.java index 4abc05cf2..2df5f81b9 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnFileHandler.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnFileHandler.java @@ -1,4 +1,4 @@ -package com.pubnub.api.v2.callbacks.handlers; +package com.pubnub.api.java.v2.callbacks.handlers; import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnMembershipHandler.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnMembershipHandler.java similarity index 85% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnMembershipHandler.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnMembershipHandler.java index 10370225d..c0daa9de3 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnMembershipHandler.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnMembershipHandler.java @@ -1,6 +1,6 @@ -package com.pubnub.api.v2.callbacks.handlers; +package com.pubnub.api.java.v2.callbacks.handlers; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembershipResult; @FunctionalInterface public interface OnMembershipHandler { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnMessageActionHandler.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnMessageActionHandler.java similarity index 94% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnMessageActionHandler.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnMessageActionHandler.java index 193d94944..789d7c8fa 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnMessageActionHandler.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnMessageActionHandler.java @@ -1,4 +1,4 @@ -package com.pubnub.api.v2.callbacks.handlers; +package com.pubnub.api.java.v2.callbacks.handlers; import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnMessageHandler.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnMessageHandler.java similarity index 94% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnMessageHandler.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnMessageHandler.java index 5bc07b6f9..8bb1f2cec 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnMessageHandler.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnMessageHandler.java @@ -1,4 +1,4 @@ -package com.pubnub.api.v2.callbacks.handlers; +package com.pubnub.api.java.v2.callbacks.handlers; import com.pubnub.api.models.consumer.pubsub.PNMessageResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnPresenceHandler.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnPresenceHandler.java similarity index 94% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnPresenceHandler.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnPresenceHandler.java index 01e2985e7..e477b7e71 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnPresenceHandler.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnPresenceHandler.java @@ -1,4 +1,4 @@ -package com.pubnub.api.v2.callbacks.handlers; +package com.pubnub.api.java.v2.callbacks.handlers; import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnSignalHandler.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnSignalHandler.java similarity index 94% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnSignalHandler.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnSignalHandler.java index 4e4110da4..fa9c43733 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnSignalHandler.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnSignalHandler.java @@ -1,4 +1,4 @@ -package com.pubnub.api.v2.callbacks.handlers; +package com.pubnub.api.java.v2.callbacks.handlers; import com.pubnub.api.models.consumer.pubsub.PNSignalResult; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnUuidMetadataHandler.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnUuidMetadataHandler.java similarity index 86% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnUuidMetadataHandler.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnUuidMetadataHandler.java index ac450d3eb..9a3910577 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/handlers/OnUuidMetadataHandler.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/callbacks/handlers/OnUuidMetadataHandler.java @@ -1,6 +1,6 @@ -package com.pubnub.api.v2.callbacks.handlers; +package com.pubnub.api.java.v2.callbacks.handlers; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadataResult; @FunctionalInterface public interface OnUuidMetadataHandler { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/endpoints/pubsub/PublishBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/endpoints/pubsub/PublishBuilder.java similarity index 78% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/endpoints/pubsub/PublishBuilder.java rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/endpoints/pubsub/PublishBuilder.java index df33f8c72..92c13dac2 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/endpoints/pubsub/PublishBuilder.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/endpoints/pubsub/PublishBuilder.java @@ -1,6 +1,6 @@ -package com.pubnub.api.v2.endpoints.pubsub; +package com.pubnub.api.java.v2.endpoints.pubsub; -import com.pubnub.api.endpoints.Endpoint; +import com.pubnub.api.java.endpoints.Endpoint; import com.pubnub.api.models.consumer.PNPublishResult; public interface PublishBuilder extends Endpoint { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/endpoints/pubsub/SignalBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/endpoints/pubsub/SignalBuilder.java new file mode 100644 index 000000000..321ef9edd --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/endpoints/pubsub/SignalBuilder.java @@ -0,0 +1,6 @@ +package com.pubnub.api.java.v2.endpoints.pubsub; + +import com.pubnub.api.java.endpoints.pubsub.Signal; + +public interface SignalBuilder extends Signal { +} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/Channel.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/entities/Channel.kt similarity index 75% rename from pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/Channel.kt rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/entities/Channel.kt index 5cf99a193..262f2dd3c 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/Channel.kt +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/entities/Channel.kt @@ -1,19 +1,44 @@ -package com.pubnub.api.v2.entities +package com.pubnub.api.java.v2.entities -import com.pubnub.api.PNConfiguration -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.endpoints.pubsub.PublishBuilder -import com.pubnub.api.v2.endpoints.pubsub.SignalBuilder -import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.java.v2.endpoints.pubsub.PublishBuilder +import com.pubnub.api.java.v2.subscriptions.Subscription +import com.pubnub.api.v2.entities.Subscribable +import com.pubnub.api.v2.subscriptions.SubscriptionOptions /** * A representation of a PubNub channel identified by its [name]. * * You can get a [Subscription] to this channel through [Subscribable.subscription]. * - * Use the [com.pubnub.api.PubNub.channel] factory method to create instances of this interface. + * Use the [com.pubnub.api.java.PubNub.channel] factory method to create instances of this interface. */ -interface Channel : BaseChannel { +interface Channel : com.pubnub.api.java.v2.entities.Subscribable { + /** + * The name of this channel. Supports wildcards by ending it with ".*" + * + * See more in the [documentation](https://www.pubnub.com/docs/general/channels/overview) + */ + val name: String + + /** + * Returns a [Subscription] that can be used to subscribe to this channel. + * + * Channel subscriptions support passing [com.pubnub.api.v2.subscriptions.SubscriptionOptions.receivePresenceEvents] in + * [options] to enable receiving presence events. + * + * [com.pubnub.api.v2.subscriptions.SubscriptionOptions.filter] can be used to filter events delivered to the subscription. + * + * For example, to create a subscription that only listens to presence events: + * ``` + * channel.subscription(SubscriptionOptions.receivePresenceEvents() + SubscriptionOptions.filter { it is PNPresenceEventResult } ) + * ``` + * + * @param options optional [SubscriptionOptions]. + * @return an inactive [Subscription] to this channel. You must call [Subscription.subscribe] to start receiving events. + */ + override fun subscription(options: SubscriptionOptions): Subscription + /** * Returns a [Subscription] that can be used to subscribe to this channel. * @@ -78,7 +103,7 @@ interface Channel : BaseChannel { * * @param message The payload which will be serialized and sent. */ - fun signal(message: Any): SignalBuilder + fun signal(message: Any): Signal /** * Send a message to PubNub Functions Event Handlers. diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelGroup.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/entities/ChannelGroup.kt similarity index 72% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelGroup.kt rename to pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/entities/ChannelGroup.kt index 71f0ad28c..14350bc8f 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/BaseChannelGroup.kt +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/entities/ChannelGroup.kt @@ -1,17 +1,17 @@ -package com.pubnub.api.v2.entities +package com.pubnub.api.java.v2.entities -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.subscriptions.BaseSubscription +import com.pubnub.api.java.v2.subscriptions.Subscription +import com.pubnub.api.v2.entities.Subscribable import com.pubnub.api.v2.subscriptions.SubscriptionOptions /** * A representation of a PubNub channel group identified by its [name]. * - * You can get a [BaseSubscription] to this channel group through [Subscribable.subscription]. + * You can get a [Subscription] to this channel group through [Subscribable.subscription]. * - * Use the [com.pubnub.api.PubNub.channelGroup] factory method to create instances of this interface. + * Use the [com.pubnub.api.java.PubNub.channelGroup] factory method to create instances of this interface. */ -interface BaseChannelGroup> : Subscribable { +interface ChannelGroup : com.pubnub.api.java.v2.entities.Subscribable { /** * The name of this channel group. * @@ -47,4 +47,14 @@ interface BaseChannelGroup, EventEmitter { +interface Subscription : com.pubnub.api.java.v2.callbacks.EventEmitter, SubscribeCapable, AutoCloseable { /** * Create a [SubscriptionSet] containing this [Subscription] and the added [subscription]. */ - fun plus(subscription: Subscription): SubscriptionSet + operator fun plus(subscription: Subscription): SubscriptionSet /** * Start receiving events from the subscriptions (or subscriptions) represented by this object. diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/subscriptions/SubscriptionSet.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/subscriptions/SubscriptionSet.kt new file mode 100644 index 000000000..ea9e99106 --- /dev/null +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/v2/subscriptions/SubscriptionSet.kt @@ -0,0 +1,65 @@ +package com.pubnub.api.java.v2.subscriptions + +import com.pubnub.api.java.v2.callbacks.EventEmitter +import com.pubnub.api.v2.subscriptions.SubscribeCapable + +/** + * A helper class that manages multiple [Subscription]s that can be added to it. + * + * Use the [com.pubnub.api.java.PubNub.subscriptionSetOf] factory methods to create instances of this interface. + * + * Adding multiple `Subscription`s to the set, then calling [subscribe] or [unsubscribe] on the set is more efficient + * than calling [Subscription.subscribe] on each `Subscription` object separately, as the PubNub client can minimize + * the number of required reconnections internally. + * + * Remember to always [close] the set when you're done using it to avoid memory leaks. + * Closing the set also closes all `Subscription`s that are part of this set. + */ +interface SubscriptionSet : EventEmitter, SubscribeCapable, AutoCloseable { + /** + * Start receiving events from the subscriptions (or subscriptions) represented by this object. + * + * The PubNub client will start a network connection to the server if it doesn't have one already, + * or will alter the existing connection to add channels and groups requested by this subscriptions if needed. + */ + fun subscribe() + + /** + * Add a [Subscription] to this set. + * + * Please note that this SubscriptionSet will *not* attempt to ensure all subscriptions match their + * active/inactive state. That is, if you previously called [subscribe] or [unsubscribe] on this set, it will not be + * called on the newly added [subscription] automatically. + * + * @param subscription the [Subscription] to add. + */ + fun add(subscription: Subscription) + + /** + * Remove the [subscription] from this set. + * + * Please note that removing a subscription from the set does not automatically [unsubscribe] or [close] it. + * + * @param subscription the [Subscription] to remove. + */ + fun remove(subscription: Subscription) + + /** + * Returns an immutable copy of the set of subscriptions contained in this [SubscriptionSet]. + */ + val subscriptions: Set + + /** + * Add the [subscription] to this SubscriptionSet. Equivalent to calling [add]. + * + * @see [add] + */ + operator fun plusAssign(subscription: Subscription) + + /** + * Remove the [subscription] from this set. Equivalent to calling [remove]. + * + * @see [remove] + */ + operator fun minusAssign(subscription: Subscription) +} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/EventEmitter.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/EventEmitter.java deleted file mode 100644 index 3926da4fa..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/EventEmitter.java +++ /dev/null @@ -1,223 +0,0 @@ -package com.pubnub.api.v2.callbacks; - -import com.pubnub.api.v2.callbacks.handlers.OnChannelMetadataHandler; -import com.pubnub.api.v2.callbacks.handlers.OnFileHandler; -import com.pubnub.api.v2.callbacks.handlers.OnMembershipHandler; -import com.pubnub.api.v2.callbacks.handlers.OnMessageActionHandler; -import com.pubnub.api.v2.callbacks.handlers.OnMessageHandler; -import com.pubnub.api.v2.callbacks.handlers.OnPresenceHandler; -import com.pubnub.api.v2.callbacks.handlers.OnSignalHandler; -import com.pubnub.api.v2.callbacks.handlers.OnUuidMetadataHandler; - -/** - * Interface implemented by objects that are the source of real time events from the PubNub network. - */ -public interface EventEmitter extends BaseEventEmitter { - /** - * Sets the handler for incoming message events. - * This method allows the assignment of an {@link OnMessageHandler} implementation or lambda expression to handle - * incoming messages. - * - * To deactivate the current behavior, simply set this property to `null`. - * - * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. - * For scenarios requiring multiple behaviors in response to message events, it is advisable - * to utilize {@link EventEmitter#addListener}. - * - *

Setting a Behavior Example:

- *
{@code
-     * setOnMessage(pnMessageResult -> System.out.println("Received: " + pnMessageResult.getMessage()));
-     * }
- * - *

Removing a Behavior Example:

- *
{@code
-     * setOnMessage(null);
-     * }
- * - * @param onMessageHandler An implementation of {@link OnMessageHandler} or a lambda expression to handle - * incoming messages. It can be {@code null} to remove the current handler. - */ - void setOnMessage(OnMessageHandler onMessageHandler); - - /** - * Sets the handler for incoming signal events. - * This method allows the assignment of an {@link OnSignalHandler} implementation or lambda expression to handle - * incoming signals. - * - * To deactivate the current behavior, simply set this property to `null`. - * - * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. - * For scenarios requiring multiple behaviors in response to signal events, it is advisable - * to utilize {@link EventEmitter#addListener}. - * - *

Setting a Behavior Example:

- *
{@code
-     * setOnSignal(pnSignalResult -> System.out.println("Received: " + pnSignalResult.getMessage()));
-     * }
- * - *

Removing a Behavior Example:

- *
{@code
-     * setOnSignal(null);
-     * }
- * - * @param onSignalHandler An implementation of {@link OnSignalHandler} or a lambda expression to handle - * incoming messages. It can be {@code null} to remove the current handler. - */ - void setOnSignal(OnSignalHandler onSignalHandler); - - /** - * Sets the handler for incoming presence events. - * This method allows the assignment of an {@link OnPresenceHandler} implementation or lambda expression to handle - * incoming presence events. - * - * To deactivate the current behavior, simply set this property to `null`. - * - * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. - * For scenarios requiring multiple behaviors in response to presence events, it is advisable - * to utilize {@link EventEmitter#addListener}. - * - *

Setting a Behavior Example:

- *
{@code
-     * onPresenceHandler(pnPresenceEventResult -> System.out.println("Received: " + pnPresenceEventResult.getEvent()));
-     * }
- * - *

Removing a Behavior Example:

- *
{@code
-     * onPresenceHandler(null);
-     * }
- * - * @param onPresenceHandler An implementation of {@link OnPresenceHandler} or a lambda expression to handle - * incoming messages. It can be {@code null} to remove the current handler. - */ - void setOnPresence(OnPresenceHandler onPresenceHandler); - - /** - * Sets the handler for incoming messageAction events. - * This method allows the assignment of an {@link OnMessageActionHandler} implementation or lambda expression to handle - * incoming presence events. - * - * To deactivate the current behavior, simply set this property to `null`. - * - * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. - * For scenarios requiring multiple behaviors in response to messageAction events, it is advisable - * to utilize {@link EventEmitter#addListener}. - * - *

Setting a Behavior Example:

- *
{@code
-     * onMessageActionHandler(pnMessageActionResult -> System.out.println("Received: " + pnMessageActionResult.getMessageAction()));
-     * }
- * - *

Removing a Behavior Example:

- *
{@code
-     * onMessageActionHandler(null);
-     * }
- * - * @param onMessageActionHandler An implementation of {@link OnMessageActionHandler} or a lambda expression to handle - * incoming messages. It can be {@code null} to remove the current handler. - */ - void setOnMessageAction(OnMessageActionHandler onMessageActionHandler); - - /** - * Sets the handler for incoming uuidMetadata events. - * This method allows the assignment of an {@link OnUuidMetadataHandler} implementation or lambda expression to handle - * incoming presence events. - * - * To deactivate the current behavior, simply set this property to `null`. - * - * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. - * For scenarios requiring multiple behaviors in response to uuidMetadata events, it is advisable - * to utilize {@link EventEmitter#addListener}. - * - *

Setting a Behavior Example:

- *
{@code
-     * onUuidMetadataHandler(pnUUIDMetadataResult -> System.out.println("Received: " + pnUUIDMetadataResult.getData()));
-     * }
- * - *

Removing a Behavior Example:

- *
{@code
-     * onUuidMetadataHandler(null);
-     * }
- * - * @param onUuidMetadataHandler An implementation of {@link OnUuidMetadataHandler} or a lambda expression to handle - * incoming messages. It can be {@code null} to remove the current handler. - */ - void setOnUuidMetadata(OnUuidMetadataHandler onUuidMetadataHandler); - - /** - * Sets the handler for incoming channelMetadata events. - * This method allows the assignment of an {@link OnChannelMetadataHandler} implementation or lambda expression to handle - * incoming presence events. - * - * To deactivate the current behavior, simply set this property to `null`. - * - * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. - * For scenarios requiring multiple behaviors in response to channelMetadata events, it is advisable - * to utilize {@link EventEmitter#addListener}. - * - *

Setting a Behavior Example:

- *
{@code
-     * onChannelMetadataHandler(pnChannelMetadataResult -> System.out.println("Received: " +  pnChannelMetadataResult.getEvent()));
-     * }
- * - *

Removing a Behavior Example:

- *
{@code
-     * onChannelMetadataHandler(null);
-     * }
- * - * @param onChannelMetadataHandler An implementation of {@link OnChannelMetadataHandler} or a lambda expression to handle - * incoming messages. It can be {@code null} to remove the current handler. - */ - void setOnChannelMetadata(OnChannelMetadataHandler onChannelMetadataHandler); - - /** - * Sets the handler for incoming membership events. - * This method allows the assignment of an {@link OnMembershipHandler} implementation or lambda expression to handle - * incoming presence events. - * - * To deactivate the current behavior, simply set this property to `null`. - * - * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. - * For scenarios requiring multiple behaviors in response to membership events, it is advisable - * to utilize {@link EventEmitter#addListener}. - * - *

Setting a Behavior Example:

- *
{@code
-     * onMembershipHandler(pnMembershipResult -> System.out.println("Received: " +  pnMembershipResult.getEvent()));
-     * }
- * - *

Removing a Behavior Example:

- *
{@code
-     * onMembershipHandler(null);
-     * }
- * - * @param onMembershipHandler An implementation of {@link OnMembershipHandler} or a lambda expression to handle - * incoming messages. It can be {@code null} to remove the current handler. - */ - void setOnMembership(OnMembershipHandler onMembershipHandler); - - /** - * Sets the handler for incoming file events. - * This method allows the assignment of an {@link OnFileHandler} implementation or lambda expression to handle - * incoming presence events. - * - * To deactivate the current behavior, simply set this property to `null`. - * - * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. - * For scenarios requiring multiple behaviors in response to file events, it is advisable - * to utilize {@link EventEmitter#addListener}. - * - *

Setting a Behavior Example:

- *
{@code
-     * onFileHandler(pnFileEventResult -> System.out.println("Received: " +  pnFileEventResult.getMessage()));
-     * }
- * - *

Removing a Behavior Example:

- *
{@code
-     * onFileHandler(null);
-     * }
- * - * @param onFileHandler An implementation of {@link OnFileHandler} or a lambda expression to handle - * incoming messages. It can be {@code null} to remove the current handler. - */ - void setOnFile(OnFileHandler onFileHandler); -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/EventListener.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/EventListener.java deleted file mode 100644 index 7a3a55e22..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/EventListener.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.pubnub.api.v2.callbacks; - -import com.pubnub.api.PubNub; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; -import com.pubnub.api.models.consumer.pubsub.PNMessageResult; -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; -import org.jetbrains.annotations.NotNull; - -/** - * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time - * network. - */ -public interface EventListener extends BaseEventListener { - - default void message(@NotNull PubNub pubnub, @NotNull PNMessageResult pnMessageResult) { - } - - default void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pnPresenceEventResult) { - } - - default void signal(@NotNull PubNub pubnub, @NotNull PNSignalResult pnSignalResult) { - } - - default void uuid(@NotNull PubNub pubnub, @NotNull PNUUIDMetadataResult pnUUIDMetadataResult) { - } - - default void channel(@NotNull PubNub pubnub, @NotNull PNChannelMetadataResult pnChannelMetadataResult) { - } - - default void membership(@NotNull PubNub pubnub, @NotNull PNMembershipResult pnMembershipResult) { - } - - default void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnMessageActionResult) { - } - - default void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - } - -} - diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/StatusEmitter.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/StatusEmitter.java deleted file mode 100644 index 39169181c..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/StatusEmitter.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.pubnub.api.v2.callbacks; - -/** - * Interface implemented by objects that manage the subscription connection to the PubNub network and can be monitored - * for connection state changes. - */ -public interface StatusEmitter extends BaseStatusEmitter { -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/StatusListener.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/StatusListener.java deleted file mode 100644 index 39fee8f5f..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/callbacks/StatusListener.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.api.v2.callbacks; - - -import com.pubnub.api.PubNub; -import com.pubnub.api.models.consumer.PNStatus; -import org.jetbrains.annotations.NotNull; - -/** - * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for - * PubNub connection status changes. - */ -public interface StatusListener extends BaseStatusListener { - void status(@NotNull PubNub pubnub, @NotNull PNStatus pnStatus); -} \ No newline at end of file diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/endpoints/pubsub/SignalBuilder.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/endpoints/pubsub/SignalBuilder.java deleted file mode 100644 index 1a4e0b03f..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/endpoints/pubsub/SignalBuilder.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.pubnub.api.v2.endpoints.pubsub; - -import com.pubnub.api.endpoints.Endpoint; -import com.pubnub.api.models.consumer.PNPublishResult; - -public interface SignalBuilder extends Endpoint { -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/ChannelGroup.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/ChannelGroup.kt deleted file mode 100644 index cf9be43f9..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/ChannelGroup.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.pubnub.api.v2.entities - -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.subscriptions.Subscription - -/** - * A representation of a PubNub channel group identified by its [name]. - * - * You can get a [Subscription] to this channel group through [Subscribable.subscription]. - * - * Use the [com.pubnub.api.PubNub.channelGroup] factory method to create instances of this interface. - */ -interface ChannelGroup : BaseChannelGroup { - /** - * Returns a [Subscription] that can be used to subscribe to this channel group. - * - * The returned [Subscription] is initially inactive. You must call [Subscription.subscribe] on it - * to start receiving events. - * - * @return An inactive [Subscription] to this channel. - */ - fun subscription(): Subscription -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/ChannelMetadata.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/ChannelMetadata.kt deleted file mode 100644 index f8d80d661..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/ChannelMetadata.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.pubnub.api.v2.entities - -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.subscriptions.Subscription - -/** - * A representation of a PubNub entity for tracking channel metadata changes. - * - * You can get a [Subscription] to listen for metadata events through [Subscribable.subscription]. - * - * Use the [com.pubnub.api.PubNub.channelMetadata] factory method to create instances of this interface. - */ -interface ChannelMetadata : BaseChannelMetadata { - /** - * Returns a [Subscription] that can be used to subscribe to this channel. - * - * The returned [Subscription] is initially inactive. You must call [Subscription.subscribe] on it - * to start receiving events. - * - * @return An inactive [Subscription] to this channel. - */ - fun subscription(): Subscription -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/UserMetadata.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/UserMetadata.kt deleted file mode 100644 index dab2821b6..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/entities/UserMetadata.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.pubnub.api.v2.entities - -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.subscriptions.Subscription - -/** - * A representation of a PubNub entity for tracking user metadata changes. - * - * You can get a [Subscription] to listen for metadata events through [Subscribable.subscription]. - * - * Use the [com.pubnub.api.PubNub.userMetadata] factory method to create instances of this interface. - */ -interface UserMetadata : BaseUserMetadata { - /** - * Returns a [Subscription] that can be used to subscribe to this channel. - * - * The returned [Subscription] is initially inactive. You must call [Subscription.subscribe] on it - * to start receiving events. - * - * @return An inactive [Subscription] to this channel. - */ - fun subscription(): Subscription -} diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt deleted file mode 100644 index ba7d90f6f..000000000 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.pubnub.api.v2.subscriptions - -import com.pubnub.api.v2.callbacks.EventEmitter -import com.pubnub.api.v2.callbacks.EventListener - -/** - * A helper class that manages multiple [Subscription]s that can be added to it. - * - * Use the [com.pubnub.api.PubNub.subscriptionSetOf] factory methods to create instances of this interface. - * - * Adding multiple `Subscription`s to the set, then calling [subscribe] or [unsubscribe] on the set is more efficient - * than calling [Subscription.subscribe] on each `Subscription` object separately, as the PubNub client can minimize - * the number of required reconnections internally. - * - * Remember to always [close] the set when you're done using it to avoid memory leaks. - * Closing the set also closes all `Subscription`s that are part of this set. - */ -interface SubscriptionSet : BaseSubscriptionSet, EventEmitter { - /** - * Start receiving events from the subscriptions (or subscriptions) represented by this object. - * - * The PubNub client will start a network connection to the server if it doesn't have one already, - * or will alter the existing connection to add channels and groups requested by this subscriptions if needed. - */ - fun subscribe() -} diff --git a/pubnub-gson/pubnub-gson-impl/build.gradle.kts b/pubnub-gson/pubnub-gson-impl/build.gradle.kts index da7edd6ef..6149efe4a 100644 --- a/pubnub-gson/pubnub-gson-impl/build.gradle.kts +++ b/pubnub-gson/pubnub-gson-impl/build.gradle.kts @@ -1,5 +1,4 @@ plugins { - checkstyle alias(libs.plugins.benmanes.versions) alias(libs.plugins.lombok) id("pubnub.java-library") @@ -10,9 +9,8 @@ plugins { } dependencies { - api(project(":pubnub-core:pubnub-core-api")) api(project(":pubnub-gson:pubnub-gson-api")) - implementation(project(":pubnub-core:pubnub-core-impl")) + implementation(project(":pubnub-kotlin:pubnub-kotlin-impl")) implementation(libs.slf4j) implementation(libs.jetbrains.annotations) @@ -29,21 +27,6 @@ dependencies { testImplementation(libs.junit.vintage.engine) testImplementation(libs.awaitility) testImplementation(libs.mockk) - + testImplementation("com.google.guava:guava:33.3.0-jre") "integrationTestImplementation"(libs.owner) } - -checkstyle { - toolVersion = "8.14" - configFile = rootProject.file("config/checkstyle/checkstyle.xml") - sourceSets = listOf(project.sourceSets.getByName("main")) -} - -tasks.withType().configureEach { - exclude("**/vendor/**", "**/*Test*") - - reports { - xml.required = true - html.required = true - } -} diff --git a/pubnub-gson/pubnub-gson-impl/config/ktlint/baseline.xml b/pubnub-gson/pubnub-gson-impl/config/ktlint/baseline.xml index 981420778..ad2a90c41 100644 --- a/pubnub-gson/pubnub-gson-impl/config/ktlint/baseline.xml +++ b/pubnub-gson/pubnub-gson-impl/config/ktlint/baseline.xml @@ -1,3 +1,9 @@ + + + + + + diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/FilesIntegrationTests.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/FilesIntegrationTests.java index d9b804121..dac93d77e 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/FilesIntegrationTests.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/FilesIntegrationTests.java @@ -1,11 +1,11 @@ package com.pubnub.api.integration; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.callbacks.SubscribeCallback; import com.pubnub.api.crypto.CryptoModule; import com.pubnub.api.enums.PNStatusCategory; import com.pubnub.api.integration.util.BaseIntegrationTest; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; import com.pubnub.api.models.consumer.PNStatus; import com.pubnub.api.models.consumer.files.PNDownloadFileResult; import com.pubnub.api.models.consumer.files.PNFileUploadResult; diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/HeartbeatIntegrationTest.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/HeartbeatIntegrationTest.java index 14337fd23..34f4b87bf 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/HeartbeatIntegrationTest.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/HeartbeatIntegrationTest.java @@ -1,10 +1,10 @@ package com.pubnub.api.integration; import com.google.gson.JsonObject; -import com.pubnub.api.PubNub; -import com.pubnub.api.callbacks.SubscribeCallback; import com.pubnub.api.enums.PNStatusCategory; import com.pubnub.api.integration.util.BaseIntegrationTest; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; import com.pubnub.api.models.consumer.PNStatus; import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; import org.awaitility.Awaitility; @@ -40,7 +40,7 @@ protected void onAfter() { public void testStateWithHeartbeat() { final AtomicInteger hits = new AtomicInteger(); final JsonObject expectedStatePayload = generatePayload(); - final PubNub observer = getPubNub(); + final com.pubnub.api.java.PubNub observer = getPubNub(); pubNub = getPubNub(builder -> { builder.presenceTimeout(20); @@ -48,7 +48,7 @@ public void testStateWithHeartbeat() { }); observer.addListener(new SubscribeCallback.BaseSubscribeCallback() { @Override - public void status(@NotNull PubNub pn, @NotNull PNStatus status) { + public void status(@NotNull com.pubnub.api.java.PubNub pn, @NotNull PNStatus status) { if (status.getCategory() == PNStatusCategory.PNConnectedCategory) { if (status.getAffectedChannels().contains(expectedChannel)) { pubNub.subscribe() diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/HistoryIntegrationTest.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/HistoryIntegrationTest.java index 38578f790..fcfbd9d4b 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/HistoryIntegrationTest.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/HistoryIntegrationTest.java @@ -1,11 +1,11 @@ package com.pubnub.api.integration; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; import com.pubnub.api.crypto.CryptoModule; import com.pubnub.api.integration.util.BaseIntegrationTest; import com.pubnub.api.integration.util.RandomGenerator; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.builder.PubNubErrorBuilder; import com.pubnub.api.models.consumer.PNPublishResult; import com.pubnub.api.models.consumer.history.PNFetchMessageItem; import com.pubnub.api.models.consumer.history.PNFetchMessagesResult; @@ -21,10 +21,10 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -import static com.pubnub.api.builder.PubNubErrorBuilder.PNERROBJ_HISTORY_MESSAGE_ACTIONS_MULTIPLE_CHANNELS; import static com.pubnub.api.integration.util.Utils.publishMixed; import static com.pubnub.api.integration.util.Utils.random; import static com.pubnub.api.integration.util.Utils.randomChannel; +import static com.pubnub.api.java.builder.PubNubErrorBuilder.PNERROBJ_HISTORY_MESSAGE_ACTIONS_MULTIPLE_CHANNELS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -662,7 +662,7 @@ public void testFetchSingleChannel_includeMessageTypeIsFalse() throws PubNubExce assert fetchMessagesResult != null; for (PNFetchMessageItem messageItem : fetchMessagesResult.getChannels().get(expectedChannelName)) { - assertEquals(null, messageItem.getMessageType()); + assertNull(messageItem.getMessageType()); } } } diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/MessageActionsTest.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/MessageActionsTest.java index c30ba3295..e5d4e9422 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/MessageActionsTest.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/MessageActionsTest.java @@ -1,25 +1,21 @@ package com.pubnub.api.integration; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.callbacks.SubscribeCallback; -import com.pubnub.api.endpoints.message_actions.GetMessageActions; import com.pubnub.api.enums.PNStatusCategory; import com.pubnub.api.integration.util.BaseIntegrationTest; import com.pubnub.api.integration.util.RandomGenerator; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; +import com.pubnub.api.java.endpoints.message_actions.GetMessageActions; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembershipResult; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadataResult; import com.pubnub.api.models.consumer.PNPublishResult; import com.pubnub.api.models.consumer.PNStatus; import com.pubnub.api.models.consumer.history.PNFetchMessagesResult; import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult; import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult; import com.pubnub.api.models.consumer.message_actions.PNMessageAction; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; -import com.pubnub.api.models.consumer.pubsub.PNMessageResult; -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; import org.awaitility.Awaitility; import org.awaitility.Durations; @@ -34,18 +30,18 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; -import static com.pubnub.api.builder.PubNubErrorBuilder.PNERROBJ_CHANNEL_MISSING; -import static com.pubnub.api.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_MISSING; -import static com.pubnub.api.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_TIMETOKEN_MISSING; -import static com.pubnub.api.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_TYPE_MISSING; -import static com.pubnub.api.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_VALUE_MISSING; -import static com.pubnub.api.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_TIMETOKEN_MISSING; import static com.pubnub.api.integration.util.Utils.isSorted; import static com.pubnub.api.integration.util.Utils.parseDate; import static com.pubnub.api.integration.util.Utils.publish; import static com.pubnub.api.integration.util.Utils.publishMixed; import static com.pubnub.api.integration.util.Utils.random; import static com.pubnub.api.integration.util.Utils.randomChannel; +import static com.pubnub.api.java.builder.PubNubErrorBuilder.PNERROBJ_CHANNEL_MISSING; +import static com.pubnub.api.java.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_MISSING; +import static com.pubnub.api.java.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_TIMETOKEN_MISSING; +import static com.pubnub.api.java.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_TYPE_MISSING; +import static com.pubnub.api.java.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_VALUE_MISSING; +import static com.pubnub.api.java.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_TIMETOKEN_MISSING; import static junit.framework.TestCase.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -485,11 +481,6 @@ public void testActionReceive() throws PubNubException { final AtomicInteger actionsCount = new AtomicInteger(); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } - @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus pnStatus) { if (pnStatus.getCategory() == PNStatusCategory.PNConnectedCategory) { @@ -509,21 +500,6 @@ public void status(@NotNull PubNub pubnub, @NotNull PNStatus pnStatus) { } } - @Override - public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult pnMessageResult) { - fail(); - } - - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pnPresenceEventResult) { - - } - - @Override - public void signal(@NotNull PubNub pubnub, @NotNull PNSignalResult pnSignalResult) { - fail(); - } - @Override public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { fail(); diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PAMFilesIntegrationTests.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PAMFilesIntegrationTests.java index fc62091a7..ee4b908ee 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PAMFilesIntegrationTests.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PAMFilesIntegrationTests.java @@ -1,9 +1,9 @@ package com.pubnub.api.integration; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; import com.pubnub.api.integration.util.BaseIntegrationTest; import com.pubnub.api.integration.util.ITTestConfig; +import com.pubnub.api.java.PubNub; import com.pubnub.api.models.consumer.files.PNDownloadFileResult; import com.pubnub.api.models.consumer.files.PNFileUploadResult; import org.aeonbits.owner.ConfigFactory; @@ -21,7 +21,7 @@ public class PAMFilesIntegrationTests extends BaseIntegrationTest { //See README.md in integrationTest directory for more info on running integration tests - private static ITTestConfig IT_TEST_CONFIG = ConfigFactory.create(ITTestConfig.class, System.getenv()); + private static final ITTestConfig IT_TEST_CONFIG = ConfigFactory.create(ITTestConfig.class, System.getenv()); private static final String FILENAME = "file.txt"; diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PNConfigurationIntegrationTests.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PNConfigurationIntegrationTests.java index 3505e286f..3aaad6687 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PNConfigurationIntegrationTests.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PNConfigurationIntegrationTests.java @@ -1,12 +1,12 @@ package com.pubnub.api.integration; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; import com.pubnub.api.UserId; import com.pubnub.api.integration.util.ITTestConfig; import com.pubnub.api.integration.util.Utils; -import com.pubnub.api.v2.PNConfiguration; -import com.pubnub.api.v2.PNConfigurationOverride; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.v2.PNConfiguration; +import com.pubnub.api.java.v2.PNConfigurationOverride; import org.aeonbits.owner.ConfigFactory; import org.junit.Assert; import org.junit.Test; diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PresenceEventsIntegrationTests.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PresenceEventsIntegrationTests.java index 1d6af26f4..0b730b70f 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PresenceEventsIntegrationTests.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PresenceEventsIntegrationTests.java @@ -1,18 +1,11 @@ package com.pubnub.api.integration; import com.google.gson.JsonObject; -import com.pubnub.api.PubNub; -import com.pubnub.api.callbacks.SubscribeCallback; import com.pubnub.api.integration.util.BaseIntegrationTest; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; import com.pubnub.api.models.consumer.PNStatus; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; -import com.pubnub.api.models.consumer.pubsub.PNMessageResult; import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; import org.awaitility.Awaitility; import org.jetbrains.annotations.NotNull; import org.junit.Test; @@ -33,21 +26,12 @@ public void testJoinChannel() { final AtomicBoolean success = new AtomicBoolean(false); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { } - @Override - public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { - - } - @Override public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { if (presence.getEvent().equals("join")) { @@ -57,30 +41,7 @@ public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pres } } - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull final PubNub pubnub, @NotNull final PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } + }); subscribeToChannel(pubNub, channel); @@ -96,21 +57,11 @@ public void testLeaveChannel() { final PubNub guestClient = getPubNub(); this.pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } - @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { } - @Override - public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { - - } - @Override public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { if (presence.getEvent().equals("leave")) { @@ -118,31 +69,6 @@ public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pres success.set(true); } } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull PubNub pubNub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); listen(success, () -> { @@ -168,21 +94,12 @@ public void testTimeoutFromChannel() { final int waitTime = 21; pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { } - @Override - public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { - - } - @Override public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { if (presence.getEvent().equals("timeout")) { @@ -190,31 +107,6 @@ public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pres success.set(true); } } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull PubNub pubNub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); subscribeToChannel(pubNub, channel); @@ -236,21 +128,12 @@ public void testStateChangeEvent() { subscribeToChannel(pubNub, channel); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { } - @Override - public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { - - } - @Override public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { if (presence.getEvent().equals("state-change") && presence.getUuid() @@ -261,31 +144,6 @@ public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pres } } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull PubNub pubNub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); pubNub.setPresenceState() diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PresenceIntegrationTests.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PresenceIntegrationTests.java index 0f99b4c1a..66767d462 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PresenceIntegrationTests.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PresenceIntegrationTests.java @@ -1,17 +1,17 @@ package com.pubnub.api.integration; import com.google.gson.JsonObject; -import com.pubnub.api.PubNub; -import com.pubnub.api.callbacks.SubscribeCallback; import com.pubnub.api.enums.PNHeartbeatNotificationOptions; import com.pubnub.api.enums.PNStatusCategory; import com.pubnub.api.integration.util.BaseIntegrationTest; import com.pubnub.api.integration.util.RandomGenerator; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; +import com.pubnub.api.java.v2.callbacks.EventListener; import com.pubnub.api.models.consumer.PNStatus; import com.pubnub.api.models.consumer.presence.PNHereNowChannelData; import com.pubnub.api.models.consumer.presence.PNHereNowOccupantData; import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.v2.callbacks.EventListener; import org.awaitility.Awaitility; import org.awaitility.Durations; import org.hamcrest.core.IsEqual; diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PublishIntegrationTests.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PublishIntegrationTests.java index 238da8828..b79524f62 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PublishIntegrationTests.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/PublishIntegrationTests.java @@ -2,31 +2,24 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; import com.pubnub.api.UserId; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.callbacks.SubscribeCallback; import com.pubnub.api.crypto.CryptoModule; import com.pubnub.api.enums.PNStatusCategory; import com.pubnub.api.integration.util.BaseIntegrationTest; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.callbacks.SubscribeCallback; +import com.pubnub.api.java.v2.PNConfiguration; +import com.pubnub.api.java.v2.PNConfigurationOverride; +import com.pubnub.api.java.v2.entities.Channel; +import com.pubnub.api.java.v2.subscriptions.Subscription; import com.pubnub.api.models.consumer.PNPublishResult; import com.pubnub.api.models.consumer.PNStatus; import com.pubnub.api.models.consumer.history.PNFetchMessagesResult; import com.pubnub.api.models.consumer.history.PNHistoryResult; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; import com.pubnub.api.models.consumer.pubsub.PNMessageResult; -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; -import com.pubnub.api.v2.PNConfiguration; -import com.pubnub.api.v2.PNConfigurationOverride; import com.pubnub.api.v2.callbacks.Result; -import com.pubnub.api.v2.entities.Channel; -import com.pubnub.api.v2.subscriptions.Subscription; import org.awaitility.Awaitility; import org.awaitility.Durations; import org.hamcrest.Matchers; @@ -267,10 +260,6 @@ public void testReceiveMessage() { final PubNub observer = getPubNub(); this.pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { @@ -292,35 +281,6 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { success.set(true); } - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { - - } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull PubNub pubNub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); subscribeToChannel(pubNub, expectedChannel); @@ -338,11 +298,6 @@ public void testReceiveUnencryptedMessageWithCryptoDoesntCrash() { final PubNub observer = getPubNub(builder -> builder.cryptoModule(CryptoModule.createAesCbcCryptoModule("test", false))); observer.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } - @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { if (status.getCategory() == PNStatusCategory.PNConnectedCategory) { @@ -381,35 +336,6 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { } } - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { - - } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull PubNub pubNub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); subscribeToChannel(observer, expectedChannel); @@ -477,10 +403,7 @@ public void testOrgJsonObject_Get_Receive() throws PubNubException { final AtomicBoolean success = new AtomicBoolean(); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus pnStatus) { @@ -498,37 +421,6 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult pnMessageRe e.printStackTrace(); } } - - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pnPresenceEventResult) { - - } - - @Override - public void signal(@NotNull PubNub pubnub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - - @Override - public void membership(@NotNull PubNub pubnub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnMessageActionResult) { - - } }); pubNub.subscribe() @@ -552,10 +444,7 @@ public void testOrgJsonObject_Post_Receive() throws PubNubException { final AtomicBoolean success = new AtomicBoolean(); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus pnStatus) { @@ -573,37 +462,6 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult pnMessageRe e.printStackTrace(); } } - - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pnPresenceEventResult) { - - } - - @Override - public void signal(@NotNull PubNub pubnub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - - @Override - public void membership(@NotNull PubNub pubnub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnMessageActionResult) { - - } }); pubNub.subscribe() @@ -691,10 +549,7 @@ public void testOrgJsonArray_Get_Receive() throws PubNubException { final AtomicBoolean success = new AtomicBoolean(); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus pnStatus) { @@ -712,37 +567,6 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult pnMessageRe e.printStackTrace(); } } - - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pnPresenceEventResult) { - - } - - @Override - public void signal(@NotNull PubNub pubnub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - - @Override - public void membership(@NotNull PubNub pubnub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnMessageActionResult) { - - } }); pubNub.subscribe() @@ -771,10 +595,7 @@ public void testOrgJsonArray_Post_Receive() throws PubNubException { final AtomicBoolean success = new AtomicBoolean(); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus pnStatus) { @@ -792,36 +613,6 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult pnMessageRe e.printStackTrace(); } } - - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pnPresenceEventResult) { - - } - - @Override - public void signal(@NotNull PubNub pubnub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull final PubNub pubnub, @NotNull final PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnMessageActionResult) { - - } }); pubNub.subscribe() @@ -860,10 +651,7 @@ public void testOrgJson_Combo() throws PubNubException, JSONException { final AtomicInteger count = new AtomicInteger(); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus pnStatus) { @@ -881,36 +669,6 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult pnMessageRe e.printStackTrace(); } } - - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pnPresenceEventResult) { - - } - - @Override - public void signal(@NotNull PubNub pubnub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull PubNub pubnub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnMessageActionResult) { - - } }); pubNub.subscribe() diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/RetryConfigurationIntegrationTest.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/RetryConfigurationIntegrationTest.java index ed4fbd1e4..067af7cb7 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/RetryConfigurationIntegrationTest.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/RetryConfigurationIntegrationTest.java @@ -1,23 +1,23 @@ package com.pubnub.api.integration; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; import com.pubnub.api.enums.PNStatusCategory; import com.pubnub.api.integration.util.BaseIntegrationTest; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.v2.callbacks.StatusListener; import com.pubnub.api.models.consumer.PNStatus; import com.pubnub.api.retry.RetryConfiguration; import com.pubnub.api.retry.RetryableEndpointGroup; -import com.pubnub.api.v2.callbacks.StatusListener; import org.jetbrains.annotations.NotNull; import org.junit.Test; import java.util.ArrayList; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import static com.pubnub.api.integration.util.Utils.randomChannel; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertSame; public class RetryConfigurationIntegrationTest extends BaseIntegrationTest { @Test @@ -33,12 +33,12 @@ public void whenRetryConfigurationIsDefinedShouldGetProperStatus() throws Interr pubNub.addListener(new StatusListener() { @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus pnStatus) { - assertTrue(pnStatus.getCategory() == PNStatusCategory.PNConnectionError); + assertSame(pnStatus.getCategory(), PNStatusCategory.PNConnectionError); success.set(true); } }); - pubNub.subscribe().channels(Arrays.asList(randomChannel())).execute(); + pubNub.subscribe().channels(Collections.singletonList(randomChannel())).execute(); Thread.sleep(10000); } diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/SignalIntegrationTests.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/SignalIntegrationTests.java index 466943224..07ec64262 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/SignalIntegrationTests.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/SignalIntegrationTests.java @@ -1,25 +1,17 @@ package com.pubnub.api.integration; import com.google.gson.Gson; -import com.pubnub.api.PNConfiguration; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; import com.pubnub.api.UserId; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.callbacks.SubscribeCallback; import com.pubnub.api.enums.PNStatusCategory; import com.pubnub.api.integration.util.BaseIntegrationTest; import com.pubnub.api.integration.util.RandomGenerator; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.callbacks.SubscribeCallback; import com.pubnub.api.models.consumer.PNPublishResult; import com.pubnub.api.models.consumer.PNStatus; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; -import com.pubnub.api.models.consumer.pubsub.PNMessageResult; -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; import org.awaitility.Awaitility; import org.awaitility.Durations; import org.jetbrains.annotations.NotNull; @@ -77,16 +69,13 @@ public void testReceiveSignalMessage() { final String expectedChannel = randomChannel(); final String expectedPayload = RandomGenerator.newValue(5); - final PubNub observerClient = getPubNub(); + final com.pubnub.api.java.PubNub observerClient = getPubNub(); observerClient.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - } @Override - public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { + public void status(@NotNull com.pubnub.api.java.PubNub pubnub, @NotNull PNStatus status) { if (status.getCategory() == PNStatusCategory.PNConnectedCategory) { if (status.getAffectedChannels().contains(expectedChannel)) { pubNub.signal() @@ -101,42 +90,12 @@ public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { } @Override - public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { - - } - - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { - - } - - @Override - public void signal(@NotNull PubNub pubnub, @NotNull PNSignalResult signal) { + public void signal(@NotNull com.pubnub.api.java.PubNub pubnub, @NotNull PNSignalResult signal) { assertEquals(pubNub.getConfiguration().getUserId().getValue(), signal.getPublisher()); assertEquals(expectedChannel, signal.getChannel()); assertEquals(expectedPayload, new Gson().fromJson(signal.getMessage(), String.class)); success.set(true); } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull final PubNub pubnub, @NotNull final PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); observerClient.subscribe() @@ -174,11 +133,9 @@ public void testPublishSignalMessageSyncWithoutMessage() { public void testPublishSignalMessageSyncWithoutSubKey() { try { // pubNub.getConfiguration().setSubscribeKey(null); - PubNub pubNub1 = PubNub.create(new PNConfiguration(new UserId(random()))); + PubNub pubNub1 = PubNub.create(com.pubnub.api.java.v2.PNConfiguration.builder(new UserId(random()), "").build()); - pubNub1.signal() - .channel(randomChannel()) - .message(random()) + pubNub1.signal(randomChannel(), random()) .sync(); } catch (PubNubException e) { assertEquals(PubNubErrorBuilder.PNERROBJ_SUBSCRIBE_KEY_MISSING.getMessage(), e.getPubnubError() diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/StreamFilteringIntegrationTests.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/StreamFilteringIntegrationTests.java index 69d219f29..7d5e40a56 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/StreamFilteringIntegrationTests.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/StreamFilteringIntegrationTests.java @@ -1,17 +1,10 @@ package com.pubnub.api.integration; -import com.pubnub.api.PubNub; -import com.pubnub.api.callbacks.SubscribeCallback; import com.pubnub.api.integration.util.BaseIntegrationTest; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; import com.pubnub.api.models.consumer.PNStatus; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; import com.pubnub.api.models.consumer.pubsub.PNMessageResult; -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; import org.awaitility.Awaitility; import org.jetbrains.annotations.NotNull; import org.junit.Test; @@ -66,11 +59,6 @@ public void testSubscribeWithLanguageFiltering() { subscribeToChannel(pubNub, channel); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } - @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { @@ -81,36 +69,6 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { assertTrue(message.getMessage().toString().contains(messageEnglish)); success.set(true); } - - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { - - } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull final PubNub pubnub, @NotNull final PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); publishMessage(pubNub, channel, messageFrench, metaFrench); @@ -129,10 +87,7 @@ public void testSubscribeWithMultipleLanguageFiltering() { subscribeToChannel(pubNub, channel); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { @@ -146,35 +101,6 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { assertFalse(message.getMessage().toString().contains("spanish")); } - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { - - } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull PubNub pubNub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); publishMessage(pubNub, channel, messageFrench, metaFrench); @@ -196,10 +122,6 @@ public void testSubscribeWithLanguageNegationFiltering() { subscribeToChannel(pubNub, channel); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { @@ -212,35 +134,6 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { assertFalse(message.getMessage().toString().contains("english")); } - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { - - } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull PubNub pubNub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); publishMessage(pubNub, channel, messageFrench, metaFrench); @@ -262,10 +155,6 @@ public void testSubscribeWithGreaterThanFiltering() { subscribeToChannel(pubNub, channel); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { @@ -279,35 +168,6 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { assertFalse(message.getMessage().toString().contains("35")); } - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { - - } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull PubNub pubNub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); final String messageTemp25 = "This is just message for today temperature : 25"; @@ -335,10 +195,7 @@ public void testSubscribeWithLikeFiltering() { final Map metaMessage_2_Part = getMetaLikeFilter(messageSuccess); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { @@ -347,43 +204,11 @@ public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { @Override public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { - boolean correctMessage = false; - if (message.getMessage().toString().contains("success")) { - correctMessage = true; - } + boolean correctMessage = message.getMessage().toString().contains("success"); assertTrue(correctMessage); success.set(true); } - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { - - } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull PubNub pubNub, @NotNull PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); publishMessage(pubNub, channel, messageBoring, metaMessage_1_Part); diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/SubscribeIntegrationTests.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/SubscribeIntegrationTests.java index f3cdbe382..ea01a4c72 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/SubscribeIntegrationTests.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/SubscribeIntegrationTests.java @@ -1,30 +1,25 @@ package com.pubnub.api.integration; import com.google.gson.JsonObject; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.callbacks.SubscribeCallback; import com.pubnub.api.integration.util.BaseIntegrationTest; import com.pubnub.api.integration.util.RandomGenerator; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership; +import com.pubnub.api.java.v2.callbacks.handlers.OnMessageHandler; +import com.pubnub.api.java.v2.entities.Channel; +import com.pubnub.api.java.v2.entities.ChannelMetadata; +import com.pubnub.api.java.v2.entities.UserMetadata; +import com.pubnub.api.java.v2.subscriptions.Subscription; +import com.pubnub.api.java.v2.subscriptions.SubscriptionSet; import com.pubnub.api.models.consumer.PNPublishResult; import com.pubnub.api.models.consumer.PNStatus; import com.pubnub.api.models.consumer.message_actions.PNMessageAction; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; import com.pubnub.api.models.consumer.pubsub.PNMessageResult; import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; -import com.pubnub.api.v2.callbacks.handlers.OnMessageHandler; -import com.pubnub.api.v2.entities.Channel; -import com.pubnub.api.v2.entities.ChannelMetadata; -import com.pubnub.api.v2.entities.UserMetadata; -import com.pubnub.api.v2.subscriptions.Subscription; import com.pubnub.api.v2.subscriptions.SubscriptionOptions; -import com.pubnub.api.v2.subscriptions.SubscriptionSet; +import org.awaitility.Durations; import org.jetbrains.annotations.NotNull; import org.junit.Test; @@ -99,11 +94,6 @@ public void testWildcardSubscribe() { subscribeToChannel(mGuestClient, "my.test"); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } - @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { @@ -114,36 +104,7 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { assertTrue(message.getMessage().toString().contains("Cool message")); success.set(true); } - - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { - - } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull final PubNub pubnub, @NotNull final PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } + }); publishMessage(mGuestClient, "my.test", "Cool message!"); @@ -160,10 +121,7 @@ public void testUnsubscribeFromChannel() { subscribeToChannel(pubNub, expectedChannel); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - } @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { @@ -188,36 +146,11 @@ public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { success.set(true); } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull final PubNub pubnub, @NotNull final PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } }); unsubscribeFromChannel(pubNub, expectedChannel); - listen(success); + listen(success, Durations.TEN_SECONDS); } @Test @@ -302,7 +235,7 @@ public void testAssignBehaviourForUuidMetadataUsingChannelObject() throws PubNub Thread.sleep(2000); // to get event related to uuidMetadata changes we need to add this uuid to channel that we subscribed to. - pubNub.setMemberships().channelMemberships(Arrays.asList(PNChannelMembership.channel(channel.getName()))).sync(); + pubNub.setMemberships().channelMemberships(Collections.singletonList(PNChannelMembership.channel(channel.getName()))).sync(); pubNub.setUUIDMetadata().name("uuid name").sync(); Thread.sleep(1000); @@ -330,7 +263,7 @@ public void testAssignBehaviourForUuidMetadataUsingUserMetadataObject() throws P Thread.sleep(2000); // to get event related to uuidMetadata changes we need to add this uuid to channel that we subscribed to. - pubNub.setMemberships().channelMemberships(Arrays.asList(PNChannelMembership.channel(channelName))).sync(); + pubNub.setMemberships().channelMemberships(Collections.singletonList(PNChannelMembership.channel(channelName))).sync(); pubNub.setUUIDMetadata().name("uuid name").sync(); Thread.sleep(1000); @@ -386,7 +319,7 @@ public void testAssigningEventBehaviourToSubscription() throws InterruptedExcept PNMessageAction pnMessageAction = new PNMessageAction().setType("reaction").setValue(RandomGenerator.emoji()).setMessageTimetoken(pnPublishResult01.getTimetoken()); pubNub.addMessageAction().messageAction(pnMessageAction).channel(chan01.getName()).sync(); pubNub.setChannelMetadata().channel(chan01.getName()).name("Channel name").description("-=desc").status("active").type("Chat").sync(); - pubNub.setMemberships().channelMemberships(Arrays.asList(PNChannelMembership.channel(chan01.getName()))).sync(); + pubNub.setMemberships().channelMemberships(Collections.singletonList(PNChannelMembership.channel(chan01.getName()))).sync(); pubNub.sendFile().channel(chan01.getName()).fileName(random()).inputStream(inputStream).message("message").sync(); Thread.sleep(1000); @@ -413,7 +346,7 @@ public void testAssigningEventBehaviourToSubscription() throws InterruptedExcept pnMessageAction = new PNMessageAction().setType("reaction02").setValue(RandomGenerator.emoji()).setMessageTimetoken(pnPublishResult02.getTimetoken()); pubNub.addMessageAction().messageAction(pnMessageAction).channel(chan01.getName()).sync(); pubNub.setChannelMetadata().channel(chan01.getName()).name("Channel name").description("desc").status("active").type("Chat").sync(); - pubNub.setMemberships().channelMemberships(Arrays.asList(PNChannelMembership.channel(chan01.getName()))).uuid("differentUUID").sync(); + pubNub.setMemberships().channelMemberships(Collections.singletonList(PNChannelMembership.channel(chan01.getName()))).uuid("differentUUID").sync(); pubNub.sendFile().channel(chan01.getName()).fileName(random()).inputStream(inputStream).message("message").sync(); Thread.sleep(1000); diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java index ccc2f5792..ffc3d91e2 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java @@ -1,11 +1,12 @@ package com.pubnub.api.integration.managers.subscription; -import com.pubnub.api.PNConfiguration; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; import com.pubnub.api.UserId; import com.pubnub.api.enums.PNStatusCategory; import com.pubnub.api.integration.util.ITTestConfig; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; +import com.pubnub.api.java.v2.PNConfiguration; import com.pubnub.api.models.consumer.PNStatus; import org.aeonbits.owner.ConfigFactory; import org.jetbrains.annotations.NotNull; @@ -36,7 +37,7 @@ import static org.mockito.Mockito.verify; class AssumingProperConfig implements TestRule { - private ITTestConfig itPamTestConfig = ConfigFactory.create(ITTestConfig.class, System.getenv()); + private final ITTestConfig itPamTestConfig = ConfigFactory.create(ITTestConfig.class, System.getenv()); @NotNull @Override @@ -62,7 +63,7 @@ public abstract class AbstractReconnectionProblemIT { protected static final int SUBSCRIBE_TIMEOUT = 5; protected final List collectedStatuses = Collections.synchronizedList(new ArrayList<>()); - protected PubNub pn; + protected com.pubnub.api.java.PubNub pn; protected String authKey = randomId(); @@ -71,7 +72,7 @@ private static String randomId() { } private void grantAccess(final String... protectedChannelNames) throws PubNubException { - final PubNub pnAdmin = adminPubNub(); + final com.pubnub.api.java.PubNub pnAdmin = adminPubNub(); pnAdmin.grant() .authKeys(singletonList(authKey)) .channels(asList(protectedChannelNames)) @@ -80,7 +81,7 @@ private void grantAccess(final String... protectedChannelNames) throws PubNubExc } private void grantAccessToChannelGroup(final String... protectedChannelGroupNames) throws PubNubException { - final PubNub pnAdmin = adminPubNub(); + final com.pubnub.api.java.PubNub pnAdmin = adminPubNub(); pnAdmin.grant() .authKeys(singletonList(authKey)) .channelGroups(asList(protectedChannelGroupNames)) @@ -99,22 +100,22 @@ public void disconnectClients() { pn = null; } - protected void subscribe(final PubNub pnClient, final boolean reportCallStack, final String... channels) { + protected void subscribe(final com.pubnub.api.java.PubNub pnClient, final boolean reportCallStack, final String... channels) { subscribe(pnClient, reportCallStack, null, channels); } - protected void subscribe(final PubNub pnClient, final String... channelNames) { + protected void subscribe(final com.pubnub.api.java.PubNub pnClient, final String... channelNames) { subscribe(pnClient, false, null, channelNames); } - protected void subscribe(final PubNub pnClient, final BiConsumer block, final String... channels) { + protected void subscribe(final com.pubnub.api.java.PubNub pnClient, final BiConsumer block, final String... channels) { subscribe(pnClient, false, block, channels); } - protected void subscribe(final PubNub pnClient, boolean reportCallStack, final BiConsumer block, final String... channels) { - pnClient.addListener(new SubscribeCallbackAdapter() { + protected void subscribe(final com.pubnub.api.java.PubNub pnClient, boolean reportCallStack, final BiConsumer block, final String... channels) { + pnClient.addListener(new SubscribeCallback() { @Override - public void status(final PubNub pubnub, final PNStatus pnStatus) { + public void status(final com.pubnub.api.java.PubNub pubnub, final PNStatus pnStatus) { final Exception exception = new Exception(); synchronized (collectedStatuses) { collectedStatuses.add(new CollectedStatus(pnStatus, exception)); @@ -127,7 +128,7 @@ public void status(final PubNub pubnub, final PNStatus pnStatus) { exception.printStackTrace(System.out); } if (block != null) { - block.accept(pubnub, pnStatus); + block.accept(pnClient, pnStatus); } } }); @@ -135,20 +136,20 @@ public void status(final PubNub pubnub, final PNStatus pnStatus) { pnClient.subscribe().channels(asList(channels)).execute(); } - protected void subscribeToGroup(final PubNub pnClient, final boolean reportCallStack, final String... channelGroups) { + protected void subscribeToGroup(final com.pubnub.api.java.PubNub pnClient, final boolean reportCallStack, final String... channelGroups) { subscribeToGroup(pnClient, reportCallStack, null, channelGroups); } - protected void subscribeToGroup(final PubNub pnClient, final String... channelGroups) { + protected void subscribeToGroup(final com.pubnub.api.java.PubNub pnClient, final String... channelGroups) { subscribeToGroup(pnClient, false, null, channelGroups); } - protected void subscribeToGroup(final PubNub pnClient, final BiConsumer block, final String... channelGroups) { + protected void subscribeToGroup(final com.pubnub.api.java.PubNub pnClient, final BiConsumer block, final String... channelGroups) { subscribeToGroup(pnClient, false, block, channelGroups); } - protected void subscribeToGroup(final PubNub pnClient, boolean reportCallStack, final BiConsumer block, final String... channelGroups) { - pnClient.addListener(new SubscribeCallbackAdapter() { + protected void subscribeToGroup(final com.pubnub.api.java.PubNub pnClient, boolean reportCallStack, final BiConsumer block, final String... channelGroups) { + pnClient.addListener(new SubscribeCallback() { @Override public void status(final PubNub pubnub, final PNStatus pnStatus) { final Exception exception = new Exception(); @@ -164,7 +165,7 @@ public void status(final PubNub pubnub, final PNStatus pnStatus) { exception.printStackTrace(System.out); } if (block != null) { - block.accept(pubnub, pnStatus); + block.accept(pnClient, pnStatus); } } }); @@ -175,31 +176,31 @@ public void status(final PubNub pubnub, final PNStatus pnStatus) { } - protected void createChannelGroup(final PubNub pnClient, final String channelGroup, final String... channelNames) throws PubNubException { + protected void createChannelGroup(final com.pubnub.api.java.PubNub pnClient, final String channelGroup, final String... channelNames) throws PubNubException { pnClient.addChannelsToChannelGroup() .channelGroup(channelGroup) .channels(asList(channelNames)) .sync(); } - protected abstract PubNub privilegedClientPubNub(); + protected abstract @NotNull com.pubnub.api.java.PubNub privilegedClientPubNub(); - PNConfiguration getPNConfiguration() { - PNConfiguration pnConfiguration = null; + PNConfiguration.Builder getPNConfiguration() { + PNConfiguration.Builder pnConfiguration = null; try { - pnConfiguration = new PNConfiguration(new UserId("pn-" + UUID.randomUUID())); + pnConfiguration = PNConfiguration.builder(new UserId("pn-" + UUID.randomUUID()), ""); } catch (PubNubException e) { throw new RuntimeException(e); } return pnConfiguration; } - private PubNub adminPubNub() { - PNConfiguration pnConfiguration = getPNConfiguration(); - pnConfiguration.setSubscribeKey(itPamTestConfig.pamSubKey()); - pnConfiguration.setPublishKey(itPamTestConfig.pamPubKey()); - pnConfiguration.setSecretKey(itPamTestConfig.pamSecKey()); - return PubNub.create(pnConfiguration); + private com.pubnub.api.java.PubNub adminPubNub() { + PNConfiguration.Builder pnConfiguration = getPNConfiguration(); + pnConfiguration.subscribeKey(itPamTestConfig.pamSubKey()); + pnConfiguration.publishKey(itPamTestConfig.pamPubKey()); + pnConfiguration.secretKey(itPamTestConfig.pamSecKey()); + return com.pubnub.api.java.PubNub.create(pnConfiguration.build()); } @Test @@ -293,19 +294,16 @@ public void continueSubscriptionToChannelGroupAfterUnsubscribeFromForbiddenChann grantAccessToChannelGroup(channelGroup1); - subscribeToGroup(pn, true, new BiConsumer() { - @Override - public void accept(final PubNub pubNub, final PNStatus status) { - if (status.getCategory() == PNStatusCategory.PNConnectionError) { - if (status.getException().getStatusCode() == 403) { - final List channelGroupsToUnsubscribe = status.getException().getAffectedChannelGroups(); + subscribeToGroup(pn, true, (pubNub, status) -> { + if (status.getCategory() == PNStatusCategory.PNConnectionError) { + if (status.getException().getStatusCode() == 403) { + final List channelGroupsToUnsubscribe = status.getException().getAffectedChannelGroups(); - try { - System.out.println("Unsubscribing from groups: " + channelGroupsToUnsubscribe); - pubNub.unsubscribe().channelGroups(channelGroupsToUnsubscribe).execute(); - } catch (Exception e) { - e.printStackTrace(); - } + try { + System.out.println("Unsubscribing from groups: " + channelGroupsToUnsubscribe); + pn.unsubscribe().channelGroups(channelGroupsToUnsubscribe).execute(); + } catch (Exception e) { + e.printStackTrace(); } } } @@ -334,13 +332,10 @@ public void accept(final PubNub pubNub, final PNStatus status) { public void stopSubscriptionWhenRequestedToDisconnectOnAccessDenied() throws InterruptedException { final String channel = "ch-" + randomId(); - subscribe(pn, true, new BiConsumer() { - @Override - public void accept(final PubNub pubNub, final PNStatus status) { - if (status.getCategory() == PNStatusCategory.PNConnectionError) { - if (status.getException().getStatusCode() == 403) { - pn.disconnect(); - } + subscribe(pn, true, (pubNub, status) -> { + if (status.getCategory() == PNStatusCategory.PNConnectionError) { + if (status.getException().getStatusCode() == 403) { + pn.disconnect(); } } }, channel); @@ -361,13 +356,10 @@ public void accept(final PubNub pubNub, final PNStatus status) { public void stopSubscriptionToChannelGroupWhenRequestedToDisconnectOnAccessDenied() throws InterruptedException { final String channelGroup = "chg-" + randomId(); - subscribeToGroup(pn, true, new BiConsumer() { - @Override - public void accept(final PubNub pubNub, final PNStatus status) { - if (status.getCategory() == PNStatusCategory.PNConnectionError) { - if (status.getException().getStatusCode() == 403) { - pn.disconnect(); - } + subscribeToGroup(pn, true, (pubNub, status) -> { + if (status.getCategory() == PNStatusCategory.PNConnectionError) { + if (status.getException().getStatusCode() == 403) { + pn.disconnect(); } } }, channelGroup); diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/ReconnectionProblemWithReconnectionPolicyIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/ReconnectionProblemWithReconnectionPolicyIT.java index 7e00430b5..d39f04bec 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/ReconnectionProblemWithReconnectionPolicyIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/ReconnectionProblemWithReconnectionPolicyIT.java @@ -1,23 +1,22 @@ package com.pubnub.api.integration.managers.subscription; -import com.pubnub.api.PNConfiguration; -import com.pubnub.api.PubNub; import com.pubnub.api.enums.PNLogVerbosity; - -import static com.pubnub.api.enums.PNReconnectionPolicy.LINEAR; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.v2.PNConfiguration; +import com.pubnub.api.retry.RetryConfiguration; +import org.jetbrains.annotations.NotNull; public class ReconnectionProblemWithReconnectionPolicyIT extends AbstractReconnectionProblemIT { @Override - protected PubNub privilegedClientPubNub() { - PNConfiguration pnConfiguration = getPNConfiguration(); - pnConfiguration.setSubscribeKey(itPamTestConfig.pamSubKey()); - pnConfiguration.setPublishKey(itPamTestConfig.pamPubKey()); - pnConfiguration.setSubscribeTimeout(5); - pnConfiguration.setLogVerbosity(PNLogVerbosity.BODY); - pnConfiguration.setReconnectionPolicy(LINEAR); - pnConfiguration.setMaximumReconnectionRetries(1); - pnConfiguration.setAuthKey(authKey); - return PubNub.create(pnConfiguration); + protected @NotNull PubNub privilegedClientPubNub() { + PNConfiguration.Builder pnConfiguration = getPNConfiguration(); + pnConfiguration.subscribeKey(itPamTestConfig.pamSubKey()); + pnConfiguration.publishKey(itPamTestConfig.pamPubKey()); + pnConfiguration.subscribeTimeout(5); + pnConfiguration.logVerbosity(PNLogVerbosity.BODY); + pnConfiguration.retryConfiguration(new RetryConfiguration.Linear(2, 1)); + pnConfiguration.authKey(authKey); + return PubNub.create(pnConfiguration.build()); } } diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/ReconnectionProblemWithoutReconnectionPolicyIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/ReconnectionProblemWithoutReconnectionPolicyIT.java index 7f9e45ab5..b930df9b4 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/ReconnectionProblemWithoutReconnectionPolicyIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/ReconnectionProblemWithoutReconnectionPolicyIT.java @@ -1,31 +1,31 @@ package com.pubnub.api.integration.managers.subscription; -import com.pubnub.api.PNConfiguration; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; import com.pubnub.api.UserId; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.retry.RetryConfiguration; +import org.jetbrains.annotations.NotNull; import java.util.UUID; import static com.pubnub.api.enums.PNLogVerbosity.BODY; -import static com.pubnub.api.enums.PNReconnectionPolicy.NONE; public class ReconnectionProblemWithoutReconnectionPolicyIT extends AbstractReconnectionProblemIT { @Override - protected PubNub privilegedClientPubNub() { - PNConfiguration pnConfiguration; + protected @NotNull PubNub privilegedClientPubNub() { + com.pubnub.api.java.v2.PNConfiguration.Builder pnConfiguration; try { - pnConfiguration = new PNConfiguration(new UserId("pn-" + UUID.randomUUID())); + pnConfiguration = com.pubnub.api.java.v2.PNConfiguration.builder(new UserId("pn-" + UUID.randomUUID()), ""); } catch (PubNubException e) { throw new RuntimeException(e); } - pnConfiguration.setSubscribeKey(itPamTestConfig.pamSubKey()); - pnConfiguration.setPublishKey(itPamTestConfig.pamPubKey()); - pnConfiguration.setSubscribeTimeout(SUBSCRIBE_TIMEOUT); - pnConfiguration.setLogVerbosity(BODY); - pnConfiguration.setAuthKey(authKey); - pnConfiguration.setReconnectionPolicy(NONE); - return PubNub.create(pnConfiguration); + pnConfiguration.subscribeKey(itPamTestConfig.pamSubKey()); + pnConfiguration.publishKey(itPamTestConfig.pamPubKey()); + pnConfiguration.subscribeTimeout(SUBSCRIBE_TIMEOUT); + pnConfiguration.logVerbosity(BODY); + pnConfiguration.authKey(authKey); + pnConfiguration.retryConfiguration(RetryConfiguration.None.INSTANCE); + return PubNub.create(pnConfiguration.build()); } } diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/SubscribeCallbackAdapter.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/SubscribeCallbackAdapter.java deleted file mode 100644 index 3a07f40f2..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/SubscribeCallbackAdapter.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.pubnub.api.integration.managers.subscription; - -import com.pubnub.api.PubNub; -import com.pubnub.api.callbacks.SubscribeCallback; -import com.pubnub.api.models.consumer.PNStatus; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; -import com.pubnub.api.models.consumer.pubsub.PNMessageResult; -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; - -public class SubscribeCallbackAdapter extends SubscribeCallback { - - @Override - public void status(final PubNub pubnub, final PNStatus pnStatus) { - - } - - @Override - public void message(final PubNub pubnub, final PNMessageResult pnMessageResult) { - - } - - @Override - public void presence(final PubNub pubnub, final PNPresenceEventResult pnPresenceEventResult) { - - } - - @Override - public void signal(final PubNub pubnub, final PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(final PubNub pubnub, final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(final PubNub pubnub, final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(final PubNub pubnub, final PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(final PubNub pubnub, final PNMessageActionResult pnMessageActionResult) { - - } - - @Override - public void file(final PubNub pubnub, final PNFileEventResult pnFileEventResult) { - - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/ObjectsApiBaseIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/ObjectsApiBaseIT.java index 02db7adc4..9193cb1f9 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/ObjectsApiBaseIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/ObjectsApiBaseIT.java @@ -1,11 +1,11 @@ package com.pubnub.api.integration.objects; -import com.pubnub.api.PNConfiguration; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; import com.pubnub.api.UserId; import com.pubnub.api.enums.PNLogVerbosity; import com.pubnub.api.integration.util.ITTestConfig; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.v2.PNConfiguration; import org.aeonbits.owner.ConfigFactory; import org.junit.Before; @@ -17,21 +17,21 @@ public abstract class ObjectsApiBaseIT { //See README.md in integrationTest directory for more info on running integration tests - private ITTestConfig itTestConfig = ConfigFactory.create(ITTestConfig.class, System.getenv()); + private final ITTestConfig itTestConfig = ConfigFactory.create(ITTestConfig.class, System.getenv()); protected final PubNub pubNubUnderTest = pubNub(); private PubNub pubNub() { - PNConfiguration pnConfiguration; + PNConfiguration.Builder pnConfiguration; try { - pnConfiguration = new PNConfiguration(new UserId("pn-" + UUID.randomUUID())); + pnConfiguration = PNConfiguration.builder(new UserId("pn-" + UUID.randomUUID()), ""); } catch (PubNubException e) { throw new RuntimeException(e); } - pnConfiguration.setSubscribeKey(itTestConfig.subscribeKey()); - pnConfiguration.setLogVerbosity(PNLogVerbosity.BODY); + pnConfiguration.subscribeKey(itTestConfig.subscribeKey()); + pnConfiguration.logVerbosity(PNLogVerbosity.BODY); - return PubNub.create(pnConfiguration); + return PubNub.create(pnConfiguration.build()); } @Before diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/ObjectsApiSubscriptionIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/ObjectsApiSubscriptionIT.java index 17a7854f0..ebb713f7c 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/ObjectsApiSubscriptionIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/ObjectsApiSubscriptionIT.java @@ -1,17 +1,12 @@ package com.pubnub.api.integration.objects; -import com.pubnub.api.PubNub; -import com.pubnub.api.callbacks.SubscribeCallback; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembershipResult; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadataResult; import com.pubnub.api.models.consumer.PNStatus; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; -import com.pubnub.api.models.consumer.pubsub.PNMessageResult; -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; import org.jetbrains.annotations.NotNull; import org.junit.Test; @@ -36,38 +31,6 @@ class TestSubscribeCallbackAdapter extends SubscribeCallback { @Override public void status(@NotNull PubNub pubnub, @NotNull PNStatus pnStatus) { } - - @Override - public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult pnMessageResult) { - } - - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pnPresenceEventResult) { - } - - @Override - public void signal(@NotNull PubNub pubnub, @NotNull PNSignalResult pnSignalResult) { - } - - @Override - public void uuid(@NotNull PubNub pubnub, @NotNull PNUUIDMetadataResult pnUUIDMetadataResult) { - } - - @Override - public void channel(@NotNull PubNub pubnub, @NotNull PNChannelMetadataResult pnChannelMetadataResult) { - } - - @Override - public void membership(@NotNull PubNub pubnub, @NotNull PNMembershipResult pnMembershipResult) { - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnMessageActionResult) { - } - - @Override - public void file(@NotNull final PubNub pubnub, @NotNull final PNFileEventResult pnFileEventResult) { - } } @Test diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/channel/ChannelMetadataIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/channel/ChannelMetadataIT.java index d428316c0..0ec0178cd 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/channel/ChannelMetadataIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/channel/ChannelMetadataIT.java @@ -2,11 +2,11 @@ import com.pubnub.api.PubNubException; import com.pubnub.api.integration.objects.ObjectsApiBaseIT; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadata; -import com.pubnub.api.models.consumer.objects_api.channel.PNGetAllChannelsMetadataResult; -import com.pubnub.api.models.consumer.objects_api.channel.PNGetChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.channel.PNRemoveChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.channel.PNSetChannelMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadata; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNGetAllChannelsMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNGetChannelMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNRemoveChannelMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNSetChannelMetadataResult; import org.apache.commons.lang3.RandomStringUtils; import org.apache.http.HttpStatus; import org.jetbrains.annotations.NotNull; diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/ChannelMembersIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/ChannelMembersIT.java index db49c0a4f..416b8b39a 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/ChannelMembersIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/ChannelMembersIT.java @@ -2,13 +2,13 @@ import com.pubnub.api.PubNubException; import com.pubnub.api.integration.objects.ObjectsApiBaseIT; -import com.pubnub.api.models.consumer.objects_api.member.PNGetChannelMembersResult; -import com.pubnub.api.models.consumer.objects_api.member.PNManageChannelMembersResult; -import com.pubnub.api.models.consumer.objects_api.member.PNMembers; -import com.pubnub.api.models.consumer.objects_api.member.PNRemoveChannelMembersResult; -import com.pubnub.api.models.consumer.objects_api.member.PNSetChannelMembersResult; -import com.pubnub.api.models.consumer.objects_api.member.PNUUID; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadata; +import com.pubnub.api.java.models.consumer.objects_api.member.PNGetChannelMembersResult; +import com.pubnub.api.java.models.consumer.objects_api.member.PNManageChannelMembersResult; +import com.pubnub.api.java.models.consumer.objects_api.member.PNMembers; +import com.pubnub.api.java.models.consumer.objects_api.member.PNRemoveChannelMembersResult; +import com.pubnub.api.java.models.consumer.objects_api.member.PNSetChannelMembersResult; +import com.pubnub.api.java.models.consumer.objects_api.member.PNUUID; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadata; import org.apache.http.HttpStatus; import org.junit.After; import org.junit.Test; @@ -26,7 +26,7 @@ import java.util.UUID; import java.util.stream.Collectors; -import static com.pubnub.api.endpoints.objects_api.utils.Include.PNUUIDDetailsLevel.UUID_WITH_CUSTOM; +import static com.pubnub.api.java.endpoints.objects_api.utils.Include.PNUUIDDetailsLevel.UUID_WITH_CUSTOM; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsInAnyOrder; diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/CustomMetadataInMembersPropagationIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/CustomMetadataInMembersPropagationIT.java index 1a6e5d0ca..84fdaba00 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/CustomMetadataInMembersPropagationIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/CustomMetadataInMembersPropagationIT.java @@ -2,10 +2,10 @@ import com.pubnub.api.PubNubException; import com.pubnub.api.integration.objects.ObjectsApiBaseIT; -import com.pubnub.api.models.consumer.objects_api.member.PNGetChannelMembersResult; -import com.pubnub.api.models.consumer.objects_api.member.PNSetChannelMembersResult; -import com.pubnub.api.models.consumer.objects_api.member.PNUUID; -import com.pubnub.api.models.consumer.objects_api.uuid.PNSetUUIDMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.member.PNGetChannelMembersResult; +import com.pubnub.api.java.models.consumer.objects_api.member.PNSetChannelMembersResult; +import com.pubnub.api.java.models.consumer.objects_api.member.PNUUID; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNSetUUIDMetadataResult; import org.junit.After; import org.junit.Test; @@ -14,7 +14,7 @@ import java.util.Map; import java.util.UUID; -import static com.pubnub.api.endpoints.objects_api.utils.Include.PNUUIDDetailsLevel; +import static com.pubnub.api.java.endpoints.objects_api.utils.Include.PNUUIDDetailsLevel; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.hasItem; diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/CustomMetadataInMembershipPropagationIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/CustomMetadataInMembershipPropagationIT.java index 9e4ad1450..bbb444130 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/CustomMetadataInMembershipPropagationIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/CustomMetadataInMembershipPropagationIT.java @@ -1,15 +1,17 @@ package com.pubnub.api.integration.objects.memberships; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.integration.managers.subscription.SubscribeCallbackAdapter; import com.pubnub.api.integration.objects.ObjectsApiBaseIT; -import com.pubnub.api.models.consumer.objects_api.channel.PNSetChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNGetMembershipsResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNSetMembershipResult; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNSetChannelMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNGetMembershipsResult; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembershipResult; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNSetMembershipResult; +import com.pubnub.api.models.consumer.PNStatus; import org.awaitility.core.ThrowingRunnable; +import org.jetbrains.annotations.NotNull; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -21,8 +23,8 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; -import static com.pubnub.api.endpoints.objects_api.utils.Include.PNChannelDetailsLevel.CHANNEL; -import static com.pubnub.api.endpoints.objects_api.utils.Include.PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM; +import static com.pubnub.api.java.endpoints.objects_api.utils.Include.PNChannelDetailsLevel.CHANNEL; +import static com.pubnub.api.java.endpoints.objects_api.utils.Include.PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM; import static org.awaitility.Awaitility.await; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; @@ -48,11 +50,16 @@ public class CustomMetadataInMembershipPropagationIT extends ObjectsApiBaseIT { private PNSetMembershipResult setMembershipResult; - private CopyOnWriteArrayList pnMembershipResults = new CopyOnWriteArrayList<>(); + private final CopyOnWriteArrayList pnMembershipResults = new CopyOnWriteArrayList<>(); @Before public void setCallbackListener() { - pubNubUnderTest.addListener(new SubscribeCallbackAdapter() { + pubNubUnderTest.addListener(new SubscribeCallback() { + @Override + public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { + + } + @Override public void membership(final PubNub pubnub, final PNMembershipResult pnMembershipResult) { pnMembershipResults.add(pnMembershipResult); diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/MembershipIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/MembershipIT.java index 77994a17a..a2be42abd 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/MembershipIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/MembershipIT.java @@ -2,12 +2,12 @@ import com.pubnub.api.PubNubException; import com.pubnub.api.integration.objects.ObjectsApiBaseIT; -import com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNGetMembershipsResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNManageMembershipResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNRemoveMembershipResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNSetMembershipResult; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNGetMembershipsResult; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNManageMembershipResult; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembership; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNRemoveMembershipResult; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNSetMembershipResult; import org.apache.http.HttpStatus; import org.junit.After; import org.junit.Test; @@ -22,7 +22,7 @@ import java.util.Map; import java.util.UUID; -import static com.pubnub.api.endpoints.objects_api.utils.Include.PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM; +import static com.pubnub.api.java.endpoints.objects_api.utils.Include.PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.hasItem; diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/uuid/UUIDMetadataIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/uuid/UUIDMetadataIT.java index bb4127d5c..368914757 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/uuid/UUIDMetadataIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/uuid/UUIDMetadataIT.java @@ -2,10 +2,10 @@ import com.pubnub.api.PubNubException; import com.pubnub.api.integration.objects.ObjectsApiBaseIT; -import com.pubnub.api.models.consumer.objects_api.uuid.PNGetAllUUIDMetadataResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNGetUUIDMetadataResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNRemoveUUIDMetadataResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNSetUUIDMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNGetAllUUIDMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNGetUUIDMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNRemoveUUIDMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNSetUUIDMetadataResult; import org.apache.commons.lang3.RandomStringUtils; import org.apache.http.HttpStatus; import org.junit.After; diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/AccessManagerIntegrationTest.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/AccessManagerIntegrationTest.java index 13f143bcc..929f7ea3b 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/AccessManagerIntegrationTest.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/AccessManagerIntegrationTest.java @@ -2,25 +2,18 @@ import com.google.gson.Gson; import com.google.gson.JsonObject; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.callbacks.SubscribeCallback; -import com.pubnub.api.endpoints.access.Grant; import com.pubnub.api.integration.util.BaseIntegrationTest; import com.pubnub.api.integration.util.RandomGenerator; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; +import com.pubnub.api.java.endpoints.access.Grant; +import com.pubnub.api.java.models.consumer.access_manager.PNAccessManagerGrantResult; import com.pubnub.api.models.consumer.PNPublishResult; import com.pubnub.api.models.consumer.PNStatus; -import com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult; import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult; import com.pubnub.api.models.consumer.message_actions.PNMessageAction; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; -import com.pubnub.api.models.consumer.pubsub.PNMessageResult; import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; import org.awaitility.Awaitility; import org.awaitility.Durations; import org.awaitility.pollinterval.FibonacciPollInterval; @@ -555,21 +548,13 @@ public void testPresenceWithPermission() { requestAccess(READ); pubNub.addListener(new SubscribeCallback() { - @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - } @Override public void status(@NotNull PubNub pubNub, @NotNull PNStatus pnStatus) { } - @Override - public void message(@NotNull PubNub pubNub, @NotNull PNMessageResult pnMessageResult) { - - } - @Override public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pnPresenceEventResult) { if ((pnPresenceEventResult.getEvent().equals("join")) @@ -580,31 +565,6 @@ public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult pnPr } } - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull final PubNub pubnub, @NotNull final PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } - }); subscribeToChannel(pubNub, expectedChannel); diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/GrantIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/GrantIT.java index d9de841d1..35f1d6554 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/GrantIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/GrantIT.java @@ -2,8 +2,8 @@ import com.pubnub.api.PubNubException; import com.pubnub.api.integration.util.BaseIntegrationTest; -import com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult; -import com.pubnub.api.models.consumer.access_manager.PNAccessManagerKeyData; +import com.pubnub.api.java.models.consumer.access_manager.PNAccessManagerGrantResult; +import com.pubnub.api.java.models.consumer.access_manager.PNAccessManagerKeyData; import org.junit.Test; import java.util.Collections; diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/GrantTokenIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/GrantTokenIT.java index be747c316..84e177bdb 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/GrantTokenIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/pam/GrantTokenIT.java @@ -1,15 +1,15 @@ package com.pubnub.api.integration.pam; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.SpaceId; import com.pubnub.api.UserId; import com.pubnub.api.enums.PNLogVerbosity; import com.pubnub.api.integration.util.BaseIntegrationTest; -import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions; -import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions; -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant; -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.SpaceId; +import com.pubnub.api.java.models.consumer.access_manager.sum.SpacePermissions; +import com.pubnub.api.java.models.consumer.access_manager.sum.UserPermissions; +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGrant; +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGroupGrant; import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult; import com.pubnub.api.models.consumer.access_manager.v3.PNToken; import org.junit.Test; diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/BaseIntegrationTest.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/BaseIntegrationTest.java index 9f33e6b25..97320f0d8 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/BaseIntegrationTest.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/BaseIntegrationTest.java @@ -1,23 +1,15 @@ package com.pubnub.api.integration.util; import com.google.gson.JsonObject; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubError; import com.pubnub.api.PubNubException; import com.pubnub.api.UserId; -import com.pubnub.api.callbacks.SubscribeCallback; import com.pubnub.api.enums.PNLogVerbosity; import com.pubnub.api.enums.PNStatusCategory; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.callbacks.SubscribeCallback; +import com.pubnub.api.java.v2.PNConfiguration; import com.pubnub.api.models.consumer.PNStatus; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; -import com.pubnub.api.models.consumer.pubsub.PNMessageResult; -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; -import com.pubnub.api.v2.PNConfiguration; import okhttp3.logging.HttpLoggingInterceptor; import org.aeonbits.owner.ConfigFactory; import org.awaitility.Awaitility; @@ -33,6 +25,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.time.Duration; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -57,13 +50,13 @@ public abstract class BaseIntegrationTest { private static String PAM_PUB_KEY; private static String PAM_SEC_KEY; - public PubNub pubNub; - public PubNub server; + public com.pubnub.api.java.PubNub pubNub; + public com.pubnub.api.java.PubNub server; public int TIMEOUT_MEDIUM = 5; public int TIMEOUT_LOW = 2; - private List mGuestClients = new ArrayList<>(); + private List mGuestClients = new ArrayList<>(); @BeforeClass public static void onlyOnce() { @@ -90,34 +83,34 @@ public void after() { onAfter(); destroyClient(pubNub); if (mGuestClients != null) { - for (PubNub guestClient : mGuestClients) { + for (com.pubnub.api.java.PubNub guestClient : mGuestClients) { destroyClient(guestClient); } } // properties.clear(); } - public PubNub getPubNub(@Nullable Consumer action) { + public com.pubnub.api.java.PubNub getPubNub(@Nullable Consumer action) { PNConfiguration pnConfiguration = provideStagingConfiguration(action); if (pnConfiguration == null) { pnConfiguration = getBasicPnConfiguration(action); } - final PubNub pubNub = PubNub.create(pnConfiguration); + final com.pubnub.api.java.PubNub pubNub = com.pubnub.api.java.PubNub.create(pnConfiguration); registerGuestClient(pubNub); return pubNub; } - public PubNub getPubNub() { + public com.pubnub.api.java.PubNub getPubNub() { return getPubNub(null); } - protected PubNub getServer(@Nullable Consumer action) { - final PubNub pubNub = PubNub.create(getServerPnConfiguration(action)); + protected com.pubnub.api.java.PubNub getServer(@Nullable Consumer action) { + final com.pubnub.api.java.PubNub pubNub = com.pubnub.api.java.PubNub.create(getServerPnConfiguration(action)); registerGuestClient(pubNub); return pubNub; } - public PubNub getServer() { + public com.pubnub.api.java.PubNub getServer() { return getServer(null); } @@ -127,26 +120,26 @@ public PubNub getServer() { // return pubNub; // } - protected void registerGuestClient(PubNub guestClient) { + protected void registerGuestClient(com.pubnub.api.java.PubNub guestClient) { if (mGuestClients == null) { mGuestClients = new ArrayList<>(); } mGuestClients.add(guestClient); } - protected void destroyClient(PubNub client) { + protected void destroyClient(com.pubnub.api.java.PubNub client) { client.unsubscribeAll(); client.forceDestroy(); } private PNConfiguration getBasicPnConfiguration(@Nullable Consumer action) { - final com.pubnub.api.v2.PNConfiguration.Builder pnConfiguration; + final com.pubnub.api.java.v2.PNConfiguration.Builder pnConfiguration; try { if (!needsServer()) { - pnConfiguration = com.pubnub.api.v2.PNConfiguration.builder(new UserId("client-".concat(UUID.randomUUID().toString())), SUB_KEY); + pnConfiguration = com.pubnub.api.java.v2.PNConfiguration.builder(new UserId("client-".concat(UUID.randomUUID().toString())), SUB_KEY); pnConfiguration.publishKey(PUB_KEY); } else { - pnConfiguration = com.pubnub.api.v2.PNConfiguration.builder(new UserId("client-".concat(UUID.randomUUID().toString())), PAM_SUB_KEY); + pnConfiguration = com.pubnub.api.java.v2.PNConfiguration.builder(new UserId("client-".concat(UUID.randomUUID().toString())), PAM_SUB_KEY); pnConfiguration.publishKey(PAM_PUB_KEY); pnConfiguration.authKey(provideAuthKey()); } @@ -184,7 +177,7 @@ private HttpLoggingInterceptor createInterceptor() { return interceptor; } - protected void subscribeToChannel(@NotNull PubNub pubnub, @NotNull String... channels) { + protected void subscribeToChannel(@NotNull com.pubnub.api.java.PubNub pubnub, @NotNull String... channels) { pubnub.subscribe() .channels(Arrays.asList(channels)) .withPresence() @@ -192,18 +185,13 @@ protected void subscribeToChannel(@NotNull PubNub pubnub, @NotNull String... cha pause(1); } - protected void subscribeToChannel(final PubNub pubnub, final List channels) { + protected void subscribeToChannel(final com.pubnub.api.java.PubNub pubnub, final List channels) { final AtomicBoolean subscribeSuccess = new AtomicBoolean(); pubnub.addListener(new SubscribeCallback() { @Override - public void file(@NotNull PubNub pubnub, @NotNull PNFileEventResult pnFileEventResult) { - - } - - @Override - public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { + public void status(@NotNull com.pubnub.api.java.PubNub pubnub, @NotNull PNStatus status) { if (status.getCategory() == PNStatusCategory.PNConnectedCategory) { if (status.getAffectedChannels().containsAll(channels)) { subscribeSuccess.set(true); @@ -214,42 +202,6 @@ public void status(@NotNull PubNub pubnub, @NotNull PNStatus status) { } } } - - @Override - public void message(@NotNull PubNub pubnub, @NotNull PNMessageResult message) { - - } - - @Override - public void presence(@NotNull PubNub pubnub, @NotNull PNPresenceEventResult presence) { - - } - - @Override - public void signal(@NotNull PubNub pubNub, @NotNull PNSignalResult pnSignalResult) { - - } - - @Override - public void uuid(@NotNull final PubNub pubnub, @NotNull final PNUUIDMetadataResult pnUUIDMetadataResult) { - - } - - @Override - public void channel(@NotNull final PubNub pubnub, @NotNull final PNChannelMetadataResult pnChannelMetadataResult) { - - } - - @Override - public void membership(@NotNull final PubNub pubnub, @NotNull final PNMembershipResult pnMembershipResult) { - - } - - @Override - public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult pnActionResult) { - - } - }); pubnub.subscribe() @@ -260,7 +212,7 @@ public void messageAction(@NotNull PubNub pubnub, @NotNull PNMessageActionResult Awaitility.await().atMost(Durations.TEN_SECONDS).untilTrue(subscribeSuccess); } - protected void subscribeToChannelGroup(@NotNull PubNub pubnub, @NotNull String group) { + protected void subscribeToChannelGroup(@NotNull com.pubnub.api.java.PubNub pubnub, @NotNull String group) { pubnub.subscribe() .channelGroups(Collections.singletonList(group)) .withPresence() @@ -268,19 +220,19 @@ protected void subscribeToChannelGroup(@NotNull PubNub pubnub, @NotNull String g pause(1); } - protected void unsubscribeFromChannel(PubNub pubNub, String channel) { + protected void unsubscribeFromChannel(com.pubnub.api.java.PubNub pubNub, String channel) { pubNub.unsubscribe() .channels(Collections.singletonList(channel)) .execute(); pause(1); } - protected void unsubscribeFromAllChannels(PubNub pubNub) { + protected void unsubscribeFromAllChannels(com.pubnub.api.java.PubNub pubNub) { pubNub.unsubscribeAll(); pause(1); } - protected Map generateMessage(PubNub pubNub, String message) { + protected Map generateMessage(com.pubnub.api.java.PubNub pubNub, String message) { final Map map = new HashMap<>(); map.put("publisher", pubNub.getConfiguration().getUserId().getValue()); map.put("text", "mymsg" + RandomGenerator.newValue(5) + "+" + RandomGenerator.newValue(5)); @@ -325,7 +277,7 @@ protected HashMap generateMap() { return map; } - protected void publishMessage(PubNub pubNub, String channel, String message) { + protected void publishMessage(com.pubnub.api.java.PubNub pubNub, String channel, String message) { pubNub.publish() .message(generateMessage(pubNub, message)) .channel(channel) @@ -335,7 +287,7 @@ protected void publishMessage(PubNub pubNub, String channel, String message) { }); } - protected void publishMessage(PubNub pubNub, String channel, String message, Map meta) { + protected void publishMessage(com.pubnub.api.java.PubNub pubNub, String channel, String message, Map meta) { pubNub.publish() .message(generateMessage(pubNub, message)) .channel(channel) @@ -348,7 +300,7 @@ protected void publishMessage(PubNub pubNub, String channel, String message, Map protected void pause(int seconds) { try { - Thread.sleep(seconds * 1_000); + Thread.sleep(seconds * 1_000L); } catch (InterruptedException e) { e.printStackTrace(); } @@ -364,6 +316,12 @@ protected void listen(AtomicBoolean success) { .with() .untilTrue(success); } + protected void listen(AtomicBoolean success, Duration timeout) { + Awaitility.await() + .atMost(timeout) + .with() + .untilTrue(success); + } protected void listen(AtomicBoolean success, Callable callable) { Awaitility.await() diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/RandomGenerator.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/RandomGenerator.java index 1f39b9df6..2315324d6 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/RandomGenerator.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/RandomGenerator.java @@ -134,7 +134,7 @@ public static String emoji() { emojiSet.add("🙀"); emojiSet.add("😿"); emojiSet.add("😾"); - return emojiSet.get(random.nextInt(emojiSet.size())) + ""; + return emojiSet.get(random.nextInt(emojiSet.size())); } public static String unicode(int length) { diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/Utils.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/Utils.java index a69063e5f..510b12d5a 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/Utils.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/util/Utils.java @@ -1,8 +1,8 @@ package com.pubnub.api.integration.util; -import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.endpoints.pubsub.Publish; +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.endpoints.pubsub.Publish; import com.pubnub.api.models.consumer.PNPublishResult; import java.text.SimpleDateFormat; @@ -36,7 +36,7 @@ public static boolean isSorted(List list) { return list.equals(sorted) || list.equals(reversed); } - public static PNPublishResult publish(PubNub pubnub, String channel, int indicator) { + public static PNPublishResult publish(com.pubnub.api.java.PubNub pubnub, String channel, int indicator) { try { return pubnub.publish() .channel(channel) diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/PubNubImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/PubNubImpl.java deleted file mode 100644 index adb9fdbd7..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/PubNubImpl.java +++ /dev/null @@ -1,673 +0,0 @@ -package com.pubnub.internal; - -import com.pubnub.api.PNConfiguration; -import com.pubnub.api.PubNub; -import com.pubnub.api.PubNubError; -import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PresenceBuilder; -import com.pubnub.api.builder.SubscribeBuilder; -import com.pubnub.api.builder.UnsubscribeBuilder; -import com.pubnub.api.callbacks.Listener; -import com.pubnub.api.callbacks.SubscribeCallback; -import com.pubnub.api.crypto.CryptoModule; -import com.pubnub.api.endpoints.DeleteMessages; -import com.pubnub.api.endpoints.FetchMessages; -import com.pubnub.api.endpoints.History; -import com.pubnub.api.endpoints.MessageCounts; -import com.pubnub.api.endpoints.Time; -import com.pubnub.api.endpoints.access.Grant; -import com.pubnub.api.endpoints.access.RevokeToken; -import com.pubnub.api.endpoints.access.builder.GrantTokenBuilder; -import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup; -import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup; -import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup; -import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup; -import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup; -import com.pubnub.api.endpoints.files.DeleteFile; -import com.pubnub.api.endpoints.files.DownloadFile; -import com.pubnub.api.endpoints.files.GetFileUrl; -import com.pubnub.api.endpoints.files.ListFiles; -import com.pubnub.api.endpoints.files.PublishFileMessage; -import com.pubnub.api.endpoints.files.SendFile; -import com.pubnub.api.endpoints.message_actions.AddMessageAction; -import com.pubnub.api.endpoints.message_actions.GetMessageActions; -import com.pubnub.api.endpoints.message_actions.RemoveMessageAction; -import com.pubnub.api.endpoints.objects_api.channel.GetAllChannelsMetadata; -import com.pubnub.api.endpoints.objects_api.channel.GetChannelMetadata; -import com.pubnub.api.endpoints.objects_api.channel.RemoveChannelMetadata; -import com.pubnub.api.endpoints.objects_api.channel.SetChannelMetadata; -import com.pubnub.api.endpoints.objects_api.members.GetChannelMembers; -import com.pubnub.api.endpoints.objects_api.members.ManageChannelMembers; -import com.pubnub.api.endpoints.objects_api.members.RemoveChannelMembers; -import com.pubnub.api.endpoints.objects_api.members.SetChannelMembers; -import com.pubnub.api.endpoints.objects_api.memberships.GetMemberships; -import com.pubnub.api.endpoints.objects_api.memberships.ManageMemberships; -import com.pubnub.api.endpoints.objects_api.memberships.RemoveMemberships; -import com.pubnub.api.endpoints.objects_api.memberships.SetMemberships; -import com.pubnub.api.endpoints.objects_api.uuid.GetAllUUIDMetadata; -import com.pubnub.api.endpoints.objects_api.uuid.GetUUIDMetadata; -import com.pubnub.api.endpoints.objects_api.uuid.RemoveUUIDMetadata; -import com.pubnub.api.endpoints.objects_api.uuid.SetUUIDMetadata; -import com.pubnub.api.endpoints.presence.GetState; -import com.pubnub.api.endpoints.presence.HereNow; -import com.pubnub.api.endpoints.presence.SetState; -import com.pubnub.api.endpoints.presence.WhereNow; -import com.pubnub.api.endpoints.pubsub.Publish; -import com.pubnub.api.endpoints.pubsub.Signal; -import com.pubnub.api.endpoints.push.AddChannelsToPush; -import com.pubnub.api.endpoints.push.ListPushProvisions; -import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice; -import com.pubnub.api.endpoints.push.RemoveChannelsFromPush; -import com.pubnub.api.v2.BasePNConfiguration; -import com.pubnub.api.v2.callbacks.EventListener; -import com.pubnub.api.v2.callbacks.StatusListener; -import com.pubnub.api.v2.endpoints.pubsub.PublishBuilder; -import com.pubnub.api.v2.endpoints.pubsub.SignalBuilder; -import com.pubnub.api.v2.entities.Channel; -import com.pubnub.api.v2.entities.ChannelGroup; -import com.pubnub.api.v2.entities.ChannelMetadata; -import com.pubnub.api.v2.entities.UserMetadata; -import com.pubnub.api.v2.subscriptions.Subscription; -import com.pubnub.api.v2.subscriptions.SubscriptionSet; -import com.pubnub.internal.callbacks.DelegatingStatusListener; -import com.pubnub.internal.callbacks.DelegatingSubscribeCallback; -import com.pubnub.internal.endpoints.DeleteMessagesImpl; -import com.pubnub.internal.endpoints.FetchMessagesImpl; -import com.pubnub.internal.endpoints.HistoryImpl; -import com.pubnub.internal.endpoints.MessageCountsImpl; -import com.pubnub.internal.endpoints.TimeImpl; -import com.pubnub.internal.endpoints.access.GrantImpl; -import com.pubnub.internal.endpoints.access.GrantTokenImpl; -import com.pubnub.internal.endpoints.access.RevokeTokenImpl; -import com.pubnub.internal.endpoints.channel_groups.AddChannelChannelGroupImpl; -import com.pubnub.internal.endpoints.channel_groups.AllChannelsChannelGroupImpl; -import com.pubnub.internal.endpoints.channel_groups.DeleteChannelGroupImpl; -import com.pubnub.internal.endpoints.channel_groups.ListAllChannelGroupImpl; -import com.pubnub.internal.endpoints.channel_groups.RemoveChannelChannelGroupImpl; -import com.pubnub.internal.endpoints.files.DeleteFileImpl; -import com.pubnub.internal.endpoints.files.DownloadFileImpl; -import com.pubnub.internal.endpoints.files.GetFileUrlImpl; -import com.pubnub.internal.endpoints.files.ListFilesImpl; -import com.pubnub.internal.endpoints.files.PublishFileMessageImpl; -import com.pubnub.internal.endpoints.files.SendFileImpl; -import com.pubnub.internal.endpoints.message_actions.AddMessageActionImpl; -import com.pubnub.internal.endpoints.message_actions.GetMessageActionsImpl; -import com.pubnub.internal.endpoints.message_actions.RemoveMessageActionImpl; -import com.pubnub.internal.endpoints.objects_api.channel.GetAllChannelsMetadataImpl; -import com.pubnub.internal.endpoints.objects_api.channel.GetChannelMetadataImpl; -import com.pubnub.internal.endpoints.objects_api.channel.RemoveChannelMetadataImpl; -import com.pubnub.internal.endpoints.objects_api.channel.SetChannelMetadataImpl; -import com.pubnub.internal.endpoints.objects_api.members.GetChannelMembersImpl; -import com.pubnub.internal.endpoints.objects_api.members.ManageChannelMembersImpl; -import com.pubnub.internal.endpoints.objects_api.members.RemoveChannelMembersImpl; -import com.pubnub.internal.endpoints.objects_api.members.SetChannelMembersImpl; -import com.pubnub.internal.endpoints.objects_api.memberships.GetMembershipsImpl; -import com.pubnub.internal.endpoints.objects_api.memberships.ManageMembershipsImpl; -import com.pubnub.internal.endpoints.objects_api.memberships.RemoveMembershipsImpl; -import com.pubnub.internal.endpoints.objects_api.memberships.SetMembershipsImpl; -import com.pubnub.internal.endpoints.objects_api.uuid.GetAllUUIDMetadataImpl; -import com.pubnub.internal.endpoints.objects_api.uuid.GetUUIDMetadataImpl; -import com.pubnub.internal.endpoints.objects_api.uuid.RemoveUUIDMetadataImpl; -import com.pubnub.internal.endpoints.objects_api.uuid.SetUUIDMetadataImpl; -import com.pubnub.internal.endpoints.presence.GetStateImpl; -import com.pubnub.internal.endpoints.presence.HereNowImpl; -import com.pubnub.internal.endpoints.presence.SetStateImpl; -import com.pubnub.internal.endpoints.presence.WhereNowImpl; -import com.pubnub.internal.endpoints.pubsub.PublishImpl; -import com.pubnub.internal.endpoints.pubsub.SignalImpl; -import com.pubnub.internal.endpoints.push.AddChannelsToPushImpl; -import com.pubnub.internal.endpoints.push.ListPushProvisionsImpl; -import com.pubnub.internal.endpoints.push.RemoveAllPushChannelsForDeviceImpl; -import com.pubnub.internal.endpoints.push.RemoveChannelsFromPushImpl; -import com.pubnub.internal.v2.callbacks.DelegatingEventListener; -import com.pubnub.internal.v2.entities.ChannelGroupImpl; -import com.pubnub.internal.v2.entities.ChannelImpl; -import com.pubnub.internal.v2.entities.ChannelMetadataImpl; -import com.pubnub.internal.v2.entities.UserMetadataImpl; -import com.pubnub.internal.v2.subscription.SubscriptionImpl; -import com.pubnub.internal.v2.subscription.SubscriptionSetImpl; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.io.InputStream; -import java.util.List; -import java.util.Set; - -public class PubNubImpl extends BasePubNubImpl< - EventListener, - Subscription, - Channel, - ChannelGroup, - ChannelMetadata, - UserMetadata, - SubscriptionSet, - StatusListener> implements PubNub { - - private static final String PNSDK_PUBNUB_JAVA = "PubNub-Java"; - private final @NotNull BasePNConfiguration configuration; - - public PubNubImpl(@NotNull BasePNConfiguration configuration) { - super(configuration, PNSDK_PUBNUB_JAVA); - this.configuration = configuration; - } - - @Override - @NotNull - public BasePNConfiguration getConfiguration() { - return configuration; - } - - @Override - @NotNull - public SubscribeBuilder subscribe() { - return new SubscribeBuilder(getPubNubCore()); - } - - @Override - @NotNull - public UnsubscribeBuilder unsubscribe() { - return new UnsubscribeBuilder(getPubNubCore()); - } - - @Override - @NotNull - public PresenceBuilder presence() { - return new PresenceBuilder(getPubNubCore()); - } - - // start push - - @Override - @NotNull - public AddChannelsToPush addPushNotificationsOnChannels() { - return new AddChannelsToPushImpl(getPubNubCore()); - } - - @Override - @NotNull - public RemoveChannelsFromPush removePushNotificationsFromChannels() { - return new RemoveChannelsFromPushImpl(getPubNubCore()); - } - - @Override - @NotNull - public RemoveAllPushChannelsForDevice removeAllPushNotificationsFromDeviceWithPushToken() { - return new RemoveAllPushChannelsForDeviceImpl(getPubNubCore()); - } - - @Override - @NotNull - public ListPushProvisions auditPushChannelProvisions() { - return new ListPushProvisionsImpl(getPubNubCore()); - } - - // end push - - @Override - @NotNull - public WhereNow whereNow() { - return new WhereNowImpl(getPubNubCore()); - } - - @Override - @NotNull - public HereNow hereNow() { - return new HereNowImpl(getPubNubCore()); - } - - @Override - @NotNull - public Time time() { - return new TimeImpl(getPubNubCore()); - } - - @Override - @NotNull - public History history() { - return new HistoryImpl(getPubNubCore()); - } - - @Override - @NotNull - public FetchMessages fetchMessages() { - return new FetchMessagesImpl(getPubNubCore()); - } - - @Override - @NotNull - public DeleteMessages deleteMessages() { - return new DeleteMessagesImpl(getPubNubCore()); - } - - @Override - @NotNull - public MessageCounts messageCounts() { - return new MessageCountsImpl(getPubNubCore()); - } - - @Override - @NotNull - public Grant grant() { - return new GrantImpl(getPubNubCore()); - } - - /** - * @deprecated Use {@link #grantToken(int)} instead. - */ - @Override - @NotNull - public GrantTokenBuilder grantToken() { - return new GrantTokenImpl(getPubNubCore()); - } - - @Override - @NotNull - @SuppressWarnings("deprecation") - public GrantTokenBuilder grantToken(int ttl) { - return new GrantTokenImpl(getPubNubCore()).ttl(ttl); - } - - @Override - @NotNull - public RevokeToken revokeToken() { - return new RevokeTokenImpl(getPubNubCore()); - } - - @Override - @NotNull - public GetState getPresenceState() { - return new GetStateImpl(getPubNubCore()); - } - - @Override - @NotNull - public SetState setPresenceState() { - return new SetStateImpl(getPubNubCore()); - } - - @Override - @NotNull - public Publish publish() { - return new PublishImpl(getPubNubCore()); - } - - @Override - @NotNull - public PublishBuilder publish(@NotNull Object message, @NotNull String channel) { - return new PublishImpl(getPubNubCore()).message(message).channel(channel); - } - - @Override - @NotNull - public Signal signal() { - return new SignalImpl(getPubNubCore()); - } - - @Override - @NotNull - public SignalBuilder signal(@NotNull Object message, @NotNull String channel) { - return new SignalImpl(getPubNubCore()).message(message).channel(channel); - } - - @Override - @NotNull - public ListAllChannelGroup listAllChannelGroups() { - return new ListAllChannelGroupImpl(getPubNubCore()); - } - - @Override - @NotNull - public AllChannelsChannelGroup listChannelsForChannelGroup() { - return new AllChannelsChannelGroupImpl(getPubNubCore()); - } - - @Override - @NotNull - public AddChannelChannelGroup addChannelsToChannelGroup() { - return new AddChannelChannelGroupImpl(getPubNubCore()); - } - - @Override - @NotNull - public RemoveChannelChannelGroup removeChannelsFromChannelGroup() { - return new RemoveChannelChannelGroupImpl(getPubNubCore()); - } - - @Override - @NotNull - public DeleteChannelGroup deleteChannelGroup() { - return new DeleteChannelGroupImpl(getPubNubCore()); - } - - // Start Objects API - - @Override - public SetUUIDMetadata setUUIDMetadata() { - return new SetUUIDMetadataImpl(getPubNubCore()); - } - - @Override - @NotNull - public GetAllUUIDMetadata getAllUUIDMetadata() { - return new GetAllUUIDMetadataImpl(getPubNubCore()); - } - - @Override - @NotNull - public GetUUIDMetadata getUUIDMetadata() { - return new GetUUIDMetadataImpl(getPubNubCore()); - } - - @Override - @NotNull - public RemoveUUIDMetadata removeUUIDMetadata() { - return new RemoveUUIDMetadataImpl(getPubNubCore()); - } - - @Override - public SetChannelMetadata.Builder setChannelMetadata() { - return new SetChannelMetadataImpl.Builder(getPubNubCore()); - } - - @Override - @NotNull - public GetAllChannelsMetadata getAllChannelsMetadata() { - return new GetAllChannelsMetadataImpl(getPubNubCore()); - } - - @Override - @NotNull - public GetChannelMetadata.Builder getChannelMetadata() { - return new GetChannelMetadataImpl.Builder(getPubNubCore()); - } - - @Override - public RemoveChannelMetadata.Builder removeChannelMetadata() { - return new RemoveChannelMetadataImpl.Builder(getPubNubCore()); - } - - @Override - @NotNull - public GetMemberships getMemberships() { - return new GetMembershipsImpl(getPubNubCore()); - } - - @Override - @NotNull - public SetMemberships.Builder setMemberships() { - return new SetMembershipsImpl.Builder(getPubNubCore()); - } - - @Override - public RemoveMemberships.Builder removeMemberships() { - return new RemoveMembershipsImpl.Builder(getPubNubCore()); - } - - @Override - public ManageMemberships.Builder manageMemberships() { - return new ManageMembershipsImpl.Builder(getPubNubCore()); - } - - @Override - public GetChannelMembers.Builder getChannelMembers() { - return new GetChannelMembersImpl.Builder(getPubNubCore()); - } - - @Override - public SetChannelMembers.Builder setChannelMembers() { - return new SetChannelMembersImpl.Builder(getPubNubCore()); - } - - @Override - public RemoveChannelMembers.Builder removeChannelMembers() { - return new RemoveChannelMembersImpl.Builder(getPubNubCore()); - } - - @Override - public ManageChannelMembers.Builder manageChannelMembers() { - return new ManageChannelMembersImpl.Builder(getPubNubCore()); - } - - // End Objects API - - // Start Message Actions API - - @Override - @NotNull - public AddMessageAction addMessageAction() { - return new AddMessageActionImpl(getPubNubCore()); - } - - @Override - @NotNull - public GetMessageActions getMessageActions() { - return new GetMessageActionsImpl(getPubNubCore()); - } - - @Override - @NotNull - public RemoveMessageAction removeMessageAction() { - return new RemoveMessageActionImpl(getPubNubCore()); - } - - // End Message Actions API - - @Override - public SendFile.Builder sendFile() { - return new SendFileImpl.Builder(getPubNubCore()); - } - - @Override - public ListFiles.Builder listFiles() { - return new ListFilesImpl.Builder(getPubNubCore()); - } - - @Override - public GetFileUrl.Builder getFileUrl() { - return GetFileUrlImpl.builder(getPubNubCore()); - } - - @Override - public DownloadFile.Builder downloadFile() { - return DownloadFileImpl.builder(getPubNubCore()); - } - - @Override - public DeleteFile.Builder deleteFile() { - return DeleteFileImpl.builder(getPubNubCore()); - } - - @Override - public PublishFileMessage.Builder publishFileMessage() { - return PublishFileMessageImpl.builder(getPubNubCore()); - } - - @Override - public void reconnect() { - reconnect(0); - } - - // public methods - @SuppressWarnings("deprecation") - @NotNull - private CryptoModule getCryptoModuleOrThrow(@Nullable String cipherKey) throws PubNubException { - if (cipherKey != null) { - if (configuration instanceof PNConfiguration) { - return CryptoModule.createLegacyCryptoModule(cipherKey, ((PNConfiguration) configuration).getUseRandomInitializationVector()); - } else { - return CryptoModule.createLegacyCryptoModule(cipherKey, true); - } - } else if (configuration.getCryptoModule() != null) { - return configuration.getCryptoModule(); - } else { - throw new PubNubException(PubNubError.CRYPTO_ERROR, "Crypto module is not initialized"); - } - } - - /** - * Perform Cryptographic decryption of an input string using cipher key provided by PNConfiguration - * - * @param inputString String to be encrypted - * @return String containing the encryption of inputString using cipherKey - */ - @Override - @NotNull - public String decrypt(@NotNull String inputString) throws PubNubException { - return decrypt(inputString, null); - } - - /** - * Perform Cryptographic decryption of an input string using the cipher key - * - * @param inputString String to be encrypted - * @param cipherKey cipher key to be used for encryption - * @return String containing the encryption of inputString using cipherKey - * @throws PubNubException throws exception in case of failed encryption - */ - @Override - @NotNull - public String decrypt(@NotNull String inputString, String cipherKey) throws PubNubException { - if (inputString == null) { - throw new PubNubException(PubNubError.INVALID_ARGUMENTS); - } - return getPubNubCore().decrypt(inputString, getCryptoModuleOrThrow(cipherKey)); - } - - @Override - @NotNull - public InputStream decryptInputStream(@NotNull InputStream inputStream) throws PubNubException { - return decryptInputStream(inputStream, null); - } - - @Override - @NotNull - public InputStream decryptInputStream(@NotNull InputStream inputStream, @Nullable String cipherKey) throws PubNubException { - if (inputStream == null) { - throw new PubNubException(PubNubError.INVALID_ARGUMENTS); - } - return getPubNubCore().decryptInputStream(inputStream, getCryptoModuleOrThrow(cipherKey)); - } - - /** - * Perform Cryptographic encryption of an input string and the cipher key provided by PNConfiguration - * - * @param inputString String to be encrypted - * @return String containing the encryption of inputString using cipherKey - */ - @Override - @NotNull - public String encrypt(@NotNull String inputString) throws PubNubException { - return encrypt(inputString, null); - } - - /** - * Perform Cryptographic encryption of an input string and the cipher key. - * - * @param inputString String to be encrypted - * @param cipherKey cipher key to be used for encryption - * @return String containing the encryption of inputString using cipherKey - * @throws PubNubException throws exception in case of failed encryption - */ - @Override - @NotNull - public String encrypt(@NotNull String inputString, String cipherKey) throws PubNubException { - if (inputString == null) { - throw new PubNubException(PubNubError.INVALID_ARGUMENTS); - } - return getPubNubCore().encrypt(inputString, getCryptoModuleOrThrow(cipherKey)); - } - - @Override - @NotNull - public InputStream encryptInputStream(@NotNull InputStream inputStream) throws PubNubException { - return encryptInputStream(inputStream, null); - } - - @Override - @NotNull - public InputStream encryptInputStream(@NotNull InputStream inputStream, String cipherKey) throws PubNubException { - return getPubNubCore().encryptInputStream(inputStream, getCryptoModuleOrThrow(cipherKey)); - } - - @Override - @NotNull - public Publish fire() { - return publish().shouldStore(false).replicate(false); - } - - @Override - @NotNull - public PublishBuilder fire(Object message, String channel) { - return publish(message, channel).shouldStore(false).replicate(false); - } - - @Override - @NotNull - public List getSubscribedChannels() { - return getPubNubCore().getSubscribedChannels(); - } - - @Override - @NotNull - public List getSubscribedChannelGroups() { - return getPubNubCore().getSubscribedChannelGroups(); - } - - @NotNull - @Override - public Channel channel(@NotNull String name) { - return new ChannelImpl(this, name); - } - - @NotNull - @Override - public ChannelGroup channelGroup(@NotNull String name) { - return new ChannelGroupImpl(this, name); - } - - @NotNull - @Override - public ChannelMetadata channelMetadata(@NotNull String id) { - return new ChannelMetadataImpl(this, id); - } - - @NotNull - @Override - public UserMetadata userMetadata(@NotNull String id) { - return new UserMetadataImpl(this, id); - } - - @NotNull - @Override - public SubscriptionSet subscriptionSetOf(@NotNull Set subscriptions) { - return new SubscriptionSetImpl(getPubNubCore(), (Set) subscriptions); - } - - @Override - public void addListener(@NotNull EventListener listener) { - getListenerManager().addListener(new DelegatingEventListener(listener)); - } - - @Override - public void addListener(@NotNull StatusListener listener) { - getListenerManager().addListener(new DelegatingStatusListener(listener)); - } - - @Override - public void addListener(@NotNull SubscribeCallback listener) { - getListenerManager().addListener(new DelegatingSubscribeCallback(listener)); - } - - @Override - public void removeListener(@NotNull Listener listener) { - if (listener instanceof SubscribeCallback) { - super.removeListener(new DelegatingSubscribeCallback((SubscribeCallback) listener)); - } else if (listener instanceof EventListener) { - super.removeListener(new DelegatingEventListener((EventListener) listener)); - } else if (listener instanceof StatusListener) { - super.removeListener(new DelegatingStatusListener((StatusListener) listener)); - } else { - super.removeListener(listener); - } - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/TimeImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/TimeImpl.java deleted file mode 100644 index 7f57797b8..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/TimeImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.pubnub.internal.endpoints; - -import com.pubnub.api.endpoints.Time; -import com.pubnub.api.models.consumer.PNTimeResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import org.jetbrains.annotations.NotNull; - -public class TimeImpl extends IdentityMappingEndpoint implements Time { - - public TimeImpl(PubNubCore pubnub) { - super(pubnub); - } - - @Override - @NotNull - protected EndpointInterface createAction() { - return pubnub.time(); - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupImpl.java deleted file mode 100644 index dc2a8c2c8..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups; - -import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup; -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; -import lombok.Setter; -import lombok.experimental.Accessors; - -@Setter -@Accessors(chain = true, fluent = true) -public class DeleteChannelGroupImpl extends IdentityMappingEndpoint implements DeleteChannelGroup { - private String channelGroup; - - public DeleteChannelGroupImpl(PubNubCore pubnub) { - super(pubnub); - } - - @Override - protected EndpointInterface createAction() { - return pubnub.deleteChannelGroup(channelGroup); - } - - @Override - protected void validateParams() throws PubNubException { - if (channelGroup == null) { - throw new PubNubException(PubNubErrorBuilder.PNERROBJ_GROUP_MISSING); - } - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupImpl.java deleted file mode 100644 index 9bd12a3dc..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups; - -import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup; -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; -import lombok.experimental.Accessors; -import org.jetbrains.annotations.NotNull; - -@Accessors(chain = true, fluent = true) -public class ListAllChannelGroupImpl extends IdentityMappingEndpoint implements ListAllChannelGroup { - - public ListAllChannelGroupImpl(PubNubCore pubnub) { - super(pubnub); - } - - @Override - @NotNull - protected EndpointInterface createAction() { - return pubnub.listAllChannelGroups(); - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/HeartbeatImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/HeartbeatImpl.java deleted file mode 100644 index d26511cff..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/HeartbeatImpl.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.pubnub.internal.endpoints.presence; - -import com.pubnub.api.endpoints.presence.Heartbeat; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; -import lombok.Setter; -import lombok.experimental.Accessors; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; - -@Setter -@Accessors(chain = true, fluent = true) -public class HeartbeatImpl extends IdentityMappingEndpoint implements Heartbeat { - - private List channels; - private List channelGroups; - private Object state; - - public HeartbeatImpl(PubNubCore pubnub) { - super(pubnub); - channels = new ArrayList<>(); - channelGroups = new ArrayList<>(); - } - - @Override - @NotNull - protected EndpointInterface createAction() { - return new HeartbeatEndpoint(pubnub, channels, channelGroups, state); - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/LeaveImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/LeaveImpl.java deleted file mode 100644 index 16b82fb02..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/LeaveImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.pubnub.internal.endpoints.presence; - -import com.pubnub.api.endpoints.presence.Leave; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; -import lombok.Setter; -import lombok.experimental.Accessors; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.List; - -@Setter -@Accessors(chain = true, fluent = true) -public class LeaveImpl extends IdentityMappingEndpoint implements Leave { - private List channels = new ArrayList<>(); - private List channelGroups = new ArrayList<>(); - - public LeaveImpl(PubNubCore pubnub) { - super(pubnub); - } - - @Override - @NotNull - protected EndpointInterface createAction() { - LeaveEndpoint leave = new LeaveEndpoint(pubnub); - leave.setChannels(channels); - leave.setChannelGroups(channelGroups); - return leave; - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/WhereNowImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/WhereNowImpl.java deleted file mode 100644 index 51f405276..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/WhereNowImpl.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.pubnub.internal.endpoints.presence; - -import com.pubnub.api.endpoints.presence.WhereNow; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; -import com.pubnub.internal.models.consumer.presence.PNWhereNowResult; -import lombok.Setter; -import lombok.experimental.Accessors; -import org.jetbrains.annotations.NotNull; - -@Setter -@Accessors(chain = true, fluent = true) -public class WhereNowImpl extends IdentityMappingEndpoint implements WhereNow { - - private String uuid; - - public WhereNowImpl(PubNubCore pubnub) { - super(pubnub); - uuid = pubnub.getConfiguration().getUuid(); - } - - @Override - @NotNull - protected EndpointInterface createAction() { - return pubnub.whereNow(uuid); - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/PubNubForJavaImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/PubNubForJavaImpl.kt new file mode 100644 index 000000000..46ddd5edd --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/PubNubForJavaImpl.kt @@ -0,0 +1,430 @@ +package com.pubnub.internal.java + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.java.PubNub +import com.pubnub.api.java.builder.PresenceBuilder +import com.pubnub.api.java.builder.SubscribeBuilder +import com.pubnub.api.java.builder.UnsubscribeBuilder +import com.pubnub.api.java.callbacks.SubscribeCallback +import com.pubnub.api.java.endpoints.DeleteMessages +import com.pubnub.api.java.endpoints.FetchMessages +import com.pubnub.api.java.endpoints.History +import com.pubnub.api.java.endpoints.MessageCounts +import com.pubnub.api.java.endpoints.access.Grant +import com.pubnub.api.java.endpoints.access.RevokeToken +import com.pubnub.api.java.endpoints.access.builder.GrantTokenBuilder +import com.pubnub.api.java.endpoints.channel_groups.AddChannelChannelGroup +import com.pubnub.api.java.endpoints.channel_groups.AllChannelsChannelGroup +import com.pubnub.api.java.endpoints.channel_groups.DeleteChannelGroup +import com.pubnub.api.java.endpoints.channel_groups.RemoveChannelChannelGroup +import com.pubnub.api.java.endpoints.files.DeleteFile +import com.pubnub.api.java.endpoints.files.DownloadFile +import com.pubnub.api.java.endpoints.files.GetFileUrl +import com.pubnub.api.java.endpoints.files.ListFiles +import com.pubnub.api.java.endpoints.files.PublishFileMessage +import com.pubnub.api.java.endpoints.files.SendFile +import com.pubnub.api.java.endpoints.message_actions.AddMessageAction +import com.pubnub.api.java.endpoints.message_actions.GetMessageActions +import com.pubnub.api.java.endpoints.message_actions.RemoveMessageAction +import com.pubnub.api.java.endpoints.objects_api.channel.GetAllChannelsMetadata +import com.pubnub.api.java.endpoints.objects_api.channel.GetChannelMetadata +import com.pubnub.api.java.endpoints.objects_api.channel.RemoveChannelMetadata +import com.pubnub.api.java.endpoints.objects_api.channel.SetChannelMetadata +import com.pubnub.api.java.endpoints.objects_api.members.GetChannelMembers +import com.pubnub.api.java.endpoints.objects_api.members.ManageChannelMembers +import com.pubnub.api.java.endpoints.objects_api.members.RemoveChannelMembers +import com.pubnub.api.java.endpoints.objects_api.members.SetChannelMembers +import com.pubnub.api.java.endpoints.objects_api.memberships.GetMemberships +import com.pubnub.api.java.endpoints.objects_api.memberships.ManageMemberships +import com.pubnub.api.java.endpoints.objects_api.memberships.RemoveMemberships +import com.pubnub.api.java.endpoints.objects_api.memberships.SetMemberships +import com.pubnub.api.java.endpoints.objects_api.uuid.GetAllUUIDMetadata +import com.pubnub.api.java.endpoints.objects_api.uuid.GetUUIDMetadata +import com.pubnub.api.java.endpoints.objects_api.uuid.RemoveUUIDMetadata +import com.pubnub.api.java.endpoints.objects_api.uuid.SetUUIDMetadata +import com.pubnub.api.java.endpoints.presence.GetState +import com.pubnub.api.java.endpoints.presence.HereNow +import com.pubnub.api.java.endpoints.presence.SetState +import com.pubnub.api.java.endpoints.presence.WhereNow +import com.pubnub.api.java.endpoints.pubsub.Publish +import com.pubnub.api.java.endpoints.pubsub.Signal +import com.pubnub.api.java.endpoints.push.AddChannelsToPush +import com.pubnub.api.java.endpoints.push.ListPushProvisions +import com.pubnub.api.java.endpoints.push.RemoveAllPushChannelsForDevice +import com.pubnub.api.java.endpoints.push.RemoveChannelsFromPush +import com.pubnub.api.java.v2.PNConfiguration +import com.pubnub.api.java.v2.callbacks.EventListener +import com.pubnub.api.java.v2.callbacks.StatusListener +import com.pubnub.api.java.v2.endpoints.pubsub.PublishBuilder +import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.java.endpoints.DeleteMessagesImpl +import com.pubnub.internal.java.endpoints.FetchMessagesImpl +import com.pubnub.internal.java.endpoints.HistoryImpl +import com.pubnub.internal.java.endpoints.MessageCountsImpl +import com.pubnub.internal.java.endpoints.access.GrantImpl +import com.pubnub.internal.java.endpoints.access.GrantTokenImpl +import com.pubnub.internal.java.endpoints.access.RevokeTokenImpl +import com.pubnub.internal.java.endpoints.channel_groups.AddChannelChannelGroupImpl +import com.pubnub.internal.java.endpoints.channel_groups.AllChannelsChannelGroupImpl +import com.pubnub.internal.java.endpoints.channel_groups.DeleteChannelGroupImpl +import com.pubnub.internal.java.endpoints.channel_groups.RemoveChannelChannelGroupImpl +import com.pubnub.internal.java.endpoints.files.DeleteFileImpl +import com.pubnub.internal.java.endpoints.files.DownloadFileImpl +import com.pubnub.internal.java.endpoints.files.GetFileUrlImpl +import com.pubnub.internal.java.endpoints.files.ListFilesImpl +import com.pubnub.internal.java.endpoints.files.PublishFileMessageImpl +import com.pubnub.internal.java.endpoints.files.SendFileImpl +import com.pubnub.internal.java.endpoints.message_actions.AddMessageActionImpl +import com.pubnub.internal.java.endpoints.message_actions.GetMessageActionsImpl +import com.pubnub.internal.java.endpoints.message_actions.RemoveMessageActionImpl +import com.pubnub.internal.java.endpoints.objects_api.channel.GetAllChannelsMetadataImpl +import com.pubnub.internal.java.endpoints.objects_api.channel.GetChannelMetadataImpl +import com.pubnub.internal.java.endpoints.objects_api.channel.RemoveChannelMetadataImpl +import com.pubnub.internal.java.endpoints.objects_api.channel.SetChannelMetadataImpl +import com.pubnub.internal.java.endpoints.objects_api.members.GetChannelMembersImpl +import com.pubnub.internal.java.endpoints.objects_api.members.ManageChannelMembersImpl +import com.pubnub.internal.java.endpoints.objects_api.members.RemoveChannelMembersImpl +import com.pubnub.internal.java.endpoints.objects_api.members.SetChannelMembersImpl +import com.pubnub.internal.java.endpoints.objects_api.memberships.GetMembershipsImpl +import com.pubnub.internal.java.endpoints.objects_api.memberships.ManageMembershipsImpl +import com.pubnub.internal.java.endpoints.objects_api.memberships.RemoveMembershipsImpl +import com.pubnub.internal.java.endpoints.objects_api.memberships.SetMembershipsImpl +import com.pubnub.internal.java.endpoints.objects_api.uuid.GetAllUUIDMetadataImpl +import com.pubnub.internal.java.endpoints.objects_api.uuid.GetUUIDMetadataImpl +import com.pubnub.internal.java.endpoints.objects_api.uuid.RemoveUUIDMetadataImpl +import com.pubnub.internal.java.endpoints.objects_api.uuid.SetUUIDMetadataImpl +import com.pubnub.internal.java.endpoints.presence.GetStateImpl +import com.pubnub.internal.java.endpoints.presence.HereNowImpl +import com.pubnub.internal.java.endpoints.presence.SetStateImpl +import com.pubnub.internal.java.endpoints.presence.WhereNowImpl +import com.pubnub.internal.java.endpoints.pubsub.PublishImpl +import com.pubnub.internal.java.endpoints.pubsub.SignalImpl +import com.pubnub.internal.java.endpoints.push.AddChannelsToPushImpl +import com.pubnub.internal.java.endpoints.push.ListPushProvisionsImpl +import com.pubnub.internal.java.endpoints.push.RemoveAllPushChannelsForDeviceImpl +import com.pubnub.internal.java.endpoints.push.RemoveChannelsFromPushImpl +import com.pubnub.internal.java.v2.callbacks.DelegatingEventListener +import com.pubnub.internal.java.v2.callbacks.DelegatingStatusListener +import com.pubnub.internal.java.v2.callbacks.EventEmitterInternal +import com.pubnub.internal.java.v2.entities.ChannelGroupImpl +import com.pubnub.internal.java.v2.entities.ChannelImpl +import com.pubnub.internal.java.v2.entities.ChannelMetadataImpl +import com.pubnub.internal.java.v2.entities.UserMetadataImpl +import com.pubnub.internal.v2.entities.ChannelGroupName +import com.pubnub.internal.v2.entities.ChannelName +import com.pubnub.internal.v2.subscription.SubscriptionInternal +import java.io.InputStream + +// open so that it can be mocked in tests +open class PubNubForJavaImpl(configuration: PNConfiguration) : + PubNubImpl( + configuration, + PNSDK_PUBNUB_JAVA + ), + PubNub, + EventEmitterInternal { + override fun subscribe(): SubscribeBuilder { + return SubscribeBuilder(this) + } + + override fun unsubscribe(): UnsubscribeBuilder { + return UnsubscribeBuilder(this) + } + + override fun presence(): PresenceBuilder { + return PresenceBuilder(this) + } + + // start push + override fun addPushNotificationsOnChannels(): AddChannelsToPush { + return AddChannelsToPushImpl(this) + } + + override fun removePushNotificationsFromChannels(): RemoveChannelsFromPush { + return RemoveChannelsFromPushImpl(this) + } + + override fun removeAllPushNotificationsFromDeviceWithPushToken(): RemoveAllPushChannelsForDevice { + return RemoveAllPushChannelsForDeviceImpl(this) + } + + override fun auditPushChannelProvisions(): ListPushProvisions { + return ListPushProvisionsImpl(this) + } + + // end push + override fun whereNow(): WhereNow { + return WhereNowImpl(this) + } + + override fun hereNow(): HereNow { + return HereNowImpl(this) + } + + override fun history(): History { + return HistoryImpl(this) + } + + override fun fetchMessages(): FetchMessages { + return FetchMessagesImpl(this) + } + + override fun deleteMessages(): DeleteMessages { + return DeleteMessagesImpl(this) + } + + override fun messageCounts(): MessageCounts { + return MessageCountsImpl(this) + } + + override fun grant(): Grant { + return GrantImpl(this) + } + + @Deprecated("Use {@link #grantToken(int)} instead.") + override fun grantToken(): GrantTokenBuilder { + return GrantTokenImpl(this) + } + + override fun grantToken(ttl: Int): GrantTokenBuilder { + return GrantTokenImpl(this).ttl(ttl) as GrantTokenBuilder + } + + override fun revokeToken(): RevokeToken { + return RevokeTokenImpl(this) + } + + override fun getPresenceState(): GetState { + return GetStateImpl(this) + } + + override fun setPresenceState(): SetState { + return SetStateImpl(this as PubNubImpl) + } + + override fun publish(): Publish { + return PublishImpl(this) + } + + override fun publish(message: Any, channel: String): PublishBuilder { + return PublishImpl(this).message(message).channel(channel) as PublishBuilder + } + + override fun signal(): Signal { + return SignalImpl(this) + } + + override fun signal(message: Any, channel: String): com.pubnub.api.endpoints.pubsub.Signal { + return super.signal(channel, message) + } + + override fun listChannelsForChannelGroup(): AllChannelsChannelGroup { + return AllChannelsChannelGroupImpl(this) + } + + override fun addChannelsToChannelGroup(): AddChannelChannelGroup { + return AddChannelChannelGroupImpl(this) + } + + override fun removeChannelsFromChannelGroup(): RemoveChannelChannelGroup { + return RemoveChannelChannelGroupImpl(this) + } + + override fun deleteChannelGroup(): DeleteChannelGroup { + return DeleteChannelGroupImpl(this) + } + + // Start Objects API + override fun setUUIDMetadata(): SetUUIDMetadata { + return SetUUIDMetadataImpl(this) + } + + override fun getAllUUIDMetadata(): GetAllUUIDMetadata { + return GetAllUUIDMetadataImpl(this) + } + + override fun getUUIDMetadata(): GetUUIDMetadata { + return GetUUIDMetadataImpl(this) + } + + override fun removeUUIDMetadata(): RemoveUUIDMetadata { + return RemoveUUIDMetadataImpl(this) + } + + override fun setChannelMetadata(): SetChannelMetadata.Builder { + return SetChannelMetadataImpl.Builder(this) + } + + override fun getAllChannelsMetadata(): GetAllChannelsMetadata { + return GetAllChannelsMetadataImpl(this) + } + + override fun getChannelMetadata(): GetChannelMetadata.Builder { + return GetChannelMetadataImpl.Builder(this) + } + + override fun removeChannelMetadata(): RemoveChannelMetadata.Builder { + return RemoveChannelMetadataImpl.Builder(this) + } + + override fun getMemberships(): GetMemberships { + return GetMembershipsImpl(this) + } + + override fun setMemberships(): SetMemberships.Builder { + return SetMembershipsImpl.Builder(this) + } + + override fun removeMemberships(): RemoveMemberships.Builder { + return RemoveMembershipsImpl.Builder(this) + } + + override fun manageMemberships(): ManageMemberships.Builder { + return ManageMembershipsImpl.Builder(this) + } + + override fun getChannelMembers(): GetChannelMembers.Builder { + return GetChannelMembersImpl.Builder(this) + } + + override fun setChannelMembers(): SetChannelMembers.Builder { + return SetChannelMembersImpl.Builder(this) + } + + override fun removeChannelMembers(): RemoveChannelMembers.Builder { + return RemoveChannelMembersImpl.Builder(this) + } + + override fun manageChannelMembers(): ManageChannelMembers.Builder { + return ManageChannelMembersImpl.Builder(this) + } + + // End Objects API + // Start Message Actions API + override fun addMessageAction(): AddMessageAction { + return AddMessageActionImpl(this) + } + + override fun getMessageActions(): GetMessageActions { + return GetMessageActionsImpl(this) + } + + override fun removeMessageAction(): RemoveMessageAction { + return RemoveMessageActionImpl(this) + } + + // End Message Actions API + override fun sendFile(): SendFile.Builder { + return SendFileImpl.Builder(this) + } + + override fun listFiles(): ListFiles.Builder { + return ListFilesImpl.Builder(this) + } + + override fun getFileUrl(): GetFileUrl.Builder { + return GetFileUrlImpl.builder(this) + } + + override fun downloadFile(): DownloadFile.Builder { + return DownloadFileImpl.builder(this) + } + + override fun deleteFile(): DeleteFile.Builder { + return DeleteFileImpl.builder(this) + } + + override fun publishFileMessage(): PublishFileMessage.Builder { + return PublishFileMessageImpl.builder(this) + } + + override fun reconnect() { + reconnect(0) + } + + override fun decrypt(inputString: String): String { + return super.decrypt(inputString) + } + + @Throws(com.pubnub.api.PubNubException::class) + override fun decryptInputStream(inputStream: InputStream): InputStream { + return this.decryptInputStream(inputStream, null) + } + + /** + * Perform Cryptographic encryption of an input string and the cipher key provided by PNConfiguration + * + * @param inputString String to be encrypted + * @return String containing the encryption of inputString using cipherKey + */ + @Throws(com.pubnub.api.PubNubException::class) + override fun encrypt(inputString: String): String { + return this.encrypt(inputString, null) + } + + @Throws(com.pubnub.api.PubNubException::class) + override fun encryptInputStream(inputStream: InputStream): InputStream { + return this.encryptInputStream(inputStream, null) + } + + override fun fire(): Publish { + return publish().shouldStore(false).replicate(false) + } + + override fun fire(message: Any, channel: String): PublishBuilder { + return publish(message, channel).shouldStore(false).replicate(false) + } + + override fun channel(name: String): ChannelImpl { + return ChannelImpl(this, ChannelName(name)) + } + + override fun channelGroup(name: String): ChannelGroupImpl { + return ChannelGroupImpl(this, ChannelGroupName(name)) + } + + override fun channelMetadata(id: String): ChannelMetadataImpl { + return ChannelMetadataImpl(this, ChannelName(id)) + } + + override fun userMetadata(id: String): UserMetadataImpl { + return UserMetadataImpl(this, ChannelName(id)) + } + + override fun subscriptionSetOf(subscriptions: Set): com.pubnub.api.java.v2.subscriptions.SubscriptionSet { + return com.pubnub.internal.java.v2.subscription.SubscriptionSetImpl( + this, + subscriptions as Set + ) + } + + override fun addListener(listener: SubscribeCallback) { + addListener(listener as EventListener) + addListener(listener as StatusListener) + } + + override fun addListener(listener: EventListener) { + addListener(DelegatingEventListener(listener, this)) + } + + override fun addListener(listener: StatusListener) { + addListener(DelegatingStatusListener(listener, this)) + } + + override fun removeListener(listener: Listener) { + if (listener is EventListener) { + super.removeListener(DelegatingEventListener(listener, this)) + } // no else here to support SubscribeCallbacks which implement both interfaces + if (listener is StatusListener) { + super.removeListener(DelegatingStatusListener(listener, this)) + } + } + + override fun removeAllListeners() { + super.removeAllListeners() + } + + companion object { + private const val PNSDK_PUBNUB_JAVA = "PubNub-Java" + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/DelegatingEndpoint.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/DelegatingEndpoint.kt similarity index 59% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/DelegatingEndpoint.kt rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/DelegatingEndpoint.kt index 27ecd442c..25c2c5797 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/DelegatingEndpoint.kt +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/DelegatingEndpoint.kt @@ -1,14 +1,13 @@ -package com.pubnub.internal.endpoints +package com.pubnub.internal.java.endpoints -import com.pubnub.api.endpoints.Endpoint +import com.pubnub.api.PubNub import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction +import com.pubnub.api.java.endpoints.Endpoint import com.pubnub.api.v2.PNConfiguration -import com.pubnub.internal.EndpointInterface -import com.pubnub.internal.PubNubCore -abstract class DelegatingEndpoint(pubnub: PubNubCore) : DelegatingRemoteAction(pubnub), Endpoint { +abstract class DelegatingEndpoint(pubnub: PubNub) : DelegatingRemoteAction(pubnub), Endpoint { override val remoteAction: ExtendedRemoteAction by lazy { - val newAction = createAction() + val newAction = createRemoteAction() overrideConfiguration?.let { overrideConfigNonNull -> newAction.overrideConfiguration(overrideConfigNonNull) } @@ -21,10 +20,10 @@ abstract class DelegatingEndpoint(pubnub: PubNubCore) : DelegatingRemoteAc return this } - abstract override fun createAction(): EndpointInterface + abstract override fun createRemoteAction(): com.pubnub.api.Endpoint } -abstract class IdentityMappingEndpoint(pubnub: PubNubCore) : DelegatingEndpoint(pubnub) { +abstract class PassthroughEndpoint(pubnub: PubNub) : DelegatingEndpoint(pubnub) { final override fun mapResult(action: ExtendedRemoteAction): ExtendedRemoteAction { return action } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/DelegatingRemoteAction.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/DelegatingRemoteAction.kt similarity index 81% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/DelegatingRemoteAction.kt rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/DelegatingRemoteAction.kt index 4eadd828d..7adca7c77 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/DelegatingRemoteAction.kt +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/DelegatingRemoteAction.kt @@ -1,22 +1,22 @@ -package com.pubnub.internal.endpoints +package com.pubnub.internal.java.endpoints +import com.pubnub.api.PubNub import com.pubnub.api.PubNubException import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.enums.PNOperationType import com.pubnub.api.v2.callbacks.Result -import com.pubnub.internal.PubNubCore import org.jetbrains.annotations.TestOnly import java.util.function.Consumer abstract class DelegatingRemoteAction( - @JvmField protected val pubnub: PubNubCore, + @JvmField protected val pubnub: PubNub, ) : ExtendedRemoteAction { @get:TestOnly internal open val remoteAction: ExtendedRemoteAction by lazy { - mapResult(createAction()) + mapResult(createRemoteAction()) } - protected abstract fun createAction(): ExtendedRemoteAction + protected abstract fun createRemoteAction(): ExtendedRemoteAction protected abstract fun mapResult(action: ExtendedRemoteAction): ExtendedRemoteAction @@ -56,7 +56,7 @@ abstract class DelegatingRemoteAction( get() = operationType() } -abstract class IdentityMappingAction(pubnub: PubNubCore) : DelegatingRemoteAction(pubnub) { +abstract class PassthroughRemoteAction(pubnub: PubNub) : DelegatingRemoteAction(pubnub) { final override fun mapResult(action: ExtendedRemoteAction): ExtendedRemoteAction { return action } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/DeleteMessagesImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/DeleteMessagesImpl.java similarity index 61% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/DeleteMessagesImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/DeleteMessagesImpl.java index d00f07124..eb66f7a72 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/DeleteMessagesImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/DeleteMessagesImpl.java @@ -1,11 +1,11 @@ -package com.pubnub.internal.endpoints; +package com.pubnub.internal.java.endpoints; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.DeleteMessages; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.DeleteMessages; import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -15,17 +15,17 @@ @Setter @Accessors(chain = true, fluent = true) -public class DeleteMessagesImpl extends IdentityMappingEndpoint implements DeleteMessages { +public class DeleteMessagesImpl extends PassthroughEndpoint implements DeleteMessages { private List channels = new ArrayList<>(); private Long start; private Long end; - public DeleteMessagesImpl(PubNubCore pubnub) { + public DeleteMessagesImpl(PubNub pubnub) { super(pubnub); } @Override - protected @NotNull EndpointInterface createAction() { + protected @NotNull Endpoint createRemoteAction() { return pubnub.deleteMessages(channels, start, end); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/FetchMessagesImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/FetchMessagesImpl.java similarity index 87% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/FetchMessagesImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/FetchMessagesImpl.java index 57ee55a13..a82bf9319 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/FetchMessagesImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/FetchMessagesImpl.java @@ -1,11 +1,12 @@ -package com.pubnub.internal.endpoints; +package com.pubnub.internal.java.endpoints; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.FetchMessages; import com.pubnub.api.models.consumer.PNBoundedPage; import com.pubnub.api.models.consumer.history.PNFetchMessagesResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; import lombok.Setter; import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; @@ -17,7 +18,7 @@ @Setter @Slf4j @Accessors(chain = true, fluent = true) -public class FetchMessagesImpl extends IdentityMappingEndpoint implements com.pubnub.api.endpoints.FetchMessages { +public class FetchMessagesImpl extends PassthroughEndpoint implements FetchMessages { private static final int SINGLE_CHANNEL_DEFAULT_MESSAGES = 100; private static final int SINGLE_CHANNEL_MAX_MESSAGES = 100; private static final int MULTIPLE_CHANNEL_DEFAULT_MESSAGES = 25; @@ -35,13 +36,13 @@ public class FetchMessagesImpl extends IdentityMappingEndpoint createAction() { + protected Endpoint createRemoteAction() { return pubnub.fetchMessages( channels, new PNBoundedPage(start, end, maximumPerChannel), diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/HistoryImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/HistoryImpl.java similarity index 68% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/HistoryImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/HistoryImpl.java index e08854df8..9d1147460 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/HistoryImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/HistoryImpl.java @@ -1,10 +1,10 @@ -package com.pubnub.internal.endpoints; +package com.pubnub.internal.java.endpoints; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; +import com.pubnub.api.java.builder.PubNubErrorBuilder; import com.pubnub.api.models.consumer.history.PNHistoryResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; import lombok.Setter; import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; @@ -13,7 +13,7 @@ @Setter @Slf4j @Accessors(chain = true, fluent = true) -public class HistoryImpl extends IdentityMappingEndpoint implements com.pubnub.api.endpoints.History { +public class HistoryImpl extends PassthroughEndpoint implements com.pubnub.api.java.endpoints.History { private String channel; private Long start; private Long end; @@ -22,13 +22,13 @@ public class HistoryImpl extends IdentityMappingEndpoint implem private boolean includeTimetoken; private boolean includeMeta; - public HistoryImpl(PubNubCore pubnub) { + public HistoryImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.history(channel, start, end, count, reverse, includeTimetoken, includeMeta); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/MessageCountsImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/MessageCountsImpl.java similarity index 73% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/MessageCountsImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/MessageCountsImpl.java index 586ae2d6b..5cb9301b7 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/MessageCountsImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/MessageCountsImpl.java @@ -1,11 +1,11 @@ -package com.pubnub.internal.endpoints; +package com.pubnub.internal.java.endpoints; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.MessageCounts; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.MessageCounts; import com.pubnub.api.models.consumer.history.PNMessageCountResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ @Setter @Accessors(chain = true, fluent = true) -public class MessageCountsImpl extends IdentityMappingEndpoint implements MessageCounts { +public class MessageCountsImpl extends PassthroughEndpoint implements MessageCounts { /** * The channel name you wish to pull history from. May be a single channel, or multiple channels, separated by @@ -28,13 +28,13 @@ public class MessageCountsImpl extends IdentityMappingEndpoint channelsTimetoken; - public MessageCountsImpl(PubNubCore pubnub) { + public MessageCountsImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.messageCounts(channels, channelsTimetoken); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/access/GrantImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/access/GrantImpl.java similarity index 59% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/access/GrantImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/access/GrantImpl.java index cf626411e..af918c397 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/access/GrantImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/access/GrantImpl.java @@ -1,12 +1,12 @@ -package com.pubnub.internal.endpoints.access; +package com.pubnub.internal.java.endpoints.access; -import com.pubnub.api.endpoints.access.Grant; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; -import com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; +import com.pubnub.api.java.endpoints.access.Grant; +import com.pubnub.api.java.models.consumer.access_manager.PNAccessManagerGrantResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -18,7 +18,7 @@ @Setter @Accessors(chain = true, fluent = true) -public class GrantImpl extends DelegatingEndpoint implements Grant { +public class GrantImpl extends DelegatingEndpoint implements Grant { private boolean read; private boolean write; @@ -34,13 +34,13 @@ public class GrantImpl extends DelegatingEndpoint channelGroups = new ArrayList<>(); private List uuids = Collections.emptyList(); - public GrantImpl(PubNubCore pubnub) { + public GrantImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.grant( read, write, @@ -59,7 +59,7 @@ protected EndpointInterface mapResult(@NotNull ExtendedRemoteAction action) { - return new MappingRemoteAction<>(action, PNAccessManagerGrantResult::from); + protected ExtendedRemoteAction mapResult(@NotNull ExtendedRemoteAction action) { + return new MappingRemoteAction<>(action, com.pubnub.api.java.models.consumer.access_manager.PNAccessManagerGrantResult::from); } } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/access/GrantTokenImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/access/GrantTokenImpl.java similarity index 65% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/access/GrantTokenImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/access/GrantTokenImpl.java index edd52e669..461b871c2 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/access/GrantTokenImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/access/GrantTokenImpl.java @@ -1,21 +1,21 @@ -package com.pubnub.internal.endpoints.access; +package com.pubnub.internal.java.endpoints.access; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; import com.pubnub.api.UserId; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.access.GrantToken; -import com.pubnub.api.endpoints.access.builder.GrantTokenBuilder; -import com.pubnub.api.endpoints.access.builder.GrantTokenEntitiesBuilder; -import com.pubnub.api.endpoints.access.builder.GrantTokenObjectsBuilder; -import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions; -import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions; -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant; -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.access.GrantToken; +import com.pubnub.api.java.endpoints.access.builder.GrantTokenBuilder; +import com.pubnub.api.java.endpoints.access.builder.GrantTokenEntitiesBuilder; +import com.pubnub.api.java.endpoints.access.builder.GrantTokenObjectsBuilder; +import com.pubnub.api.java.models.consumer.access_manager.sum.SpacePermissions; +import com.pubnub.api.java.models.consumer.access_manager.sum.UserPermissions; +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGrant; +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGroupGrant; +import com.pubnub.api.java.models.consumer.access_manager.v3.UUIDGrant; import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult; -import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -26,7 +26,7 @@ @Setter @Accessors(chain = true, fluent = true) -public class GrantTokenImpl extends IdentityMappingEndpoint implements GrantToken, GrantTokenBuilder, GrantTokenEntitiesBuilder, GrantTokenObjectsBuilder { +public class GrantTokenImpl extends PassthroughEndpoint implements GrantToken, GrantTokenBuilder, GrantTokenEntitiesBuilder, GrantTokenObjectsBuilder { private Integer ttl; private Object meta; @@ -35,7 +35,7 @@ public class GrantTokenImpl extends IdentityMappingEndpoint private List channelGroups = Collections.emptyList(); private List uuids = Collections.emptyList(); - public GrantTokenImpl(PubNubCore pubnub) { + public GrantTokenImpl(PubNub pubnub) { super(pubnub); } @@ -48,7 +48,7 @@ protected void validateParams() throws PubNubException { @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.grantToken( ttl, meta, @@ -129,33 +129,33 @@ public GrantTokenEntitiesBuilder authorizedUserId(UserId userId) { return this; } - private List toInternalChannels(List channels) { - ArrayList list = new ArrayList<>(channels.size()); + private List toInternalChannels(List channels) { + ArrayList list = new ArrayList<>(channels.size()); for (ChannelGrant channel : channels) { list.add(toInternal(channel)); } return list; } - private List toInternalChannelGroups(List channels) { - ArrayList list = new ArrayList<>(channels.size()); + private List toInternalChannelGroups(List channels) { + ArrayList list = new ArrayList<>(channels.size()); for (ChannelGroupGrant channel : channels) { list.add(toInternal(channel)); } return list; } - private List toInternalUuids(List uuids) { - ArrayList list = new ArrayList<>(uuids.size()); + private List toInternalUuids(List uuids) { + ArrayList list = new ArrayList<>(uuids.size()); for (UUIDGrant uuid : uuids) { list.add(toInternal(uuid)); } return list; } - static com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant toInternal(ChannelGrant grant) { + static com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant toInternal(ChannelGrant grant) { if (grant.isPatternResource()) { - return com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant.Companion.pattern( + return com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant.Companion.pattern( grant.getId(), grant.isRead(), grant.isWrite(), @@ -167,7 +167,7 @@ static com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant toInte grant.isUpdate() ); } else { - return com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant.Companion.name( + return com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant.Companion.name( grant.getId(), grant.isRead(), grant.isWrite(), @@ -181,15 +181,15 @@ static com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant toInte } } - static com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant toInternal(ChannelGroupGrant grant) { + static com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant toInternal(ChannelGroupGrant grant) { if (grant.isPatternResource()) { - return com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant.Companion.pattern( + return com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant.Companion.pattern( grant.getId(), grant.isRead(), grant.isManage() ); } else { - return com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant.Companion.id( + return com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant.Companion.id( grant.getId(), grant.isRead(), grant.isManage() @@ -197,16 +197,16 @@ static com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant t } } - static com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant toInternal(UUIDGrant grant) { + static com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant toInternal(UUIDGrant grant) { if (grant.isPatternResource()) { - return com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant.Companion.pattern( + return com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant.Companion.pattern( grant.getId(), grant.isGet(), grant.isUpdate(), grant.isDelete() ); } else { - return com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant.Companion.id( + return com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant.Companion.id( grant.getId(), grant.isGet(), grant.isUpdate(), diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/access/RevokeTokenImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/access/RevokeTokenImpl.java similarity index 53% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/access/RevokeTokenImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/access/RevokeTokenImpl.java index a02bb19f6..619540b8e 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/access/RevokeTokenImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/access/RevokeTokenImpl.java @@ -1,11 +1,11 @@ -package com.pubnub.internal.endpoints.access; +package com.pubnub.internal.java.endpoints.access; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.access.RevokeToken; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.access.RevokeToken; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import kotlin.Unit; import lombok.Setter; import lombok.experimental.Accessors; @@ -13,17 +13,17 @@ @Setter @Accessors(chain = true, fluent = true) -public class RevokeTokenImpl extends IdentityMappingEndpoint implements RevokeToken { +public class RevokeTokenImpl extends PassthroughEndpoint implements RevokeToken { private String token; - public RevokeTokenImpl(PubNubCore pubnub) { + public RevokeTokenImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.revokeToken(token); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/AddChannelChannelGroupImpl.java similarity index 55% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/AddChannelChannelGroupImpl.java index 2f1dde3ff..53b9f7e37 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/AddChannelChannelGroupImpl.java @@ -1,12 +1,12 @@ -package com.pubnub.internal.endpoints.channel_groups; +package com.pubnub.internal.java.endpoints.channel_groups; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.channel_groups.AddChannelChannelGroup; import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -16,17 +16,17 @@ @Setter @Accessors(chain = true, fluent = true) -public class AddChannelChannelGroupImpl extends IdentityMappingEndpoint implements AddChannelChannelGroup { +public class AddChannelChannelGroupImpl extends PassthroughEndpoint implements AddChannelChannelGroup { private String channelGroup; private List channels = new ArrayList<>(); - public AddChannelChannelGroupImpl(PubNubCore pubnub) { + public AddChannelChannelGroupImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.addChannelsToChannelGroup(channels, channelGroup); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/AllChannelsChannelGroupImpl.java similarity index 51% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/AllChannelsChannelGroupImpl.java index 43af03ffd..fb463cd6e 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/AllChannelsChannelGroupImpl.java @@ -1,28 +1,28 @@ -package com.pubnub.internal.endpoints.channel_groups; +package com.pubnub.internal.java.endpoints.channel_groups; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.channel_groups.AllChannelsChannelGroup; import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @Setter @Accessors(chain = true, fluent = true) -public class AllChannelsChannelGroupImpl extends IdentityMappingEndpoint implements AllChannelsChannelGroup { +public class AllChannelsChannelGroupImpl extends PassthroughEndpoint implements AllChannelsChannelGroup { private String channelGroup; - public AllChannelsChannelGroupImpl(PubNubCore pubnub) { + public AllChannelsChannelGroupImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.listChannelsForChannelGroup(channelGroup); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/DeleteChannelGroupImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/DeleteChannelGroupImpl.java new file mode 100644 index 000000000..9853022a3 --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/DeleteChannelGroupImpl.java @@ -0,0 +1,33 @@ +package com.pubnub.internal.java.endpoints.channel_groups; + +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; +import com.pubnub.api.PubNubException; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.channel_groups.DeleteChannelGroup; +import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; +import lombok.Setter; +import lombok.experimental.Accessors; + +@Setter +@Accessors(chain = true, fluent = true) +public class DeleteChannelGroupImpl extends PassthroughEndpoint implements DeleteChannelGroup { + private String channelGroup; + + public DeleteChannelGroupImpl(PubNub pubnub) { + super(pubnub); + } + + @Override + protected Endpoint createRemoteAction() { + return pubnub.deleteChannelGroup(channelGroup); + } + + @Override + protected void validateParams() throws PubNubException { + if (channelGroup == null) { + throw new PubNubException(PubNubErrorBuilder.PNERROBJ_GROUP_MISSING); + } + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/RemoveChannelChannelGroupImpl.java similarity index 55% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/RemoveChannelChannelGroupImpl.java index 419135d65..015653c2e 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/channel_groups/RemoveChannelChannelGroupImpl.java @@ -1,12 +1,12 @@ -package com.pubnub.internal.endpoints.channel_groups; +package com.pubnub.internal.java.endpoints.channel_groups; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.channel_groups.RemoveChannelChannelGroup; import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -16,18 +16,18 @@ @Setter @Accessors(chain = true, fluent = true) -public class RemoveChannelChannelGroupImpl extends IdentityMappingEndpoint implements RemoveChannelChannelGroup { +public class RemoveChannelChannelGroupImpl extends PassthroughEndpoint implements RemoveChannelChannelGroup { private String channelGroup; @NotNull private List channels = new ArrayList<>(); - public RemoveChannelChannelGroupImpl(PubNubCore pubnub) { + public RemoveChannelChannelGroupImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.removeChannelsFromChannelGroup(channels, channelGroup); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/DeleteFileImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/DeleteFileImpl.java similarity index 54% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/DeleteFileImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/DeleteFileImpl.java index a6293c1f4..47a1147db 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/DeleteFileImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/DeleteFileImpl.java @@ -1,27 +1,27 @@ -package com.pubnub.internal.endpoints.files; +package com.pubnub.internal.java.endpoints.files; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.BuilderSteps.ChannelStep; -import com.pubnub.api.endpoints.files.DeleteFile; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileIdStep; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileNameStep; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.BuilderSteps.ChannelStep; +import com.pubnub.api.java.endpoints.files.DeleteFile; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileIdStep; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileNameStep; import com.pubnub.api.models.consumer.files.PNDeleteFileResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; -import com.pubnub.internal.endpoints.files.requiredparambuilder.ChannelFileNameFileIdBuilder; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; +import com.pubnub.internal.java.endpoints.files.requiredparambuilder.ChannelFileNameFileIdBuilder; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @Accessors(chain = true, fluent = true) -public class DeleteFileImpl extends IdentityMappingEndpoint implements DeleteFile { +public class DeleteFileImpl extends PassthroughEndpoint implements DeleteFile { private final String channel; private final String fileId; private final String fileName; - public DeleteFileImpl(String channel, String fileName, String fileId, PubNubCore pubnub) { + public DeleteFileImpl(String channel, String fileName, String fileId, PubNub pubnub) { super(pubnub); this.channel = channel; this.fileName = fileName; @@ -30,7 +30,7 @@ public DeleteFileImpl(String channel, String fileName, String fileId, PubNubCore @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.deleteFile( channel, fileName, @@ -38,8 +38,8 @@ protected EndpointInterface createAction() { ); } - public static DeleteFileImpl.Builder builder(PubNubCore pubnub) { - return new DeleteFileImpl.Builder(ChannelFileNameFileIdBuilder.create((channel, fileName, fileId) -> + public static Builder builder(PubNub pubnub) { + return new Builder(ChannelFileNameFileIdBuilder.create((channel, fileName, fileId) -> new DeleteFileImpl(channel, fileName, fileId, pubnub))); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/DownloadFileImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/DownloadFileImpl.java similarity index 59% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/DownloadFileImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/DownloadFileImpl.java index f84f5de70..72e92a738 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/DownloadFileImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/DownloadFileImpl.java @@ -1,21 +1,21 @@ -package com.pubnub.internal.endpoints.files; +package com.pubnub.internal.java.endpoints.files; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.files.DownloadFile; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.files.DownloadFile; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps; import com.pubnub.api.models.consumer.files.PNDownloadFileResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; -import com.pubnub.internal.endpoints.files.requiredparambuilder.ChannelFileNameFileIdBuilder; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; +import com.pubnub.internal.java.endpoints.files.requiredparambuilder.ChannelFileNameFileIdBuilder; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @Accessors(chain = true, fluent = true) -public class DownloadFileImpl extends IdentityMappingEndpoint implements DownloadFile { +public class DownloadFileImpl extends PassthroughEndpoint implements DownloadFile { private final String channel; private final String fileId; @@ -24,7 +24,7 @@ public class DownloadFileImpl extends IdentityMappingEndpoint createAction() { + protected Endpoint createRemoteAction() { return pubnub.downloadFile( channel, fileName, @@ -42,8 +42,8 @@ protected EndpointInterface createAction() { ); } - public static DownloadFileImpl.Builder builder(PubNubCore pubnub) { - return new DownloadFileImpl.Builder(ChannelFileNameFileIdBuilder.create((channel, fileName, fileId) -> + public static Builder builder(PubNub pubnub) { + return new Builder(ChannelFileNameFileIdBuilder.create((channel, fileName, fileId) -> new DownloadFileImpl(channel, fileId, fileName, pubnub))); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/GetFileUrlImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/GetFileUrlImpl.java similarity index 56% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/GetFileUrlImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/GetFileUrlImpl.java index 435580c1d..be728342a 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/GetFileUrlImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/GetFileUrlImpl.java @@ -1,24 +1,24 @@ -package com.pubnub.internal.endpoints.files; +package com.pubnub.internal.java.endpoints.files; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.files.GetFileUrl; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.files.GetFileUrl; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps; import com.pubnub.api.models.consumer.files.PNFileUrlResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; -import com.pubnub.internal.endpoints.files.requiredparambuilder.ChannelFileNameFileIdBuilder; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; +import com.pubnub.internal.java.endpoints.files.requiredparambuilder.ChannelFileNameFileIdBuilder; import org.jetbrains.annotations.NotNull; -public class GetFileUrlImpl extends IdentityMappingEndpoint implements GetFileUrl { +public class GetFileUrlImpl extends PassthroughEndpoint implements GetFileUrl { private final String channel; private final String fileId; private final String fileName; - public GetFileUrlImpl(String channel, String fileId, String fileName, PubNubCore pubnub) { + public GetFileUrlImpl(String channel, String fileId, String fileName, PubNub pubnub) { super(pubnub); this.channel = channel; this.fileId = fileId; @@ -27,7 +27,7 @@ public GetFileUrlImpl(String channel, String fileId, String fileName, PubNubCore @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.getFileUrl( channel, fileName, @@ -41,8 +41,8 @@ private Builder(BuilderSteps.ChannelStep + public static Builder builder(PubNub pubNub) { + return new Builder(ChannelFileNameFileIdBuilder.create((channel, fileName, fileId) -> new GetFileUrlImpl(channel, fileName, fileId, pubNub))); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/ListFilesImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/ListFilesImpl.java similarity index 70% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/ListFilesImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/ListFilesImpl.java index 0acaaf4e4..59a7cfa02 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/ListFilesImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/ListFilesImpl.java @@ -1,19 +1,19 @@ -package com.pubnub.internal.endpoints.files; +package com.pubnub.internal.java.endpoints.files; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.files.ListFiles; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.files.ListFiles; import com.pubnub.api.models.consumer.files.PNListFilesResult; import com.pubnub.api.models.consumer.objects.PNPage; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @Accessors(chain = true, fluent = true) -public class ListFilesImpl extends IdentityMappingEndpoint implements ListFiles { +public class ListFilesImpl extends PassthroughEndpoint implements ListFiles { private final String channel; @@ -22,14 +22,14 @@ public class ListFilesImpl extends IdentityMappingEndpoint im @Setter private PNPage.PNNext next; - public ListFilesImpl(String channel, PubNubCore pubnub) { + public ListFilesImpl(String channel, PubNub pubnub) { super(pubnub); this.channel = channel; } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.listFiles( channel, limit, @@ -39,9 +39,9 @@ protected EndpointInterface createAction() { public static class Builder implements ListFiles.Builder { - private final PubNubCore pubnubInstance; + private final PubNub pubnubInstance; - public Builder(PubNubCore pubnubInstance) { + public Builder(PubNub pubnubInstance) { this.pubnubInstance = pubnubInstance; } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/PublishFileMessageImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/PublishFileMessageImpl.java similarity index 66% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/PublishFileMessageImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/PublishFileMessageImpl.java index aff5aadb6..7e6bd6f6d 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/PublishFileMessageImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/PublishFileMessageImpl.java @@ -1,22 +1,22 @@ -package com.pubnub.internal.endpoints.files; +package com.pubnub.internal.java.endpoints.files; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.files.PublishFileMessage; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.files.PublishFileMessage; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps; import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; -import com.pubnub.internal.endpoints.files.requiredparambuilder.ChannelFileNameFileIdBuilder; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; +import com.pubnub.internal.java.endpoints.files.requiredparambuilder.ChannelFileNameFileIdBuilder; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @Setter @Accessors(chain = true, fluent = true) -public class PublishFileMessageImpl extends IdentityMappingEndpoint implements PublishFileMessage { +public class PublishFileMessageImpl extends PassthroughEndpoint implements PublishFileMessage { @Setter private Object message; @@ -31,7 +31,7 @@ public class PublishFileMessageImpl extends IdentityMappingEndpoint createAction() { + protected Endpoint createRemoteAction() { return pubnub.publishFileMessage( channel, fileName, @@ -52,7 +52,7 @@ protected EndpointInterface createAction() { ); } - public static PublishFileMessage.Builder builder(PubNubCore pubNub) { + public static PublishFileMessage.Builder builder(PubNub pubNub) { return new Builder(ChannelFileNameFileIdBuilder.create((channel, fileName, fileId) -> new PublishFileMessageImpl(channel, fileName, fileId, pubNub))); } @@ -70,4 +70,4 @@ protected void validateParams() throws PubNubException { throw new PubNubException(PubNubErrorBuilder.PNERROBJ_CHANNEL_MISSING); } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/SendFileImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/SendFileImpl.java similarity index 76% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/SendFileImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/SendFileImpl.java index d2a3b2c00..0b97a9273 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/SendFileImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/SendFileImpl.java @@ -1,12 +1,12 @@ -package com.pubnub.internal.endpoints.files; +package com.pubnub.internal.java.endpoints.files; -import com.pubnub.api.endpoints.BuilderSteps; -import com.pubnub.api.endpoints.files.SendFile; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; +import com.pubnub.api.java.endpoints.BuilderSteps; +import com.pubnub.api.java.endpoints.files.SendFile; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps; import com.pubnub.api.models.consumer.files.PNFileUploadResult; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingAction; +import com.pubnub.internal.java.endpoints.PassthroughRemoteAction; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -15,7 +15,7 @@ @Setter @Accessors(chain = true, fluent = true) -public class SendFileImpl extends IdentityMappingAction implements SendFile { +public class SendFileImpl extends PassthroughRemoteAction implements SendFile { private final String channel; private final String fileName; @@ -32,7 +32,7 @@ public class SendFileImpl extends IdentityMappingAction impl @Setter private String cipherKey; - public SendFileImpl(PubNubCore pubnub, String channel, String fileName, InputStream inputStream) { + public SendFileImpl(PubNub pubnub, String channel, String fileName, InputStream inputStream) { super(pubnub); this.channel = channel; this.fileName = fileName; @@ -41,7 +41,7 @@ public SendFileImpl(PubNubCore pubnub, String channel, String fileName, InputStr @Override @NotNull - protected ExtendedRemoteAction createAction() { + protected ExtendedRemoteAction createRemoteAction() { return pubnub.sendFile( channel, fileName, @@ -56,9 +56,9 @@ protected ExtendedRemoteAction createAction() { public static class Builder implements SendFile.Builder { - private final PubNubCore pubnub; + private final PubNub pubnub; - public Builder(PubNubCore pubnub) { + public Builder(PubNub pubnub) { this.pubnub = pubnub; } @@ -71,11 +71,11 @@ public static class InnerBuilder implements BuilderSteps.ChannelStep>>, FilesBuilderSteps.FileNameStep>, FilesBuilderSteps.InputStreamStep { - private final PubNubCore pubnub; + private final PubNub pubnub; private String channelValue; private String fileNameValue; - private InnerBuilder(PubNubCore pubnub) { + private InnerBuilder(PubNub pubnub) { this.pubnub = pubnub; } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/requiredparambuilder/ChannelFileNameFileIdBuilder.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/requiredparambuilder/ChannelFileNameFileIdBuilder.java similarity index 82% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/requiredparambuilder/ChannelFileNameFileIdBuilder.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/requiredparambuilder/ChannelFileNameFileIdBuilder.java index 2c4d50b12..c757678da 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/files/requiredparambuilder/ChannelFileNameFileIdBuilder.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/files/requiredparambuilder/ChannelFileNameFileIdBuilder.java @@ -1,8 +1,8 @@ -package com.pubnub.internal.endpoints.files.requiredparambuilder; +package com.pubnub.internal.java.endpoints.files.requiredparambuilder; -import com.pubnub.api.endpoints.BuilderSteps.ChannelStep; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileIdStep; -import com.pubnub.api.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileNameStep; +import com.pubnub.api.java.endpoints.BuilderSteps.ChannelStep; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileIdStep; +import com.pubnub.api.java.endpoints.files.requiredparambuilder.FilesBuilderSteps.FileNameStep; import kotlin.jvm.functions.Function3; public abstract class ChannelFileNameFileIdBuilder implements diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/message_actions/AddMessageActionImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/message_actions/AddMessageActionImpl.java similarity index 57% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/message_actions/AddMessageActionImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/message_actions/AddMessageActionImpl.java index bf1ea7170..f16d13135 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/message_actions/AddMessageActionImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/message_actions/AddMessageActionImpl.java @@ -1,35 +1,35 @@ -package com.pubnub.internal.endpoints.message_actions; +package com.pubnub.internal.java.endpoints.message_actions; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.endpoints.message_actions.AddMessageAction; +import com.pubnub.api.java.endpoints.message_actions.AddMessageAction; import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult; import com.pubnub.api.models.consumer.message_actions.PNMessageAction; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; -import static com.pubnub.api.builder.PubNubErrorBuilder.PNERROBJ_CHANNEL_MISSING; -import static com.pubnub.api.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_MISSING; -import static com.pubnub.api.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_VALUE_MISSING; -import static com.pubnub.api.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_TIMETOKEN_MISSING; +import static com.pubnub.api.java.builder.PubNubErrorBuilder.PNERROBJ_CHANNEL_MISSING; +import static com.pubnub.api.java.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_MISSING; +import static com.pubnub.api.java.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_ACTION_VALUE_MISSING; +import static com.pubnub.api.java.builder.PubNubErrorBuilder.PNERROBJ_MESSAGE_TIMETOKEN_MISSING; @Setter @Accessors(chain = true, fluent = true) -public class AddMessageActionImpl extends IdentityMappingEndpoint implements AddMessageAction { +public class AddMessageActionImpl extends PassthroughEndpoint implements AddMessageAction { private String channel; private PNMessageAction messageAction; - public AddMessageActionImpl(PubNubCore pubnub) { + public AddMessageActionImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.addMessageAction(channel, messageAction); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/message_actions/GetMessageActionsImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/message_actions/GetMessageActionsImpl.java similarity index 60% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/message_actions/GetMessageActionsImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/message_actions/GetMessageActionsImpl.java index dabf0d800..fd54c9987 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/message_actions/GetMessageActionsImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/message_actions/GetMessageActionsImpl.java @@ -1,27 +1,27 @@ -package com.pubnub.internal.endpoints.message_actions; +package com.pubnub.internal.java.endpoints.message_actions; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubError; import com.pubnub.api.PubNubException; -import com.pubnub.api.endpoints.message_actions.GetMessageActions; +import com.pubnub.api.java.endpoints.message_actions.GetMessageActions; import com.pubnub.api.models.consumer.PNBoundedPage; import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @Setter @Accessors(chain = true, fluent = true) -public class GetMessageActionsImpl extends IdentityMappingEndpoint implements GetMessageActions { +public class GetMessageActionsImpl extends PassthroughEndpoint implements GetMessageActions { private String channel; private Long start; private Long end; private Integer limit; - public GetMessageActionsImpl(PubNubCore pubnub) { + public GetMessageActionsImpl(PubNub pubnub) { super(pubnub); } @@ -34,7 +34,7 @@ protected void validateParams() throws PubNubException { @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.getMessageActions(channel, new PNBoundedPage(start, end, limit)); } } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/message_actions/RemoveMessageActionImpl.java similarity index 64% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/message_actions/RemoveMessageActionImpl.java index 8f3b4f06b..7533c605d 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/message_actions/RemoveMessageActionImpl.java @@ -1,29 +1,29 @@ -package com.pubnub.internal.endpoints.message_actions; +package com.pubnub.internal.java.endpoints.message_actions; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubError; import com.pubnub.api.PubNubException; -import com.pubnub.api.endpoints.message_actions.RemoveMessageAction; +import com.pubnub.api.java.endpoints.message_actions.RemoveMessageAction; import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; @Setter @Accessors(chain = true, fluent = true) -public class RemoveMessageActionImpl extends IdentityMappingEndpoint implements RemoveMessageAction { +public class RemoveMessageActionImpl extends PassthroughEndpoint implements RemoveMessageAction { private String channel; private Long messageTimetoken; private Long actionTimetoken; - public RemoveMessageActionImpl(PubNubCore pubnub) { + public RemoveMessageActionImpl(PubNub pubnub) { super(pubnub); } @Override - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.removeMessageAction(channel, messageTimetoken, actionTimetoken); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/GetAllChannelsMetadataImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/GetAllChannelsMetadataImpl.java similarity index 57% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/GetAllChannelsMetadataImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/GetAllChannelsMetadataImpl.java index d34045b9e..a7def2f14 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/GetAllChannelsMetadataImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/GetAllChannelsMetadataImpl.java @@ -1,16 +1,16 @@ -package com.pubnub.internal.endpoints.objects_api.channel; +package com.pubnub.internal.java.endpoints.objects_api.channel; -import com.pubnub.api.endpoints.objects_api.channel.GetAllChannelsMetadata; -import com.pubnub.api.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.channel.GetAllChannelsMetadata; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNGetAllChannelsMetadataResult; +import com.pubnub.api.models.consumer.objects.PNKey; import com.pubnub.api.models.consumer.objects.PNPage; -import com.pubnub.internal.models.consumer.objects.channel.PNChannelMetadataArrayResult; -import com.pubnub.api.models.consumer.objects_api.channel.PNGetAllChannelsMetadataResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.PNKey; +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -32,13 +32,13 @@ public class GetAllChannelsMetadataImpl private boolean includeTotalCount; private boolean includeCustom; - public GetAllChannelsMetadataImpl(final PubNubCore pubnubInstance) { + public GetAllChannelsMetadataImpl(final PubNub pubnubInstance) { super(pubnubInstance); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.getAllChannelMetadata( limit, page, @@ -55,9 +55,9 @@ protected ExtendedRemoteAction mapResult(@NotNul return new MappingRemoteAction<>(action, PNGetAllChannelsMetadataResult::from); } - public static Collection> toInternal(Collection sort) { - List> list = new ArrayList<>(sort.size()); - for (com.pubnub.api.endpoints.objects_api.utils.PNSortKey pnSortKey : sort) { + public static Collection> toInternal(Collection sort) { + List> list = new ArrayList<>(sort.size()); + for (PNSortKey pnSortKey : sort) { PNKey key; switch (pnSortKey.getKey()) { case ID: @@ -72,10 +72,10 @@ public static Collection(key)); + if (pnSortKey.getDir().equals(PNSortKey.Dir.ASC)) { + list.add(new com.pubnub.api.models.consumer.objects.PNSortKey.PNAsc<>(key)); } else { - list.add(new com.pubnub.internal.models.consumer.objects.PNSortKey.PNDesc<>(key)); + list.add(new com.pubnub.api.models.consumer.objects.PNSortKey.PNDesc<>(key)); } } return list; diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/GetChannelMetadataImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/GetChannelMetadataImpl.java similarity index 67% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/GetChannelMetadataImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/GetChannelMetadataImpl.java index 8d186feb5..ab5002efe 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/GetChannelMetadataImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/GetChannelMetadataImpl.java @@ -1,22 +1,21 @@ -package com.pubnub.internal.endpoints.objects_api.channel; +package com.pubnub.internal.java.endpoints.objects_api.channel; -import com.pubnub.api.endpoints.objects_api.channel.GetChannelMetadata; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.channel.GetChannelMetadata; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadata; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNGetChannelMetadataResult; import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadata; -import com.pubnub.api.models.consumer.objects_api.channel.PNGetChannelMetadataResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import lombok.AllArgsConstructor; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @Accessors(chain = true, fluent = true) public class GetChannelMetadataImpl extends DelegatingEndpoint implements GetChannelMetadata { - public GetChannelMetadataImpl(String channel, final PubNubCore pubnubInstance) { + public GetChannelMetadataImpl(String channel, final PubNub pubnubInstance) { super(pubnubInstance); this.channel = channel; } @@ -39,13 +38,16 @@ protected ExtendedRemoteAction mapResult(@NotNull Ex @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.getChannelMetadata(channel, includeCustom); } - @AllArgsConstructor public static class Builder implements GetChannelMetadata.Builder { - private final PubNubCore pubnubInstance; + private final PubNub pubnubInstance; + + public Builder(PubNub pubnubInstance) { + this.pubnubInstance = pubnubInstance; + } @Override public GetChannelMetadata channel(final String channel) { diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/RemoveChannelMetadataImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/RemoveChannelMetadataImpl.java similarity index 64% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/RemoveChannelMetadataImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/RemoveChannelMetadataImpl.java index 5fb00933b..deba693bd 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/RemoveChannelMetadataImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/RemoveChannelMetadataImpl.java @@ -1,18 +1,17 @@ -package com.pubnub.internal.endpoints.objects_api.channel; +package com.pubnub.internal.java.endpoints.objects_api.channel; -import com.pubnub.api.endpoints.objects_api.channel.RemoveChannelMetadata; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; -import com.pubnub.api.models.consumer.objects_api.channel.PNRemoveChannelMetadataResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.PNRemoveMetadataResult; -import lombok.AllArgsConstructor; +import com.pubnub.api.java.endpoints.objects_api.channel.RemoveChannelMetadata; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNRemoveChannelMetadataResult; +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import org.jetbrains.annotations.NotNull; public class RemoveChannelMetadataImpl extends DelegatingEndpoint implements RemoveChannelMetadata { - public RemoveChannelMetadataImpl(String channel, final PubNubCore pubnubInstance) { + public RemoveChannelMetadataImpl(String channel, final PubNub pubnubInstance) { super(pubnubInstance); this.channel = channel; } @@ -32,13 +31,16 @@ protected ExtendedRemoteAction mapResult(@NotNull @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.removeChannelMetadata(channel); } - @AllArgsConstructor public static class Builder implements RemoveChannelMetadata.Builder { - private final PubNubCore pubnubInstance; + private final PubNub pubnubInstance; + + public Builder(PubNub pubnubInstance) { + this.pubnubInstance = pubnubInstance; + } @Override public RemoveChannelMetadata channel(String channel) { diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/SetChannelMetadataImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/SetChannelMetadataImpl.java similarity index 77% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/SetChannelMetadataImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/SetChannelMetadataImpl.java index 508cb5cde..79f1b9666 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/channel/SetChannelMetadataImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/channel/SetChannelMetadataImpl.java @@ -1,15 +1,14 @@ -package com.pubnub.internal.endpoints.objects_api.channel; +package com.pubnub.internal.java.endpoints.objects_api.channel; -import com.pubnub.api.endpoints.objects_api.channel.SetChannelMetadata; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.channel.SetChannelMetadata; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadata; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNSetChannelMetadataResult; import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadata; -import com.pubnub.api.models.consumer.objects_api.channel.PNSetChannelMetadataResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import lombok.AllArgsConstructor; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -21,7 +20,7 @@ public class SetChannelMetadataImpl extends DelegatingEndpoint implements SetChannelMetadata { - public SetChannelMetadataImpl(final String channel, final PubNubCore pubnubInstance) { + public SetChannelMetadataImpl(final String channel, final PubNub pubnubInstance) { super(pubnubInstance); this.channel = channel; } @@ -39,7 +38,7 @@ protected ExtendedRemoteAction mapResult(@NotNull Ex @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.setChannelMetadata( channel, name, @@ -80,9 +79,12 @@ public SetChannelMetadata custom(Map custom) { return this; } - @AllArgsConstructor public static class Builder implements SetChannelMetadata.Builder { - private final PubNubCore pubnubInstance; + private final PubNub pubnubInstance; + + public Builder(PubNub pubnubInstance) { + this.pubnubInstance = pubnubInstance; + } @Override public SetChannelMetadata channel(final String channel) { diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/GetChannelMembersImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/GetChannelMembersImpl.java similarity index 68% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/GetChannelMembersImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/GetChannelMembersImpl.java index 80891a154..5d70394ae 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/GetChannelMembersImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/GetChannelMembersImpl.java @@ -1,17 +1,16 @@ -package com.pubnub.internal.endpoints.objects_api.members; +package com.pubnub.internal.java.endpoints.objects_api.members; -import com.pubnub.api.endpoints.objects_api.members.GetChannelMembers; -import com.pubnub.api.endpoints.objects_api.utils.Include; -import com.pubnub.api.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.members.GetChannelMembers; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.member.PNGetChannelMembersResult; import com.pubnub.api.models.consumer.objects.PNPage; -import com.pubnub.api.models.consumer.objects_api.member.PNGetChannelMembersResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult; -import lombok.AllArgsConstructor; +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -33,7 +32,7 @@ public class GetChannelMembersImpl extends DelegatingEndpoint mapResult(@NotNull Ext } @Override - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.getChannelMembers( channel, limit, @@ -59,9 +58,12 @@ protected EndpointInterface createAction() { ); } - @AllArgsConstructor public static class Builder implements GetChannelMembers.Builder { - private final PubNubCore pubnubInstance; + private final PubNub pubnubInstance; + + public Builder(PubNub pubnubInstance) { + this.pubnubInstance = pubnubInstance; + } @Override public GetChannelMembers channel(final String channel) { diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/ManageChannelMembersImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/ManageChannelMembersImpl.java similarity index 80% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/ManageChannelMembersImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/ManageChannelMembersImpl.java index 31205ade6..3a107cef8 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/ManageChannelMembersImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/ManageChannelMembersImpl.java @@ -1,21 +1,20 @@ -package com.pubnub.internal.endpoints.objects_api.members; +package com.pubnub.internal.java.endpoints.objects_api.members; -import com.pubnub.api.endpoints.objects_api.members.ManageChannelMembers; -import com.pubnub.api.endpoints.objects_api.utils.Include; -import com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps; -import com.pubnub.api.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.members.ManageChannelMembers; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.member.PNManageChannelMembersResult; +import com.pubnub.api.java.models.consumer.objects_api.member.PNUUID; import com.pubnub.api.models.consumer.objects.PNPage; -import com.pubnub.api.models.consumer.objects_api.member.PNManageChannelMembersResult; -import com.pubnub.api.models.consumer.objects_api.member.PNUUID; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.member.MemberInput; -import com.pubnub.internal.models.consumer.objects.member.PNMember; -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult; -import lombok.AllArgsConstructor; +import com.pubnub.api.models.consumer.objects.member.MemberInput; +import com.pubnub.api.models.consumer.objects.member.PNMember; +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -41,7 +40,7 @@ public class ManageChannelMembersImpl extends DelegatingEndpoint uuidsToSet; private final Collection uuidsToRemove; - public ManageChannelMembersImpl(String channel, Collection uuidsToSet, Collection uuidsToRemove, final PubNubCore pubnubInstance) { + public ManageChannelMembersImpl(String channel, Collection uuidsToSet, Collection uuidsToRemove, final PubNub pubnubInstance) { super(pubnubInstance); this.channel = channel; this.uuidsToSet = uuidsToSet; @@ -56,7 +55,7 @@ protected ExtendedRemoteAction mapResult(@NotNull @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { List toRemove = new ArrayList(uuidsToRemove.size()); for (PNUUID pnuuid : uuidsToRemove) { toRemove.add(pnuuid.getUuid().getId()); @@ -85,9 +84,12 @@ protected EndpointInterface createAction() { ); } - @AllArgsConstructor public static class Builder implements ManageChannelMembers.Builder { - private final PubNubCore pubnubInstance; + private final PubNub pubnubInstance; + + public Builder(PubNub pubnubInstance) { + this.pubnubInstance = pubnubInstance; + } @Override public ObjectsBuilderSteps.RemoveOrSetStep channel(final String channel) { diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/RemoveChannelMembersImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/RemoveChannelMembersImpl.java similarity index 71% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/RemoveChannelMembersImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/RemoveChannelMembersImpl.java index e6afc5ea9..1b012a512 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/RemoveChannelMembersImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/RemoveChannelMembersImpl.java @@ -1,19 +1,18 @@ -package com.pubnub.internal.endpoints.objects_api.members; +package com.pubnub.internal.java.endpoints.objects_api.members; -import com.pubnub.api.endpoints.objects_api.members.RemoveChannelMembers; -import com.pubnub.api.endpoints.objects_api.utils.Include; -import com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps; -import com.pubnub.api.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.members.RemoveChannelMembers; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.member.PNRemoveChannelMembersResult; +import com.pubnub.api.java.models.consumer.objects_api.member.PNUUID; import com.pubnub.api.models.consumer.objects.PNPage; -import com.pubnub.api.models.consumer.objects_api.member.PNRemoveChannelMembersResult; -import com.pubnub.api.models.consumer.objects_api.member.PNUUID; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult; -import lombok.AllArgsConstructor; +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -38,7 +37,7 @@ public class RemoveChannelMembersImpl extends DelegatingEndpoint uuids; private Include.PNUUIDDetailsLevel includeUUID; - public RemoveChannelMembersImpl(String channel, Collection uuids, final PubNubCore pubnubInstance) { + public RemoveChannelMembersImpl(String channel, Collection uuids, final PubNub pubnubInstance) { super(pubnubInstance); this.channel = channel; this.uuids = new ArrayList<>(uuids.size()); @@ -55,7 +54,7 @@ protected ExtendedRemoteAction mapResult(@NotNull @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.removeChannelMembers( channel, uuids, @@ -70,9 +69,12 @@ protected EndpointInterface createAction() { ); } - @AllArgsConstructor public static class Builder implements RemoveChannelMembers.Builder { - private final PubNubCore pubnubInstance; + private final PubNub pubnubInstance; + + public Builder(PubNub pubnubInstance) { + this.pubnubInstance = pubnubInstance; + } @Override public ObjectsBuilderSteps.UUIDsStep channel(final String channel) { diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/SetChannelMembersImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/SetChannelMembersImpl.java similarity index 67% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/SetChannelMembersImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/SetChannelMembersImpl.java index 5893e6c62..d42e1274d 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/members/SetChannelMembersImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/members/SetChannelMembersImpl.java @@ -1,23 +1,22 @@ -package com.pubnub.internal.endpoints.objects_api.members; +package com.pubnub.internal.java.endpoints.objects_api.members; -import com.pubnub.api.endpoints.objects_api.members.SetChannelMembers; -import com.pubnub.api.endpoints.objects_api.utils.Include; -import com.pubnub.api.endpoints.objects_api.utils.ObjectsBuilderSteps; -import com.pubnub.api.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.members.SetChannelMembers; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.ObjectsBuilderSteps; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.member.PNSetChannelMembersResult; +import com.pubnub.api.java.models.consumer.objects_api.member.PNUUID; +import com.pubnub.api.models.consumer.objects.PNMemberKey; import com.pubnub.api.models.consumer.objects.PNPage; -import com.pubnub.api.models.consumer.objects_api.member.PNSetChannelMembersResult; -import com.pubnub.api.models.consumer.objects_api.member.PNUUID; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.PNMemberKey; -import com.pubnub.internal.models.consumer.objects.member.MemberInput; -import com.pubnub.internal.models.consumer.objects.member.PNMember; -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult; -import com.pubnub.internal.models.consumer.objects.member.PNUUIDDetailsLevel; -import lombok.AllArgsConstructor; +import com.pubnub.api.models.consumer.objects.member.MemberInput; +import com.pubnub.api.models.consumer.objects.member.PNMember; +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult; +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -43,7 +42,7 @@ public class SetChannelMembersImpl extends DelegatingEndpoint uuids; - public SetChannelMembersImpl(final PubNubCore pubnubInstance, String channel, Collection uuids) { + public SetChannelMembersImpl(final PubNub pubnubInstance, String channel, Collection uuids) { super(pubnubInstance); this.channel = channel; this.uuids = uuids; @@ -57,7 +56,7 @@ protected ExtendedRemoteAction mapResult(@NotNull Ext @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { List memberInputs = new ArrayList<>(uuids.size()); for (PNUUID uuid : uuids) { memberInputs.add(new PNMember.Partial(uuid.getUuid().getId(), (uuid instanceof PNUUID.UUIDWithCustom) ? ((PNUUID.UUIDWithCustom) uuid).getCustom() : null, uuid.getStatus())); @@ -65,8 +64,8 @@ protected EndpointInterface createAction() { return pubnub.setChannelMembers(channel, memberInputs, limit, page, filter, toInternal(sort), includeTotalCount, includeCustom, toInternal(includeUUID), includeType); } - static Collection> toInternal(Collection sort) { - List> list = new ArrayList<>(sort.size()); + static Collection> toInternal(Collection sort) { + List> list = new ArrayList<>(sort.size()); for (PNSortKey pnSortKey : sort) { PNMemberKey key = null; switch (pnSortKey.getKey()) { @@ -83,9 +82,9 @@ static Collection(key)); + list.add(new com.pubnub.api.models.consumer.objects.PNSortKey.PNAsc<>(key)); } else { - list.add(new com.pubnub.internal.models.consumer.objects.PNSortKey.PNDesc<>(key)); + list.add(new com.pubnub.api.models.consumer.objects.PNSortKey.PNDesc<>(key)); } } return list; @@ -106,9 +105,12 @@ static PNUUIDDetailsLevel toInternal(Include.PNUUIDDetailsLevel detailLevel) { } } - @AllArgsConstructor public static class Builder implements SetChannelMembers.Builder { - private final PubNubCore pubnubInstance; + private final PubNub pubnubInstance; + + public Builder(PubNub pubnubInstance) { + this.pubnubInstance = pubnubInstance; + } @Override public ObjectsBuilderSteps.UUIDsStep channel(final String channel) { diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/GetMembershipsImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/GetMembershipsImpl.java similarity index 68% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/GetMembershipsImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/GetMembershipsImpl.java index be76749dc..81edea30b 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/GetMembershipsImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/GetMembershipsImpl.java @@ -1,16 +1,16 @@ -package com.pubnub.internal.endpoints.objects_api.memberships; +package com.pubnub.internal.java.endpoints.objects_api.memberships; -import com.pubnub.api.endpoints.objects_api.memberships.GetMemberships; -import com.pubnub.api.endpoints.objects_api.utils.Include; -import com.pubnub.api.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.memberships.GetMemberships; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNGetMembershipsResult; import com.pubnub.api.models.consumer.objects.PNPage; -import com.pubnub.api.models.consumer.objects_api.membership.PNGetMembershipsResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult; +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -32,7 +32,7 @@ public class GetMembershipsImpl extends DelegatingEndpoint mapResult(@NotNull Extend @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.getMemberships(uuid, limit, page, diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/ManageMembershipsImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/ManageMembershipsImpl.java similarity index 77% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/ManageMembershipsImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/ManageMembershipsImpl.java index a3c24e499..b9858c65e 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/ManageMembershipsImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/ManageMembershipsImpl.java @@ -1,19 +1,18 @@ -package com.pubnub.internal.endpoints.objects_api.memberships; +package com.pubnub.internal.java.endpoints.objects_api.memberships; -import com.pubnub.api.endpoints.objects_api.memberships.ManageMemberships; -import com.pubnub.api.endpoints.objects_api.utils.Include; -import com.pubnub.api.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.memberships.ManageMemberships; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNManageMembershipResult; import com.pubnub.api.models.consumer.objects.PNPage; -import com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNManageMembershipResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.membership.ChannelMembershipInput; -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult; -import lombok.AllArgsConstructor; +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput; +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -37,7 +36,7 @@ public class ManageMembershipsImpl extends DelegatingEndpoint channelsToSet, Collection channelsToRemove, final PubNubCore pubnubInstance) { + public ManageMembershipsImpl(Collection channelsToSet, Collection channelsToRemove, final PubNub pubnubInstance) { super(pubnubInstance); set = channelsToSet; remove = channelsToRemove; @@ -51,10 +50,10 @@ protected ExtendedRemoteAction mapResult(@NotNull Exte @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { ArrayList toSet = new ArrayList<>(set.size()); for (PNChannelMembership channel : set) { - toSet.add(new com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership.Partial( + toSet.add(new com.pubnub.api.models.consumer.objects.membership.PNChannelMembership.Partial( channel.getChannel().getId(), (channel instanceof PNChannelMembership.ChannelWithCustom) ? ((PNChannelMembership.ChannelWithCustom) channel).getCustom() @@ -83,9 +82,12 @@ protected EndpointInterface createAction() { ); } - @AllArgsConstructor public static class Builder implements ManageMemberships.Builder { - private final PubNubCore pubnubInstance; + private final PubNub pubnubInstance; + + public Builder(PubNub pubnubInstance) { + this.pubnubInstance = pubnubInstance; + } @Override public RemoveStep set(final Collection channelsToSet) { diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/RemoveMembershipsImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/RemoveMembershipsImpl.java similarity index 70% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/RemoveMembershipsImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/RemoveMembershipsImpl.java index b6e4d18cb..53cc85ae1 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/RemoveMembershipsImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/RemoveMembershipsImpl.java @@ -1,18 +1,17 @@ -package com.pubnub.internal.endpoints.objects_api.memberships; +package com.pubnub.internal.java.endpoints.objects_api.memberships; -import com.pubnub.api.endpoints.objects_api.memberships.RemoveMemberships; -import com.pubnub.api.endpoints.objects_api.utils.Include; -import com.pubnub.api.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.memberships.RemoveMemberships; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNRemoveMembershipResult; import com.pubnub.api.models.consumer.objects.PNPage; -import com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNRemoveMembershipResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult; -import lombok.AllArgsConstructor; +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -35,7 +34,7 @@ public class RemoveMembershipsImpl extends DelegatingEndpoint channelMemberships, final PubNubCore pubnubInstance) { + public RemoveMembershipsImpl(@NotNull Collection channelMemberships, final PubNub pubnubInstance) { super(pubnubInstance); this.channelMemberships = channelMemberships; } @@ -48,7 +47,7 @@ protected ExtendedRemoteAction mapResult(@NotNull Exte @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { ArrayList channelList = new ArrayList<>(channelMemberships.size()); for (PNChannelMembership channel : channelMemberships) { channelList.add(channel.getChannel().getId()); @@ -67,9 +66,12 @@ protected EndpointInterface createAction() { ); } - @AllArgsConstructor public static class Builder implements RemoveMemberships.Builder { - private final PubNubCore pubnubInstance; + private final PubNub pubnubInstance; + + public Builder(PubNub pubnubInstance) { + this.pubnubInstance = pubnubInstance; + } @Override public RemoveMemberships channelMemberships(@NotNull final Collection channelMemberships) { diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/SetMembershipsImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/SetMembershipsImpl.java similarity index 64% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/SetMembershipsImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/SetMembershipsImpl.java index bdcea9834..680dc0047 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/memberships/SetMembershipsImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/memberships/SetMembershipsImpl.java @@ -1,21 +1,20 @@ -package com.pubnub.internal.endpoints.objects_api.memberships; +package com.pubnub.internal.java.endpoints.objects_api.memberships; -import com.pubnub.api.endpoints.objects_api.memberships.SetMemberships; -import com.pubnub.api.endpoints.objects_api.utils.Include; -import com.pubnub.api.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.memberships.SetMemberships; +import com.pubnub.api.java.endpoints.objects_api.utils.Include; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNChannelMembership; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNSetMembershipResult; +import com.pubnub.api.models.consumer.objects.PNMembershipKey; import com.pubnub.api.models.consumer.objects.PNPage; -import com.pubnub.api.models.consumer.objects_api.membership.PNChannelMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNSetMembershipResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.PNMembershipKey; -import com.pubnub.internal.models.consumer.objects.membership.ChannelMembershipInput; -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership.Partial; -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult; -import lombok.AllArgsConstructor; +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput; +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership.Partial; +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -40,14 +39,14 @@ public class SetMembershipsImpl extends DelegatingEndpoint channelMemberships, final PubNubCore pubnubInstance) { + public SetMembershipsImpl(@NotNull Collection channelMemberships, final PubNub pubnubInstance) { super(pubnubInstance); this.channels = channelMemberships; } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { ArrayList channelList = new ArrayList<>(channels.size()); for (PNChannelMembership channel : channels) { channelList.add(new Partial( @@ -78,9 +77,12 @@ protected ExtendedRemoteAction mapResult(@NotNull Extende return new MappingRemoteAction<>(action, PNSetMembershipResult::from); } - @AllArgsConstructor public static class Builder implements SetMemberships.Builder { - private final PubNubCore pubnubInstance; + private final PubNub pubnubInstance; + + public Builder(PubNub pubnubInstance) { + this.pubnubInstance = pubnubInstance; + } public SetMemberships channelMemberships(@NotNull final Collection channelMemberships) { return new SetMembershipsImpl(channelMemberships, pubnubInstance); @@ -88,22 +90,22 @@ public SetMemberships channelMemberships(@NotNull final Collection> toInternal(Collection sort) { - List> list = new ArrayList<>(sort.size()); + static Collection> toInternal(Collection sort) { + List> list = new ArrayList<>(sort.size()); for (PNSortKey pnSortKey : sort) { PNMembershipKey key = null; switch (pnSortKey.getKey()) { @@ -120,9 +122,9 @@ static Collection(key)); + list.add(new com.pubnub.api.models.consumer.objects.PNSortKey.PNAsc<>(key)); } else { - list.add(new com.pubnub.internal.models.consumer.objects.PNSortKey.PNDesc<>(key)); + list.add(new com.pubnub.api.models.consumer.objects.PNSortKey.PNDesc<>(key)); } } return list; diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/GetAllUUIDMetadataImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/GetAllUUIDMetadataImpl.java similarity index 64% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/GetAllUUIDMetadataImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/GetAllUUIDMetadataImpl.java index 3b3e37715..fd4d4c012 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/GetAllUUIDMetadataImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/GetAllUUIDMetadataImpl.java @@ -1,15 +1,15 @@ -package com.pubnub.internal.endpoints.objects_api.uuid; +package com.pubnub.internal.java.endpoints.objects_api.uuid; -import com.pubnub.api.endpoints.objects_api.utils.PNSortKey; -import com.pubnub.api.endpoints.objects_api.uuid.GetAllUUIDMetadata; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.endpoints.objects_api.utils.PNSortKey; +import com.pubnub.api.java.endpoints.objects_api.uuid.GetAllUUIDMetadata; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNGetAllUUIDMetadataResult; import com.pubnub.api.models.consumer.objects.PNPage; -import com.pubnub.api.models.consumer.objects_api.uuid.PNGetAllUUIDMetadataResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataArrayResult; +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ import java.util.Collection; import java.util.Collections; -import static com.pubnub.internal.endpoints.objects_api.channel.GetAllChannelsMetadataImpl.toInternal; +import static com.pubnub.internal.java.endpoints.objects_api.channel.GetAllChannelsMetadataImpl.toInternal; @Setter @Accessors(chain = true, fluent = true) @@ -31,13 +31,13 @@ public class GetAllUUIDMetadataImpl private String filter; private Collection sort = Collections.emptyList(); - public GetAllUUIDMetadataImpl(final PubNubCore pubnub) { + public GetAllUUIDMetadataImpl(final PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.getAllUUIDMetadata( limit, page, diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/GetUUIDMetadataImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/GetUUIDMetadataImpl.java similarity index 62% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/GetUUIDMetadataImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/GetUUIDMetadataImpl.java index c0cbc5039..1095588f4 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/GetUUIDMetadataImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/GetUUIDMetadataImpl.java @@ -1,14 +1,14 @@ -package com.pubnub.internal.endpoints.objects_api.uuid; +package com.pubnub.internal.java.endpoints.objects_api.uuid; -import com.pubnub.api.endpoints.objects_api.uuid.GetUUIDMetadata; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; -import com.pubnub.api.models.consumer.objects_api.uuid.PNGetUUIDMetadataResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadata; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataResult; +import com.pubnub.api.java.endpoints.objects_api.uuid.GetUUIDMetadata; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNGetUUIDMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadata; +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -20,13 +20,13 @@ public class GetUUIDMetadataImpl extends DelegatingEndpoint createAction() { + protected Endpoint createRemoteAction() { return pubnub.getUUIDMetadata( uuid, includeCustom diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/RemoveUUIDMetadataImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/RemoveUUIDMetadataImpl.java similarity index 63% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/RemoveUUIDMetadataImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/RemoveUUIDMetadataImpl.java index 9f76b5eda..0f05ddb54 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/RemoveUUIDMetadataImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/RemoveUUIDMetadataImpl.java @@ -1,13 +1,13 @@ -package com.pubnub.internal.endpoints.objects_api.uuid; +package com.pubnub.internal.java.endpoints.objects_api.uuid; -import com.pubnub.api.endpoints.objects_api.uuid.RemoveUUIDMetadata; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; -import com.pubnub.api.models.consumer.objects_api.uuid.PNRemoveUUIDMetadataResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.PNRemoveMetadataResult; +import com.pubnub.api.java.endpoints.objects_api.uuid.RemoveUUIDMetadata; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNRemoveUUIDMetadataResult; +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -18,13 +18,13 @@ public class RemoveUUIDMetadataImpl extends DelegatingEndpoint createAction() { + protected Endpoint createRemoteAction() { return pubnub.removeUUIDMetadata(uuid); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/SetUUIDMetadataImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/SetUUIDMetadataImpl.java similarity index 72% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/SetUUIDMetadataImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/SetUUIDMetadataImpl.java index 229f5c3a3..894ed6f75 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/objects_api/uuid/SetUUIDMetadataImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/objects_api/uuid/SetUUIDMetadataImpl.java @@ -1,14 +1,14 @@ -package com.pubnub.internal.endpoints.objects_api.uuid; +package com.pubnub.internal.java.endpoints.objects_api.uuid; -import com.pubnub.api.endpoints.objects_api.uuid.SetUUIDMetadata; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; -import com.pubnub.api.models.consumer.objects_api.uuid.PNSetUUIDMetadataResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadata; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; -import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataResult; +import com.pubnub.api.java.endpoints.objects_api.uuid.SetUUIDMetadata; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNSetUUIDMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadata; +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -37,11 +37,12 @@ public class SetUUIDMetadataImpl extends DelegatingEndpoint custom) { + @Override + public SetUUIDMetadata custom(Map custom) { final HashMap customHashMap = new HashMap<>(); if (custom != null) { customHashMap.putAll(custom); @@ -52,7 +53,7 @@ public SetUUIDMetadataImpl(final PubNubCore pubnub) { @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.setUUIDMetadata( uuid, name, diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/GetStateImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/GetStateImpl.java similarity index 59% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/GetStateImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/GetStateImpl.java index e8a8e1d5c..2859820c5 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/GetStateImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/GetStateImpl.java @@ -1,10 +1,10 @@ -package com.pubnub.internal.endpoints.presence; +package com.pubnub.internal.java.endpoints.presence; -import com.pubnub.api.endpoints.presence.GetState; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; +import com.pubnub.api.java.endpoints.presence.GetState; import com.pubnub.api.models.consumer.presence.PNGetStateResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -14,20 +14,20 @@ @Setter @Accessors(chain = true, fluent = true) -public class GetStateImpl extends IdentityMappingEndpoint implements GetState { +public class GetStateImpl extends PassthroughEndpoint implements GetState { private List channels = new ArrayList<>(); private List channelGroups = new ArrayList<>(); private String uuid; - public GetStateImpl(PubNubCore pubnub) { + public GetStateImpl(PubNub pubnub) { super(pubnub); uuid = pubnub.getConfiguration().getUuid(); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.getPresenceState( channels, channelGroups, diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/HeartbeatImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/HeartbeatImpl.java new file mode 100644 index 000000000..04e75c655 --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/HeartbeatImpl.java @@ -0,0 +1,34 @@ +package com.pubnub.internal.java.endpoints.presence; + +import com.pubnub.api.Endpoint; +import com.pubnub.api.java.endpoints.presence.Heartbeat; +import com.pubnub.internal.PubNubImpl; +import com.pubnub.internal.endpoints.presence.HeartbeatEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; +import lombok.Setter; +import lombok.experimental.Accessors; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +@Setter +@Accessors(chain = true, fluent = true) +public class HeartbeatImpl extends PassthroughEndpoint implements Heartbeat { + + private List channels; + private List channelGroups; + private Object state; + + public HeartbeatImpl(PubNubImpl pubnub) { + super(pubnub); + channels = new ArrayList<>(); + channelGroups = new ArrayList<>(); + } + + @Override + @NotNull + protected Endpoint createRemoteAction() { + return new HeartbeatEndpoint((PubNubImpl) pubnub, channels, channelGroups, state); + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/HereNowImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/HereNowImpl.java similarity index 60% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/HereNowImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/HereNowImpl.java index b81bfbc78..2d6f54d46 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/HereNowImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/HereNowImpl.java @@ -1,11 +1,11 @@ -package com.pubnub.internal.endpoints.presence; +package com.pubnub.internal.java.endpoints.presence; -import com.pubnub.api.endpoints.presence.HereNow; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; +import com.pubnub.api.java.endpoints.presence.HereNow; import com.pubnub.api.models.consumer.presence.PNHereNowResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -15,19 +15,19 @@ @Setter @Accessors(chain = true, fluent = true) -public class HereNowImpl extends IdentityMappingEndpoint implements HereNow { +public class HereNowImpl extends PassthroughEndpoint implements HereNow { private List channels = new ArrayList<>(); private List channelGroups = new ArrayList<>(); private boolean includeState = false; private boolean includeUUIDs = true; - public HereNowImpl(PubNubCore pubnub) { + public HereNowImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.hereNow( channels, channelGroups, diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/LeaveImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/LeaveImpl.java new file mode 100644 index 000000000..353c539fd --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/LeaveImpl.java @@ -0,0 +1,34 @@ +package com.pubnub.internal.java.endpoints.presence; + +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; +import com.pubnub.api.java.endpoints.presence.Leave; +import com.pubnub.internal.PubNubImpl; +import com.pubnub.internal.endpoints.presence.LeaveEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; +import lombok.Setter; +import lombok.experimental.Accessors; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +@Setter +@Accessors(chain = true, fluent = true) +public class LeaveImpl extends PassthroughEndpoint implements Leave { + private List channels = new ArrayList<>(); + private List channelGroups = new ArrayList<>(); + + public LeaveImpl(PubNub pubnub) { + super(pubnub); + } + + @Override + @NotNull + protected Endpoint createRemoteAction() { + LeaveEndpoint leave = new LeaveEndpoint((PubNubImpl) pubnub); + leave.setChannels(channels); + leave.setChannelGroups(channelGroups); + return leave; + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/SetStateImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/SetStateImpl.java similarity index 77% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/SetStateImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/SetStateImpl.java index 12bae7346..6b72a7087 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/presence/SetStateImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/SetStateImpl.java @@ -1,14 +1,15 @@ -package com.pubnub.internal.endpoints.presence; +package com.pubnub.internal.java.endpoints.presence; +import com.pubnub.api.Endpoint; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.presence.SetState; import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction; import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.presence.SetState; import com.pubnub.api.models.consumer.presence.PNSetStateResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.DelegatingEndpoint; +import com.pubnub.internal.PubNubImpl; +import com.pubnub.internal.endpoints.presence.HeartbeatEndpoint; +import com.pubnub.internal.java.endpoints.DelegatingEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -34,7 +35,7 @@ public class SetStateImpl extends DelegatingEndpoint i private boolean withHeartbeat; - public SetStateImpl(PubNubCore pubnub) { + public SetStateImpl(PubNubImpl pubnub) { super(pubnub); } @@ -44,7 +45,7 @@ protected void validateParams() throws PubNubException { throw new PubNubException(PubNubErrorBuilder.PNERROBJ_STATE_MISSING); } - String stringifiedState = pubnub.getMapper().toJson(state); + String stringifiedState = ((PubNubImpl) pubnub).getMapper().toJson(state); if (!isJsonObject(stringifiedState)) { throw new PubNubException(PubNubErrorBuilder.PNERROBJ_STATE_MUST_BE_JSON_OBJECT); } @@ -68,7 +69,7 @@ private boolean isJsonObject(String json) { @Override protected ExtendedRemoteAction mapResult(@NotNull ExtendedRemoteAction action) { if (withHeartbeat) { - return new MappingRemoteAction<>(action, result -> new PNSetStateResult(pubnub.getMapper().toJsonTree(state))); + return new MappingRemoteAction<>(action, result -> new PNSetStateResult(((PubNubImpl) pubnub).getMapper().toJsonTree(state))); } else { return new MappingRemoteAction<>(action, result -> (PNSetStateResult) result); } @@ -76,10 +77,10 @@ protected ExtendedRemoteAction mapResult(@NotNull ExtendedRemo @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { if (!withHeartbeat) { // Regular way of setting presence explicitly is through SetPresenceState: - return (EndpointInterface) (Object) pubnub.setPresenceState( + return (Endpoint) (Object) pubnub.setPresenceState( channels, channelGroups, state, @@ -88,7 +89,7 @@ protected EndpointInterface createAction() { } else { // Some clients require alternative way of setting it through Heartbeat // Which is a feature brought over from the legacy Java SDK, and we need to be compatible: - return (EndpointInterface) (Object) new HeartbeatEndpoint(pubnub, channels, channelGroups, composeStateParamValue()); + return (Endpoint) (Object) new HeartbeatEndpoint((PubNubImpl) pubnub, channels, channelGroups, composeStateParamValue()); } } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/WhereNowImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/WhereNowImpl.java new file mode 100644 index 000000000..ced6df587 --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/presence/WhereNowImpl.java @@ -0,0 +1,28 @@ +package com.pubnub.internal.java.endpoints.presence; + +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; +import com.pubnub.api.java.endpoints.presence.WhereNow; +import com.pubnub.api.models.consumer.presence.PNWhereNowResult; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; +import lombok.Setter; +import lombok.experimental.Accessors; +import org.jetbrains.annotations.NotNull; + +@Setter +@Accessors(chain = true, fluent = true) +public class WhereNowImpl extends PassthroughEndpoint implements WhereNow { + + private String uuid; + + public WhereNowImpl(PubNub pubnub) { + super(pubnub); + uuid = pubnub.getConfiguration().getUuid(); + } + + @Override + @NotNull + protected Endpoint createRemoteAction() { + return pubnub.whereNow(uuid); + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/pubsub/PublishImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/pubsub/PublishImpl.java similarity index 65% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/pubsub/PublishImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/pubsub/PublishImpl.java index 135766715..8b9062c56 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/pubsub/PublishImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/pubsub/PublishImpl.java @@ -1,20 +1,20 @@ -package com.pubnub.internal.endpoints.pubsub; +package com.pubnub.internal.java.endpoints.pubsub; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.pubsub.Publish; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.pubsub.Publish; +import com.pubnub.api.java.v2.endpoints.pubsub.PublishBuilder; import com.pubnub.api.models.consumer.PNPublishResult; -import com.pubnub.api.v2.endpoints.pubsub.PublishBuilder; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @Setter @Accessors(chain = true, fluent = true) -public class PublishImpl extends IdentityMappingEndpoint implements Publish, PublishBuilder { +public class PublishImpl extends PassthroughEndpoint implements Publish, PublishBuilder { private Object message; private String channel; @@ -24,14 +24,14 @@ public class PublishImpl extends IdentityMappingEndpoint implem private boolean replicate; private Integer ttl; - public PublishImpl(PubNubCore pubnub) { + public PublishImpl(PubNub pubnub) { super(pubnub); this.replicate = true; } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.publish( channel, message, diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/pubsub/SignalImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/pubsub/SignalImpl.java similarity index 57% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/pubsub/SignalImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/pubsub/SignalImpl.java index 6ab440c6b..b7030eb59 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/pubsub/SignalImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/pubsub/SignalImpl.java @@ -1,31 +1,31 @@ -package com.pubnub.internal.endpoints.pubsub; +package com.pubnub.internal.java.endpoints.pubsub; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; -import com.pubnub.api.endpoints.pubsub.Signal; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.pubsub.Signal; +import com.pubnub.api.java.v2.endpoints.pubsub.SignalBuilder; import com.pubnub.api.models.consumer.PNPublishResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.api.v2.endpoints.pubsub.SignalBuilder; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @Setter @Accessors(chain = true, fluent = true) -public class SignalImpl extends IdentityMappingEndpoint implements Signal, SignalBuilder { +public class SignalImpl extends PassthroughEndpoint implements Signal, SignalBuilder { private Object message; private String channel; - public SignalImpl(PubNubCore pubnub) { + public SignalImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.signal(channel, message); } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/AddChannelsToPushImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/AddChannelsToPushImpl.java similarity index 71% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/AddChannelsToPushImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/AddChannelsToPushImpl.java index e4a98d922..cc40d1d16 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/AddChannelsToPushImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/AddChannelsToPushImpl.java @@ -1,13 +1,14 @@ -package com.pubnub.internal.endpoints.push; +package com.pubnub.internal.java.endpoints.push; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; import com.pubnub.api.enums.PNPushEnvironment; import com.pubnub.api.enums.PNPushType; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.push.AddChannelsToPush; import com.pubnub.api.models.consumer.push.PNPushAddChannelResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -16,7 +17,7 @@ @Setter @Accessors(chain = true, fluent = true) -public class AddChannelsToPushImpl extends IdentityMappingEndpoint implements com.pubnub.api.endpoints.push.AddChannelsToPush { +public class AddChannelsToPushImpl extends PassthroughEndpoint implements AddChannelsToPush { private PNPushType pushType; private List channels; @@ -24,13 +25,13 @@ public class AddChannelsToPushImpl extends IdentityMappingEndpoint createAction() { + protected Endpoint createRemoteAction() { return pubnub.addPushNotificationsOnChannels( pushType, channels, diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/ListPushProvisionsImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/ListPushProvisionsImpl.java similarity index 67% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/ListPushProvisionsImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/ListPushProvisionsImpl.java index ce4e5c9a9..3ca22984f 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/ListPushProvisionsImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/ListPushProvisionsImpl.java @@ -1,33 +1,34 @@ -package com.pubnub.internal.endpoints.push; +package com.pubnub.internal.java.endpoints.push; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; import com.pubnub.api.enums.PNPushEnvironment; import com.pubnub.api.enums.PNPushType; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.push.ListPushProvisions; import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @Setter @Accessors(chain = true, fluent = true) -public class ListPushProvisionsImpl extends IdentityMappingEndpoint implements com.pubnub.api.endpoints.push.ListPushProvisions { +public class ListPushProvisionsImpl extends PassthroughEndpoint implements ListPushProvisions { private PNPushType pushType; private String deviceId; private PNPushEnvironment environment = PNPushEnvironment.DEVELOPMENT; private String topic; - public ListPushProvisionsImpl(PubNubCore pubnub) { + public ListPushProvisionsImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.auditPushChannelProvisions( pushType, deviceId, diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/RemoveAllPushChannelsForDeviceImpl.java similarity index 65% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/RemoveAllPushChannelsForDeviceImpl.java index 1f927f387..75ecee747 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/RemoveAllPushChannelsForDeviceImpl.java @@ -1,32 +1,33 @@ -package com.pubnub.internal.endpoints.push; +package com.pubnub.internal.java.endpoints.push; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; import com.pubnub.api.enums.PNPushEnvironment; import com.pubnub.api.enums.PNPushType; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.push.RemoveAllPushChannelsForDevice; import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @Setter @Accessors(chain = true, fluent = true) -public class RemoveAllPushChannelsForDeviceImpl extends IdentityMappingEndpoint implements com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice { +public class RemoveAllPushChannelsForDeviceImpl extends PassthroughEndpoint implements RemoveAllPushChannelsForDevice { private PNPushType pushType; private String deviceId; private PNPushEnvironment environment = PNPushEnvironment.DEVELOPMENT; private String topic; - public RemoveAllPushChannelsForDeviceImpl(PubNubCore pubnub) { + public RemoveAllPushChannelsForDeviceImpl(PubNub pubnub) { super(pubnub); } @Override @NotNull - protected EndpointInterface createAction() { + protected Endpoint createRemoteAction() { return pubnub.removeAllPushNotificationsFromDeviceWithPushToken( pushType, deviceId, diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushImpl.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/RemoveChannelsFromPushImpl.java similarity index 70% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushImpl.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/RemoveChannelsFromPushImpl.java index 7a169abba..341fa67d8 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushImpl.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/endpoints/push/RemoveChannelsFromPushImpl.java @@ -1,13 +1,14 @@ -package com.pubnub.internal.endpoints.push; +package com.pubnub.internal.java.endpoints.push; +import com.pubnub.api.Endpoint; +import com.pubnub.api.PubNub; import com.pubnub.api.PubNubException; -import com.pubnub.api.builder.PubNubErrorBuilder; import com.pubnub.api.enums.PNPushEnvironment; import com.pubnub.api.enums.PNPushType; +import com.pubnub.api.java.builder.PubNubErrorBuilder; +import com.pubnub.api.java.endpoints.push.RemoveChannelsFromPush; import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult; -import com.pubnub.internal.EndpointInterface; -import com.pubnub.internal.PubNubCore; -import com.pubnub.internal.endpoints.IdentityMappingEndpoint; +import com.pubnub.internal.java.endpoints.PassthroughEndpoint; import lombok.Setter; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; @@ -16,7 +17,7 @@ @Setter @Accessors(chain = true, fluent = true) -public class RemoveChannelsFromPushImpl extends IdentityMappingEndpoint implements com.pubnub.api.endpoints.push.RemoveChannelsFromPush { +public class RemoveChannelsFromPushImpl extends PassthroughEndpoint implements RemoveChannelsFromPush { private PNPushType pushType; private List channels; @@ -24,13 +25,13 @@ public class RemoveChannelsFromPushImpl extends IdentityMappingEndpoint createAction() { + protected Endpoint createRemoteAction() { return pubnub.removePushNotificationsFromChannels( pushType, channels, diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/PNConfigurationImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/PNConfigurationImpl.kt similarity index 65% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/PNConfigurationImpl.kt rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/PNConfigurationImpl.kt index 25eed4871..c8de6d401 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/PNConfigurationImpl.kt +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/PNConfigurationImpl.kt @@ -1,12 +1,12 @@ -package com.pubnub.internal.v2 +package com.pubnub.internal.java.v2 import com.pubnub.api.UserId import com.pubnub.api.crypto.CryptoModule import com.pubnub.api.enums.PNHeartbeatNotificationOptions import com.pubnub.api.enums.PNLogVerbosity +import com.pubnub.api.java.v2.PNConfiguration +import com.pubnub.api.java.v2.PNConfigurationOverride import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.PNConfiguration import okhttp3.Authenticator import okhttp3.CertificatePinner import okhttp3.ConnectionSpec @@ -20,59 +20,67 @@ import javax.net.ssl.X509ExtendedTrustManager class PNConfigurationImpl( override val userId: UserId, - override val subscribeKey: String, - override val publishKey: String, - override val secretKey: String, - override val authKey: String, - override val cryptoModule: CryptoModule?, - override val origin: String, - override val secure: Boolean, - override val logVerbosity: PNLogVerbosity, - override val heartbeatNotificationOptions: PNHeartbeatNotificationOptions, - override val presenceTimeout: Int, - override val heartbeatInterval: Int, - override val subscribeTimeout: Int, - override val connectTimeout: Int, - override val nonSubscribeReadTimeout: Int, - override val cacheBusting: Boolean, - override val suppressLeaveEvents: Boolean, - override val maintainPresenceState: Boolean, - override val filterExpression: String, - override val includeInstanceIdentifier: Boolean, - override val includeRequestIdentifier: Boolean, - override val maximumConnections: Int?, - override val googleAppEngineNetworking: Boolean, - override val proxy: Proxy?, - override val proxySelector: ProxySelector?, - override val proxyAuthenticator: Authenticator?, - override val certificatePinner: CertificatePinner?, - override val httpLoggingInterceptor: HttpLoggingInterceptor?, - override val sslSocketFactory: SSLSocketFactory?, - override val x509ExtendedTrustManager: X509ExtendedTrustManager?, - override val connectionSpec: ConnectionSpec?, - override val hostnameVerifier: HostnameVerifier?, - override val fileMessagePublishRetryLimit: Int, - override val dedupOnSubscribe: Boolean, - override val maximumMessagesCacheSize: Int, - override val pnsdkSuffixes: Map, - override val retryConfiguration: RetryConfiguration, - override val managePresenceListManually: Boolean, -) : BasePNConfigurationImpl(userId), PNConfiguration { - class Builder internal constructor(defaultConfiguration: BasePNConfiguration) : - BasePNConfigurationImpl.Builder(defaultConfiguration), - PNConfiguration.Builder { + override val subscribeKey: String = "", + override val publishKey: String = "", + override val secretKey: String = "", + override val authKey: String = "", + override val cryptoModule: CryptoModule? = null, + override val origin: String = "", + override val secure: Boolean = true, + override val logVerbosity: PNLogVerbosity = PNLogVerbosity.NONE, + override val heartbeatNotificationOptions: PNHeartbeatNotificationOptions = PNHeartbeatNotificationOptions.FAILURES, + override val presenceTimeout: Int = PRESENCE_TIMEOUT, + override val heartbeatInterval: Int = 0, + override val subscribeTimeout: Int = SUBSCRIBE_TIMEOUT, + override val connectTimeout: Int = CONNECT_TIMEOUT, + override val nonSubscribeReadTimeout: Int = NON_SUBSCRIBE_REQUEST_TIMEOUT, + override val cacheBusting: Boolean = false, + override val suppressLeaveEvents: Boolean = false, + override val maintainPresenceState: Boolean = true, + override val filterExpression: String = "", + override val includeInstanceIdentifier: Boolean = false, + override val includeRequestIdentifier: Boolean = true, + override val maximumConnections: Int? = null, + override val googleAppEngineNetworking: Boolean = false, + override val proxy: Proxy? = null, + override val proxySelector: ProxySelector? = null, + override val proxyAuthenticator: Authenticator? = null, + override val certificatePinner: CertificatePinner? = null, + override val httpLoggingInterceptor: HttpLoggingInterceptor? = null, + override val sslSocketFactory: SSLSocketFactory? = null, + override val x509ExtendedTrustManager: X509ExtendedTrustManager? = null, + override val connectionSpec: ConnectionSpec? = null, + override val hostnameVerifier: HostnameVerifier? = null, + override val fileMessagePublishRetryLimit: Int = 5, + override val dedupOnSubscribe: Boolean = false, + override val maximumMessagesCacheSize: Int = DEFAULT_DEDUPE_SIZE, + override val pnsdkSuffixes: Map = emptyMap(), + override val retryConfiguration: RetryConfiguration = RetryConfiguration.None, + override val managePresenceListManually: Boolean = false, +) : PNConfiguration { + companion object { + const val DEFAULT_DEDUPE_SIZE = 100 + const val PRESENCE_TIMEOUT = 300 + const val MINIMUM_PRESENCE_TIMEOUT = 20 + const val NON_SUBSCRIBE_REQUEST_TIMEOUT = 10 + const val SUBSCRIBE_TIMEOUT = 310 + const val CONNECT_TIMEOUT = 5 + } + + class Builder internal constructor(defaultConfiguration: com.pubnub.api.v2.PNConfiguration) : + PNConfiguration.Builder, PNConfigurationOverride.Builder { + constructor(userId: UserId, subscribeKey: String) : this(PNConfigurationImpl(userId, subscribeKey)) + private val log = LoggerFactory.getLogger(this::class.simpleName) - override var userId: UserId = super.userId - private set + override var userId: UserId = defaultConfiguration.userId override fun setUserId(userId: UserId): PNConfiguration.Builder { this.userId = userId return this } - override var subscribeKey: String = super.subscribeKey - private set + override var subscribeKey: String = defaultConfiguration.subscribeKey override fun subscribeKey(subscribeKey: String): PNConfiguration.Builder { this.subscribeKey = subscribeKey @@ -84,64 +92,57 @@ class PNConfigurationImpl( return this } - override var publishKey: String = super.publishKey - private set + override var publishKey: String = defaultConfiguration.publishKey override fun secretKey(secretKey: String): Builder { this.secretKey = secretKey return this } - override var secretKey: String = super.secretKey - private set + override var secretKey: String = defaultConfiguration.secretKey override fun authKey(authKey: String): Builder { this.authKey = authKey return this } - override var authKey: String = super.authKey - private set + override var authKey: String = defaultConfiguration.authKey override fun cryptoModule(cryptoModule: CryptoModule?): Builder { this.cryptoModule = cryptoModule return this } - override var cryptoModule: CryptoModule? = super.cryptoModule - private set + override var cryptoModule: CryptoModule? = defaultConfiguration.cryptoModule override fun origin(origin: String): Builder { this.origin = origin return this } - override var origin: String = super.origin - private set + override var origin: String = defaultConfiguration.origin override fun secure(secure: Boolean): Builder { this.secure = secure return this } - override var secure: Boolean = super.secure - private set + override var secure: Boolean = defaultConfiguration.secure override fun logVerbosity(logVerbosity: PNLogVerbosity): Builder { this.logVerbosity = logVerbosity return this } - override var logVerbosity: PNLogVerbosity = super.logVerbosity - private set + override var logVerbosity: PNLogVerbosity = defaultConfiguration.logVerbosity override fun heartbeatNotificationOptions(heartbeatNotificationOptions: PNHeartbeatNotificationOptions): Builder { this.heartbeatNotificationOptions = heartbeatNotificationOptions return this } - override var heartbeatNotificationOptions: PNHeartbeatNotificationOptions = super.heartbeatNotificationOptions - private set + override var heartbeatNotificationOptions: PNHeartbeatNotificationOptions = + defaultConfiguration.heartbeatNotificationOptions override fun presenceTimeout(presenceTimeout: Int): Builder { this.presenceTimeout = if (presenceTimeout < MINIMUM_PRESENCE_TIMEOUT) { @@ -154,32 +155,28 @@ class PNConfigurationImpl( return this } - override var presenceTimeout: Int = super.presenceTimeout - private set + override var presenceTimeout: Int = defaultConfiguration.presenceTimeout override fun heartbeatInterval(heartbeatInterval: Int): Builder { this.heartbeatInterval = heartbeatInterval return this } - override var heartbeatInterval: Int = super.heartbeatInterval - private set + override var heartbeatInterval: Int = defaultConfiguration.heartbeatInterval override fun subscribeTimeout(subscribeTimeout: Int): Builder { this.subscribeTimeout = subscribeTimeout return this } - override var subscribeTimeout: Int = super.subscribeTimeout - private set + override var subscribeTimeout: Int = defaultConfiguration.subscribeTimeout override fun connectTimeout(connectTimeout: Int): Builder { this.connectTimeout = connectTimeout return this } - override var connectTimeout: Int = super.connectTimeout - private set + override var connectTimeout: Int = defaultConfiguration.connectTimeout @Deprecated( "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", @@ -194,192 +191,168 @@ class PNConfigurationImpl( return this } - override var nonSubscribeReadTimeout: Int = super.nonSubscribeReadTimeout - private set + override var nonSubscribeReadTimeout: Int = defaultConfiguration.nonSubscribeReadTimeout override fun cacheBusting(cacheBusting: Boolean): Builder { this.cacheBusting = cacheBusting return this } - override var cacheBusting: Boolean = super.cacheBusting - private set + override var cacheBusting: Boolean = defaultConfiguration.cacheBusting override fun suppressLeaveEvents(suppressLeaveEvents: Boolean): Builder { this.suppressLeaveEvents = suppressLeaveEvents return this } - override var suppressLeaveEvents: Boolean = super.suppressLeaveEvents - private set + override var suppressLeaveEvents: Boolean = defaultConfiguration.suppressLeaveEvents override fun maintainPresenceState(maintainPresenceState: Boolean): Builder { this.maintainPresenceState = maintainPresenceState return this } - override var maintainPresenceState: Boolean = super.maintainPresenceState - private set + override var maintainPresenceState: Boolean = defaultConfiguration.maintainPresenceState override fun filterExpression(filterExpression: String): Builder { this.filterExpression = filterExpression return this } - override var filterExpression: String = super.filterExpression - private set + override var filterExpression: String = defaultConfiguration.filterExpression override fun includeInstanceIdentifier(includeInstanceIdentifier: Boolean): Builder { this.includeInstanceIdentifier = includeInstanceIdentifier return this } - override var includeInstanceIdentifier: Boolean = super.includeInstanceIdentifier - private set + override var includeInstanceIdentifier: Boolean = defaultConfiguration.includeInstanceIdentifier override fun includeRequestIdentifier(includeRequestIdentifier: Boolean): Builder { this.includeRequestIdentifier = includeRequestIdentifier return this } - override var includeRequestIdentifier: Boolean = super.includeRequestIdentifier - private set + override var includeRequestIdentifier: Boolean = defaultConfiguration.includeRequestIdentifier override fun maximumConnections(maximumConnections: Int?): Builder { this.maximumConnections = maximumConnections return this } - override var maximumConnections: Int? = super.maximumConnections - private set + override var maximumConnections: Int? = defaultConfiguration.maximumConnections override fun googleAppEngineNetworking(googleAppEngineNetworking: Boolean): Builder { this.googleAppEngineNetworking = googleAppEngineNetworking return this } - override var googleAppEngineNetworking: Boolean = super.googleAppEngineNetworking - private set + override var googleAppEngineNetworking: Boolean = defaultConfiguration.googleAppEngineNetworking override fun proxy(proxy: Proxy?): Builder { this.proxy = proxy return this } - override var proxy: Proxy? = super.proxy - private set + override var proxy: Proxy? = defaultConfiguration.proxy override fun proxySelector(proxySelector: ProxySelector?): Builder { this.proxySelector = proxySelector return this } - override var proxySelector: ProxySelector? = super.proxySelector - private set + override var proxySelector: ProxySelector? = defaultConfiguration.proxySelector override fun proxyAuthenticator(proxyAuthenticator: Authenticator?): Builder { this.proxyAuthenticator = proxyAuthenticator return this } - override var proxyAuthenticator: Authenticator? = super.proxyAuthenticator - private set + override var proxyAuthenticator: Authenticator? = defaultConfiguration.proxyAuthenticator override fun certificatePinner(certificatePinner: CertificatePinner?): Builder { this.certificatePinner = certificatePinner return this } - override var certificatePinner: CertificatePinner? = super.certificatePinner - private set + override var certificatePinner: CertificatePinner? = defaultConfiguration.certificatePinner override fun httpLoggingInterceptor(httpLoggingInterceptor: HttpLoggingInterceptor?): Builder { this.httpLoggingInterceptor = httpLoggingInterceptor return this } - override var httpLoggingInterceptor: HttpLoggingInterceptor? = super.httpLoggingInterceptor - private set + override var httpLoggingInterceptor: HttpLoggingInterceptor? = defaultConfiguration.httpLoggingInterceptor override fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?): Builder { this.sslSocketFactory = sslSocketFactory return this } - override var sslSocketFactory: SSLSocketFactory? = super.sslSocketFactory - private set + override var sslSocketFactory: SSLSocketFactory? = defaultConfiguration.sslSocketFactory override fun x509ExtendedTrustManager(x509ExtendedTrustManager: X509ExtendedTrustManager?): Builder { this.x509ExtendedTrustManager = x509ExtendedTrustManager return this } - override var x509ExtendedTrustManager: X509ExtendedTrustManager? = super.x509ExtendedTrustManager - private set + override var x509ExtendedTrustManager: X509ExtendedTrustManager? = defaultConfiguration.x509ExtendedTrustManager override fun connectionSpec(connectionSpec: ConnectionSpec?): Builder { this.connectionSpec = connectionSpec return this } - override var connectionSpec: ConnectionSpec? = super.connectionSpec - private set + override var connectionSpec: ConnectionSpec? = defaultConfiguration.connectionSpec override fun hostnameVerifier(hostnameVerifier: HostnameVerifier?): Builder { this.hostnameVerifier = hostnameVerifier return this } - override var hostnameVerifier: HostnameVerifier? = super.hostnameVerifier - private set + override var hostnameVerifier: HostnameVerifier? = defaultConfiguration.hostnameVerifier override fun fileMessagePublishRetryLimit(fileMessagePublishRetryLimit: Int): Builder { this.fileMessagePublishRetryLimit = fileMessagePublishRetryLimit return this } - override var fileMessagePublishRetryLimit: Int = super.fileMessagePublishRetryLimit - private set + override var fileMessagePublishRetryLimit: Int = defaultConfiguration.fileMessagePublishRetryLimit override fun dedupOnSubscribe(dedupOnSubscribe: Boolean): Builder { this.dedupOnSubscribe = dedupOnSubscribe return this } - override var dedupOnSubscribe: Boolean = super.dedupOnSubscribe - private set + override var dedupOnSubscribe: Boolean = defaultConfiguration.dedupOnSubscribe override fun maximumMessagesCacheSize(maximumMessagesCacheSize: Int): Builder { this.maximumMessagesCacheSize = maximumMessagesCacheSize return this } - override var maximumMessagesCacheSize: Int = super.maximumMessagesCacheSize - private set + override var maximumMessagesCacheSize: Int = defaultConfiguration.maximumMessagesCacheSize override fun pnsdkSuffixes(pnsdkSuffixes: Map): Builder { this.pnsdkSuffixes = pnsdkSuffixes return this } - override var pnsdkSuffixes: Map = super.pnsdkSuffixes - private set + override var pnsdkSuffixes: Map = defaultConfiguration.pnsdkSuffixes override fun retryConfiguration(retryConfiguration: RetryConfiguration): Builder { this.retryConfiguration = retryConfiguration return this } - override var retryConfiguration: RetryConfiguration = super.retryConfiguration - private set + override var retryConfiguration: RetryConfiguration = defaultConfiguration.retryConfiguration override fun managePresenceListManually(managePresenceListManually: Boolean): Builder { this.managePresenceListManually = managePresenceListManually return this } - override var managePresenceListManually: Boolean = super.managePresenceListManually - private set + override var managePresenceListManually: Boolean = defaultConfiguration.managePresenceListManually override fun build(): PNConfiguration { return PNConfigurationImpl( diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingEventListener.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/Converters.java similarity index 58% rename from pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingEventListener.java rename to pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/Converters.java index 106615008..d1929ef81 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingEventListener.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/Converters.java @@ -1,81 +1,67 @@ -package com.pubnub.internal.v2.callbacks; - -import com.pubnub.api.BasePubNub; -import com.pubnub.api.PubNub; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadata; -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembership; -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadata; -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult; -import com.pubnub.api.models.consumer.pubsub.PNMessageResult; -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult; -import com.pubnub.api.models.consumer.pubsub.PNSignalResult; -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult; -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult; -import com.pubnub.api.v2.callbacks.EventListener; -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage; -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage; -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage; -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventMessage; -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult; -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage; -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetMembershipEvent; -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetMembershipEventMessage; -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage; +package com.pubnub.internal.java.v2.callbacks; + +import com.pubnub.api.java.PubNub; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadata; +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadataResult; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembership; +import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembershipResult; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadata; +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadataResult; +import com.pubnub.api.java.v2.callbacks.EventListener; +import com.pubnub.api.models.consumer.pubsub.objects.ObjectResult; +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage; +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage; +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage; +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventMessage; +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult; +import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage; +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent; +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage; +import com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage; import org.jetbrains.annotations.NotNull; -import java.util.Objects; - -public class DelegatingEventListener implements EventListenerCore { - private final EventListener listener; - - public DelegatingEventListener(EventListener listener) { - this.listener = listener; +class Converters { + private Converters() { } - public EventListener getListener() { - return listener; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof DelegatingEventListener)) { - return false; + static ObjectResult objects(@NotNull PNObjectEventResult objectEvent) { + PNObjectEventMessage message = objectEvent.getExtractedMessage(); + if (message instanceof PNDeleteMembershipEventMessage) { + return getDeleteMembershipResult(objectEvent, (PNDeleteMembershipEventMessage) message); + } else if (message instanceof PNSetMembershipEventMessage) { + return getSetMembershipResult(objectEvent, (PNSetMembershipEventMessage) message); + } else if (message instanceof PNDeleteChannelMetadataEventMessage) { + return getDeleteChannelMetadataResult(objectEvent, (PNDeleteChannelMetadataEventMessage) message); + } else if (message instanceof PNSetChannelMetadataEventMessage) { + return getSetChannelMetadataResult(objectEvent, (PNSetChannelMetadataEventMessage) message); + } else if (message instanceof PNDeleteUUIDMetadataEventMessage) { + return getDeleteUuidMetadataResult(objectEvent, (PNDeleteUUIDMetadataEventMessage) message); + } else if (message instanceof PNSetUUIDMetadataEventMessage) { + return getSetUuidMetadataResult(objectEvent, (PNSetUUIDMetadataEventMessage) message); } - DelegatingEventListener that = (DelegatingEventListener) o; - return Objects.equals(listener, that.listener); + return null; } - @Override - public int hashCode() { - return Objects.hash(listener); - } - - @Override - public final void objects(@NotNull BasePubNub pubnub, @NotNull PNObjectEventResult objectEvent) { + static void objects(@NotNull PNObjectEventResult objectEvent, @NotNull EventListener emitter, @NotNull PubNub pubnub) { PNObjectEventMessage message = objectEvent.getExtractedMessage(); if (message instanceof PNDeleteMembershipEventMessage) { PNMembershipResult result = getDeleteMembershipResult(objectEvent, (PNDeleteMembershipEventMessage) message); - listener.membership((PubNub) pubnub, result); + emitter.membership(pubnub, result); } else if (message instanceof PNSetMembershipEventMessage) { PNMembershipResult result = getSetMembershipResult(objectEvent, (PNSetMembershipEventMessage) message); - listener.membership((PubNub) pubnub, result); + emitter.membership(pubnub, result); } else if (message instanceof PNDeleteChannelMetadataEventMessage) { PNChannelMetadataResult result = getDeleteChannelMetadataResult(objectEvent, (PNDeleteChannelMetadataEventMessage) message); - listener.channel((PubNub) pubnub, result); + emitter.channel(pubnub, result); } else if (message instanceof PNSetChannelMetadataEventMessage) { PNChannelMetadataResult result = getSetChannelMetadataResult(objectEvent, (PNSetChannelMetadataEventMessage) message); - listener.channel((PubNub) pubnub, result); + emitter.channel(pubnub, result); } else if (message instanceof PNDeleteUUIDMetadataEventMessage) { PNUUIDMetadataResult result = getDeleteUuidMetadataResult(objectEvent, (PNDeleteUUIDMetadataEventMessage) message); - listener.uuid((PubNub) pubnub, result); + emitter.uuid(pubnub, result); } else if (message instanceof PNSetUUIDMetadataEventMessage) { PNUUIDMetadataResult result = getSetUuidMetadataResult(objectEvent, (PNSetUUIDMetadataEventMessage) message); - listener.uuid((PubNub) pubnub, result); + emitter.uuid(pubnub, result); } } @@ -178,30 +164,4 @@ static PNMembershipResult getSetMembershipResult(@NotNull PNObjectEventResult ob objectEvent.getPublisher() ); } - - - @Override - public void message(@NotNull BasePubNub pubnub, @NotNull PNMessageResult message) { - listener.message((PubNub) pubnub, message); - } - - @Override - public void presence(@NotNull BasePubNub pubnub, @NotNull PNPresenceEventResult presenceEvent) { - listener.presence((PubNub) pubnub, presenceEvent); - } - - @Override - public void signal(@NotNull BasePubNub pubnub, @NotNull PNSignalResult signal) { - listener.signal((PubNub) pubnub, signal); - } - - @Override - public void messageAction(@NotNull BasePubNub pubnub, @NotNull PNMessageActionResult messageAction) { - listener.messageAction((PubNub) pubnub, messageAction); - } - - @Override - public void file(@NotNull BasePubNub pubnub, @NotNull PNFileEventResult fileEvent) { - listener.file((PubNub) pubnub, fileEvent); - } } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/DelegatingEventListener.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/DelegatingEventListener.kt new file mode 100644 index 000000000..81121f2c8 --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/DelegatingEventListener.kt @@ -0,0 +1,52 @@ +package com.pubnub.internal.java.v2.callbacks + +import com.pubnub.api.PubNub +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventListener + +/** + * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time + * network. + */ +data class DelegatingEventListener( + private val listener: com.pubnub.api.java.v2.callbacks.EventListener, + private val pubnubJava: com.pubnub.api.java.PubNub, +) : EventListener { + override fun message(pubnub: PubNub, result: PNMessageResult) { + listener.message(pubnubJava, result) + } + + override fun presence( + pubnub: PubNub, + result: PNPresenceEventResult, + ) { + listener.presence(pubnubJava, result) + } + + override fun signal(pubnub: PubNub, result: PNSignalResult) { + listener.signal(pubnubJava, result) + } + + override fun messageAction( + pubnub: PubNub, + result: PNMessageActionResult, + ) { + listener.messageAction(pubnubJava, result) + } + + override fun file( + pubnub: PubNub, + result: PNFileEventResult, + ) { + listener.file(pubnubJava, result) + } + + override fun objects(pubnub: PubNub, result: PNObjectEventResult) { + Converters.objects(result, listener, pubnubJava) + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/DelegatingStatusListener.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/DelegatingStatusListener.kt new file mode 100644 index 000000000..b192b158f --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/DelegatingStatusListener.kt @@ -0,0 +1,14 @@ +package com.pubnub.internal.java.v2.callbacks + +import com.pubnub.api.PubNub +import com.pubnub.api.models.consumer.PNStatus +import com.pubnub.api.v2.callbacks.StatusListener + +data class DelegatingStatusListener( + private val listener: com.pubnub.api.java.v2.callbacks.StatusListener, + private val pubnubJava: com.pubnub.api.java.PubNub, +) : StatusListener { + override fun status(pubnub: PubNub, status: PNStatus) { + listener.status(pubnubJava, status) + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/EventEmitterInternal.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/EventEmitterInternal.kt new file mode 100644 index 000000000..9a74afe3a --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/EventEmitterInternal.kt @@ -0,0 +1,269 @@ +package com.pubnub.internal.java.v2.callbacks + +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadataResult +import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembershipResult +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadataResult +import com.pubnub.api.java.v2.callbacks.handlers.OnChannelMetadataHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnFileHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnMembershipHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnMessageActionHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnMessageHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnPresenceHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnSignalHandler +import com.pubnub.api.java.v2.callbacks.handlers.OnUuidMetadataHandler +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventEmitter + +/** + * Interface implemented by objects that are the source of real time events from the PubNub network. + */ +interface EventEmitterInternal : EventEmitter, com.pubnub.api.java.v2.callbacks.EventEmitter { + /** + * Sets the handler for incoming message events. + * This method allows the assignment of an [OnMessageHandler] implementation or lambda expression to handle + * incoming messages. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to message events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`setOnMessage(pnMessageResult -> System.out.println("Received: " + pnMessageResult.getMessage()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`setOnMessage(null);
+     `
* + * + * @param onMessageHandler An implementation of [OnMessageHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + override fun setOnMessage(onMessageHandler: OnMessageHandler?) { + onMessage = onMessageHandler?.let { handler -> + handler::handle + } + } + + /** + * Sets the handler for incoming signal events. + * This method allows the assignment of an [OnSignalHandler] implementation or lambda expression to handle + * incoming signals. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to signal events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`setOnSignal(pnSignalResult -> System.out.println("Received: " + pnSignalResult.getMessage()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`setOnSignal(null);
+     `
* + * + * @param onSignalHandler An implementation of [OnSignalHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + override fun setOnSignal(onSignalHandler: OnSignalHandler?) { + onSignal = onSignalHandler?.let { handler -> + handler::handle + } + } + + /** + * Sets the handler for incoming presence events. + * This method allows the assignment of an [OnPresenceHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to presence events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onPresenceHandler(pnPresenceEventResult -> System.out.println("Received: " + pnPresenceEventResult.getEvent()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onPresenceHandler(null);
+     `
* + * + * @param onPresenceHandler An implementation of [OnPresenceHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + override fun setOnPresence(onPresenceHandler: OnPresenceHandler?) { + onPresence = onPresenceHandler?.let { handler -> + handler::handle + } + } + + /** + * Sets the handler for incoming messageAction events. + * This method allows the assignment of an [OnMessageActionHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to messageAction events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onMessageActionHandler(pnMessageActionResult -> System.out.println("Received: " + pnMessageActionResult.getMessageAction()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onMessageActionHandler(null);
+     `
* + * + * @param onMessageActionHandler An implementation of [OnMessageActionHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + override fun setOnMessageAction(onMessageActionHandler: OnMessageActionHandler?) { + onMessageAction = onMessageActionHandler?.let { handler -> + handler::handle + } + } + + /** + * Sets the handler for incoming uuidMetadata events. + * This method allows the assignment of an [OnUuidMetadataHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to uuidMetadata events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onUuidMetadataHandler(pnUUIDMetadataResult -> System.out.println("Received: " + pnUUIDMetadataResult.getData()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onUuidMetadataHandler(null);
+     `
* + * + * @param onUuidMetadataHandler An implementation of [OnUuidMetadataHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + override fun setOnUuidMetadata(onUuidMetadataHandler: OnUuidMetadataHandler?) { + onObjects = (onObjects as? CombinedObjectHandler)?.copy(uuidHandler = onUuidMetadataHandler) ?: CombinedObjectHandler(uuidHandler = onUuidMetadataHandler) + } + + /** + * Sets the handler for incoming channelMetadata events. + * This method allows the assignment of an [OnChannelMetadataHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to channelMetadata events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onChannelMetadataHandler(pnChannelMetadataResult -> System.out.println("Received: " +  pnChannelMetadataResult.getEvent()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onChannelMetadataHandler(null);
+     `
* + * + * @param onChannelMetadataHandler An implementation of [OnChannelMetadataHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + override fun setOnChannelMetadata(onChannelMetadataHandler: OnChannelMetadataHandler?) { + onObjects = (onObjects as? CombinedObjectHandler)?.copy(channelHandler = onChannelMetadataHandler) ?: CombinedObjectHandler(channelHandler = onChannelMetadataHandler) + } + + /** + * Sets the handler for incoming membership events. + * This method allows the assignment of an [OnMembershipHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to membership events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onMembershipHandler(pnMembershipResult -> System.out.println("Received: " +  pnMembershipResult.getEvent()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onMembershipHandler(null);
+     `
* + * + * @param onMembershipHandler An implementation of [OnMembershipHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + override fun setOnMembership(onMembershipHandler: OnMembershipHandler?) { + onObjects = (onObjects as? CombinedObjectHandler)?.copy(membershipHandler = onMembershipHandler) ?: CombinedObjectHandler(membershipHandler = onMembershipHandler) + } + + /** + * Sets the handler for incoming file events. + * This method allows the assignment of an [OnFileHandler] implementation or lambda expression to handle + * incoming presence events. + * + * To deactivate the current behavior, simply set this property to `null`. + * + * Note that this property allows for the assignment of a singular behavior at a time, as any new assignment will override the previous one. + * For scenarios requiring multiple behaviors in response to file events, it is advisable + * to utilize [EventEmitter.addListener]. + * + * + * **Setting a Behavior Example:** + *
`onFileHandler(pnFileEventResult -> System.out.println("Received: " +  pnFileEventResult.getMessage()));
+     `
* + * + * + * **Removing a Behavior Example:** + *
`onFileHandler(null);
+     `
* + * + * @param onFileHandler An implementation of [OnFileHandler] or a lambda expression to handle + * incoming messages. It can be `null` to remove the current handler. + */ + override fun setOnFile(onFileHandler: OnFileHandler?) { + onFile = onFileHandler?.let { handler -> + handler::handle + } + } +} + +private data class CombinedObjectHandler( + val membershipHandler: OnMembershipHandler? = null, + val uuidHandler: OnUuidMetadataHandler? = null, + val channelHandler: OnChannelMetadataHandler? = null, +) : ((PNObjectEventResult) -> Unit) { + override fun invoke(objectEvent: PNObjectEventResult) { + val objectResult = Converters.objects(objectEvent) + when (objectResult) { + is PNMembershipResult -> membershipHandler?.handle(objectResult) + is PNChannelMetadataResult -> channelHandler?.handle(objectResult) + is PNUUIDMetadataResult -> uuidHandler?.handle(objectResult) + } + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelGroupImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelGroupImpl.kt new file mode 100644 index 000000000..df3a0562d --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelGroupImpl.kt @@ -0,0 +1,20 @@ +package com.pubnub.internal.java.v2.entities + +import com.pubnub.api.v2.subscriptions.EmptyOptions +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.java.PubNubForJavaImpl +import com.pubnub.internal.java.v2.subscription.SubscriptionImpl +import com.pubnub.internal.v2.entities.ChannelGroupImpl +import com.pubnub.internal.v2.entities.ChannelGroupName + +class ChannelGroupImpl(pubnub: PubNubForJavaImpl, channelGroupName: ChannelGroupName) : + ChannelGroupImpl(pubnub, channelGroupName), + com.pubnub.api.java.v2.entities.ChannelGroup { + override fun subscription(options: SubscriptionOptions): SubscriptionImpl { + return SubscriptionImpl.from(super.subscription(options)) + } + + override fun subscription(): com.pubnub.api.java.v2.subscriptions.Subscription { + return subscription(EmptyOptions) + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelImpl.kt new file mode 100644 index 000000000..e16b2138b --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelImpl.kt @@ -0,0 +1,33 @@ +package com.pubnub.internal.java.v2.entities + +import com.pubnub.api.endpoints.pubsub.Signal +import com.pubnub.api.java.v2.endpoints.pubsub.PublishBuilder +import com.pubnub.api.v2.subscriptions.EmptyOptions +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.java.PubNubForJavaImpl +import com.pubnub.internal.java.v2.subscription.SubscriptionImpl +import com.pubnub.internal.v2.entities.ChannelImpl +import com.pubnub.internal.v2.entities.ChannelName + +class ChannelImpl(private val pubnub: PubNubForJavaImpl, channelName: ChannelName) : + com.pubnub.api.java.v2.entities.Channel, ChannelImpl(pubnub, channelName) { + override fun subscription(): com.pubnub.api.java.v2.subscriptions.Subscription { + return subscription(EmptyOptions) + } + + override fun subscription(options: SubscriptionOptions): SubscriptionImpl { + return SubscriptionImpl.from(super.subscription(options)) + } + + override fun publish(message: Any): PublishBuilder { + return pubnub.publish(message, name) + } + + override fun signal(message: Any): Signal { + return pubnub.signal(message, name) + } + + override fun fire(message: Any): PublishBuilder { + return pubnub.publish(message, name).replicate(false).shouldStore(false) + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelMetadataImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelMetadataImpl.kt new file mode 100644 index 000000000..e0e9c5235 --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/ChannelMetadataImpl.kt @@ -0,0 +1,20 @@ +package com.pubnub.internal.java.v2.entities + +import com.pubnub.api.java.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.EmptyOptions +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.java.PubNubForJavaImpl +import com.pubnub.internal.java.v2.subscription.SubscriptionImpl +import com.pubnub.internal.v2.entities.ChannelName + +class ChannelMetadataImpl(pubnub: PubNubForJavaImpl, channelName: ChannelName) : + com.pubnub.internal.v2.entities.ChannelMetadataImpl(pubnub, channelName), + com.pubnub.api.java.v2.entities.ChannelMetadata { + override fun subscription(options: SubscriptionOptions): SubscriptionImpl { + return SubscriptionImpl.from(super.subscription(options)) + } + + override fun subscription(): Subscription { + return subscription(EmptyOptions) + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/UserMetadataImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/UserMetadataImpl.kt new file mode 100644 index 000000000..5edd9cd84 --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/entities/UserMetadataImpl.kt @@ -0,0 +1,20 @@ +package com.pubnub.internal.java.v2.entities + +import com.pubnub.api.v2.subscriptions.EmptyOptions +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.java.PubNubForJavaImpl +import com.pubnub.internal.java.v2.subscription.SubscriptionImpl +import com.pubnub.internal.v2.entities.ChannelName +import com.pubnub.internal.v2.entities.UserMetadataImpl + +class UserMetadataImpl(pubnub: PubNubForJavaImpl, channelName: ChannelName) : + UserMetadataImpl(pubnub, channelName), + com.pubnub.api.java.v2.entities.UserMetadata { + override fun subscription(options: SubscriptionOptions): SubscriptionImpl { + return SubscriptionImpl.from(super.subscription(options)) + } + + override fun subscription(): com.pubnub.api.java.v2.subscriptions.Subscription { + return subscription(EmptyOptions) + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/EmitterHelper.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/EmitterHelper.kt new file mode 100644 index 000000000..dbf098662 --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/EmitterHelper.kt @@ -0,0 +1,96 @@ +// package com.pubnub.internal.java.v2.subscription +// +// import com.pubnub.api.PubNub +// import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadataResult +// import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembershipResult +// import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadataResult +// import com.pubnub.api.models.consumer.pubsub.PNMessageResult +// import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +// import com.pubnub.api.models.consumer.pubsub.PNSignalResult +// import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +// import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +// import com.pubnub.api.v2.callbacks.BaseEventEmitter +// import com.pubnub.api.v2.callbacks.EventListener +// import com.pubnub.api.v2.callbacks.handlers.OnChannelMetadataHandler +// import com.pubnub.api.v2.callbacks.handlers.OnFileHandler +// import com.pubnub.api.v2.callbacks.handlers.OnMembershipHandler +// import com.pubnub.api.v2.callbacks.handlers.OnMessageActionHandler +// import com.pubnub.api.v2.callbacks.handlers.OnMessageHandler +// import com.pubnub.api.v2.callbacks.handlers.OnPresenceHandler +// import com.pubnub.api.v2.callbacks.handlers.OnSignalHandler +// import com.pubnub.api.v2.callbacks.handlers.OnUuidMetadataHandler +// import com.pubnub.internal.v2.callbacks.DelegatingEventListener +// import com.pubnub.internal.v2.callbacks.EventListenerCore +// +// class EmitterHelper { +// private val listener = object : EventListener { +// override fun message( +// pubnub: PubNub, +// result: PNMessageResult, +// ) { +// onMessage?.handle(result) +// } +// +// override fun presence( +// pubnub: PubNub, +// result: PNPresenceEventResult, +// ) { +// onPresence?.handle(result) +// } +// +// override fun signal( +// pubnub: PubNub, +// result: PNSignalResult, +// ) { +// onSignal?.handle(result) +// } +// +// override fun messageAction( +// pubnub: PubNub, +// result: PNMessageActionResult, +// ) { +// onMessageAction?.handle(result) +// } +// +// override fun uuid( +// pubnub: PubNub, +// result: PNUUIDMetadataResult, +// ) { +// onUuid?.handle(result) +// } +// +// override fun channel( +// pubnub: PubNub, +// result: PNChannelMetadataResult, +// ) { +// onChannel?.handle(result) +// } +// +// override fun membership( +// pubnub: PubNub, +// result: PNMembershipResult, +// ) { +// onMembership?.handle(result) +// } +// +// override fun file( +// pubnub: PubNub, +// result: PNFileEventResult, +// ) { +// onFile?.handle(result) +// } +// } +// +// fun initialize(eventEmitter: BaseEventEmitter) { +// eventEmitter.addListener(DelegatingEventListener(listener)) +// } +// +// var onMessage: OnMessageHandler? = null +// var onPresence: OnPresenceHandler? = null +// var onSignal: OnSignalHandler? = null +// var onMessageAction: OnMessageActionHandler? = null +// var onUuid: OnUuidMetadataHandler? = null +// var onChannel: OnChannelMetadataHandler? = null +// var onMembership: OnMembershipHandler? = null +// var onFile: OnFileHandler? = null +// } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/SubscriptionImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/SubscriptionImpl.kt new file mode 100644 index 000000000..81b5e28f3 --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/SubscriptionImpl.kt @@ -0,0 +1,60 @@ +package com.pubnub.internal.java.v2.subscription + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.java.v2.callbacks.EventListener +import com.pubnub.api.java.v2.callbacks.StatusListener +import com.pubnub.api.v2.subscriptions.EmptyOptions +import com.pubnub.api.v2.subscriptions.SubscriptionCursor +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.java.PubNubForJavaImpl +import com.pubnub.internal.java.v2.callbacks.DelegatingEventListener +import com.pubnub.internal.java.v2.callbacks.DelegatingStatusListener +import com.pubnub.internal.java.v2.callbacks.EventEmitterInternal +import com.pubnub.internal.v2.entities.ChannelGroupName +import com.pubnub.internal.v2.entities.ChannelName +import com.pubnub.internal.v2.subscription.SubscriptionImpl +import com.pubnub.internal.v2.subscription.SubscriptionInternal + +class SubscriptionImpl( + override val pubnub: PubNubForJavaImpl, + channels: Set = emptySet(), + channelGroups: Set = emptySet(), + options: SubscriptionOptions = EmptyOptions +) : + SubscriptionImpl(pubnub, channels, channelGroups, options), + com.pubnub.api.java.v2.subscriptions.Subscription, + EventEmitterInternal { + override fun plus( + subscription: com.pubnub.api.java.v2.subscriptions.Subscription, + ): com.pubnub.api.java.v2.subscriptions.SubscriptionSet { + return SubscriptionSetImpl(pubnub, setOf(this, subscription) as Set) + } + + override fun subscribe() { + subscribe(SubscriptionCursor(0)) + } + + override fun addListener(listener: EventListener) { + addListener(DelegatingEventListener(listener, pubnub)) + } + + override fun removeListener(listener: Listener) { + if (listener is EventListener) { + super.removeListener(DelegatingEventListener(listener, pubnub)) + } // no else here to support SubscribeCallbacks which implement both interfaces + if (listener is StatusListener) { + super.removeListener(DelegatingStatusListener(listener, pubnub)) + } + } + + companion object { + fun from(subscription: SubscriptionImpl): com.pubnub.internal.java.v2.subscription.SubscriptionImpl { + return com.pubnub.internal.java.v2.subscription.SubscriptionImpl( + subscription.pubnub as PubNubForJavaImpl, + subscription.channels, + subscription.channelGroups, + subscription.options + ) + } + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/SubscriptionSetImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/SubscriptionSetImpl.kt new file mode 100644 index 000000000..f86a4cca0 --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/subscription/SubscriptionSetImpl.kt @@ -0,0 +1,41 @@ +package com.pubnub.internal.java.v2.subscription + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.java.v2.callbacks.EventListener +import com.pubnub.api.java.v2.callbacks.StatusListener +import com.pubnub.api.java.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionCursor +import com.pubnub.internal.java.PubNubForJavaImpl +import com.pubnub.internal.java.v2.callbacks.DelegatingEventListener +import com.pubnub.internal.java.v2.callbacks.DelegatingStatusListener +import com.pubnub.internal.java.v2.callbacks.EventEmitterInternal +import com.pubnub.internal.v2.subscription.BaseSubscriptionSetImpl +import com.pubnub.internal.v2.subscription.SubscriptionInternal + +class SubscriptionSetImpl( + private val pubnubJava: PubNubForJavaImpl, + initialSubscriptions: Set +) : + BaseSubscriptionSetImpl(pubnubJava, initialSubscriptions), + com.pubnub.api.java.v2.subscriptions.SubscriptionSet, + EventEmitterInternal { + override val subscriptions: Set + get() = subscriptionsInternal as Set + + override fun subscribe() { + subscribe(SubscriptionCursor(0)) + } + + override fun addListener(listener: EventListener) { + addListener(DelegatingEventListener(listener, pubnubJava)) + } + + override fun removeListener(listener: Listener) { + if (listener is EventListener) { + super.removeListener(DelegatingEventListener(listener, pubnubJava)) + } // no else here to support SubscribeCallbacks which implement both interfaces + if (listener is StatusListener) { + super.removeListener(DelegatingStatusListener(listener, pubnubJava)) + } + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingStatusListener.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingStatusListener.kt deleted file mode 100644 index da293c991..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingStatusListener.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.pubnub.internal.callbacks - -import com.pubnub.api.BasePubNub -import com.pubnub.api.PubNub -import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.api.v2.callbacks.StatusListener - -data class DelegatingStatusListener(private val listener: StatusListener) : - com.pubnub.internal.v2.callbacks.StatusListenerCore { - override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - status: PNStatus, - ) { - listener.status(pubnub as PubNub, status) - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallback.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallback.kt deleted file mode 100644 index 0d5ff5880..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallback.kt +++ /dev/null @@ -1,22 +0,0 @@ -package com.pubnub.internal.callbacks - -import com.pubnub.api.BasePubNub -import com.pubnub.api.PubNub -import com.pubnub.api.callbacks.SubscribeCallback -import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.internal.v2.callbacks.DelegatingEventListener -import com.pubnub.internal.v2.callbacks.StatusListenerCore - -data class DelegatingSubscribeCallback(private val listener: SubscribeCallback) : - com.pubnub.internal.callbacks.SubscribeCallback, - DelegatingEventListener( - listener, - ), - StatusListenerCore { - override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - status: PNStatus, - ) { - listener.status(pubnub as PubNub, status) - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelGroupImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelGroupImpl.kt deleted file mode 100644 index 883b7672a..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelGroupImpl.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.pubnub.internal.v2.entities - -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.entities.ChannelGroup -import com.pubnub.api.v2.subscriptions.EmptyOptions -import com.pubnub.api.v2.subscriptions.Subscription -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.v2.subscription.SubscriptionImpl - -class ChannelGroupImpl(pubnub: PubNubImpl, channelGroupName: String) : - BaseChannelGroupImpl( - pubnub.pubNubCore, - ChannelGroupName(channelGroupName), - { channels, channelGroups, options -> SubscriptionImpl(pubnub, channels, channelGroups, options) }, - ), - ChannelGroup { - override fun subscription(): Subscription { - return subscription(EmptyOptions) - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelImpl.kt deleted file mode 100644 index 00e7e847b..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelImpl.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.pubnub.internal.v2.entities - -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.endpoints.pubsub.PublishBuilder -import com.pubnub.api.v2.endpoints.pubsub.SignalBuilder -import com.pubnub.api.v2.entities.Channel -import com.pubnub.api.v2.subscriptions.EmptyOptions -import com.pubnub.api.v2.subscriptions.Subscription -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.v2.subscription.SubscriptionImpl - -class ChannelImpl(pubnub: PubNubImpl, channelName: String) : - BaseChannelImpl( - pubnub.pubNubCore, - ChannelName(channelName), - { channels, channelGroups, options -> SubscriptionImpl(pubnub, channels, channelGroups, options) }, - ), - Channel { - private val pubNubImpl: PubNubImpl = pubnub - - override fun subscription(): Subscription { - return subscription(EmptyOptions) - } - - override fun publish(message: Any): PublishBuilder { - return pubNubImpl.publish(message, channelName.id) - } - - override fun signal(message: Any): SignalBuilder { - return pubNubImpl.signal(message, channelName.id) - } - - override fun fire(message: Any): PublishBuilder { - return pubNubImpl.publish(message, channelName.id).replicate(false).shouldStore(false) - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelMetadataImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelMetadataImpl.kt deleted file mode 100644 index 8e9376a32..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/ChannelMetadataImpl.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.pubnub.internal.v2.entities - -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.entities.ChannelMetadata -import com.pubnub.api.v2.subscriptions.EmptyOptions -import com.pubnub.api.v2.subscriptions.Subscription -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.v2.subscription.SubscriptionImpl - -class ChannelMetadataImpl(pubnub: PubNubImpl, id: String) : - BaseChannelMetadataImpl( - pubnub.pubNubCore, - ChannelName(id), - { channels, channelGroups, options -> SubscriptionImpl(pubnub, channels, channelGroups, options) }, - ), - ChannelMetadata { - override fun subscription(): Subscription { - return subscription(EmptyOptions) - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/UserMetadataImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/UserMetadataImpl.kt deleted file mode 100644 index 2feac95a8..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/entities/UserMetadataImpl.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.pubnub.internal.v2.entities - -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.entities.UserMetadata -import com.pubnub.api.v2.subscriptions.EmptyOptions -import com.pubnub.api.v2.subscriptions.Subscription -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.v2.subscription.SubscriptionImpl - -class UserMetadataImpl(pubnub: PubNubImpl, id: String) : - BaseUserMetadataImpl( - pubnub.pubNubCore, - ChannelName(id), - { channels, channelGroups, options -> SubscriptionImpl(pubnub, channels, channelGroups, options) }, - ), - UserMetadata { - override fun subscription(): Subscription { - return subscription(EmptyOptions) - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/EmitterHelper.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/EmitterHelper.kt deleted file mode 100644 index cc77df994..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/EmitterHelper.kt +++ /dev/null @@ -1,96 +0,0 @@ -package com.pubnub.internal.v2.subscription - -import com.pubnub.api.PubNub -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -import com.pubnub.api.models.consumer.pubsub.PNSignalResult -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.api.v2.callbacks.BaseEventEmitter -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.handlers.OnChannelMetadataHandler -import com.pubnub.api.v2.callbacks.handlers.OnFileHandler -import com.pubnub.api.v2.callbacks.handlers.OnMembershipHandler -import com.pubnub.api.v2.callbacks.handlers.OnMessageActionHandler -import com.pubnub.api.v2.callbacks.handlers.OnMessageHandler -import com.pubnub.api.v2.callbacks.handlers.OnPresenceHandler -import com.pubnub.api.v2.callbacks.handlers.OnSignalHandler -import com.pubnub.api.v2.callbacks.handlers.OnUuidMetadataHandler -import com.pubnub.internal.v2.callbacks.DelegatingEventListener -import com.pubnub.internal.v2.callbacks.EventListenerCore - -class EmitterHelper { - private val listener = object : EventListener { - override fun message( - pubnub: PubNub, - result: PNMessageResult, - ) { - onMessage?.handle(result) - } - - override fun presence( - pubnub: PubNub, - result: PNPresenceEventResult, - ) { - onPresence?.handle(result) - } - - override fun signal( - pubnub: PubNub, - result: PNSignalResult, - ) { - onSignal?.handle(result) - } - - override fun messageAction( - pubnub: PubNub, - result: PNMessageActionResult, - ) { - onMessageAction?.handle(result) - } - - override fun uuid( - pubnub: PubNub, - result: PNUUIDMetadataResult, - ) { - onUuid?.handle(result) - } - - override fun channel( - pubnub: PubNub, - result: PNChannelMetadataResult, - ) { - onChannel?.handle(result) - } - - override fun membership( - pubnub: PubNub, - result: PNMembershipResult, - ) { - onMembership?.handle(result) - } - - override fun file( - pubnub: PubNub, - result: PNFileEventResult, - ) { - onFile?.handle(result) - } - } - - fun initialize(eventEmitter: BaseEventEmitter) { - eventEmitter.addListener(DelegatingEventListener(listener)) - } - - var onMessage: OnMessageHandler? = null - var onPresence: OnPresenceHandler? = null - var onSignal: OnSignalHandler? = null - var onMessageAction: OnMessageActionHandler? = null - var onUuid: OnUuidMetadataHandler? = null - var onChannel: OnChannelMetadataHandler? = null - var onMembership: OnMembershipHandler? = null - var onFile: OnFileHandler? = null -} diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/SubscriptionImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/SubscriptionImpl.kt deleted file mode 100644 index 73c4a9ba0..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/SubscriptionImpl.kt +++ /dev/null @@ -1,112 +0,0 @@ -package com.pubnub.internal.v2.subscription - -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.callbacks.SubscribeCallback -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.handlers.OnChannelMetadataHandler -import com.pubnub.api.v2.callbacks.handlers.OnFileHandler -import com.pubnub.api.v2.callbacks.handlers.OnMembershipHandler -import com.pubnub.api.v2.callbacks.handlers.OnMessageActionHandler -import com.pubnub.api.v2.callbacks.handlers.OnMessageHandler -import com.pubnub.api.v2.callbacks.handlers.OnPresenceHandler -import com.pubnub.api.v2.callbacks.handlers.OnSignalHandler -import com.pubnub.api.v2.callbacks.handlers.OnUuidMetadataHandler -import com.pubnub.api.v2.subscriptions.Subscription -import com.pubnub.api.v2.subscriptions.SubscriptionCursor -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.api.v2.subscriptions.SubscriptionSet -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.callbacks.DelegatingSubscribeCallback -import com.pubnub.internal.managers.AnnouncementCallback -import com.pubnub.internal.v2.callbacks.DelegatingEventListener -import com.pubnub.internal.v2.callbacks.EventEmitterImpl -import com.pubnub.internal.v2.entities.ChannelGroupName -import com.pubnub.internal.v2.entities.ChannelName - -class SubscriptionImpl - @JvmOverloads - constructor( - val pubnub: PubNubImpl, - channels: Set, - channelGroups: Set, - options: SubscriptionOptions, - private val emitterHelper: EmitterHelper = EmitterHelper(), - eventEmitterFactory: (BaseSubscriptionImpl) -> EventEmitterImpl = { baseSubscriptionImpl -> - EventEmitterImpl(AnnouncementCallback.Phase.SUBSCRIPTION, baseSubscriptionImpl::accepts) - }, - ) : Subscription, - BaseSubscriptionImpl(pubnub.pubNubCore, channels, channelGroups, options, eventEmitterFactory) { - init { - emitterHelper.initialize(eventEmitter) - } - - /** - * Add a listener. - * - * @param listener The listener to be added. - */ - override fun addListener(listener: EventListener) { - addListener(DelegatingEventListener(listener)) - } - - /** - * Create a [SubscriptionSet] that contains both subscriptions. - * - * @param subscription the other [Subscription] to add to the [SubscriptionSet] - */ - override fun plus(subscription: Subscription): SubscriptionSet { - return pubnub.subscriptionSetOf(setOf(this, subscription)) - } - - override fun subscribe() { - subscribe(SubscriptionCursor(0)) - } - - override fun removeListener(listener: Listener) { - when (listener) { - is SubscribeCallback -> { - super.removeListener(DelegatingSubscribeCallback(listener)) - } - - is EventListener -> { - super.removeListener(DelegatingEventListener(listener)) - } - - else -> { - super.removeListener(listener) - } - } - } - - override fun setOnMessage(onMessageHandler: OnMessageHandler?) { - emitterHelper.onMessage = onMessageHandler - } - - override fun setOnSignal(onSignalHandler: OnSignalHandler?) { - emitterHelper.onSignal = onSignalHandler - } - - override fun setOnPresence(onPresenceHandler: OnPresenceHandler?) { - emitterHelper.onPresence = onPresenceHandler - } - - override fun setOnMessageAction(onMessageActionHandler: OnMessageActionHandler?) { - emitterHelper.onMessageAction = onMessageActionHandler - } - - override fun setOnUuidMetadata(onUuidMetadataHandler: OnUuidMetadataHandler?) { - emitterHelper.onUuid = onUuidMetadataHandler - } - - override fun setOnChannelMetadata(onChannelMetadataHandler: OnChannelMetadataHandler?) { - emitterHelper.onChannel = onChannelMetadataHandler - } - - override fun setOnMembership(onMembershipHandler: OnMembershipHandler?) { - emitterHelper.onMembership = onMembershipHandler - } - - override fun setOnFile(onFileHandler: OnFileHandler?) { - emitterHelper.onFile = onFileHandler - } - } diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/SubscriptionSetImpl.kt b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/SubscriptionSetImpl.kt deleted file mode 100644 index c0e8916b0..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/v2/subscription/SubscriptionSetImpl.kt +++ /dev/null @@ -1,92 +0,0 @@ -package com.pubnub.internal.v2.subscription - -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.callbacks.SubscribeCallback -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.handlers.OnChannelMetadataHandler -import com.pubnub.api.v2.callbacks.handlers.OnFileHandler -import com.pubnub.api.v2.callbacks.handlers.OnMembershipHandler -import com.pubnub.api.v2.callbacks.handlers.OnMessageActionHandler -import com.pubnub.api.v2.callbacks.handlers.OnMessageHandler -import com.pubnub.api.v2.callbacks.handlers.OnPresenceHandler -import com.pubnub.api.v2.callbacks.handlers.OnSignalHandler -import com.pubnub.api.v2.callbacks.handlers.OnUuidMetadataHandler -import com.pubnub.api.v2.subscriptions.Subscription -import com.pubnub.api.v2.subscriptions.SubscriptionCursor -import com.pubnub.api.v2.subscriptions.SubscriptionSet -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.callbacks.DelegatingSubscribeCallback -import com.pubnub.internal.v2.callbacks.DelegatingEventListener - -class SubscriptionSetImpl - @JvmOverloads - constructor( - pubnub: PubNubCore, - initialSubscriptions: Set, - private val emitterHelper: EmitterHelper = EmitterHelper(), - ) : SubscriptionSet, BaseSubscriptionSetImpl(pubnub, initialSubscriptions) { - init { - emitterHelper.initialize(eventEmitter) - } - - override fun subscribe() { - subscribe(SubscriptionCursor(0)) - } - - /** - * Add a listener. - * - * @param listener The listener to be added. - */ - override fun addListener(listener: EventListener) { - addListener(DelegatingEventListener(listener)) - } - - override fun removeListener(listener: Listener) { - when (listener) { - is SubscribeCallback -> { - super.removeListener(DelegatingSubscribeCallback(listener)) - } - - is EventListener -> { - super.removeListener(DelegatingEventListener(listener)) - } - - else -> { - super.removeListener(listener) - } - } - } - - override fun setOnMessage(onMessageHandler: OnMessageHandler?) { - emitterHelper.onMessage = onMessageHandler - } - - override fun setOnSignal(onSignalHandler: OnSignalHandler?) { - emitterHelper.onSignal = onSignalHandler - } - - override fun setOnPresence(onPresenceHandler: OnPresenceHandler?) { - emitterHelper.onPresence = onPresenceHandler - } - - override fun setOnMessageAction(onMessageActionHandler: OnMessageActionHandler?) { - emitterHelper.onMessageAction = onMessageActionHandler - } - - override fun setOnUuidMetadata(onUuidHandler: OnUuidMetadataHandler?) { - emitterHelper.onUuid = onUuidHandler - } - - override fun setOnChannelMetadata(onChannelMetadataHandler: OnChannelMetadataHandler?) { - emitterHelper.onChannel = onChannelMetadataHandler - } - - override fun setOnMembership(onMembershipHandler: OnMembershipHandler?) { - emitterHelper.onMembership = onMembershipHandler - } - - override fun setOnFile(onFileHandler: OnFileHandler?) { - emitterHelper.onFile = onFileHandler - } - } diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/api/PNConfigurationTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/api/PNConfigurationTest.kt index 6c9ad7f37..88bd0bd49 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/api/PNConfigurationTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/api/PNConfigurationTest.kt @@ -1,121 +1,120 @@ package com.pubnub.api -import com.pubnub.api.crypto.CryptoModule -import com.pubnub.api.enums.PNReconnectionPolicy -import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.api.v2.PNConfigurationOverride -import com.pubnub.internal.BasePubNubImpl +import com.pubnub.api.java.v2.PNConfiguration +import com.pubnub.api.java.v2.PNConfigurationOverride import org.junit.Assert import org.junit.Test class PNConfigurationTest { - @Suppress("DEPRECATION") - @Test(expected = PubNubException::class) - fun setUUIDToEmptyString() { - PNConfiguration("") - } - - @Suppress("DEPRECATION") - @Test(expected = PubNubException::class) - fun resetUUIDToEmptyString() { - val config = PNConfiguration(BasePubNubImpl.generateUUID()) - config.setUuid("") - } - - @Suppress("DEPRECATION") - @Test - fun resetUUIDToNonEmptyString() { - val config = PNConfiguration(BasePubNubImpl.generateUUID()) - val newUUID = BasePubNubImpl.generateUUID() - config.setUuid(newUUID) - - Assert.assertEquals(newUUID, config.userId.value) - } - - @Test - fun testDefaultTimeoutValues() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - Assert.assertEquals(300, config.presenceTimeout) - Assert.assertEquals(0, config.heartbeatInterval) - } - - @Test - fun testCustomTimeoutValues1() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - config.setPresenceTimeout(100) - Assert.assertEquals(100, config.presenceTimeout) - Assert.assertEquals(49, config.heartbeatInterval) - } - - @Test - fun testCustomTimeoutValues2() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - config.setHeartbeatInterval(100) - Assert.assertEquals(300, config.presenceTimeout) - Assert.assertEquals(100, config.heartbeatInterval) - } - - @Test - fun testCustomTimeoutValues3() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - config.setHeartbeatInterval(40) - config.setPresenceTimeout(50) - Assert.assertEquals(50, config.presenceTimeout) - Assert.assertEquals(24, config.heartbeatInterval) - } - - @Test - fun `reconnection policy should set retry configuration`() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - config.setReconnectionPolicy(PNReconnectionPolicy.NONE) - Assert.assertTrue(config.retryConfiguration is RetryConfiguration.None) - - config.setReconnectionPolicy(PNReconnectionPolicy.LINEAR) - Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Linear) - - config.setReconnectionPolicy(PNReconnectionPolicy.EXPONENTIAL) - Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Exponential) - } - - @Test - fun `maximumReconnectionRetries policy should reset retry configuration`() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - - config.setReconnectionPolicy(PNReconnectionPolicy.LINEAR) - config.setMaximumReconnectionRetries(5) - Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Linear) - Assert.assertEquals(5, (config.retryConfiguration as RetryConfiguration.Linear).maxRetryNumber) - - config.setMaximumReconnectionRetries(10) - Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Linear) - Assert.assertEquals(10, (config.retryConfiguration as RetryConfiguration.Linear).maxRetryNumber) - } - - @Test - fun `cryptomodule uses cipherKey when cryptomodule is not set`() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - - config.setCryptoModule(null) - config.setCipherKey("enigma") - Assert.assertNotNull(config.cryptoModule) - } - - @Test - fun `cryptomodule uses cryptomodule when cryptomodule is set`() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - val expectedCryptoModule = CryptoModule.createAesCbcCryptoModule("cipher") - config.setCryptoModule(expectedCryptoModule) - config.setCipherKey("enigma") - - Assert.assertEquals(expectedCryptoModule, config.cryptoModule) - } +// @Suppress("DEPRECATION") +// @Test(expected = PubNubException::class) +// fun setUUIDToEmptyString() { +// PNConfiguration("") +// } +// +// @Suppress("DEPRECATION") +// @Test(expected = PubNubException::class) +// fun resetUUIDToEmptyString() { +// val config = PNConfiguration(PubNub.generateUUID()) +// config.setUuid("") +// } +// +// @Suppress("DEPRECATION") +// @Test +// fun resetUUIDToNonEmptyString() { +// val config = PNConfiguration(PubNub.generateUUID()) +// val newUUID = PubNub.generateUUID() +// config.setUuid(newUUID) +// +// Assert.assertEquals(newUUID, config.userId.value) +// } +// +// @Test +// fun testDefaultTimeoutValues() { +// val config = PNConfiguration(UserId(PubNub.generateUUID())) +// Assert.assertEquals(300, config.presenceTimeout) +// Assert.assertEquals(0, config.heartbeatInterval) +// } +// +// @Test +// fun testCustomTimeoutValues1() { +// val config = PNConfiguration(UserId(PubNub.generateUUID())) +// config.setPresenceTimeout(100) +// Assert.assertEquals(100, config.presenceTimeout) +// Assert.assertEquals(49, config.heartbeatInterval) +// } +// +// @Test +// fun testCustomTimeoutValues2() { +// val config = PNConfiguration(UserId(PubNub.generateUUID())) +// config.setHeartbeatInterval(100) +// Assert.assertEquals(300, config.presenceTimeout) +// Assert.assertEquals(100, config.heartbeatInterval) +// } +// +// @Test +// fun testCustomTimeoutValues3() { +// val config = PNConfiguration(UserId(PubNub.generateUUID())) +// config.setHeartbeatInterval(40) +// config.setPresenceTimeout(50) +// Assert.assertEquals(50, config.presenceTimeout) +// Assert.assertEquals(24, config.heartbeatInterval) +// } +// +// @Test +// fun `reconnection policy should set retry configuration`() { +// val config = PNConfiguration(UserId(PubNub.generateUUID())) +// config.setReconnectionPolicy(PNReconnectionPolicy.NONE) +// Assert.assertTrue(config.retryConfiguration is RetryConfiguration.None) +// +// config.setReconnectionPolicy(PNReconnectionPolicy.LINEAR) +// Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Linear) +// +// config.setReconnectionPolicy(PNReconnectionPolicy.EXPONENTIAL) +// Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Exponential) +// } +// +// @Test +// fun `maximumReconnectionRetries policy should reset retry configuration`() { +// val config = PNConfiguration(UserId(PubNub.generateUUID())) +// +// config.setReconnectionPolicy(PNReconnectionPolicy.LINEAR) +// config.setMaximumReconnectionRetries(5) +// Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Linear) +// Assert.assertEquals(5, (config.retryConfiguration as RetryConfiguration.Linear).maxRetryNumber) +// +// config.setMaximumReconnectionRetries(10) +// Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Linear) +// Assert.assertEquals(10, (config.retryConfiguration as RetryConfiguration.Linear).maxRetryNumber) +// } +// +// @Test +// fun `cryptomodule uses cipherKey when cryptomodule is not set`() { +// val config = PNConfiguration(UserId(PubNub.generateUUID())) +// +// config.setCryptoModule(null) +// config.setCipherKey("enigma") +// Assert.assertNotNull(config.cryptoModule) +// } +// +// @Test +// fun `cryptomodule uses cryptomodule when cryptomodule is set`() { +// val config = PNConfiguration(UserId(PubNub.generateUUID())) +// val expectedCryptoModule = CryptoModule.createAesCbcCryptoModule("cipher") +// config.setCryptoModule(expectedCryptoModule) +// config.setCipherKey("enigma") +// +// Assert.assertEquals(expectedCryptoModule, config.cryptoModule) +// } @Test fun `create config override from existing config`() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) + val config = PNConfiguration(UserId(PubNub.generateUUID())) val override = PNConfigurationOverride.from(config).apply { setUserId(UserId("override")) }.build() Assert.assertEquals("override", override.userId.value) } } + +private fun PNConfiguration(userId: UserId) = PNConfiguration.builder(userId, "").build() diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/MigrationGeneratorTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/MigrationGeneratorTest.kt new file mode 100644 index 000000000..2872e41ca --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/MigrationGeneratorTest.kt @@ -0,0 +1,22 @@ +package com.pubnub.internal + +import com.google.common.reflect.ClassPath +import org.junit.Test + +class MigrationGeneratorTest { + /** + * Use this test to generate the content of the /migration_utils/replacements.txt file + */ + @Test + fun generateMigrations() { + ClassPath + .from(ClassLoader.getSystemClassLoader()) + .allClasses + .filter { it.packageName.startsWith("com.pubnub.api.java") } + .mapNotNull { it.load().canonicalName } + .sorted() + .forEach { + println(it.replace("com.pubnub.api.java.", "com.pubnub.api.") + ":" + it) + } + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/DelegatingEndpointTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/DelegatingEndpointTest.kt similarity index 67% rename from pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/DelegatingEndpointTest.kt rename to pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/DelegatingEndpointTest.kt index 55699ff0f..78d3796a4 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/DelegatingEndpointTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/DelegatingEndpointTest.kt @@ -1,14 +1,14 @@ -package com.pubnub.internal.endpoints +package com.pubnub.internal.java.endpoints +import com.pubnub.api.Endpoint import com.pubnub.api.UserId import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction import com.pubnub.api.enums.PNOperationType -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.java.v2.PNConfiguration +import com.pubnub.api.v2.PNConfigurationOverride import com.pubnub.api.v2.callbacks.Result import com.pubnub.api.v2.callbacks.getOrThrow -import com.pubnub.internal.EndpointInterface import io.mockk.mockk import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.Assertions.assertTrue @@ -18,53 +18,16 @@ import java.util.function.Consumer internal class DelegatingEndpointTest { private lateinit var delegatingEndpoint: DelegatingEndpoint - var validateParamsCalled = false - var silentCancelCalled = false - var retryCalled = false - var mapping: (ExtendedRemoteAction) -> ExtendedRemoteAction = { it } - - val action = - object : EndpointInterface { - private lateinit var overridenConfiguration: BasePNConfiguration - - override fun operationType(): PNOperationType { - return PNOperationType.FileOperation - } - - override fun retry() { - retryCalled = true - } - - override fun sync(): Boolean { - return true - } - override fun silentCancel() { - silentCancelCalled = true - } - - override fun overrideConfiguration(configuration: BasePNConfiguration) { - overridenConfiguration = configuration - } - - override val configuration: BasePNConfiguration - get() = overridenConfiguration - - override fun async(callback: Consumer>) { - callback.accept(Result.success(true)) - } - } + var mapping: (ExtendedRemoteAction) -> ExtendedRemoteAction = { it } + val action = TestAction() @BeforeEach fun setUp() { - validateParamsCalled = false - silentCancelCalled = false - retryCalled = false - delegatingEndpoint = object : DelegatingEndpoint(mockk()) { - override fun createAction(): EndpointInterface { + override fun createRemoteAction(): Endpoint { return action } @@ -108,7 +71,7 @@ internal class DelegatingEndpointTest { delegatingEndpoint.overrideConfiguration(overridingConfig) delegatingEndpoint.remoteAction - assertEquals(overridingConfig, action.configuration) + assertEquals(overridingConfig, action.overridenConfiguration) } @Test @@ -123,13 +86,13 @@ internal class DelegatingEndpointTest { @Test fun `when retry is called calls retry on delegate`() { delegatingEndpoint.retry() - assertTrue(retryCalled) + assertTrue(action.retryCalled) } @Test fun `when silentCancel is called calls silentCancel on delegate`() { delegatingEndpoint.silentCancel() - assertTrue(silentCancelCalled) + assertTrue(action.silentCancelCalled) } @Test @@ -140,9 +103,44 @@ internal class DelegatingEndpointTest { @Test fun `IdentityMappingEndpoint returns the same remote action`() { - delegatingEndpoint = object : IdentityMappingEndpoint(mockk()) { - override fun createAction(): EndpointInterface = action + delegatingEndpoint = object : PassthroughEndpoint(mockk()) { + override fun createRemoteAction(): Endpoint = action } assertEquals(action, delegatingEndpoint.remoteAction) } } + +class TestAction() : Endpoint { + lateinit var overridenConfiguration: com.pubnub.api.v2.PNConfiguration + var retryCalled: Boolean = false + var silentCancelCalled: Boolean = false + + override fun operationType(): PNOperationType { + return PNOperationType.FileOperation + } + + override fun retry() { + retryCalled = true + } + + override fun sync(): Boolean { + return true + } + + override fun silentCancel() { + silentCancelCalled = true + } + + override fun async(callback: Consumer>) { + callback.accept(Result.success(true)) + } + + override fun overrideConfiguration(action: PNConfigurationOverride.Builder.() -> Unit): Endpoint { + TODO("Not yet implemented") + } + + override fun overrideConfiguration(configuration: com.pubnub.api.v2.PNConfiguration): Endpoint { + overridenConfiguration = configuration + return this + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/DelegatingRemoteActionTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/DelegatingRemoteActionTest.kt similarity index 91% rename from pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/DelegatingRemoteActionTest.kt rename to pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/DelegatingRemoteActionTest.kt index 516d8304b..2951a278c 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/DelegatingRemoteActionTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/DelegatingRemoteActionTest.kt @@ -1,4 +1,4 @@ -package com.pubnub.internal.endpoints +package com.pubnub.internal.java.endpoints import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.enums.PNOperationType @@ -49,7 +49,7 @@ internal class DelegatingRemoteActionTest { delegatingRemoteAction = object : DelegatingRemoteAction(mockk()) { - override fun createAction(): ExtendedRemoteAction { + override fun createRemoteAction(): ExtendedRemoteAction { return action } @@ -104,8 +104,8 @@ internal class DelegatingRemoteActionTest { @Test fun `IdentityMappingEndpoint returns the same remote action`() { - delegatingRemoteAction = object : IdentityMappingAction(mockk()) { - override fun createAction(): ExtendedRemoteAction = action + delegatingRemoteAction = object : PassthroughRemoteAction(mockk()) { + override fun createRemoteAction(): ExtendedRemoteAction = action } assertEquals(action, delegatingRemoteAction.remoteAction) } diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/DeleteMessagesImplTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/DeleteMessagesImplTest.kt similarity index 83% rename from pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/DeleteMessagesImplTest.kt rename to pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/DeleteMessagesImplTest.kt index cdba4c352..cc1c84a4b 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/DeleteMessagesImplTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/DeleteMessagesImplTest.kt @@ -1,8 +1,8 @@ -package com.pubnub.internal.endpoints +package com.pubnub.internal.java.endpoints +import com.pubnub.api.PubNub import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult -import com.pubnub.internal.PubNubCore import io.mockk.mockk import io.mockk.verify import org.junit.jupiter.api.Assertions.assertTrue @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test class DeleteMessagesImplTest { private lateinit var objectUnderTest: DeleteMessagesImpl - private val pubNubCore: PubNubCore = mockk(relaxed = true) + private val pubNubCore: PubNub = mockk(relaxed = true) private val channels: List = listOf("Channel01") private val start: Long = 123456789L private val end: Long = 987654321L @@ -25,7 +25,7 @@ class DeleteMessagesImplTest { objectUnderTest.end(end) // when - val action = objectUnderTest.createAction() + val action = objectUnderTest.createRemoteAction() // then verify { pubNubCore.deleteMessages(channels, start, end) } diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/FetchMessagesImplTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/FetchMessagesImplTest.kt similarity index 89% rename from pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/FetchMessagesImplTest.kt rename to pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/FetchMessagesImplTest.kt index 53c016439..1d800fa3f 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/FetchMessagesImplTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/FetchMessagesImplTest.kt @@ -1,9 +1,9 @@ -package com.pubnub.internal.endpoints +package com.pubnub.internal.java.endpoints +import com.pubnub.api.PubNub import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.PNFetchMessagesResult -import com.pubnub.internal.PubNubCore import io.mockk.mockk import io.mockk.verify import org.junit.jupiter.api.Assertions.assertTrue @@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test class FetchMessagesImplTest { private lateinit var objectUnderTest: FetchMessagesImpl - private val pubNubCore: PubNubCore = mockk(relaxed = true) + private val pubNubCore: PubNub = mockk(relaxed = true) private val channels: List = listOf("Channel01") private val maximumPerChannel: Int = 2 private val start: Long = 123 @@ -36,7 +36,7 @@ class FetchMessagesImplTest { objectUnderTest.includeUUID(includeUUID) // when - val action = objectUnderTest.createAction() + val action = objectUnderTest.createRemoteAction() // then verify { diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/access/GrantTokenImplTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/access/GrantTokenImplTest.kt similarity index 63% rename from pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/access/GrantTokenImplTest.kt rename to pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/access/GrantTokenImplTest.kt index bc6fabb14..df87eb2b2 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/endpoints/access/GrantTokenImplTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/endpoints/access/GrantTokenImplTest.kt @@ -1,9 +1,10 @@ -package com.pubnub.internal.endpoints.access +package com.pubnub.internal.java.endpoints.access -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant -import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant -import com.pubnub.internal.PubNubCore +import com.pubnub.api.PubNub +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.java.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.java.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.internal.endpoints.access.GrantTokenEndpoint import io.mockk.CapturingSlot import io.mockk.every import io.mockk.mockk @@ -15,7 +16,7 @@ import org.junit.jupiter.api.Test class GrantTokenImplTest { private lateinit var objectUnderTest: GrantTokenImpl - private val pubNubCore: PubNubCore = mockk() + private val pubNubCore: PubNub = mockk() private val grantTokenEndpoint: GrantTokenEndpoint = mockk() private val ttl: Int = 123 private val meta: Any? = null @@ -23,11 +24,11 @@ class GrantTokenImplTest { private val channels = listOf(ChannelGrant.name("myChannel01").delete(), ChannelGrant.name("myChannel02").manage()) private val channelGroups = listOf(ChannelGroupGrant.pattern("myChannelGroup01").manage()) private val uuids = listOf(UUIDGrant.id("myUUID").update()) - private val channelsCapture: CapturingSlot> = + private val channelsCapture: CapturingSlot> = slot() - private val channelGroupsCapture: CapturingSlot> = + private val channelGroupsCapture: CapturingSlot> = slot() - private val uuidsCapture: CapturingSlot> = + private val uuidsCapture: CapturingSlot> = slot() @Test @@ -52,15 +53,15 @@ class GrantTokenImplTest { } returns grantTokenEndpoint // when - val action = objectUnderTest.createAction() + val action = objectUnderTest.createRemoteAction() // then verify { pubNubCore.grantToken(ttl, meta, authorizedUUID, any(), any(), any()) } - val capturedChannels: List = + val capturedChannels: List = channelsCapture.captured - val capturedChannelGroups: List = + val capturedChannelGroups: List = channelGroupsCapture.captured - val capturedUUIDs: List = uuidsCapture.captured + val capturedUUIDs: List = uuidsCapture.captured assertEquals(2, capturedChannels.size) assertEquals(1, capturedChannelGroups.size) assertEquals(1, capturedUUIDs.size) diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/PNConfigurationImplTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/PNConfigurationImplTest.kt similarity index 92% rename from pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/PNConfigurationImplTest.kt rename to pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/PNConfigurationImplTest.kt index b2f8af26e..eb820b40e 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/PNConfigurationImplTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/PNConfigurationImplTest.kt @@ -1,12 +1,13 @@ -package com.pubnub.internal.v2 +package com.PubNubForJava.internal.java.v2 import com.pubnub.api.UserId import com.pubnub.api.crypto.CryptoModule import com.pubnub.api.enums.PNHeartbeatNotificationOptions import com.pubnub.api.enums.PNLogVerbosity +import com.pubnub.api.java.PubNub +import com.pubnub.api.java.v2.PNConfiguration import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.api.v2.PNConfiguration -import com.pubnub.internal.BasePubNubImpl +import com.pubnub.internal.java.v2.PNConfigurationImpl import io.mockk.mockk import okhttp3.Authenticator import okhttp3.CertificatePinner @@ -24,14 +25,14 @@ import javax.net.ssl.X509ExtendedTrustManager class PNConfigurationImplTest { @Test fun testDefaultTimeoutValues() { - val config = PNConfiguration.builder(UserId(BasePubNubImpl.generateUUID()), "demo") + val config = PNConfiguration.builder(UserId(PubNub.generateUUID()), "demo") assertEquals(300, config.presenceTimeout) assertEquals(0, config.heartbeatInterval) } @Test fun testCustomTimeoutValues1() { - val config = PNConfiguration.builder(UserId(BasePubNubImpl.generateUUID()), "demo") + val config = PNConfiguration.builder(UserId(PubNub.generateUUID()), "demo") config.presenceTimeout(100) assertEquals(100, config.presenceTimeout) assertEquals(49, config.heartbeatInterval) @@ -39,7 +40,7 @@ class PNConfigurationImplTest { @Test fun testCustomTimeoutValues2() { - val config = PNConfiguration.builder(UserId(BasePubNubImpl.generateUUID()), "demo") + val config = PNConfiguration.builder(UserId(PubNub.generateUUID()), "demo") config.heartbeatInterval(100) assertEquals(300, config.presenceTimeout) assertEquals(100, config.heartbeatInterval) @@ -47,7 +48,7 @@ class PNConfigurationImplTest { @Test fun testCustomTimeoutValues3() { - val config = PNConfiguration.builder(UserId(BasePubNubImpl.generateUUID()), "demo") + val config = PNConfiguration.builder(UserId(PubNub.generateUUID()), "demo") config.heartbeatInterval(40) config.presenceTimeout(50) assertEquals(50, config.presenceTimeout) @@ -56,7 +57,7 @@ class PNConfigurationImplTest { @Test fun `build uses all values from Builder`() { - val expectedUserId = UserId(BasePubNubImpl.generateUUID()) + val expectedUserId = UserId(PubNub.generateUUID()) val expectedCryptoModule = CryptoModule.createAesCbcCryptoModule("cipher") val expectedProxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(80)) val expectedProxySelector = DefaultProxySelector() @@ -149,10 +150,10 @@ class PNConfigurationImplTest { } @Test - fun `builder has all default values from BasePNConfiguration`() { - val expectedUserId = UserId(BasePubNubImpl.generateUUID()) + fun `builder has all default values from PNConfiguration`() { + val expectedUserId = UserId(PubNub.generateUUID()) val builder = PNConfiguration.builder(expectedUserId, "subKey") - val expectedDefaults = BasePNConfigurationImpl(expectedUserId) + val expectedDefaults = PNConfigurationImpl(expectedUserId) assertEquals(expectedUserId, builder.userId) assertEquals("subKey", builder.subscribeKey) @@ -196,7 +197,7 @@ class PNConfigurationImplTest { @Test fun `can reset userId and subscribeKey`() { - val expectedUserId = UserId(BasePubNubImpl.generateUUID()) + val expectedUserId = UserId(PubNub.generateUUID()) val expectedSubKey = "expectedSubKey" val config = PNConfiguration.builder(UserId("aaa"), "subKey") diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/callbacks/DelegatingEventListenerTest.kt similarity index 82% rename from pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt rename to pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/callbacks/DelegatingEventListenerTest.kt index 36caea8b0..b8c05a707 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/callbacks/DelegatingEventListenerTest.kt @@ -1,36 +1,38 @@ -package com.pubnub.internal.v2.callbacks +package com.pubnub.internal.java.v2.callbacks import com.google.gson.JsonPrimitive -import com.pubnub.api.PNConfiguration -import com.pubnub.api.PubNub import com.pubnub.api.UserId +import com.pubnub.api.java.PubNub +import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadataResult +import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembershipResult +import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadataResult +import com.pubnub.api.java.v2.PNConfiguration +import com.pubnub.api.java.v2.callbacks.EventListener +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -import com.pubnub.api.models.consumer.objects_api.channel.PNChannelMetadataResult -import com.pubnub.api.models.consumer.objects_api.membership.PNMembershipResult -import com.pubnub.api.models.consumer.objects_api.uuid.PNUUIDMetadataResult import com.pubnub.api.models.consumer.pubsub.BasePubSubResult +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEvent +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage import com.pubnub.api.utils.PatchValue -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteMembershipEvent -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetMembershipEvent -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetMembershipEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test internal class DelegatingEventListenerTest { @Test fun testEquals() { + val pubnub = PubNub.create(PNConfiguration.builder(UserId("abc"), "demo").build()) val eventListener = object : EventListener {} val otherEventListener = object : EventListener {} - val delegating1 = DelegatingEventListener(eventListener) - val delegating2 = DelegatingEventListener(eventListener) - val otherDelegating = DelegatingEventListener(otherEventListener) + val delegating1 = DelegatingEventListener(eventListener, pubnub) + val delegating2 = DelegatingEventListener(eventListener, pubnub) + val otherDelegating = DelegatingEventListener(otherEventListener, pubnub) Assertions.assertEquals(delegating1, delegating2) Assertions.assertEquals(delegating2, delegating1) @@ -69,8 +71,9 @@ internal class DelegatingEventListenerTest { membershipCalled = true } } - val delegating = DelegatingEventListener(eventListener) - val pn = PubNub.create(PNConfiguration(UserId("a"))) + val pubnub = PubNub.create(PNConfiguration.builder(UserId("abc"), "demo").build()) + val pn = com.pubnub.api.PubNub.create(PNConfiguration.builder(UserId("a"), "demo").build()) + val delegating = DelegatingEventListener(eventListener, pubnub) delegating.objects( pn, PNObjectEventResult( @@ -100,7 +103,7 @@ internal class DelegatingEventListenerTest { "b", "c", "d", - com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata( + PNChannelMetadata( "a", PatchValue.of("b"), null, @@ -159,7 +162,7 @@ internal class DelegatingEventListenerTest { val message = PNSetUUIDMetadataEventMessage(source, version, event, type, metadata) val objectEvent = PNObjectEventResult(BasePubSubResult(channel, subscription, timetoken, userMetadata, publisher), message) - val result: PNUUIDMetadataResult = DelegatingEventListener.getSetUuidMetadataResult(objectEvent, message) + val result: PNUUIDMetadataResult = Converters.getSetUuidMetadataResult(objectEvent, message) Assertions.assertEquals(event, result.event) result.data.let { data -> @@ -185,7 +188,7 @@ internal class DelegatingEventListenerTest { fun getDeleteUuidMetadataResult() { val message = PNDeleteUUIDMetadataEventMessage(source, version, event, type, uuid) val objectEvent = PNObjectEventResult(BasePubSubResult(channel, subscription, timetoken, userMetadata, publisher), message) - val result: PNUUIDMetadataResult = DelegatingEventListener.getDeleteUuidMetadataResult(objectEvent, message) + val result: PNUUIDMetadataResult = Converters.getDeleteUuidMetadataResult(objectEvent, message) Assertions.assertEquals(event, result.event) result.data.let { data -> @@ -210,7 +213,7 @@ internal class DelegatingEventListenerTest { @Test fun getSetChannelMetadataResult() { val metadata = - com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata( + PNChannelMetadata( id, PatchValue.of(name), PatchValue.of(description), @@ -223,7 +226,7 @@ internal class DelegatingEventListenerTest { val message = PNSetChannelMetadataEventMessage(source, version, event, type, metadata) val objectEvent = PNObjectEventResult(BasePubSubResult(channel, subscription, timetoken, userMetadata, publisher), message) - val result: PNChannelMetadataResult = DelegatingEventListener.getSetChannelMetadataResult(objectEvent, message) + val result: PNChannelMetadataResult = Converters.getSetChannelMetadataResult(objectEvent, message) Assertions.assertEquals(event, result.event) result.data.let { data -> @@ -248,7 +251,7 @@ internal class DelegatingEventListenerTest { val message = PNDeleteChannelMetadataEventMessage(source, version, event, type, channel) val objectEvent = PNObjectEventResult(BasePubSubResult(channel, subscription, timetoken, userMetadata, publisher), message) - val result: PNChannelMetadataResult = DelegatingEventListener.getDeleteChannelMetadataResult(objectEvent, message) + val result: PNChannelMetadataResult = Converters.getDeleteChannelMetadataResult(objectEvent, message) Assertions.assertEquals(event, result.event) result.data.let { data -> @@ -274,7 +277,7 @@ internal class DelegatingEventListenerTest { val message = PNDeleteMembershipEventMessage(source, version, event, type, membershipEvent) val objectEvent = PNObjectEventResult(BasePubSubResult(channel, subscription, timetoken, userMetadata, publisher), message) - val result: PNMembershipResult = DelegatingEventListener.getDeleteMembershipResult(objectEvent, message) + val result: PNMembershipResult = Converters.getDeleteMembershipResult(objectEvent, message) Assertions.assertEquals(event, result.event) result.data.let { data -> @@ -298,7 +301,7 @@ internal class DelegatingEventListenerTest { val message = PNSetMembershipEventMessage(source, version, event, type, metadata) val objectEvent = PNObjectEventResult(BasePubSubResult(channel, subscription, timetoken, userMetadata, publisher), message) - val result: PNMembershipResult = DelegatingEventListener.getSetMembershipResult(objectEvent, message) + val result: PNMembershipResult = Converters.getSetMembershipResult(objectEvent, message) Assertions.assertEquals(event, result.event) result.data.let { data -> diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingStatusListenerTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/callbacks/DelegatingStatusListenerTest.kt similarity index 72% rename from pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingStatusListenerTest.kt rename to pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/callbacks/DelegatingStatusListenerTest.kt index 9595360d3..9f1d0c94a 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingStatusListenerTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/callbacks/DelegatingStatusListenerTest.kt @@ -1,18 +1,22 @@ -package com.pubnub.internal.v2.callbacks +package com.pubnub.internal.java.v2.callbacks -import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.internal.callbacks.DelegatingStatusListener +import com.pubnub.api.UserId +import com.pubnub.api.java.PubNub +import com.pubnub.api.java.v2.PNConfiguration +import com.pubnub.api.java.v2.callbacks.StatusListener import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Test internal class DelegatingStatusListenerTest { @Test fun testEquals() { + val pubnub = PubNub.create(PNConfiguration.builder(UserId("abc"), "demo").build()) + val statusListener = StatusListener { pubnub, pnStatus -> TODO("Not yet implemented") } val otherStatusListener = StatusListener { pubnub, pnStatus -> TODO("Not yet implemented") } - val delegating1 = DelegatingStatusListener(statusListener) - val delegating2 = DelegatingStatusListener(statusListener) - val otherDelegating = DelegatingStatusListener(otherStatusListener) + val delegating1 = DelegatingStatusListener(statusListener, pubnub) + val delegating2 = DelegatingStatusListener(statusListener, pubnub) + val otherDelegating = DelegatingStatusListener(otherStatusListener, pubnub) Assertions.assertEquals(delegating1, delegating2) Assertions.assertEquals(delegating2, delegating1) diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/entities/ChannelGroupImplTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/entities/ChannelGroupImplTest.kt similarity index 51% rename from pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/entities/ChannelGroupImplTest.kt rename to pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/entities/ChannelGroupImplTest.kt index 1b36f3389..4b2c04273 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/entities/ChannelGroupImplTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/entities/ChannelGroupImplTest.kt @@ -1,23 +1,23 @@ -package com.pubnub.internal.v2.entities +package com.pubnub.internal.java.v2.entities import com.pubnub.api.v2.subscriptions.EmptyOptions -import com.pubnub.api.v2.subscriptions.Subscription -import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.java.PubNubForJavaImpl +import com.pubnub.internal.v2.entities.ChannelGroupName import io.mockk.mockk +import io.mockk.spyk import io.mockk.verify import org.junit.jupiter.api.Test class ChannelGroupImplTest { private lateinit var objectUnderTest: ChannelGroupImpl - private val pubnub: PubNubImpl = mockk(relaxed = true) + private val pubnub: PubNubForJavaImpl = mockk(relaxed = true) @Test fun shouldCallSubscriptionWithEmptyOptionObjectWhenCallingSubscriptionWithoutOptions() { - val channelGroupName = "myChannelGroupName" - objectUnderTest = ChannelGroupImpl(pubnub, channelGroupName) + objectUnderTest = spyk(ChannelGroupImpl(pubnub, ChannelGroupName("abc"))) - val subscription: Subscription = objectUnderTest.subscription() + objectUnderTest.subscription() verify { objectUnderTest.subscription(EmptyOptions) } } diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/entities/ChannelImplTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/entities/ChannelImplTest.kt similarity index 58% rename from pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/entities/ChannelImplTest.kt rename to pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/entities/ChannelImplTest.kt index 4faa76425..f8ace8cfc 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/entities/ChannelImplTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/entities/ChannelImplTest.kt @@ -1,20 +1,21 @@ -package com.pubnub.internal.v2.entities +package com.pubnub.internal.java.v2.entities import com.pubnub.api.v2.subscriptions.EmptyOptions -import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.java.PubNubForJavaImpl +import com.pubnub.internal.v2.entities.ChannelName import io.mockk.mockk +import io.mockk.spyk import io.mockk.verify import org.junit.jupiter.api.Test class ChannelImplTest { private lateinit var objectUnderTest: ChannelImpl - private val pubnub: PubNubImpl = mockk(relaxed = true) + private val pubnub: PubNubForJavaImpl = mockk(relaxed = true) @Test fun shouldCallSubscriptionWithEmptyOptionObjectWhenCallingSubscriptionWithoutOpitons() { - val channelName = "myChannelName" - objectUnderTest = ChannelImpl(pubnub, channelName) + objectUnderTest = spyk(ChannelImpl(pubnub, ChannelName("abc"))) objectUnderTest.subscription() diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/subscription/SubscriptionImplTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/subscription/SubscriptionImplTest.kt new file mode 100644 index 000000000..bd14b54aa --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/subscription/SubscriptionImplTest.kt @@ -0,0 +1,188 @@ + +import com.pubnub.api.java.v2.subscriptions.Subscription +import com.pubnub.api.java.v2.subscriptions.SubscriptionSet +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.java.PubNubForJavaImpl +import com.pubnub.internal.java.v2.subscription.SubscriptionImpl +import com.pubnub.internal.java.v2.subscription.SubscriptionSetImpl +import com.pubnub.internal.v2.entities.ChannelGroupName +import com.pubnub.internal.v2.entities.ChannelName +import io.mockk.every +import io.mockk.mockk +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test + +// package com.pubnub.internal.java.v2.subscription +// +// import com.pubnub.api.java.callbacks.SubscribeCallback +// import com.pubnub.api.java.v2.callbacks.EventListener +// import com.pubnub.api.java.v2.callbacks.handlers.OnChannelMetadataHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnFileHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnMembershipHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnMessageActionHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnMessageHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnPresenceHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnSignalHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnUuidMetadataHandler +// import com.pubnub.api.v2.subscriptions.Subscription +// import io.mockk.mockk +// import io.mockk.slot +// import io.mockk.verify +// import org.junit.jupiter.api.Assertions.assertEquals +// import org.junit.jupiter.api.Assertions.assertTrue +// import org.junit.jupiter.api.BeforeEach +// import org.junit.jupiter.api.Test +// +// class SubscriptionImplTest { +// private lateinit var objectUnderTest: SubscriptionImpl +// val underlyingSubscription: Subscription = mockk() +// private val eventListener: EventListener = mockk() +// private val listenerSubscribeCallback: SubscribeCallback = mockk() +// +// @BeforeEach +// fun setUp() { +// objectUnderTest = SubscriptionImpl(underlyingSubscription) +// } +// +// @Test +// fun `addListener should call addListener on eventEmitter`() { +// val capturedListeners = mutableListOf() +// objectUnderTest.addListener(eventListener) +// +// verify { underlyingSubscription.addListener(capture(capturedListeners)) } +// assertTrue(capturedListeners.contains(eventListener)) +// } +// +// @Test +// fun `removeListener which is SubscribeCallback should call proper removeListener on eventEmitter`() { +// val delegatingSubscribeCallbackSlot = slot() +// objectUnderTest.removeListener(listenerSubscribeCallback) +// +// verify(exactly = 1) { underlyingSubscription.removeListener(capture(delegatingSubscribeCallbackSlot)) } +// assertEquals(delegatingSubscribeCallbackSlot.captured, listenerSubscribeCallback) +// } +// +// @Test +// fun `removeListener which is EventListener should call proper removeListener on eventEmitter`() { +// val delegatingEventListenerSlot = slot() +// objectUnderTest.removeListener(eventListener) +// +// verify(exactly = 1) { underlyingSubscription.removeListener(capture(delegatingEventListenerSlot)) } +// assertEquals(delegatingEventListenerSlot.captured, eventListener) +// } +// +// @Test +// fun `removeAllListeners should call removeAllListeners on eventEmitter`() { +// objectUnderTest.removeAllListeners() +// +// verify(exactly = 1) { underlyingSubscription.removeAllListeners() } +// } +// +// @Test +// fun `setOnMessage should set property on emitterHelper`() { +// val onMessageHandler: OnMessageHandler = mockk() +// +// objectUnderTest.setOnMessage(onMessageHandler) +// +// verify { underlyingSubscription.onMessage = any() } +// } +// +// @Test +// fun `setOnSignal should set property on emitterHelper`() { +// val onSignalHandler: OnSignalHandler = mockk() +// +// objectUnderTest.setOnSignal(onSignalHandler) +// +// verify { underlyingSubscription.onSignal = any() } +// } +// +// @Test +// fun `setOnPresence should set property on emitterHelper`() { +// val onPresenceHandler: OnPresenceHandler = mockk() +// +// objectUnderTest.setOnPresence(onPresenceHandler) +// +// verify { underlyingSubscription.onPresence = any() } +// } +// +// @Test +// fun `setOnMessageAction should set property on emitterHelper`() { +// val onMessageActionHandler: OnMessageActionHandler = mockk() +// +// objectUnderTest.setOnMessageAction(onMessageActionHandler) +// +// verify { underlyingSubscription.onMessageAction = any() } +// } +// +// @Test +// fun `setOnUuidMetadata should set property on emitterHelper`() { +// val onUuidMetadataHandler: OnUuidMetadataHandler = mockk() +// +// objectUnderTest.setOnUuidMetadata(onUuidMetadataHandler) +// +// verify { underlyingSubscription.onObjects = any() } +// } +// +// @Test +// fun `setOnChannelMetadata should set property on emitterHelper`() { +// val onChannelMetadataHandler: OnChannelMetadataHandler = mockk() +// +// objectUnderTest.setOnChannelMetadata(onChannelMetadataHandler) +// +// verify { underlyingSubscription.onObjects = any() } +// } +// +// @Test +// fun `setOnMembership should set property on emitterHelper`() { +// val onMembershipHandler: OnMembershipHandler = mockk() +// +// objectUnderTest.setOnMembership(onMembershipHandler) +// +// verify { underlyingSubscription.onObjects = any() } +// } +// +// @Test +// fun `setOnFile should set property on emitterHelper`() { +// val onFileHandler: OnFileHandler = mockk() +// +// objectUnderTest.setOnFile(onFileHandler) +// +// verify { underlyingSubscription.onFile = any() } +// } +// } + +class SubscriptionImplTest { + private lateinit var objectUnderTest: Subscription + + private val pubNubImpl: PubNubForJavaImpl = mockk(relaxed = true) + private val subscriptionSetImpl: SubscriptionSetImpl = mockk() + + private val channels = setOf(ChannelName("Channel1")) + private val channels02 = setOf(ChannelName("Channel2")) + private val channelGroups = setOf(ChannelGroupName("ChannelGroup1")) + private val channelGroups02 = setOf(ChannelGroupName("ChannelGroup2")) + + @BeforeEach + fun setUp() { + objectUnderTest = SubscriptionImpl(pubNubImpl, channels, channelGroups, SubscriptionOptions.receivePresenceEvents()) + } + + @Test + fun `should add subscription to subscription creating subscriptionSet when using plus method`() { + // given + val subscriptionToBeAdded: Subscription = + SubscriptionImpl(pubNubImpl, channels02, channelGroups02, SubscriptionOptions.receivePresenceEvents()) + every { pubNubImpl.subscriptionSetOf(any>()) } returns subscriptionSetImpl + every { subscriptionSetImpl.subscriptions } returns setOf(objectUnderTest, subscriptionToBeAdded) + + // when + val subscriptionSet: SubscriptionSet = objectUnderTest + subscriptionToBeAdded + + // then + assertEquals(2, subscriptionSet.subscriptions.size) + assertTrue(subscriptionSet.subscriptions.contains(objectUnderTest)) + assertTrue(subscriptionSet.subscriptions.contains(subscriptionToBeAdded)) + } +} diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/subscription/SubscriptionSetImplTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/subscription/SubscriptionSetImplTest.kt new file mode 100644 index 000000000..7a556b06f --- /dev/null +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/subscription/SubscriptionSetImplTest.kt @@ -0,0 +1,157 @@ +package com.pubnub.internal.java.v2.subscription + +import com.pubnub.api.v2.subscriptions.EmptyOptions +import com.pubnub.api.v2.subscriptions.SubscriptionOptions +import com.pubnub.internal.java.PubNubForJavaImpl +import com.pubnub.internal.managers.ListenerManager +import com.pubnub.internal.v2.entities.ChannelGroupName +import com.pubnub.internal.v2.entities.ChannelName +import io.mockk.every +import io.mockk.mockk +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test + +class SubscriptionSetImplTest { + private lateinit var objectUnderTest: SubscriptionSetImpl + + private val pubNubImpl: PubNubForJavaImpl = mockk() + + private val channel = setOf(ChannelName("Channel2")) + private val channelGroup = setOf(ChannelGroupName("ChannelGroup2")) + + @BeforeEach + fun setUp() { + val listenerManager = ListenerManager(pubNubImpl) + every { pubNubImpl.listenerManager } returns listenerManager + + objectUnderTest = SubscriptionSetImpl(pubNubImpl, emptySet()) + } + + @Test + fun `should add subscription to subscription set when using plusAssign method`() { + // given + val subscriptionToBeAdded = SubscriptionImpl(pubNubImpl, channel, channelGroup, SubscriptionOptions.receivePresenceEvents()) + + // when + objectUnderTest += subscriptionToBeAdded + + // then + assertEquals(1, objectUnderTest.subscriptions.size) + assertTrue(objectUnderTest.subscriptions.contains(subscriptionToBeAdded)) + } + + @Test + fun `should remove subscription from subscription set when using minusAssign method`() { + // given + val subscriptionToBeRemoved = SubscriptionImpl(pubNubImpl, channel, channelGroup, EmptyOptions) + objectUnderTest += subscriptionToBeRemoved + assertTrue(objectUnderTest.subscriptions.contains(subscriptionToBeRemoved)) + + // when + objectUnderTest -= subscriptionToBeRemoved + + // then + assertEquals(0, objectUnderTest.subscriptions.size) + } +} + +// +// import com.pubnub.api.PubNub +// import com.pubnub.api.java.v2.callbacks.handlers.OnChannelMetadataHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnFileHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnMembershipHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnMessageActionHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnMessageHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnPresenceHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnSignalHandler +// import com.pubnub.api.java.v2.callbacks.handlers.OnUuidMetadataHandler +// import com.pubnub.api.v2.subscriptions.SubscriptionSet +// import io.mockk.mockk +// import io.mockk.verify +// import org.junit.jupiter.api.BeforeEach +// import org.junit.jupiter.api.Test +// +// class SubscriptionSetImplTest { +// private lateinit var objectUnderTest: SubscriptionSetImpl +// private val underlyingSet: SubscriptionSet = mockk() +// private val pubNub: PubNub = mockk(relaxed = true) +// +// @BeforeEach +// fun setUp() { +// objectUnderTest = SubscriptionSetImpl(underlyingSet) +// } +// +// @Test +// fun `setOnMessage sets onMessageHandler in EmitterHelper`() { +// val onMessageHandler: OnMessageHandler = mockk() +// +// objectUnderTest.setOnMessage(onMessageHandler) +// +// verify { underlyingSet.onMessage = any() } +// } +// +// @Test +// fun `setOnSignal should set property on underlyingSet`() { +// val onSignalHandler: OnSignalHandler = mockk() +// +// objectUnderTest.setOnSignal(onSignalHandler) +// +// verify { underlyingSet.onSignal = any() } +// } +// +// @Test +// fun `setOnPresence should set property on underlyingSet`() { +// val onPresenceHandler: OnPresenceHandler = mockk() +// +// objectUnderTest.setOnPresence(onPresenceHandler) +// +// verify { underlyingSet.onPresence = any() } +// } +// +// @Test +// fun `setOnMessageAction should set property on underlyingSet`() { +// val onMessageActionHandler: OnMessageActionHandler = mockk() +// +// objectUnderTest.setOnMessageAction(onMessageActionHandler) +// +// verify { underlyingSet.onMessageAction = any() } +// } +// +// @Test +// fun `setOnUuidMetadata should set property on underlyingSet`() { +// val onUuidMetadataHandler: OnUuidMetadataHandler = mockk() +// +// objectUnderTest.setOnUuidMetadata(onUuidMetadataHandler) +// +// verify { underlyingSet.onObjects = any() } +// } +// +// @Test +// fun `setOnChannelMetadata should set property on underlyingSet`() { +// val onChannelMetadataHandler: OnChannelMetadataHandler = mockk() +// +// objectUnderTest.setOnChannelMetadata(onChannelMetadataHandler) +// +// verify { underlyingSet.onObjects = any() } +// } +// +// @Test +// fun `setOnMembership should set property on underlyingSet`() { +// val onMembershipHandler: OnMembershipHandler = mockk() +// +// objectUnderTest.setOnMembership(onMembershipHandler) +// +// verify { underlyingSet.onObjects = any() } +// } +// +// @Test +// fun `setOnFile should set property on underlyingSet`() { +// val onFileHandler: OnFileHandler = mockk() +// +// objectUnderTest.setOnFile(onFileHandler) +// +// verify { underlyingSet.onFile = any() } +// } +// } diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt deleted file mode 100644 index 82d47bfe4..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt +++ /dev/null @@ -1,38 +0,0 @@ -package com.pubnub.internal.v2.callbacks - -import com.pubnub.api.PubNub -import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.internal.callbacks.DelegatingSubscribeCallback -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test - -internal class DelegatingSubscribeCallbackTest { - @Test - fun testEquals() { - val statusListener = - object : com.pubnub.api.callbacks.SubscribeCallback() { - override fun status( - pubnub: PubNub, - pnStatus: PNStatus, - ) { } - } - val otherStatusListener = - object : com.pubnub.api.callbacks.SubscribeCallback() { - override fun status( - pubnub: PubNub, - pnStatus: PNStatus, - ) {} - } - - val delegating1 = DelegatingSubscribeCallback(statusListener) - val delegating2 = DelegatingSubscribeCallback(statusListener) - val otherDelegating = DelegatingSubscribeCallback(otherStatusListener) - - Assertions.assertEquals(delegating1, delegating2) - Assertions.assertEquals(delegating2, delegating1) - Assertions.assertNotEquals(delegating1, otherDelegating) - Assertions.assertNotEquals(delegating2, otherDelegating) - Assertions.assertNotEquals(otherDelegating, delegating1) - Assertions.assertNotEquals(otherDelegating, delegating2) - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionImplTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionImplTest.kt deleted file mode 100644 index dee2e806c..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionImplTest.kt +++ /dev/null @@ -1,160 +0,0 @@ -package com.pubnub.internal.v2.subscription - -import com.pubnub.api.callbacks.SubscribeCallback -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.handlers.OnChannelMetadataHandler -import com.pubnub.api.v2.callbacks.handlers.OnFileHandler -import com.pubnub.api.v2.callbacks.handlers.OnMembershipHandler -import com.pubnub.api.v2.callbacks.handlers.OnMessageActionHandler -import com.pubnub.api.v2.callbacks.handlers.OnMessageHandler -import com.pubnub.api.v2.callbacks.handlers.OnPresenceHandler -import com.pubnub.api.v2.callbacks.handlers.OnSignalHandler -import com.pubnub.api.v2.callbacks.handlers.OnUuidMetadataHandler -import com.pubnub.api.v2.subscriptions.EmptyOptions -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.callbacks.DelegatingSubscribeCallback -import com.pubnub.internal.v2.callbacks.DelegatingEventListener -import com.pubnub.internal.v2.callbacks.EventEmitterImpl -import com.pubnub.internal.v2.callbacks.EventListenerCore -import com.pubnub.internal.v2.entities.ChannelGroupName -import com.pubnub.internal.v2.entities.ChannelName -import io.mockk.every -import io.mockk.mockk -import io.mockk.slot -import io.mockk.verify -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class SubscriptionImplTest { - private lateinit var objectUnderTest: SubscriptionImpl - - private val pubnub: PubNubImpl = mockk(relaxed = true) - private val pubnubCore: PubNubCore = mockk() - private val channels: Set = emptySet() - private val channelGroups: Set = emptySet() - private val options: SubscriptionOptions = EmptyOptions - private val eventEmitter: EventEmitterImpl = mockk(relaxed = true) - private val eventListener: EventListener = mockk() - private val listenerSubscribeCallback: SubscribeCallback = mockk() - private val emitterHelper: EmitterHelper = mockk(relaxed = true) - - @BeforeEach - fun setUp() { - every { pubnub.pubNubCore } returns pubnubCore - every { eventEmitter.addListener(any()) } returns Unit - every { emitterHelper.initialize(eventEmitter) } returns Unit - objectUnderTest = SubscriptionImpl(pubnub, channels, channelGroups, options, emitterHelper) { eventEmitter } - } - - @Test - fun `addListener should call addListener on eventEmitter`() { - val capturedListeners = mutableListOf() - objectUnderTest.addListener(eventListener) - - verify { eventEmitter.addListener(capture(capturedListeners)) } - assertTrue(capturedListeners.all { it is DelegatingEventListener }) - } - - @Test - fun `removeListener which is SubscribeCallback should call proper removeListener on eventEmitter`() { - val delegatingSubscribeCallbackSlot = slot() - objectUnderTest.removeListener(listenerSubscribeCallback) - - verify(exactly = 1) { eventEmitter.removeListener(capture(delegatingSubscribeCallbackSlot)) } - assertTrue(delegatingSubscribeCallbackSlot.captured is DelegatingSubscribeCallback) - assertEquals(listenerSubscribeCallback, delegatingSubscribeCallbackSlot.captured.listener) - } - - @Test - fun `removeListener which is EventListener should call proper removeListener on eventEmitter`() { - val delegatingEventListenerSlot = slot() - objectUnderTest.removeListener(eventListener) - - verify(exactly = 1) { eventEmitter.removeListener(capture(delegatingEventListenerSlot)) } - assertTrue(delegatingEventListenerSlot.captured is DelegatingEventListener) - assertEquals(eventListener, delegatingEventListenerSlot.captured.listener) - } - - @Test - fun `removeAllListeners should call removeAllListeners on eventEmitter`() { - objectUnderTest.removeAllListeners() - - verify(exactly = 1) { eventEmitter.removeAllListeners() } - } - - @Test - fun `setOnMessage should set property on emitterHelper`() { - val onMessageHandler: OnMessageHandler = mockk() - - objectUnderTest.setOnMessage(onMessageHandler) - - verify { emitterHelper.onMessage = onMessageHandler } - } - - @Test - fun `setOnSignal should set property on emitterHelper`() { - val onSignalHandler: OnSignalHandler = mockk() - - objectUnderTest.setOnSignal(onSignalHandler) - - verify { emitterHelper.onSignal = onSignalHandler } - } - - @Test - fun `setOnPresence should set property on emitterHelper`() { - val onPresenceHandler: OnPresenceHandler = mockk() - - objectUnderTest.setOnPresence(onPresenceHandler) - - verify { emitterHelper.onPresence = onPresenceHandler } - } - - @Test - fun `setOnMessageAction should set property on emitterHelper`() { - val onMessageActionHandler: OnMessageActionHandler = mockk() - - objectUnderTest.setOnMessageAction(onMessageActionHandler) - - verify { emitterHelper.onMessageAction = onMessageActionHandler } - } - - @Test - fun `setOnUuidMetadata should set property on emitterHelper`() { - val onUuidMetadataHandler: OnUuidMetadataHandler = mockk() - - objectUnderTest.setOnUuidMetadata(onUuidMetadataHandler) - - verify { emitterHelper.onUuid = onUuidMetadataHandler } - } - - @Test - fun `setOnChannelMetadata should set property on emitterHelper`() { - val onChannelMetadataHandler: OnChannelMetadataHandler = mockk() - - objectUnderTest.setOnChannelMetadata(onChannelMetadataHandler) - - verify { emitterHelper.onChannel = onChannelMetadataHandler } - } - - @Test - fun `setOnMembership should set property on emitterHelper`() { - val onMembershipHandler: OnMembershipHandler = mockk() - - objectUnderTest.setOnMembership(onMembershipHandler) - - verify { emitterHelper.onMembership = onMembershipHandler } - } - - @Test - fun `setOnFile should set property on emitterHelper`() { - val onFileHandler: OnFileHandler = mockk() - - objectUnderTest.setOnFile(onFileHandler) - - verify { emitterHelper.onFile = onFileHandler } - } -} diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImplTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImplTest.kt deleted file mode 100644 index 95359889f..000000000 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImplTest.kt +++ /dev/null @@ -1,106 +0,0 @@ -package com.pubnub.internal.v2.subscription - -import com.pubnub.api.v2.callbacks.handlers.OnChannelMetadataHandler -import com.pubnub.api.v2.callbacks.handlers.OnFileHandler -import com.pubnub.api.v2.callbacks.handlers.OnMembershipHandler -import com.pubnub.api.v2.callbacks.handlers.OnMessageActionHandler -import com.pubnub.api.v2.callbacks.handlers.OnMessageHandler -import com.pubnub.api.v2.callbacks.handlers.OnPresenceHandler -import com.pubnub.api.v2.callbacks.handlers.OnSignalHandler -import com.pubnub.api.v2.callbacks.handlers.OnUuidMetadataHandler -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.managers.ListenerManager -import io.mockk.Runs -import io.mockk.every -import io.mockk.just -import io.mockk.mockk -import io.mockk.verify -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test - -class SubscriptionSetImplTest { - private lateinit var objectUnderTest: SubscriptionSetImpl - - private val pubNubCore: PubNubCore = mockk(relaxed = true) - private val emitterHelper: EmitterHelper = mockk(relaxed = true) - private val listenerManager: ListenerManager = mockk(relaxed = true) - - @BeforeEach - fun setUp() { - every { pubNubCore.listenerManager } returns listenerManager - every { emitterHelper.initialize(any()) } just Runs - objectUnderTest = SubscriptionSetImpl(pubNubCore, emptySet(), emitterHelper) - } - - @Test - fun `setOnMessage sets onMessageHandler in EmitterHelper`() { - val onMessageHandler: OnMessageHandler = mockk() - - objectUnderTest.setOnMessage(onMessageHandler) - - verify { emitterHelper.onMessage = onMessageHandler } - } - - @Test - fun `setOnSignal should set property on emitterHelper`() { - val onSignalHandler: OnSignalHandler = mockk() - - objectUnderTest.setOnSignal(onSignalHandler) - - verify { emitterHelper.onSignal = onSignalHandler } - } - - @Test - fun `setOnPresence should set property on emitterHelper`() { - val onPresenceHandler: OnPresenceHandler = mockk() - - objectUnderTest.setOnPresence(onPresenceHandler) - - verify { emitterHelper.onPresence = onPresenceHandler } - } - - @Test - fun `setOnMessageAction should set property on emitterHelper`() { - val onMessageActionHandler: OnMessageActionHandler = mockk() - - objectUnderTest.setOnMessageAction(onMessageActionHandler) - - verify { emitterHelper.onMessageAction = onMessageActionHandler } - } - - @Test - fun `setOnUuidMetadata should set property on emitterHelper`() { - val onUuidMetadataHandler: OnUuidMetadataHandler = mockk() - - objectUnderTest.setOnUuidMetadata(onUuidMetadataHandler) - - verify { emitterHelper.onUuid = onUuidMetadataHandler } - } - - @Test - fun `setOnChannelMetadata should set property on emitterHelper`() { - val onChannelMetadataHandler: OnChannelMetadataHandler = mockk() - - objectUnderTest.setOnChannelMetadata(onChannelMetadataHandler) - - verify { emitterHelper.onChannel = onChannelMetadataHandler } - } - - @Test - fun `setOnMembership should set property on emitterHelper`() { - val onMembershipHandler: OnMembershipHandler = mockk() - - objectUnderTest.setOnMembership(onMembershipHandler) - - verify { emitterHelper.onMembership = onMembershipHandler } - } - - @Test - fun `setOnFile should set property on emitterHelper`() { - val onFileHandler: OnFileHandler = mockk() - - objectUnderTest.setOnFile(onFileHandler) - - verify { emitterHelper.onFile = onFileHandler } - } -} diff --git a/pubnub-kotlin/build.gradle.kts b/pubnub-kotlin/build.gradle.kts index c6059f2d6..8b068e6b6 100644 --- a/pubnub-kotlin/build.gradle.kts +++ b/pubnub-kotlin/build.gradle.kts @@ -5,8 +5,6 @@ plugins { } dependencies { - api(project(":pubnub-core:pubnub-core-api")) api(project(":pubnub-kotlin:pubnub-kotlin-api")) - implementation(project(":pubnub-core:pubnub-core-impl")) implementation(project(":pubnub-kotlin:pubnub-kotlin-impl")) } diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index 96e10880c..c9f60d159 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -14,13 +14,20 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - api(project(":pubnub-core:pubnub-core-api")) +// api(project(":pubnub-core:pubnub-core-api")) + implementation(libs.kotlinx.atomicfu) } } val jvmMain by getting { dependencies { - implementation(project(":pubnub-core:pubnub-core-impl")) +// implementation(project(":pubnub-core:pubnub-core-impl")) + api(libs.retrofit2) + api(libs.okhttp) + api(libs.okhttp.logging) + api(libs.json) + api(libs.gson) + implementation(libs.slf4j) implementation(libs.slf4j) } } @@ -50,7 +57,7 @@ kotlin { if (enableAnyIosTarget) { (this as ExtensionAware).extensions.configure { framework { - export(project(":pubnub-core:pubnub-core-api")) +// export(project(":pubnub-core:pubnub-core-api")) } } } diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/JsonElement.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt index f410310e8..5a6ba7a25 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNub.kt @@ -89,7 +89,7 @@ expect interface PubNub { channel: String, message: Any, meta: Any? = null, - shouldStore: Boolean = true, + shouldStore: Boolean? = null, usePost: Boolean = false, replicate: Boolean = true, ttl: Int? = null, diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubError.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNubError.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubError.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNubError.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/PubNubException.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/UserId.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/UserId.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/UserId.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/UserId.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/callbacks/Listener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/callbacks/Listener.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/callbacks/Listener.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/callbacks/Listener.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/endpoints/remoteaction/RemoteAction.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNHeartbeatNotificationOptions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNHeartbeatNotificationOptions.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNHeartbeatNotificationOptions.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNHeartbeatNotificationOptions.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNLogVerbosity.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNLogVerbosity.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNLogVerbosity.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNLogVerbosity.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNOperationType.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNOperationType.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNOperationType.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNOperationType.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushEnvironment.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNPushType.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNReconnectionPolicy.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNReconnectionPolicy.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNReconnectionPolicy.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNReconnectionPolicy.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNStatusCategory.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNStatusCategory.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/enums/PNStatusCategory.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/enums/PNStatusCategory.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/TokenBitmask.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/TokenBitmask.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/TokenBitmask.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/TokenBitmask.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNBoundedPage.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNBoundedPage.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNBoundedPage.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNBoundedPage.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNPublishResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNPublishResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNPublishResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNPublishResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNStatus.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNTimeResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNTimeResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNTimeResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/PNTimeResult.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResults.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResults.kt index c985a7ff6..0489df329 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResults.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/PNAccessManagerGrantResults.kt @@ -1,5 +1,7 @@ package com.pubnub.api.models.consumer.access_manager +import com.pubnub.api.utils.SerializedName + /** * Result of the [PubNubCore.grant] operation * @@ -16,33 +18,45 @@ class PNAccessManagerGrantResult( val subscribeKey: String, val channels: Map?>, val channelGroups: Map?>, + val uuids: Map?>, ) open class PNAccessManagerKeyData { /** * Is `true` if *read* rights are granted. */ + @field:SerializedName("r") var readEnabled: Boolean = false /** * Is `true` if *write* rights are granted. */ + @field:SerializedName("w") var writeEnabled: Boolean = false /** * Is `true` if *manage* rights are granted. */ + @field:SerializedName("m") var manageEnabled: Boolean = false /** * Is `true` if *delete* rights are granted. */ + @field:SerializedName("d") var deleteEnabled: Boolean = false + + @field:SerializedName("g") var getEnabled: Boolean = false + + @field:SerializedName("u") var updateEnabled: Boolean = false + + @field:SerializedName("j") var joinEnabled: Boolean = false } class PNAccessManagerKeysData { + @field:SerializedName("auths") val authKeys: Map? = null } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/Grants.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/Grants.kt index bd707e462..35debc05a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/Grants.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/Grants.kt @@ -15,7 +15,7 @@ interface PNGrant { val id: String } -internal sealed class PNAbstractGrant( +sealed class PNAbstractGrant protected constructor( override val read: Boolean = false, override val write: Boolean = false, override val manage: Boolean = false, @@ -26,9 +26,9 @@ internal sealed class PNAbstractGrant( override val update: Boolean = false, ) : PNGrant -internal sealed class PNResourceGrant : PNAbstractGrant() +sealed class PNResourceGrant : PNAbstractGrant() -internal sealed class PNPatternGrant : PNAbstractGrant() +sealed class PNPatternGrant : PNAbstractGrant() internal data class PNChannelResourceGrant( override val id: String, diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNGrantTokenResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNGrantTokenResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNGrantTokenResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNGrantTokenResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNToken.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNToken.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNToken.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/access_manager/v3/PNToken.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/channel_group/PNChannelGroupsResults.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/channel_group/PNChannelGroupsResults.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/channel_group/PNChannelGroupsResults.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/channel_group/PNChannelGroupsResults.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDeleteFileResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDeleteFileResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDeleteFileResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDeleteFileResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadFileResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadableFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadableFile.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadableFile.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNDownloadableFile.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFile.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFile.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFile.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFile.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUploadResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUploadResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUploadResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUploadResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUrlResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUrlResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUrlResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNFileUrlResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNListFilesResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNListFilesResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNListFilesResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNListFilesResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNPublishFileMessageResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNPublishFileMessageResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNPublishFileMessageResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/files/PNPublishFileMessageResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/HistoryMessageType.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNDeleteMessagesResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNDeleteMessagesResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNDeleteMessagesResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNDeleteMessagesResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNFetchMessage.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNHistoryResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNMessageCountResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNMessageCountResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNMessageCountResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/history/PNMessageCountResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNAddMessageActionResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNAddMessageActionResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNAddMessageActionResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNAddMessageActionResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt similarity index 60% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt index b0bf61340..32eaa4bd9 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.kt @@ -1,6 +1,7 @@ package com.pubnub.api.models.consumer.message_actions import com.pubnub.api.models.consumer.PNBoundedPage +import com.pubnub.api.utils.SerializedName /** * Result for the GetMessageActions API operation. @@ -8,7 +9,10 @@ import com.pubnub.api.models.consumer.PNBoundedPage * @property actions List of message actions for a certain message in a certain channel. * @property page Information about next page. When null there's no next page. */ -expect class PNGetMessageActionsResult(actions: List, page: PNBoundedPage?) { - val actions: List - val page: PNBoundedPage? -} + +class PNGetMessageActionsResult( + @field:SerializedName("data") + val actions: List, + @field:SerializedName("more") + val page: PNBoundedPage?, +) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNMessageAction.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNRemoveMessageActionResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNRemoveMessageActionResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNRemoveMessageActionResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNRemoveMessageActionResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNPage.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNPage.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNPage.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/PNPage.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadata.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataArrayResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/channel/PNChannelMetadataResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/objects/uuid/PNUUIDMetadata.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNGetStateResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNHereNow.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/presence/PNSetStateResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/BasePubSubResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/MessageResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNEvent.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNEvent.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNEvent.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNEvent.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNMessageResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNPresenceEventResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/PNSignalResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/files/PNFileEventResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/message_actions/PNMessageActionResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectPayload.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/pubsub/objects/ObjectResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushAddChannelResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushAddChannelResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushAddChannelResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushAddChannelResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushListProvisionsResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushListProvisionsResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushListProvisionsResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushListProvisionsResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveAllChannelsResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveAllChannelsResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveAllChannelsResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveAllChannelsResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveChannelResult.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveChannelResult.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveChannelResult.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/PNPushRemoveChannelResult.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadHelper.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadSerializer.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadSerializer.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadSerializer.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/models/consumer/push/payload/PushPayloadSerializer.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryConfiguration.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryableEndpointGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryableEndpointGroup.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryableEndpointGroup.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/retry/RetryableEndpointGroup.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt similarity index 99% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt index 38c7acc88..e456df7d8 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/utils/PatchValue.kt @@ -1,4 +1,5 @@ package com.pubnub.api.utils + import kotlin.jvm.JvmStatic /** diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/utils/SerializedName.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/utils/SerializedName.kt new file mode 100644 index 000000000..9b2657daa --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/utils/SerializedName.kt @@ -0,0 +1,7 @@ +@file:OptIn(ExperimentalMultiplatform::class) + +package com.pubnub.api.utils + +@OptionalExpectation +@Target(AnnotationTarget.FIELD) +expect annotation class SerializedName(val value: String, val alternate: Array = []) diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt index e77ebdff5..c698a62b9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventEmitter.kt @@ -1,5 +1,6 @@ package com.pubnub.api.v2.callbacks +import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult @@ -10,7 +11,26 @@ import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult /** * Interface implemented by objects that are the source of real time events from the PubNub network. */ -interface EventEmitter : BaseEventEmitter { +interface EventEmitter { + /** + * Add a listener. + * + * @param listener The listener to be added. + */ + fun addListener(listener: EventListener) + + /** + * Remove a listener. + * + * @param listener The listener to be removed, previously added with [addListener]. + */ + fun removeListener(listener: Listener) + + /** + * Removes all listeners. + */ + fun removeAllListeners() + /** * A nullable property that can be set to a function (or lambda expression) to handle incoming message events. * This function is invoked whenever a new message is received, providing a convenient way to process or react to messages. @@ -33,6 +53,8 @@ interface EventEmitter : BaseEventEmitter { * ``` */ var onMessage: ((PNMessageResult) -> Unit)? + get() = error("Not supported") + set(value) = error("Not supported") /** * A nullable property designed to set a function or lambda expression for handling incoming presence events. @@ -56,6 +78,8 @@ interface EventEmitter : BaseEventEmitter { * ``` */ var onPresence: ((PNPresenceEventResult) -> Unit)? + get() = error("Not supported") + set(value) = error("Not supported") /** * A nullable property for assigning a function or lambda expression to handle incoming signal events. @@ -79,6 +103,8 @@ interface EventEmitter : BaseEventEmitter { * ``` */ var onSignal: ((PNSignalResult) -> Unit)? + get() = error("Not supported") + set(value) = error("Not supported") /** * A nullable property that allows setting a function or lambda to react to message action events. @@ -102,6 +128,8 @@ interface EventEmitter : BaseEventEmitter { * ``` */ var onMessageAction: ((PNMessageActionResult) -> Unit)? + get() = error("Not supported") + set(value) = error("Not supported") /** * A nullable property for assigning a function or lambda to handle object events. @@ -125,6 +153,8 @@ interface EventEmitter : BaseEventEmitter { * ``` */ var onObjects: ((PNObjectEventResult) -> Unit)? + get() = error("Not supported") + set(value) = error("Not supported") /** * A nullable property to set a function or lambda for responding to file events. @@ -148,4 +178,6 @@ interface EventEmitter : BaseEventEmitter { * ``` */ var onFile: ((PNFileEventResult) -> Unit)? + get() = error("Not supported") + set(value) = error("Not supported") } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt index d751791b5..9f419ffa9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt @@ -1,7 +1,9 @@ package com.pubnub.api.v2.callbacks +import com.pubnub.api.callbacks.Listener + /** * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -expect interface EventListener : BaseEventListener +expect interface EventListener : Listener diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/callbacks/Result.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt index 5b5ad4df1..82762f387 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Channel.kt @@ -4,8 +4,8 @@ import com.pubnub.api.endpoints.files.DeleteFile import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.pubsub.Publish import com.pubnub.api.endpoints.pubsub.Signal -import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.kmp.Uploadable /** @@ -15,7 +15,32 @@ import com.pubnub.kmp.Uploadable * * Use the [com.pubnub.api.PubNub.channel] factory method to create instances of this interface. */ -interface Channel : BaseChannel { +interface Channel : Subscribable { + /** + * The name of this channel. Supports wildcards by ending it with ".*" + * + * See more in the [documentation](https://www.pubnub.com/docs/general/channels/overview) + */ + val name: String + + /** + * Returns a [Subscription] that can be used to subscribe to this channel. + * + * Channel subscriptions support passing [com.pubnub.api.v2.subscriptions.SubscriptionOptions.receivePresenceEvents] in + * [options] to enable receiving presence events. + * + * [com.pubnub.api.v2.subscriptions.SubscriptionOptions.filter] can be used to filter events delivered to the subscription. + * + * For example, to create a subscription that only listens to presence events: + * ``` + * channel.subscription(SubscriptionOptions.receivePresenceEvents() + SubscriptionOptions.filter { it is PNPresenceEventResult } ) + * ``` + * + * @param options optional [SubscriptionOptions]. + * @return an inactive [Subscription] to this channel. You must call [Subscription.subscribe] to start receiving events. + */ + override fun subscription(options: SubscriptionOptions): Subscription + /** * Send a message to all subscribers of the channel. * diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt index 2bd90ac29..e0c355039 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelGroup.kt @@ -1,7 +1,7 @@ package com.pubnub.api.v2.entities -import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions /** * A representation of a PubNub channel group identified by its [name]. @@ -10,4 +10,40 @@ import com.pubnub.api.v2.subscriptions.Subscription * * Use the [com.pubnub.api.PubNub.channelGroup] factory method to create instances of this interface. */ -interface ChannelGroup : BaseChannelGroup +interface ChannelGroup : Subscribable { + /** + * The name of this channel group. + * + * See more in the [documentation](https://www.pubnub.com/docs/general/channels/subscribe#channel-groups) + */ + val name: String + + /** + * Returns a [Subscription] that can be used to subscribe to this channel group. + * + * Channel group subscriptions support passing [com.pubnub.api.v2.subscriptions.SubscriptionOptions.receivePresenceEvents] + * in [options] to enable receiving presence events. + * + * [com.pubnub.api.v2.subscriptions.SubscriptionOptions.filter] can be used to filter events delivered to the subscription. + * + * For example, to create a subscription that only listens to presence events: + * ``` + * channelGroup.subscription(SubscriptionOptions.receivePresenceEvents() + SubscriptionOptions.filter { it is PNPresenceEventResult } ) + * ``` + * + * *Warning:* if a channel is part of more than one channel group, and you create subscription to both (or more) + * those groups using a single [com.pubnub.api.PubNub] instance, you will only receive events for that channel in + * one channel group subscription. + * + * For example, let's say "channel_1" is part of groups "cg_1" and "cg_2". If you only subscribe to "cg_1", + * or you only subscribe to "cg_2", you will get all events for "channel_1". However, if in your app you subscribe + * to both "cg_1" and "cg_2" at the same time, you will only receive events for "channel_1" in one of those + * subscriptions, chosen at random. + * + * This limitation is due to how the server manages channels and channel groups. + * + * @param options optional [SubscriptionOptions]. + * @return an inactive [Subscription] to this channel group. You must call [Subscription.subscribe] to start receiving events. + */ + override fun subscription(options: SubscriptionOptions): Subscription +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt index 5bb2b819e..cc89bb3e3 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/ChannelMetadata.kt @@ -1,7 +1,7 @@ package com.pubnub.api.v2.entities -import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions /** * A representation of a PubNub entity for tracking channel metadata changes. @@ -10,4 +10,21 @@ import com.pubnub.api.v2.subscriptions.Subscription * * Use the [com.pubnub.api.PubNub.channelMetadata] factory method to create instances of this interface. */ -interface ChannelMetadata : BaseChannelMetadata +interface ChannelMetadata : Subscribable { + /** + * The id for this channel metadata object. + * + * See more in the [documentation](https://www.pubnub.com/docs/general/metadata/channel-metadata) + */ + val id: String + + /** + * Returns a [Subscription] that can be used to subscribe to this channel metadata. + * + * [com.pubnub.api.v2.subscriptions.SubscriptionOptions.filter] can be used to filter events delivered to the subscription. + * + * @param options optional [SubscriptionOptions]. + * @return an inactive [Subscription] to this channel metadata. You must call [Subscription.subscribe] to start receiving events. + */ + override fun subscription(options: SubscriptionOptions): Subscription +} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Subscribable.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Subscribable.kt similarity index 78% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Subscribable.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Subscribable.kt index 28c796609..a869d8b82 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Subscribable.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/Subscribable.kt @@ -1,20 +1,19 @@ package com.pubnub.api.v2.entities -import com.pubnub.api.v2.callbacks.BaseEventListener -import com.pubnub.api.v2.subscriptions.BaseSubscription import com.pubnub.api.v2.subscriptions.EmptyOptions +import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions /** * This interface is implemented by entities that can be subscribed to, such as channels, channel groups, and user and * channel metadata. */ -interface Subscribable { +interface Subscribable { /** * Returns a [com.pubnub.api.v2.subscriptions.Subscription] that can be used to subscribe to this `Subscribable`. * * @param options optional [SubscriptionOptions]. * @return an inactive [Subscription] to this `Subscribable`. You must call [Subscription.subscribe] to start receiving events. */ - fun subscription(options: SubscriptionOptions = EmptyOptions): BaseSubscription + fun subscription(options: SubscriptionOptions = EmptyOptions): Subscription } diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt index 6f68eefc8..bd71c498c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/entities/UserMetadata.kt @@ -1,7 +1,7 @@ package com.pubnub.api.v2.entities -import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions /** * A representation of a PubNub entity for tracking user metadata changes. @@ -10,4 +10,21 @@ import com.pubnub.api.v2.subscriptions.Subscription * * Use the [com.pubnub.api.PubNub.userMetadata] factory method to create instances of this interface. */ -interface UserMetadata : BaseUserMetadata +interface UserMetadata : Subscribable { + /** + * The id for this user metadata object. + * + * See more in the [documentation](https://www.pubnub.com/docs/general/metadata/users-metadata) + */ + val id: String + + /** + * Returns a [Subscription] that can be used to subscribe to this user metadata. + * + * [com.pubnub.api.v2.subscriptions.SubscriptionOptions.filter] can be used to filter events delivered to the subscription. + * + * @param options optional [SubscriptionOptions]. + * @return an inactive [Subscription] to this user metadata. You must call [Subscription.subscribe] to start receiving events. + */ + override fun subscription(options: SubscriptionOptions): Subscription +} diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscribeCapable.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscribeCapable.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscribeCapable.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscribeCapable.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt index 6b6eb7a6c..bf17cc02b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/Subscription.kt @@ -1,7 +1,6 @@ package com.pubnub.api.v2.subscriptions import com.pubnub.api.v2.callbacks.EventEmitter -import com.pubnub.api.v2.callbacks.EventListener /** * Represents a potential subscription to the PubNub real-time network. @@ -15,7 +14,7 @@ import com.pubnub.api.v2.callbacks.EventListener * This class implements the [AutoCloseable] interface to help you release resources by calling [unsubscribe] * and removing all listeners on [close]. Remember to always call [close] when you no longer need this Subscription. */ -interface Subscription : BaseSubscription, EventEmitter { +interface Subscription : EventEmitter, SubscribeCapable, AutoCloseable { /** * Create a [SubscriptionSet] containing this [Subscription] and the added [subscription]. */ diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt similarity index 54% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt index 83ceb0be5..bc209c560 100644 --- a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionCursor.kt @@ -3,7 +3,7 @@ package com.pubnub.api.v2.subscriptions /** * A holder for a timetoken value. * - * Used with [BaseSubscription.subscribe] to start listening for events newer or equal to the requested timetoken. + * Used with [Subscription.subscribe] to start listening for events newer or equal to the requested timetoken. */ class SubscriptionCursor( val timetoken: Long, diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionOptions.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt index 7b2f0c09d..aadcc688f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/api/v2/subscriptions/SubscriptionSet.kt @@ -1,7 +1,6 @@ package com.pubnub.api.v2.subscriptions import com.pubnub.api.v2.callbacks.EventEmitter -import com.pubnub.api.v2.callbacks.EventListener /** * A helper class that manages multiple [Subscription]s that can be added to it. @@ -15,7 +14,32 @@ import com.pubnub.api.v2.callbacks.EventListener * Remember to always [close] the set when you're done using it to avoid memory leaks. * Closing the set also closes all `Subscription`s that are part of this set. */ -interface SubscriptionSet : BaseSubscriptionSet, EventEmitter { +interface SubscriptionSet : EventEmitter, SubscribeCapable, AutoCloseable { + /** + * Add a [Subscription] to this set. + * + * Please note that this SubscriptionSet will *not* attempt to ensure all subscriptions match their + * active/inactive state. That is, if you previously called [subscribe] or [unsubscribe] on this set, it will not be + * called on the newly added [subscription] automatically. + * + * @param subscription the [Subscription] to add. + */ + fun add(subscription: Subscription) + + /** + * Remove the [subscription] from this set. + * + * Please note that removing a subscription from the set does not automatically [unsubscribe] or [close] it. + * + * @param subscription the [Subscription] to remove. + */ + fun remove(subscription: Subscription) + + /** + * Returns an immutable copy of the set of subscriptions contained in this [SubscriptionSet]. + */ + val subscriptions: Set + /** * Add the [subscription] to this SubscriptionSet. Equivalent to calling [add]. * diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Downloadable.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/PNFuture.kt diff --git a/pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/futures.kt diff --git a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/kmp/JsonElementTest.kt diff --git a/pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/commonTest/kotlin/com/pubnub/kmp/PNFutureTest.kt diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/JsonElement.ios.kt diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubException.ios.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index a6e9d6bac..24503d37b 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -185,7 +185,7 @@ class PubNubImpl(private val pubNubObjC: KMPPubNub) : PubNub { channel: String, message: Any, meta: Any?, - shouldStore: Boolean, + shouldStore: Boolean?, usePost: Boolean, replicate: Boolean, ttl: Int? diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.ios.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt index a77aeb352..217b06626 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.ios.kt @@ -2,6 +2,7 @@ package com.pubnub.api.v2.callbacks import cocoapods.PubNubSwift.KMPEventListener import com.pubnub.api.PubNub +import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult @@ -16,7 +17,7 @@ import kotlinx.cinterop.ExperimentalForeignApi */ @OptIn(ExperimentalForeignApi::class) -actual interface EventListener : BaseEventListener { +actual interface EventListener : Listener { val underlying: KMPEventListener val onMessage: (PubNub, PNMessageResult) -> Unit val onPresence: (PubNub, PNPresenceEventResult) -> Unit diff --git a/pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/kmp/Downloadable.ios.kt diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/JsonElement.js.kt diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/PubNubException.js.kt diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.js.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.js.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/models/consumer/message_actions/PNGetMessageActionsResult.js.kt diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.js.kt diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/Downloadable.js.kt diff --git a/pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jsMain/kotlin/com/pubnub/kmp/JsMap.kt diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/JsonElement.jvm.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PNConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PNConfiguration.kt deleted file mode 100644 index 4802be24f..000000000 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PNConfiguration.kt +++ /dev/null @@ -1,394 +0,0 @@ -package com.pubnub.api - -import com.pubnub.api.crypto.CryptoModule -import com.pubnub.api.enums.PNHeartbeatNotificationOptions -import com.pubnub.api.enums.PNLogVerbosity -import com.pubnub.api.enums.PNReconnectionPolicy -import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.api.v2.PNConfiguration -import com.pubnub.internal.v2.BasePNConfigurationImpl -import com.pubnub.internal.v2.BasePNConfigurationImpl.Companion.MINIMUM_PRESENCE_TIMEOUT -import okhttp3.Authenticator -import okhttp3.CertificatePinner -import okhttp3.logging.HttpLoggingInterceptor -import org.slf4j.LoggerFactory -import java.net.Proxy -import java.net.ProxySelector -import javax.net.ssl.SSLSocketFactory -import javax.net.ssl.X509ExtendedTrustManager - -@Deprecated( - message = "Use `com.pubnub.api.v2.PNConfiguration.builder` instead.", - replaceWith = ReplaceWith("com.pubnub.api.v2.PNConfiguration.builder(userId, subscribeKey)"), -) -class PNConfiguration(override var userId: UserId) : PNConfiguration { - private val configuration = BasePNConfigurationImpl(userId) - private val log = LoggerFactory.getLogger("PNConfiguration") - - @Deprecated( - replaceWith = ReplaceWith( - "PNConfiguration(userId = UserId(uuid))", - "com.pubnub.api.PNConfiguration", - ), - level = DeprecationLevel.WARNING, - message = "Use PNConfiguration(UserId) instead.", - ) - @Throws(PubNubException::class) - constructor(uuid: String) : this(UserId(uuid)) - - @Deprecated( - "Use UserId instead e.g. config.userId.value", - replaceWith = ReplaceWith("userId.value"), - level = DeprecationLevel.WARNING, - ) - override var uuid - get() = userId.value - set(value) { - userId = UserId(value) - } - - /** - * The subscribe key from the admin panel. - */ - override var subscribeKey = "" - - /** - * The publish key from the admin panel (only required if publishing). - */ - override var publishKey = configuration.publishKey - - /** - * The secret key from the admin panel (only required for modifying/revealing access permissions). - * - * Keep away from Android. - */ - override var secretKey = configuration.secretKey - - /** - * If Access Manager is utilized, client will use this authKey in all restricted requests. - */ - override var authKey = configuration.authKey - - /** - * If set, all communications to and from PubNub will be encrypted. - */ - @Deprecated( - """Instead of cipherKey and useRandomInitializationVector use CryptoModule instead - e.g. config.cryptoModule = CryptoModule.createLegacyCryptoModule(cipherKey = cipherKey, randomIv = true) - or config.cryptoModule = CryptoModule.createAesCbcCryptoModule(cipherKey = cipherKey, randomIv = true)""", - level = DeprecationLevel.WARNING, - ) - var cipherKey: String? = null - - /** - * Should initialization vector for encrypted messages be random. - * - * Defaults to `true`. - */ - @Deprecated( - """Instead of cipherKey and useRandomInitializationVector use CryptoModule instead - e.g. config.cryptoModule = CryptoModule.createLegacyCryptoModule(cipherKey = cipherKey, randomIv = true) - or config.cryptoModule = CryptoModule.createAesCbcCryptoModule(cipherKey = cipherKey, randomIv = true)""", - level = DeprecationLevel.WARNING, - ) - var useRandomInitializationVector = true - - /** - * CryptoModule is responsible for handling encryption and decryption. - * If set, all communications to and from PubNub will be encrypted. - */ - override var cryptoModule: CryptoModule? = configuration.cryptoModule - get() = field ?: cipherKey?.let { cipherKey -> - if (cipherKey.isNotBlank()) { - log.warn("cipherKey is deprecated. Use CryptoModule instead") - field = - CryptoModule.createLegacyCryptoModule(cipherKey = cipherKey, randomIv = useRandomInitializationVector) - field - } else { - null - } - } - - /** - * Custom origin if needed. - * - * Defaults to `ps.pndsn.com` - */ - override var origin = configuration.origin - - /** - * If set to `true`, requests will be made over HTTPS. - * - * Deafults to `true`. - */ - override var secure = configuration.secure - - /** - * Set to [PNLogVerbosity.BODY] to enable logging of network traffic, otherwise se to [PNLogVerbosity.NONE]. - */ - override var logVerbosity: PNLogVerbosity = configuration.logVerbosity - - /** - * Set Heartbeat notification options. - * - * By default, the SDK alerts on failed heartbeats (equivalent to [PNHeartbeatNotificationOptions.FAILURES]). - */ - override var heartbeatNotificationOptions = configuration.heartbeatNotificationOptions - - /** - * Set to [PNReconnectionPolicy.LINEAR] for automatic reconnects. - * - * Use [PNReconnectionPolicy.NONE] to disable automatic reconnects. - * - * Use [PNReconnectionPolicy.EXPONENTIAL] to set exponential retry interval. - * - * Defaults to [PNReconnectionPolicy.NONE]. - */ - @Deprecated( - """Instead of reconnectionPolicy and maximumReconnectionRetries use retryConfiguration - e.g. config.retryConfiguration = RetryConfiguration.Linear(delayInSec = 3, maxRetryNumber = 5) - or config.retryConfiguration = RetryConfiguration.Exponential(minDelayInSec = 3, maxDelayInSec = 10, maxRetryNumber = 5)""", - level = DeprecationLevel.WARNING, - ) - var reconnectionPolicy: PNReconnectionPolicy = PNReconnectionPolicy.NONE - set(value) { - field = value - calculateRetryConfiguration() - } - - private fun calculateRetryConfiguration() { - retryConfiguration = when (reconnectionPolicy) { - PNReconnectionPolicy.NONE -> RetryConfiguration.None - PNReconnectionPolicy.LINEAR -> RetryConfiguration.Linear( - maxRetryNumber = getMaximumReconnectionRetriesFor(reconnectionPolicy), - ) - - PNReconnectionPolicy.EXPONENTIAL -> RetryConfiguration.Exponential( - maxRetryNumber = getMaximumReconnectionRetriesFor(reconnectionPolicy), - ) - } - } - - private fun getMaximumReconnectionRetriesFor(reconnectionPolicy: PNReconnectionPolicy): Int { - val maxRetryNumber = if (reconnectionPolicy == PNReconnectionPolicy.LINEAR) { - RetryConfiguration.Linear.MAX_RETRIES - } else { - RetryConfiguration.Exponential.MAX_RETRIES - } - return when { - maximumReconnectionRetries <= -1 -> maxRetryNumber - maximumReconnectionRetries > maxRetryNumber -> maxRetryNumber - else -> maximumReconnectionRetries - } - } - - /** - * Sets the custom presence server timeout. - * - * The value is in seconds, and the minimum value is 20 seconds. - * - * Also sets the value of [heartbeatInterval] - */ - override var presenceTimeout = configuration.presenceTimeout - set(value) { - field = - if (value < MINIMUM_PRESENCE_TIMEOUT) { - log.warn("Presence timeout is too low. Defaulting to: $MINIMUM_PRESENCE_TIMEOUT") - MINIMUM_PRESENCE_TIMEOUT - } else { - value - } - heartbeatInterval = (presenceTimeout / 2) - 1 - } - - /** - * How often the client will announce itself to server. - * - * The value is in seconds. - * - * Defaults to 0 (disabled). - */ - override var heartbeatInterval = configuration.heartbeatInterval - - /** - * The subscribe request timeout. - * - * The value is in seconds. - * - * Defaults to 310. - */ - override var subscribeTimeout = configuration.subscribeTimeout - - /** - * How long before the client gives up trying to connect with the server. - * - * The value is in seconds. - * - * Defaults to 5. - */ - override var connectTimeout = configuration.connectTimeout - - @Deprecated( - "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", - replaceWith = ReplaceWith("nonSubscribeReadTimeout") - ) - override var nonSubscribeRequestTimeout: Int - get() = nonSubscribeReadTimeout - set(value) { - nonSubscribeReadTimeout = value - } - - override var nonSubscribeReadTimeout: Int = configuration.nonSubscribeReadTimeout - - /** - * If operating behind a misbehaving proxy, allow the client to shuffle the subdomains. - * - * Defaults to `false`. - */ - override var cacheBusting = configuration.cacheBusting - - /** - * When `true` the SDK doesn't send out the leave requests. - * - * Defaults to `false`. - */ - override var suppressLeaveEvents = configuration.suppressLeaveEvents - - /** - * When `true` the SDK will resend the last channel state that was set using [PubNub.setPresenceState] - * for the current [userId] with every automatic heartbeat (if [heartbeatInterval] is greater than 0) - * and initial subscribe connection (also after e.g. loss of network). - * - * Defaults to `true`. - * - * Please note that `maintainPresenceState` doesn't apply to state that was set on channel groups. - * It is recommended to disable this option if you set state for channel groups using [PubNub.setPresenceState], - * otherwise that state may be overwritten by individual channel states. - */ - override var maintainPresenceState = configuration.maintainPresenceState - - /** - * Feature to subscribe with a custom filter expression. - */ - override var filterExpression = configuration.filterExpression - - /** - * Whether to include a instanceId with every request. - * - * Defaults to `false`. - */ - override var includeInstanceIdentifier = configuration.includeInstanceIdentifier - - /** - * Whether to include a requestId with every request. - * - * Defaults to `true`. - */ - override var includeRequestIdentifier = configuration.includeRequestIdentifier - - /** - * Sets how many times to retry to reconnect before giving up. - * Must be used in combination with [reconnectionPolicy]. - * - * The default value is `-1` which means unlimited retries. - */ - @Deprecated( - """Instead of reconnectionPolicy and maximumReconnectionRetries use retryConfiguration - e.g. config.retryConfiguration = RetryConfiguration.Linear(delayInSec = 3, maxRetryNumber = 5) - or config.retryConfiguration = RetryConfiguration.Exponential(minDelayInSec = 3, maxDelayInSec = 10, maxRetryNumber = 5)""", - level = DeprecationLevel.WARNING, - ) - var maximumReconnectionRetries = -1 - set(value) { - field = value - calculateRetryConfiguration() - } - - /** - * @see [okhttp3.Dispatcher.setMaxRequestsPerHost] - */ - override var maximumConnections = configuration.maximumConnections - - /** - * Enable Google App Engine networking. - * - * Defaults to `false`. - */ - override var googleAppEngineNetworking = configuration.googleAppEngineNetworking - - /** - * Instructs the SDK to use a proxy configuration when communicating with PubNub servers. - * - * @see [Proxy] - */ - override var proxy = configuration.proxy - - /** - * @see [ProxySelector] - */ - override var proxySelector = configuration.proxySelector - - /** - * @see [Authenticator] - */ - override var proxyAuthenticator = configuration.proxyAuthenticator - - /** - * @see [CertificatePinner] - */ - override var certificatePinner = configuration.certificatePinner - - /** - * Sets a custom [HttpLoggingInterceptor] for logging network traffic. - * - * @see [HttpLoggingInterceptor] - */ - override var httpLoggingInterceptor = configuration.httpLoggingInterceptor - - /** - * @see [SSLSocketFactory] - */ - override var sslSocketFactory = configuration.sslSocketFactory - - /** - * @see [X509ExtendedTrustManager] - */ - override var x509ExtendedTrustManager = configuration.x509ExtendedTrustManager - - /** - * @see [okhttp3.ConnectionSpec] - */ - override var connectionSpec = configuration.connectionSpec - - /** - * @see [javax.net.ssl.HostnameVerifier] - */ - override var hostnameVerifier = configuration.hostnameVerifier - - /** - * How many times publishing file message should automatically retry before marking the action as failed - * - * Defaults to `5` - */ - override var fileMessagePublishRetryLimit = configuration.fileMessagePublishRetryLimit - - override var dedupOnSubscribe = configuration.dedupOnSubscribe - - override var maximumMessagesCacheSize = configuration.maximumMessagesCacheSize - - override val pnsdkSuffixes: MutableMap = configuration.pnsdkSuffixes.toMutableMap() - - @Suppress("DeprecatedCallableAddReplaceWith") - @Deprecated("To be used by components", level = DeprecationLevel.WARNING) - fun addPnsdkSuffix(vararg nameToSuffixes: Pair) { - @Suppress("DEPRECATION") - addPnsdkSuffix(nameToSuffixes.toMap()) - } - - @Deprecated("To be used by components", level = DeprecationLevel.WARNING) - fun addPnsdkSuffix(nameToSuffixes: Map) = pnsdkSuffixes.putAll(nameToSuffixes) - - override var retryConfiguration = configuration.retryConfiguration - - override var managePresenceListManually: Boolean = configuration.managePresenceListManually -} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt index e9a4336bc..673ed8f0d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNub.kt @@ -52,6 +52,7 @@ import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNToken import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant import com.pubnub.api.models.consumer.history.PNHistoryResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction @@ -64,9 +65,9 @@ import com.pubnub.api.models.consumer.objects.member.MemberInput import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventEmitter -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.api.v2.callbacks.StatusEmitter import com.pubnub.api.v2.entities.Channel import com.pubnub.api.v2.entities.ChannelGroup import com.pubnub.api.v2.entities.ChannelMetadata @@ -74,48 +75,238 @@ import com.pubnub.api.v2.entities.UserMetadata import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet -import com.pubnub.internal.BasePubNubImpl import com.pubnub.kmp.CustomObject import java.io.InputStream +import java.util.UUID + +actual interface PubNub : StatusEmitter, EventEmitter { + val timestamp: Int + val baseUrl: String + + /** + * The current version of the PubNub SDK. + */ + val version: String + + /** + * Create a handle to a [Channel] that can be used to obtain a [Subscription]. + * + * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server + * state. It is therefore permitted to use this method whenever a representation of a channel is required. + * + * The returned [Channel] holds a reference to this [PubNub] instance internally. + * + * @param name the name of the channel to return. Supports wildcards by ending it with ".*". See more in the + * [documentation](https://www.pubnub.com/docs/general/channels/overview) + * + * @return a [Channel] instance representing the channel with the given [name] + */ + actual fun channel(name: String): Channel + + /** + * Create a handle to a [ChannelGroup] that can be used to obtain a [Subscription]. + * + * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server + * state. It is therefore permitted to use this method whenever a representation of a channel group is required. + * + * The returned [ChannelGroup] holds a reference to this [PubNub] instance internally. + * + * @param name the name of the channel group to return. See more in the + * [documentation](https://www.pubnub.com/docs/general/channels/subscribe#channel-groups) + * + * @return a [ChannelGroup] instance representing the channel group with the given [name] + */ + actual fun channelGroup(name: String): ChannelGroup + + /** + * Create a handle to a [ChannelMetadata] object that can be used to obtain a [Subscription] to metadata events. + * + * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server + * state. It is therefore permitted to use this method whenever a representation of a metadata channel is required. + * + * The returned [ChannelMetadata] holds a reference to this [PubNub] instance internally. + * + * @param id the id of the channel metadata to return. See more in the + * [documentation](https://www.pubnub.com/docs/general/metadata/channel-metadata) + * + * @return a [ChannelMetadata] instance representing the channel metadata with the given [id] + */ + actual fun channelMetadata(id: String): ChannelMetadata + + /** + * Create a handle to a [UserMetadata] object that can be used to obtain a [Subscription] to user metadata events. + * + * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server + * state. It is therefore permitted to use this method whenever a representation of a user metadata is required. + * + * The returned [UserMetadata] holds a reference to this [PubNub] instance internally. + * + * @param id the id of the user. See more in the + * [documentation](https://www.pubnub.com/docs/general/metadata/users-metadata) + * + * @return a [UserMetadata] instance representing the channel metadata with the given [id] + */ + actual fun userMetadata(id: String): UserMetadata + + /** + * Create a [SubscriptionSet] from the given [subscriptions]. + * + * @param subscriptions the subscriptions that will be added to the returned [SubscriptionSet] + * @return a [SubscriptionSet] containing all [subscriptions] + */ + actual fun subscriptionSetOf(subscriptions: Set): SubscriptionSet + + /** + * Create a [SubscriptionSet] containing [Subscription] objects for the given sets of [channels] and + * [channelGroups]. + * + * Please note that the subscriptions are not active until you call [SubscriptionSet.subscribe]. + * + * This is a convenience method, and it is equal to calling [PubNub.channel] followed by [Channel.subscription] for + * each channel, then creating a [subscriptionSetOf] using the returned [Subscription] objects (and similarly for + * channel groups). + * + * @param channels the channels to create subscriptions for + * @param channelGroups the channel groups to create subscriptions for + * @param options the [SubscriptionOptions] to pass for each subscription. Refer to supported options in [Channel] and + * [ChannelGroup] documentation. + * @return a [SubscriptionSet] containing subscriptions for the given [channels] and [channelGroups] + */ + actual fun subscriptionSetOf( + channels: Set, + channelGroups: Set, + options: SubscriptionOptions, + ): SubscriptionSet + + /** + * Perform Cryptographic decryption of an input string using cipher key provided by [PNConfiguration.cipherKey]. + * + * @param inputString String to be decrypted. + * + * @return String containing the decryption of `inputString` using `cipherKey`. + * @throws PubNubException throws exception in case of failed decryption. + */ + @Throws(PubNubException::class) + fun decrypt(inputString: String): String + + /** + * Perform Cryptographic decryption of an input string using a cipher key. + * + * @param inputString String to be decrypted. + * @param cipherKey cipher key to be used for decryption. Default is [PNConfiguration.cipherKey] + * + * @return String containing the decryption of `inputString` using `cipherKey`. + * @throws PubNubException throws exception in case of failed decryption. + */ + @Throws(PubNubException::class) + fun decrypt( + inputString: String, + cipherKey: String? = null, + ): String + + /** + * Perform Cryptographic decryption of an input stream using provided cipher key. + * + * @param inputStream InputStream to be encrypted. + * @param cipherKey Cipher key to be used for decryption. + * + * @return InputStream containing the encryption of `inputStream` using `cipherKey`. + * @throws PubNubException Throws exception in case of failed decryption. + */ + @Throws(PubNubException::class) + fun decryptInputStream( + inputStream: InputStream, + cipherKey: String? = null, + ): InputStream + + /** + * Perform Cryptographic encryption of an input string and a cipher key. + * + * @param inputString String to be encrypted. + * @param cipherKey Cipher key to be used for encryption. Default is [PNConfiguration.cipherKey] + * + * @return String containing the encryption of `inputString` using `cipherKey`. + * @throws PubNubException Throws exception in case of failed encryption. + */ + @Throws(PubNubException::class) + fun encrypt( + inputString: String, + cipherKey: String? = null, + ): String + + /** + * Perform Cryptographic encryption of an input stream using provided cipher key. + * + * @param inputStream InputStream to be encrypted. + * @param cipherKey Cipher key to be used for encryption. + * + * @return InputStream containing the encryption of `inputStream` using `cipherKey`. + * @throws PubNubException Throws exception in case of failed encryption. + */ + @Throws(PubNubException::class) + fun encryptInputStream( + inputStream: InputStream, + cipherKey: String? = null, + ): InputStream + + @Throws(PubNubException::class) + actual fun parseToken(token: String): PNToken + + actual fun setToken(token: String?) + + /** + * Force the SDK to try and reach out PubNub. Monitor the results in [SubscribeCallback.status] + * + * @param timetoken optional timetoken to use for the subscriptions on reconnection. + */ + fun reconnect(timetoken: Long = 0L) + + /** + * Cancel any subscribe and heartbeat loops or ongoing re-connections. + * + * Monitor the results in [SubscribeCallback.status] + */ + fun disconnect() + + /** + * Unsubscribe from all channels and all channel groups + */ + actual fun unsubscribeAll() + + /** + * Frees up threads eventually and allows for a clean exit. + */ + actual fun destroy() + + /** + * Same as [destroy] but immediately. + */ + fun forceDestroy() -actual interface PubNub : - BasePubNub, - EventEmitter { companion object { /** * Initialize and return an instance of the PubNub client. * @param configuration the configuration to use * @return the PubNub client */ - fun create(configuration: com.pubnub.api.v2.PNConfiguration): PubNub { - return Class.forName( - "com.pubnub.internal.PubNubImpl", - ).getConstructor(com.pubnub.api.v2.PNConfiguration::class.java).newInstance(configuration) as PubNub - } - - @Deprecated( - message = "Use `create` with the new PNConfiguration.Builder instead", - replaceWith = ReplaceWith("create(userId, subscribeKey, builder)") - ) - fun create( - userId: UserId, - builder: PNConfiguration.() -> Unit, - ): PubNub { + @JvmStatic + fun create(configuration: PNConfiguration): PubNub { return Class.forName( "com.pubnub.internal.PubNubImpl", - ).getConstructor(com.pubnub.api.v2.PNConfiguration::class.java).newInstance(PNConfiguration(userId).apply(builder)) as PubNub + ).getConstructor(PNConfiguration::class.java).newInstance(configuration) as PubNub } + @JvmStatic fun create( userId: UserId, subscribeKey: String, - builder: com.pubnub.api.v2.PNConfiguration.Builder.() -> Unit, + builder: PNConfiguration.Builder.() -> Unit, ): PubNub { return Class.forName( "com.pubnub.internal.PubNubImpl", - ).getConstructor(com.pubnub.api.v2.PNConfiguration::class.java) + ).getConstructor(PNConfiguration::class.java) .newInstance( - com.pubnub.api.v2.PNConfiguration.builder(userId, subscribeKey, builder).build() + PNConfiguration.builder(userId, subscribeKey, builder).build() ) as PubNub } @@ -123,7 +314,8 @@ actual interface PubNub : * Generates random UUID to use. You should set a unique UUID to identify the user or the device * that connects to PubNub. */ - fun generateUUID(): String = BasePubNubImpl.generateUUID() + @JvmStatic + fun generateUUID(): String = "pn-${UUID.randomUUID()}" } /** @@ -131,7 +323,7 @@ actual interface PubNub : * Modifying the values in this configuration is not advised, as it may lead * to undefined behavior. */ - actual val configuration: com.pubnub.api.v2.PNConfiguration + actual val configuration: PNConfiguration /** * Add a legacy listener for both client status and events. @@ -191,7 +383,7 @@ actual interface PubNub : channel: String, message: Any, meta: Any?, - shouldStore: Boolean, + shouldStore: Boolean?, usePost: Boolean, replicate: Boolean, ttl: Int?, @@ -796,33 +988,33 @@ actual interface PubNub : * It's possible to grant permissions to multiple [channelGroups] simultaneously. */ fun grant( - read: Boolean, - write: Boolean, - manage: Boolean, - delete: Boolean, - ttl: Int, - authKeys: List, - channels: List, - channelGroups: List, - uuids: List, + read: Boolean = false, + write: Boolean = false, + manage: Boolean = false, + delete: Boolean = false, + ttl: Int = -1, + authKeys: List = emptyList(), + channels: List = emptyList(), + channelGroups: List = emptyList(), + uuids: List = emptyList(), ): Grant /** * See [grant] */ fun grant( - read: Boolean, - write: Boolean, - manage: Boolean, - delete: Boolean, - get: Boolean, - update: Boolean, - join: Boolean, - ttl: Int, - authKeys: List, - channels: List, - channelGroups: List, - uuids: List, + read: Boolean = false, + write: Boolean = false, + manage: Boolean = false, + delete: Boolean = false, + get: Boolean = false, + update: Boolean = false, + join: Boolean = false, + ttl: Int = -1, + authKeys: List = emptyList(), + channels: List = emptyList(), + channelGroups: List = emptyList(), + uuids: List = emptyList(), ): Grant /** @@ -1380,6 +1572,7 @@ actual interface PubNub : * Default is `false`. * @param includeCustom Include respective additional fields in the response. * @param includeUUIDDetails Include custom fields for UUIDs metadata. + * @param includeType Include the type field for UUID metadata */ fun manageChannelMembers( channel: String, @@ -1392,6 +1585,7 @@ actual interface PubNub : includeCount: Boolean = false, includeCustom: Boolean = false, includeUUIDDetails: PNUUIDDetailsLevel? = null, + includeUUIDType: Boolean = false, ): ManageChannelMembers /** @@ -1566,10 +1760,4 @@ actual interface PubNub : channels: List, channelGroups: List, ) - - actual override fun subscriptionSetOf( - channels: Set, - channelGroups: Set, - options: SubscriptionOptions - ): SubscriptionSet } diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/PubNubException.kt diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/CryptoModule.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/crypto/CryptoModule.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/CryptoModule.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/crypto/CryptoModule.kt diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/cryptor/Cryptor.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/crypto/cryptor/Cryptor.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/cryptor/Cryptor.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/crypto/cryptor/Cryptor.kt diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedData.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedData.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedData.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedData.kt diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedStreamData.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedStreamData.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedStreamData.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/crypto/data/EncryptedStreamData.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt index dc967b265..23f7393b8 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/AddChannelsToPush.kt @@ -1,9 +1,17 @@ package com.pubnub.api.endpoints.push import com.pubnub.api.Endpoint +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushAddChannelResult /** * @see [PubNub.addPushNotificationsOnChannels] */ -actual interface AddChannelsToPush : Endpoint +actual interface AddChannelsToPush : Endpoint { + val pushType: PNPushType + val channels: List + val deviceId: String + val topic: String? + val environment: PNPushEnvironment +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt index 2b02a22ca..e51b38c8d 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/ListPushProvisions.kt @@ -1,9 +1,16 @@ package com.pubnub.api.endpoints.push import com.pubnub.api.Endpoint +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult /** * @see [PubNub.auditPushChannelProvisions] */ -actual interface ListPushProvisions : Endpoint +actual interface ListPushProvisions : Endpoint { + val pushType: PNPushType + val deviceId: String + val topic: String? + val environment: PNPushEnvironment +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt index 7137ab2d5..1a708c6a6 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveAllPushChannelsForDevice.kt @@ -1,9 +1,16 @@ package com.pubnub.api.endpoints.push import com.pubnub.api.Endpoint +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult /** * @see [PubNub.removeAllPushNotificationsFromDeviceWithPushToken] */ -actual interface RemoveAllPushChannelsForDevice : Endpoint +actual interface RemoveAllPushChannelsForDevice : Endpoint { + val pushType: PNPushType + val deviceId: String + val environment: PNPushEnvironment + val topic: String? +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt index dc50d0cc7..9c8f30a9c 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/push/RemoveChannelsFromPush.kt @@ -1,9 +1,17 @@ package com.pubnub.api.endpoints.push import com.pubnub.api.Endpoint +import com.pubnub.api.enums.PNPushEnvironment +import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult /** * @see [PubNub.removePushNotificationsFromChannels] */ -actual interface RemoveChannelsFromPush : Endpoint +actual interface RemoveChannelsFromPush : Endpoint { + val pushType: PNPushType + val channels: List + val deviceId: String + val topic: String? + val environment: PNPushEnvironment +} diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/ComposableRemoteAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/ComposableRemoteAction.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/ComposableRemoteAction.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/ComposableRemoteAction.kt diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/MappingRemoteAction.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/MappingRemoteAction.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/MappingRemoteAction.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/endpoints/remoteaction/MappingRemoteAction.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/utils/SerializedName.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/utils/SerializedName.jvm.kt new file mode 100644 index 000000000..35f3301b9 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/utils/SerializedName.jvm.kt @@ -0,0 +1,5 @@ +package com.pubnub.api.utils + +import com.google.gson.annotations.SerializedName + +actual typealias SerializedName = SerializedName diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt index 7964a87a0..57cf56087 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/PNConfiguration.kt @@ -5,7 +5,6 @@ import com.pubnub.api.crypto.CryptoModule import com.pubnub.api.enums.PNHeartbeatNotificationOptions import com.pubnub.api.enums.PNLogVerbosity import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.internal.v2.BasePNConfigurationImpl import okhttp3.Authenticator import okhttp3.CertificatePinner import okhttp3.ConnectionSpec @@ -16,8 +15,278 @@ import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509ExtendedTrustManager -actual interface PNConfiguration : BasePNConfiguration { +actual interface PNConfiguration { + /** + * The user ID that the PubNub client will use. + */ + actual val userId: UserId + + /** + * The subscribe key from the admin panel. + */ + actual val subscribeKey: String + + /** + * The publish key from the admin panel (only required if publishing). + */ + actual val publishKey: String + + /** + * The secret key from the admin panel (only required for modifying/revealing access permissions). + * + * Keep away from Android. + */ + actual val secretKey: String + + /** + * If Access Manager is utilized, client will use this authKey in all restricted requests. + */ + actual val authKey: String + + /** + * CryptoModule is responsible for handling encryption and decryption. + * If set, all communications to and from PubNub will be encrypted. + */ + val cryptoModule: CryptoModule? + + /** + * Custom origin if needed. + * + * Defaults to `ps.pndsn.com` + */ + val origin: String + + /** + * If set to `true`, requests will be made over HTTPS. + * + * Deafults to `true`. + */ + val secure: Boolean + + /** + * Set to [PNLogVerbosity.BODY] to enable logging of network traffic, otherwise se to [PNLogVerbosity.NONE]. + */ + actual val logVerbosity: PNLogVerbosity + + /** + * Set Heartbeat notification options. + * + * By default, the SDK alerts on failed heartbeats (equivalent to [PNHeartbeatNotificationOptions.FAILURES]). + */ + val heartbeatNotificationOptions: PNHeartbeatNotificationOptions + + /** + * Sets the custom presence server timeout. + * + * The value is in seconds, and the minimum value is 20 seconds. + * + * Also sets the value of [heartbeatInterval] + */ + val presenceTimeout: Int + + /** + * How often the client will announce itself to server. + * + * The value is in seconds. + */ + val heartbeatInterval: Int + + /** + * The subscribe request timeout. + * + * The value is in seconds. + * + * Defaults to 310. + */ + val subscribeTimeout: Int + + /** + * How long before the client gives up trying to connect with the server. + * + * The value is in seconds. + * + * Defaults to 5. + */ + val connectTimeout: Int + + /** + * For non subscribe operations (publish, herenow, etc), + * This property relates to a read timeout that is applied from the moment the connection between a client + * and the server has been successfully established. It defines a maximum time of inactivity between two + * data packets when waiting for the server’s response. + * + * The value is in seconds. + * + * Defaults to 10. + */ + @Deprecated( + "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", + replaceWith = ReplaceWith("nonSubscribeReadTimeout") + ) + val nonSubscribeRequestTimeout: Int + get() = nonSubscribeReadTimeout + + /** + * For non subscribe operations (publish, herenow, etc), + * This property relates to a read timeout that is applied from the moment the connection between a client + * and the server has been successfully established. It defines a maximum time of inactivity between two + * data packets when waiting for the server’s response. + * + * The value is in seconds. + * + * Defaults to 10. + */ + val nonSubscribeReadTimeout: Int + + /** + * If operating behind a misbehaving proxy, allow the client to shuffle the subdomains. + * + * Defaults to `false`. + */ + val cacheBusting: Boolean + + /** + * When `true` the SDK doesn't send out the leave requests. + * + * Defaults to `false`. + */ + val suppressLeaveEvents: Boolean + + /** + * When `true` the SDK will resend the last channel state that was set using [PubNub.setPresenceState] + * for the current [userId] with every automatic heartbeat (if [heartbeatInterval] is greater than 0) + * and initial subscribe connection (also after e.g. loss of network). + * + * Defaults to `true`. + * + * Please note that `maintainPresenceState` doesn't apply to state that was set on channel groups. + * It is recommended to disable this option if you set state for channel groups using [PubNub.setPresenceState] + * otherwise that state may be overwritten by individual channel states. + */ + val maintainPresenceState: Boolean + + /** + * Feature to subscribe with a custom filter expression. + */ + val filterExpression: String + + /** + * Whether to include a [PubNubCore.instanceId] with every request. + * + * Defaults to `false`. + */ + val includeInstanceIdentifier: Boolean + + /** + * Whether to include a [PubNubCore.requestId] with every request. + * + * Defaults to `true`. + */ + val includeRequestIdentifier: Boolean + + /** + * @see [okhttp3.Dispatcher.setMaxRequestsPerHost] + */ + val maximumConnections: Int? + + /** + * Enable Google App Engine networking. + * + * Defaults to `false`. + */ + val googleAppEngineNetworking: Boolean + + /** + * Instructs the SDK to use a proxy configuration when communicating with PubNub servers. + * + * @see [Proxy] + */ + val proxy: Proxy? + + /** + * @see [ProxySelector] + */ + val proxySelector: ProxySelector? + + /** + * @see [Authenticator] + */ + val proxyAuthenticator: Authenticator? + + /** + * @see [CertificatePinner] + */ + val certificatePinner: CertificatePinner? + + /** + * Sets a custom [HttpLoggingInterceptor] for logging network traffic. + * + * @see [HttpLoggingInterceptor] + */ + val httpLoggingInterceptor: HttpLoggingInterceptor? + + /** + * @see [SSLSocketFactory] + */ + val sslSocketFactory: SSLSocketFactory? + + /** + * @see [X509ExtendedTrustManager] + */ + val x509ExtendedTrustManager: X509ExtendedTrustManager? + + /** + * @see [okhttp3.ConnectionSpec] + */ + val connectionSpec: ConnectionSpec? + + /** + * @see [javax.net.ssl.HostnameVerifier] + */ + val hostnameVerifier: HostnameVerifier? + + /** + * How many times publishing file message should automatically retry before marking the action as failed + * + * Defaults to `5` + */ + val fileMessagePublishRetryLimit: Int + + val dedupOnSubscribe: Boolean + val maximumMessagesCacheSize: Int + val pnsdkSuffixes: Map + + /** + * Retry configuration for requests. + * Defaults to [RetryConfiguration.None]. + * + * Use [RetryConfiguration.Linear] to set retry with linear delay interval + * Use [RetryConfiguration.Exponential] to set retry with exponential delay interval + * Delay will valy from provided value by random value. + */ + val retryConfiguration: RetryConfiguration + + /** + * Enables explicit presence control. + * When set to true heartbeat calls will contain only channels and groups added explicitly + * using [PubNubCore.presence]. Should be used only with ACL set on the server side. + * For more information please contact PubNub support + * @see PubNubCore.presence + * @see PNConfiguration.heartbeatInterval + */ + val managePresenceListManually: Boolean + + @Deprecated( + level = DeprecationLevel.WARNING, + message = """Use UserId instead e.g. config.userId.value""", + replaceWith = ReplaceWith("userId.value"), + ) + val uuid: String + get() = userId.value + companion object { + fun String.isValid() = isNotBlank() + @JvmStatic fun builder( userId: UserId, @@ -26,63 +295,282 @@ actual interface PNConfiguration : BasePNConfiguration { ): Builder { return ( Class.forName("com.pubnub.internal.v2.PNConfigurationImpl\$Builder") - .getConstructor(BasePNConfiguration::class.java) - .newInstance(object : BasePNConfigurationImpl(userId) { - override val subscribeKey: String = subscribeKey - }) as Builder + .getConstructor(UserId::class.java, subscribeKey::class.java) + .newInstance(userId, subscribeKey) as Builder ).apply(action) } + + @JvmStatic + fun builder(initialConfiguration: PNConfiguration): Builder { + return Class.forName("com.pubnub.internal.v2.PNConfigurationImpl\$Builder") + .getConstructor(PNConfiguration::class.java) + .newInstance(initialConfiguration) as Builder + } } - interface Builder : BasePNConfiguration.Builder { - override var userId: UserId - override var subscribeKey: String - override var publishKey: String - override var secretKey: String - override var authKey: String - override var cryptoModule: CryptoModule? - override var origin: String - override var secure: Boolean - override var logVerbosity: PNLogVerbosity - override var heartbeatNotificationOptions: PNHeartbeatNotificationOptions - override var presenceTimeout: Int - override var heartbeatInterval: Int - override var subscribeTimeout: Int - override var connectTimeout: Int + interface Builder { + /** + * The user ID that the PubNub client will use. + */ + var userId: UserId + /** + * The subscribe key from the admin panel. + */ + var subscribeKey: String + + /** + * The publish key from the admin panel (only required if publishing). + */ + var publishKey: String + + /** + * The secret key from the admin panel (only required for modifying/revealing access permissions). + * + * Keep away from Android. + */ + var secretKey: String + + /** + * If Access Manager is utilized, client will use this authKey in all restricted requests. + */ + var authKey: String + + /** + * CryptoModule is responsible for handling encryption and decryption. + * If set, all communications to and from PubNub will be encrypted. + */ + var cryptoModule: CryptoModule? + + /** + * Custom origin if needed. + * + * Defaults to `ps.pndsn.com` + */ + var origin: String + + /** + * If set to `true`, requests will be made over HTTPS. + * + * Deafults to `true`. + */ + var secure: Boolean + + /** + * Set to [PNLogVerbosity.BODY] to enable logging of network traffic, otherwise se to [PNLogVerbosity.NONE]. + */ + var logVerbosity: PNLogVerbosity + + /** + * Set Heartbeat notification options. + * + * By default, the SDK alerts on failed heartbeats (equivalent to [PNHeartbeatNotificationOptions.FAILURES]). + */ + var heartbeatNotificationOptions: PNHeartbeatNotificationOptions + + /** + * Sets the custom presence server timeout. + * + * The value is in seconds, and the minimum value is 20 seconds. + * + * Also sets the value of [heartbeatInterval] + */ + var presenceTimeout: Int + + /** + * How often the client will announce itself to server. + * + * The value is in seconds. + */ + var heartbeatInterval: Int + + /** + * The subscribe request timeout. + * + * The value is in seconds. + * + * Defaults to 310. + */ + var subscribeTimeout: Int + + /** + * How long before the client gives up trying to connect with the server. + * + * The value is in seconds. + * + * Defaults to 5. + */ + var connectTimeout: Int + + /** + * For non subscribe operations (publish, herenow, etc), + * This property relates to a read timeout that is applied from the moment the connection between a client + * and the server has been successfully established. It defines a maximum time of inactivity between two + * data packets when waiting for the server’s response. + * + * The value is in seconds. + * + * Defaults to 10. + */ @Deprecated( "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", replaceWith = ReplaceWith("nonSubscribeReadTimeout") ) - override var nonSubscribeRequestTimeout: Int + var nonSubscribeRequestTimeout: Int get() = nonSubscribeReadTimeout set(value) { nonSubscribeReadTimeout = value } - override var nonSubscribeReadTimeout: Int - override var cacheBusting: Boolean - override var suppressLeaveEvents: Boolean - override var maintainPresenceState: Boolean - override var filterExpression: String - override var includeInstanceIdentifier: Boolean - override var includeRequestIdentifier: Boolean - override var maximumConnections: Int? - override var googleAppEngineNetworking: Boolean - override var proxy: Proxy? - override var proxySelector: ProxySelector? - override var proxyAuthenticator: Authenticator? - override var certificatePinner: CertificatePinner? - override var httpLoggingInterceptor: HttpLoggingInterceptor? - override var sslSocketFactory: SSLSocketFactory? - override var x509ExtendedTrustManager: X509ExtendedTrustManager? - override var connectionSpec: ConnectionSpec? - override var hostnameVerifier: HostnameVerifier? - override var fileMessagePublishRetryLimit: Int - override var dedupOnSubscribe: Boolean - override var maximumMessagesCacheSize: Int - override var pnsdkSuffixes: Map - override var retryConfiguration: RetryConfiguration - override var managePresenceListManually: Boolean + + /** + * For non subscribe operations (publish, herenow, etc), + * This property relates to a read timeout that is applied from the moment the connection between a client + * and the server has been successfully established. It defines a maximum time of inactivity between two + * data packets when waiting for the server’s response. + * + * The value is in seconds. + * + * Defaults to 10. + */ + var nonSubscribeReadTimeout: Int + + /** + * If operating behind a misbehaving proxy, allow the client to shuffle the subdomains. + * + * Defaults to `false`. + */ + var cacheBusting: Boolean + + /** + * When `true` the SDK doesn't send out the leave requests. + * + * Defaults to `false`. + */ + var suppressLeaveEvents: Boolean + + /** + * When `true` the SDK will resend the last channel state that was set using [PubNub.setPresenceState] + * for the current [userId] with every automatic heartbeat (if [heartbeatInterval] is greater than 0) + * and initial subscribe connection (also after e.g. loss of network). + * + * Defaults to `true`. + * + * Please note that `maintainPresenceState` doesn't apply to state that was set on channel groups. + * It is recommended to disable this option if you set state for channel groups using [PubNub.setPresenceState] + * otherwise that state may be overwritten by individual channel states. + */ + var maintainPresenceState: Boolean + + /** + * Feature to subscribe with a custom filter expression. + */ + var filterExpression: String + + /** + * Whether to include a [PubNubCore.instanceId] with every request. + * + * Defaults to `false`. + */ + var includeInstanceIdentifier: Boolean + + /** + * Whether to include a [PubNubCore.requestId] with every request. + * + * Defaults to `true`. + */ + var includeRequestIdentifier: Boolean + + /** + * @see [okhttp3.Dispatcher.setMaxRequestsPerHost] + */ + var maximumConnections: Int? + + /** + * Enable Google App Engine networking. + * + * Defaults to `false`. + */ + var googleAppEngineNetworking: Boolean + + /** + * Instructs the SDK to use a proxy configuration when communicating with PubNub servers. + * + * @see [Proxy] + */ + var proxy: Proxy? + + /** + * @see [ProxySelector] + */ + var proxySelector: ProxySelector? + + /** + * @see [Authenticator] + */ + var proxyAuthenticator: Authenticator? + + /** + * @see [CertificatePinner] + */ + var certificatePinner: CertificatePinner? + + /** + * Sets a custom [HttpLoggingInterceptor] for logging network traffic. + * + * @see [HttpLoggingInterceptor] + */ + var httpLoggingInterceptor: HttpLoggingInterceptor? + + /** + * @see [SSLSocketFactory] + */ + var sslSocketFactory: SSLSocketFactory? + + /** + * @see [X509ExtendedTrustManager] + */ + var x509ExtendedTrustManager: X509ExtendedTrustManager? + + /** + * @see [okhttp3.ConnectionSpec] + */ + var connectionSpec: ConnectionSpec? + + /** + * @see [javax.net.ssl.HostnameVerifier] + */ + var hostnameVerifier: HostnameVerifier? + + /** + * How many times publishing file message should automatically retry before marking the action as failed + * + * Defaults to `5` + */ + var fileMessagePublishRetryLimit: Int + + var dedupOnSubscribe: Boolean + var maximumMessagesCacheSize: Int + var pnsdkSuffixes: Map + + /** + * Retry configuration for requests. + * Defaults to [RetryConfiguration.None]. + * + * Use [RetryConfiguration.Linear] to set retry with linear delay intervar + * Use [RetryConfiguration.Exponential] to set retry with exponential delay interval + * Delay will vary from provided value by random value. + */ + var retryConfiguration: RetryConfiguration + + /** + * Enables explicit presence control. + * When set to true heartbeat calls will contain only channels and groups added explicitly + * using [PubNubCore.presence]. Should be used only with ACL set on the server side. + * For more information please contact PubNub support + * @see PubNubCore.presence + * @see PNConfiguration.heartbeatInterval + */ + var managePresenceListManually: Boolean /** * Create a [PNConfiguration] object with values from this builder. @@ -91,28 +579,94 @@ actual interface PNConfiguration : BasePNConfiguration { } } -interface PNConfigurationOverride : BasePNConfigurationOverride { +interface PNConfigurationOverride { companion object { @JvmStatic - fun from(configuration: BasePNConfiguration): Builder { + fun from(configuration: PNConfiguration): Builder { return Class.forName("com.pubnub.internal.v2.PNConfigurationImpl\$Builder") - .getConstructor(BasePNConfiguration::class.java) + .getConstructor(PNConfiguration::class.java) .newInstance(configuration) as Builder } } - interface Builder : BasePNConfigurationOverride.Builder { - override var subscribeKey: String - override var publishKey: String - override var secretKey: String - override var retryConfiguration: RetryConfiguration - override var userId: UserId - override var includeInstanceIdentifier: Boolean - override var includeRequestIdentifier: Boolean - override var authKey: String - override var cryptoModule: CryptoModule? - override var connectTimeout: Int - override var nonSubscribeReadTimeout: Int + interface Builder { + /** + * The subscribe key from the admin panel. + */ + var subscribeKey: String + + /** + * The publish key from the admin panel (only required if publishing). + */ + var publishKey: String + + /** + * The secret key from the admin panel (only required for modifying/revealing access permissions). + * + * Keep away from Android. + */ + var secretKey: String + + /** + * Retry configuration for requests. + * Defaults to [RetryConfiguration.None]. + * + * Use [RetryConfiguration.Linear] to set retry with linear delay interval + * Use [RetryConfiguration.Exponential] to set retry with exponential delay interval + * Delay will valy from provided value by random value. + */ + var retryConfiguration: RetryConfiguration + + /** + * The user ID that the PubNub client will use. + */ + var userId: UserId + + /** + * Whether to include a [PubNub.instanceId] with every request. + * + * Defaults to `false`. + */ + var includeInstanceIdentifier: Boolean + + /** + * Whether to include a [PubNub.requestId] with every request. + * + * Defaults to `true`. + */ + var includeRequestIdentifier: Boolean + + /** + * If Access Manager is utilized, client will use this authKey in all restricted requests. + */ + var authKey: String + + /** + * CryptoModule is responsible for handling encryption and decryption. + * If set, all communications to and from PubNub will be encrypted. + */ + var cryptoModule: CryptoModule? + + /** + * How long before the client gives up trying to connect with the server. + * + * The value is in seconds. + * + * Defaults to 5. + */ + var connectTimeout: Int + + /** + * For non subscribe operations (publish, herenow, etc), + * This property relates to a read timeout that is applied from the moment the connection between a client + * and the server has been successfully established. It defines a maximum time of inactivity between two + * data packets when waiting for the server’s response. + * + * The value is in seconds. + * + * Defaults to 10. + */ + var nonSubscribeReadTimeout: Int /** * Create a [PNConfiguration] object with values from this builder. diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/Consumer.jvm.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt index edcf25483..5edbe644a 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/EventListener.kt @@ -13,7 +13,7 @@ import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult * Implement this interface and pass it into [EventEmitter.addListener] to listen for events from the PubNub real-time * network. */ -actual interface EventListener : BaseEventListener, Listener { +actual interface EventListener : Listener { /** * Receive messages at subscribed channels. * diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusEmitter.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusEmitter.kt index b3f0e34fa..9282e4f5f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusEmitter.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusEmitter.kt @@ -1,7 +1,28 @@ package com.pubnub.api.v2.callbacks +import com.pubnub.api.callbacks.Listener + /** * Interface implemented by objects that manage the subscription connection to the PubNub network and can be monitored * for connection state changes. */ -interface StatusEmitter : BaseStatusEmitter +interface StatusEmitter { + /** + * Add a listener. + * + * @param listener The listener to be added. + */ + fun addListener(listener: StatusListener) + + /** + * Remove a listener. + * + * @param listener The listener to be removed, previously added with [addListener]. + */ + fun removeListener(listener: Listener) + + /** + * Removes all listeners. + */ + fun removeAllListeners() +} diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt index 519f561f0..86c84e3ee 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/api/v2/callbacks/StatusListener.kt @@ -8,7 +8,7 @@ import com.pubnub.api.models.consumer.PNStatus * Implement this interface and pass it into [com.pubnub.api.v2.callbacks.StatusEmitter.addListener] to listen for * PubNub connection status changes. */ -actual interface StatusListener : BaseStatusListener, Listener { +actual interface StatusListener : Listener { /** * Receive status updates from the PubNub client, such as: * * [PNStatusCategory.PNConnectedCategory], @@ -16,7 +16,6 @@ actual interface StatusListener : BaseStatusListener, Listener { * * [PNStatusCategory.PNSubscriptionChanged] * * [PNStatusCategory.PNConnectionError], * * [PNStatusCategory.PNUnexpectedDisconnectCategory], - * * [PNStatusCategory.PNAcknowledgmentCategory] * * @see [PNStatus] * diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/internal/endpoints/HasOverridableConfig.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/internal/endpoints/HasOverridableConfig.kt new file mode 100644 index 000000000..d9967da67 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/internal/endpoints/HasOverridableConfig.kt @@ -0,0 +1,9 @@ +package com.pubnub.internal.endpoints + +import com.pubnub.api.v2.PNConfiguration + +interface HasOverridableConfig { + fun overrideConfigurationInternal(configuration: PNConfiguration) + + val configuration: PNConfiguration +} diff --git a/pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt similarity index 100% rename from pubnub-core/pubnub-core-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt rename to pubnub-kotlin/pubnub-kotlin-api/src/jvmMain/kotlin/com/pubnub/kmp/Downloadable.jvm.kt diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt index f6e54ec7b..587bfeb9f 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt @@ -84,16 +84,6 @@ actual interface PubNub { actual fun removeAllListeners() - actual fun publish( - channel: String, - message: Any, - meta: Any?, - shouldStore: Boolean, - usePost: Boolean, - replicate: Boolean, - ttl: Int? - ): Publish - actual fun fire( channel: String, message: Any, @@ -440,4 +430,14 @@ actual interface PubNub { ): SubscriptionSet actual fun parseToken(token: String): PNToken + + actual fun publish( + channel: String, + message: Any, + meta: Any?, + shouldStore: Boolean?, + usePost: Boolean, + replicate: Boolean, + ttl: Int?, + ): Publish } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-impl/build.gradle.kts index 17a77976a..f784165af 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-impl/build.gradle.kts @@ -1,14 +1,27 @@ +import com.pubnub.gradle.tasks.GenerateVersionTask + plugins { alias(libs.plugins.benmanes.versions) + id("pubnub.java-library") id("pubnub.kotlin-library") id("pubnub.test") id("pubnub.integration-test") } +val generateVersion = + tasks.register("generateVersion") { + version.set(providers.gradleProperty("VERSION_NAME")) + outputDirectory.set( + layout.buildDirectory.map { + it.dir("generated/sources/generateVersion") + }, + ) + } + +kotlin.sourceSets.getByName("main").kotlin.srcDir(generateVersion) + dependencies { - api(project(":pubnub-core:pubnub-core-api")) api(project(":pubnub-kotlin:pubnub-kotlin-api")) - implementation(project(":pubnub-core:pubnub-core-impl")) implementation(libs.slf4j) testImplementation(libs.wiremock) @@ -24,4 +37,38 @@ dependencies { testImplementation(libs.junit.jupiter.engine) testImplementation(libs.mockk) testImplementation(libs.owner) + implementation(libs.retrofit2) + implementation(libs.retrofit2.converter.gson) + implementation(libs.okhttp) + implementation(libs.okhttp.logging) + + implementation(libs.json) + implementation(libs.gson) + + implementation(libs.slf4j) + implementation(libs.cbor) + + testImplementation(libs.wiremock) + testImplementation(libs.logback.classic) + testImplementation(libs.logback.core) + testImplementation(libs.cucumber.java) + testImplementation(libs.cucumber.junit) + testImplementation(libs.cucumber.picocontainer) + testImplementation(libs.awaitility) + testImplementation(libs.junit4) + testImplementation(libs.junit.jupiter.engine) + testImplementation(libs.junit.vintage.engine) + testImplementation(libs.junit.jupiter) + testImplementation(libs.mockk) + testImplementation(libs.owner) +} + +task("cucumber") { + filter { + // include all tests from package + includeTestsMatching("com.pubnub.contract.*") + } + systemProperty("cucumber.filter.tags", System.getProperty("cucumber.filter.tags")) + systemProperty("cucumber.features", System.getProperty("cucumber.features")) + systemProperty("cucumber.plugins", System.getProperty("cucumber.plugins")) } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/config/ktlint/baseline.xml b/pubnub-kotlin/pubnub-kotlin-impl/config/ktlint/baseline.xml index 981420778..0490138f9 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/config/ktlint/baseline.xml +++ b/pubnub-kotlin/pubnub-kotlin-impl/config/ktlint/baseline.xml @@ -1,3 +1,160 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/AppTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/AppTest.kt index fe3ea5b78..60c92a24c 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/AppTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/AppTest.kt @@ -1,9 +1,9 @@ package com.pubnub.api.integration -import com.pubnub.api.PNConfiguration import com.pubnub.api.PubNub import com.pubnub.api.UserId import com.pubnub.api.enums.PNLogVerbosity +import com.pubnub.api.v2.PNConfiguration import com.pubnub.test.Keys import com.pubnub.test.listen import org.awaitility.Awaitility @@ -22,11 +22,10 @@ class AppTest { fun initPubnub() { pubnub = PubNub.create( - PNConfiguration(userId = UserId(PubNub.generateUUID())).apply { - subscribeKey = Keys.subKey + PNConfiguration.builder(userId = UserId(PubNub.generateUUID()), subscribeKey = Keys.subKey) { publishKey = Keys.pubKey logVerbosity = PNLogVerbosity.BODY - }, + }.build(), ) } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/test/SignatureUtils.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/test/SignatureUtils.kt index 24da57178..9545c0ffc 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/test/SignatureUtils.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/test/SignatureUtils.kt @@ -1,7 +1,7 @@ package com.pubnub.test import com.github.tomakehurst.wiremock.verification.LoggedRequest -import com.pubnub.api.PNConfiguration +import com.pubnub.api.v2.PNConfiguration import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import okhttp3.Request import okio.Buffer diff --git a/pubnub-core/pubnub-core-impl/src/main/java/com/pubnub/internal/vendor/AppEngineFactory.java b/pubnub-kotlin/pubnub-kotlin-impl/src/main/java/com/pubnub/internal/vendor/AppEngineFactory.java similarity index 91% rename from pubnub-core/pubnub-core-impl/src/main/java/com/pubnub/internal/vendor/AppEngineFactory.java rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/java/com/pubnub/internal/vendor/AppEngineFactory.java index 66f122f1b..60d71294e 100644 --- a/pubnub-core/pubnub-core-impl/src/main/java/com/pubnub/internal/vendor/AppEngineFactory.java +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/java/com/pubnub/internal/vendor/AppEngineFactory.java @@ -1,7 +1,7 @@ package com.pubnub.internal.vendor; -import com.pubnub.api.v2.BasePNConfiguration; -import com.pubnub.internal.PubNubCore; +import com.pubnub.api.v2.PNConfiguration; +import com.pubnub.internal.PubNubImpl; import com.pubnub.internal.PubNubUtil; import okhttp3.Call; import okhttp3.Callback; @@ -23,9 +23,9 @@ public class AppEngineFactory implements Call { private Request request; - private final BasePNConfiguration configuration; + private final PNConfiguration configuration; - AppEngineFactory(Request request, BasePNConfiguration configuration) { + AppEngineFactory(Request request, PNConfiguration configuration) { this.request = request; this.configuration = configuration; } @@ -39,7 +39,7 @@ public Request request() { @NotNull @Override public Response execute() throws IOException { - request = PubNubUtil.INSTANCE.signRequest(request, configuration, PubNubCore.timestamp()); + request = PubNubUtil.INSTANCE.signRequest(request, configuration, PubNubImpl.timestamp()); URL url = request.url().url(); final HttpURLConnection connection = (HttpURLConnection) url.openConnection(); @@ -137,9 +137,9 @@ public Call clone() { } public static class Factory implements Call.Factory { - private final BasePNConfiguration configuration; + private final PNConfiguration configuration; - public Factory(BasePNConfiguration configuration) { + public Factory(PNConfiguration configuration) { this.configuration = configuration; } diff --git a/pubnub-core/pubnub-core-impl/src/main/java/com/pubnub/internal/vendor/Base64.java b/pubnub-kotlin/pubnub-kotlin-impl/src/main/java/com/pubnub/internal/vendor/Base64.java similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/java/com/pubnub/internal/vendor/Base64.java rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/java/com/pubnub/internal/vendor/Base64.java diff --git a/pubnub-core/pubnub-core-impl/src/main/java/com/pubnub/internal/vendor/Crypto.java b/pubnub-kotlin/pubnub-kotlin-impl/src/main/java/com/pubnub/internal/vendor/Crypto.java similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/java/com/pubnub/internal/vendor/Crypto.java rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/java/com/pubnub/internal/vendor/Crypto.java diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/DelegatingEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/DelegatingEndpoint.kt deleted file mode 100644 index 36eabd8a5..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/DelegatingEndpoint.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.pubnub.internal - -import com.pubnub.api.PubNubException -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.enums.PNOperationType -import com.pubnub.api.v2.callbacks.Result -import java.util.function.Consumer - -abstract class DelegatingEndpoint(originalRemoteAction: EndpointInterface) : - EndpointImpl(originalRemoteAction) { - private val remoteAction: ExtendedRemoteAction = convertAction(originalRemoteAction) - - protected abstract fun convertAction(remoteAction: ExtendedRemoteAction): ExtendedRemoteAction - - @Throws(PubNubException::class) - override fun sync(): OUTPUT { - return remoteAction.sync() - } - - override fun async(callback: Consumer>) { - remoteAction.async(callback) - } - - override fun retry() { - remoteAction.retry() - } - - override fun silentCancel() { - remoteAction.silentCancel() - } - - override fun operationType(): PNOperationType { - return remoteAction.operationType() - } -} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt new file mode 100644 index 000000000..cf4e9141d --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/EndpointCore.kt @@ -0,0 +1,458 @@ +package com.pubnub.internal + +import com.google.gson.JsonElement +import com.pubnub.api.Endpoint +import com.pubnub.api.PubNubError +import com.pubnub.api.PubNubException +import com.pubnub.api.retry.RetryableEndpointGroup +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.PNConfiguration.Companion.isValid +import com.pubnub.api.v2.PNConfigurationOverride +import com.pubnub.api.v2.callbacks.Consumer +import com.pubnub.api.v2.callbacks.Result +import com.pubnub.internal.managers.RetrofitManager +import com.pubnub.internal.retry.RetryableBase +import com.pubnub.internal.retry.RetryableCallback +import com.pubnub.internal.retry.RetryableRestCaller +import com.pubnub.internal.v2.PNConfigurationImpl +import org.slf4j.LoggerFactory +import retrofit2.Call +import retrofit2.Response +import java.io.IOException +import java.net.ConnectException +import java.net.SocketTimeoutException +import java.net.UnknownHostException + +/** + * Base class for all PubNub API operation implementations. + * + * @param Input Server's response. + * @param Output Parsed and encapsulated response for endusers. + * @property pubnub The client instance. + */ +abstract class EndpointCore protected constructor(protected val pubnub: PubNubImpl) : Endpoint { + private var configOverride: PNConfiguration? = null + val configuration: PNConfiguration + get() = configOverride ?: pubnub.configuration + + protected val retrofitManager: RetrofitManager + get() = configOverride?.let { configOverrideNonNull -> + RetrofitManager(pubnub.retrofitManager, configOverrideNonNull) + } ?: pubnub.retrofitManager + + private val log = LoggerFactory.getLogger(this.javaClass.simpleName) + + private lateinit var cachedCallback: Consumer> + private lateinit var call: Call + private var silenceFailures = false + private val retryableRestCaller by lazy { + RetryableRestCaller( + configuration.retryConfiguration, + getEndpointGroupName(), + isEndpointRetryable(), + ) + } + + override fun overrideConfiguration(action: PNConfigurationOverride.Builder.() -> Unit): Endpoint { + overrideConfigurationInternal(PNConfigurationImpl.Builder(configuration).apply(action).build()) + return this + } + + override fun overrideConfiguration(configuration: PNConfiguration): Endpoint { + overrideConfigurationInternal(configuration) + return this + } + + /** + * Key-value object to pass with every PubNub API operation. Used for debugging purposes. + * todo: it should be removed! + */ + val queryParam: MutableMap = mutableMapOf() + + /** + * Executes the call synchronously. This function blocks the thread. + * + * @return A parsed and encapsulated response if the request has been successful, `null` otherwise. + * + * @throws [PubNubException] if anything goes wrong with the request. + */ + override fun sync(): Output { + validateParams() + call = doWork(createBaseParams()) + val response = retryableRestCaller.execute(call) + return handleResponse(response) + } + + private fun handleResponse(response: Response): Output { + when { + response.isSuccessful -> { + return checkAndCreateResponse(response) + } + + else -> { + val (errorString, errorJson) = extractErrorBody(response) + throw createException(response, errorString, errorJson) + } + } + } + + /** + * Executes the call asynchronously. This function does not block the thread. + * + * @param callback The callback to receive the response in. + */ + override fun async(callback: Consumer>) { + cachedCallback = callback + + try { + validateParams() + call = doWork(createBaseParams()) + } catch (pubnubException: PubNubException) { + callback.accept(Result.failure(pubnubException)) + return + } + + call.enqueue( + object : RetryableCallback( + call = call, + retryConfiguration = configuration.retryConfiguration, + endpointGroupName = getEndpointGroupName(), + isEndpointRetryable = isEndpointRetryable(), + executorService = pubnub.executorService, + ) { + override fun onFinalResponse( + call: Call, + response: Response, + ) { + when { + response.isSuccessful -> { + // query params + try { + Result.success(checkAndCreateResponse(response)) + } catch (e: PubNubException) { + Result.failure(e) + }.let { result -> + callback.accept(result) + } + } + + else -> { + val (errorString, errorJson) = extractErrorBody(response) + + callback.accept( + Result.failure( + createException( + response, + errorString, + errorJson, + ), + ), + ) + } + } + } + + override fun onFinalFailure( + call: Call, + t: Throwable, + ) { + if (silenceFailures) { + return + } + + val error: PubNubError = + when (t) { + is UnknownHostException, is ConnectException -> { + PubNubError.CONNECT_EXCEPTION + } + + is SocketTimeoutException -> { + PubNubError.SUBSCRIBE_TIMEOUT + } + + is IOException -> { + PubNubError.PARSING_ERROR + } + + is IllegalStateException -> { + PubNubError.PARSING_ERROR + } + + else -> { + PubNubError.HTTP_ERROR + } + } + + val pubnubException = + PubNubException( + errorMessage = t.toString(), + pubnubError = error, + cause = t, + remoteAction = this@EndpointCore, + ) + callback.accept(Result.failure(pubnubException)) + } + }, + ) + } + + protected fun createBaseParams(): HashMap { + val map = hashMapOf() + + map += queryParam + + map["pnsdk"] = pubnub.generatePnsdk() + map["uuid"] = configuration.userId.value + + if (configuration.includeInstanceIdentifier) { + map["instanceid"] = pubnub.instanceId + } + + if (configuration.includeRequestIdentifier) { + map["requestid"] = pubnub.requestId() + } + + if (isAuthRequired()) { + val token = pubnub.tokenManager.getToken() + if (token != null) { + map["auth"] = token + } else if (configuration.authKey.isValid()) { + map["auth"] = configuration.authKey + } + } + return map + } + + /** + * Cancel the operation but do not alert anybody, useful for restarting the heartbeats and subscribe loops. + */ + override fun silentCancel() { + if (::call.isInitialized) { + if (!call.isCanceled) { + silenceFailures = true + call.cancel() + } + } + } + + private fun createException( + response: Response, + errorString: String? = null, + errorBody: JsonElement? = null, + ): PubNubException { + val errorChannels = mutableListOf() + val errorGroups = mutableListOf() + + if (errorBody != null) { + if (pubnub.mapper.isJsonObject(errorBody) && + pubnub.mapper.hasField( + errorBody, + "payload", + ) + ) { + val payloadBody = pubnub.mapper.getField(errorBody, "payload")!! + + if (pubnub.mapper.hasField(payloadBody, "channels")) { + val iterator = pubnub.mapper.getArrayIterator(payloadBody, "channels") + while (iterator.hasNext()) { + errorChannels.add(pubnub.mapper.elementToString(iterator.next())!!) + } + } + + if (pubnub.mapper.hasField(payloadBody, "channel-groups")) { + val iterator = pubnub.mapper.getArrayIterator(payloadBody, "channel-groups") + while (iterator.hasNext()) { + val node = iterator.next() + + val channelGroupName = + pubnub.mapper.elementToString(node)!!.let { + if (it.first().toString() == ":") { + it.substring(1) + } else { + it + } + } + + errorGroups.add(channelGroupName) + } + } + } + } + + val affectedChannels = + errorChannels.ifEmpty { + try { + getAffectedChannels() + } catch (e: UninitializedPropertyAccessException) { + emptyList() + } + } + + val affectedChannelGroups = + errorGroups.ifEmpty { + try { + getAffectedChannelGroups() + } catch (e: UninitializedPropertyAccessException) { + emptyList() + } + } + + return PubNubException( + pubnubError = PubNubError.HTTP_ERROR, + errorMessage = errorString, + jso = errorBody?.toString(), + statusCode = response.code(), + affectedCall = call, + retryAfterHeaderValue = response.headers()[RetryableBase.RETRY_AFTER_HEADER_NAME]?.toIntOrNull(), + affectedChannels = affectedChannels, + affectedChannelGroups = affectedChannelGroups, + requestInfo = + PubNubException.RequestInfo( + tlsEnabled = response.raw().request.url.isHttps, + origin = response.raw().request.url.host, + uuid = response.raw().request.url.queryParameter("uuid"), + authKey = response.raw().request.url.queryParameter("auth"), + clientRequest = response.raw().request, + ), + remoteAction = this, + ) + } + + override fun retry() { + silenceFailures = false + async(cachedCallback) + } + + private fun extractErrorBody(response: Response): Pair { + val errorBodyString = + try { + response.errorBody()?.string() + } catch (e: IOException) { + "N/A" + } + + val errorBodyJson = + try { + pubnub.mapper.fromJson(errorBodyString, JsonElement::class.java) + } catch (e: PubNubException) { + null + } + + return errorBodyString to errorBodyJson + } + + private fun checkAndCreateResponse(input: Response): Output { + try { + return createResponse(input) + } catch (pubnubException: PubNubException) { + throw pubnubException.copy( + statusCode = input.code(), + jso = pubnub.mapper.toJson(input.body()), + affectedCall = call, + ) + } catch (e: KotlinNullPointerException) { + throw PubNubException( + pubnubError = PubNubError.PARSING_ERROR, + errorMessage = e.toString(), + affectedCall = call, + statusCode = input.code(), + jso = pubnub.mapper.toJson(input.body()), + cause = e, + ) + } catch (e: IllegalStateException) { + throw PubNubException( + pubnubError = PubNubError.PARSING_ERROR, + errorMessage = e.toString(), + affectedCall = call, + statusCode = input.code(), + jso = pubnub.mapper.toJson(input.body()), + cause = e, + ) + } catch (e: IndexOutOfBoundsException) { + throw PubNubException( + pubnubError = PubNubError.PARSING_ERROR, + errorMessage = e.toString(), + affectedCall = call, + statusCode = input.code(), + jso = pubnub.mapper.toJson(input.body()), + cause = e, + ) + } catch (e: NullPointerException) { + throw PubNubException( + pubnubError = PubNubError.PARSING_ERROR, + errorMessage = e.toString(), + affectedCall = call, + statusCode = input.code(), + jso = pubnub.mapper.toJson(input.body()), + cause = e, + ) + } catch (e: IllegalArgumentException) { + throw PubNubException( + pubnubError = PubNubError.PARSING_ERROR, + errorMessage = e.toString(), + affectedCall = call, + statusCode = input.code(), + jso = pubnub.mapper.toJson(input.body()), + cause = e, + ) + } catch (e: TypeCastException) { + throw PubNubException( + pubnubError = PubNubError.PARSING_ERROR, + errorMessage = e.toString(), + affectedCall = call, + statusCode = input.code(), + jso = pubnub.mapper.toJson(input.body()), + cause = e, + ) + } catch (e: ClassCastException) { + throw PubNubException( + pubnubError = PubNubError.PARSING_ERROR, + errorMessage = e.toString(), + affectedCall = call, + statusCode = input.code(), + jso = pubnub.mapper.toJson(input.body()), + cause = e, + ) + } catch (e: UninitializedPropertyAccessException) { + throw PubNubException( + pubnubError = PubNubError.PARSING_ERROR, + errorMessage = e.toString(), + affectedCall = call, + statusCode = input.code(), + jso = pubnub.mapper.toJson(input.body()), + cause = e, + ) + } + } + + protected open fun getAffectedChannels() = emptyList() + + protected open fun getAffectedChannelGroups(): List = emptyList() + + protected open fun validateParams() { + if (isSubKeyRequired() && !configuration.subscribeKey.isValid()) { + throw PubNubException(PubNubError.SUBSCRIBE_KEY_MISSING) + } + if (isPubKeyRequired() && !configuration.publishKey.isValid()) { + throw PubNubException(PubNubError.PUBLISH_KEY_MISSING) + } + } + + fun overrideConfigurationInternal(configuration: PNConfiguration) { + this.configOverride = configuration + } + + protected abstract fun doWork(queryParams: HashMap): Call + + protected abstract fun createResponse(input: Response): Output + + protected open fun isSubKeyRequired() = true + + protected open fun isPubKeyRequired() = false + + protected open fun isAuthRequired() = true + + protected abstract fun getEndpointGroupName(): RetryableEndpointGroup + + protected open fun isEndpointRetryable(): Boolean = true +} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/EndpointImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/EndpointImpl.kt deleted file mode 100644 index 45b3c6998..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/EndpointImpl.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.pubnub.internal - -import com.pubnub.api.Endpoint -import com.pubnub.api.endpoints.HasOverridableConfig -import com.pubnub.api.v2.PNConfiguration -import com.pubnub.api.v2.PNConfigurationOverride -import com.pubnub.internal.v2.PNConfigurationImpl - -abstract class EndpointImpl(private val endpoint: HasOverridableConfig) : Endpoint { - override fun overrideConfiguration(action: PNConfigurationOverride.Builder.() -> Unit): Endpoint { - endpoint.overrideConfiguration(PNConfigurationImpl.Builder(endpoint.configuration).apply(action).build()) - return this - } - - override fun overrideConfiguration(configuration: PNConfiguration): Endpoint { - endpoint.overrideConfiguration(configuration) - return this - } -} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt index 9203fbad7..fa27874be 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubImpl.kt @@ -1,6 +1,5 @@ package com.pubnub.internal -import com.pubnub.api.PNConfiguration import com.pubnub.api.PubNub import com.pubnub.api.PubNubException import com.pubnub.api.UserId @@ -56,8 +55,11 @@ import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions +import com.pubnub.api.models.consumer.access_manager.sum.toChannelGrant +import com.pubnub.api.models.consumer.access_manager.sum.toUuidGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNToken import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.api.models.consumer.objects.PNKey @@ -75,33 +77,82 @@ import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.api.v2.entities.BaseChannel -import com.pubnub.api.v2.entities.BaseChannelGroup -import com.pubnub.api.v2.entities.BaseChannelMetadata -import com.pubnub.api.v2.entities.BaseUserMetadata -import com.pubnub.api.v2.entities.Channel import com.pubnub.api.v2.entities.ChannelGroup import com.pubnub.api.v2.entities.ChannelMetadata import com.pubnub.api.v2.entities.UserMetadata -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.BaseSubscriptionSet +import com.pubnub.api.v2.subscriptions.EmptyOptions import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionCursor import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet -import com.pubnub.internal.models.toInternal -import com.pubnub.internal.models.toInternalChannelGrants -import com.pubnub.internal.models.toInternalChannelGroupGrants -import com.pubnub.internal.models.toInternalChannelMemberships -import com.pubnub.internal.models.toInternalMemberInputs -import com.pubnub.internal.models.toInternalSortKeys -import com.pubnub.internal.models.toInternalSpacePermissions -import com.pubnub.internal.models.toInternalUserPermissions -import com.pubnub.internal.models.toInternalUuidGrants -import com.pubnub.internal.v2.callbacks.DelegatingEventListener -import com.pubnub.internal.v2.callbacks.DelegatingStatusListener -import com.pubnub.internal.v2.callbacks.DelegatingSubscribeCallback +import com.pubnub.internal.crypto.decryptString +import com.pubnub.internal.crypto.encryptString +import com.pubnub.internal.endpoints.DeleteMessagesEndpoint +import com.pubnub.internal.endpoints.FetchMessagesEndpoint +import com.pubnub.internal.endpoints.HistoryEndpoint +import com.pubnub.internal.endpoints.MessageCountsEndpoint +import com.pubnub.internal.endpoints.TimeEndpoint +import com.pubnub.internal.endpoints.access.GrantEndpoint +import com.pubnub.internal.endpoints.access.GrantTokenEndpoint +import com.pubnub.internal.endpoints.access.RevokeTokenEndpoint +import com.pubnub.internal.endpoints.channel_groups.AddChannelChannelGroupEndpoint +import com.pubnub.internal.endpoints.channel_groups.AllChannelsChannelGroupEndpoint +import com.pubnub.internal.endpoints.channel_groups.DeleteChannelGroupEndpoint +import com.pubnub.internal.endpoints.channel_groups.ListAllChannelGroupEndpoint +import com.pubnub.internal.endpoints.channel_groups.RemoveChannelChannelGroupEndpoint +import com.pubnub.internal.endpoints.files.DeleteFileEndpoint +import com.pubnub.internal.endpoints.files.DownloadFileEndpoint +import com.pubnub.internal.endpoints.files.GenerateUploadUrlEndpoint +import com.pubnub.internal.endpoints.files.GetFileUrlEndpoint +import com.pubnub.internal.endpoints.files.ListFilesEndpoint +import com.pubnub.internal.endpoints.files.PublishFileMessageEndpoint +import com.pubnub.internal.endpoints.files.SendFileEndpoint +import com.pubnub.internal.endpoints.files.UploadFileEndpoint +import com.pubnub.internal.endpoints.message_actions.AddMessageActionEndpoint +import com.pubnub.internal.endpoints.message_actions.GetMessageActionsEndpoint +import com.pubnub.internal.endpoints.message_actions.RemoveMessageActionEndpoint +import com.pubnub.internal.endpoints.objects.channel.GetAllChannelMetadataEndpoint +import com.pubnub.internal.endpoints.objects.channel.GetChannelMetadataEndpoint +import com.pubnub.internal.endpoints.objects.channel.RemoveChannelMetadataEndpoint +import com.pubnub.internal.endpoints.objects.channel.SetChannelMetadataEndpoint +import com.pubnub.internal.endpoints.objects.internal.CollectionQueryParameters +import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam +import com.pubnub.internal.endpoints.objects.member.GetChannelMembersEndpoint +import com.pubnub.internal.endpoints.objects.member.ManageChannelMembersEndpoint +import com.pubnub.internal.endpoints.objects.membership.GetMembershipsEndpoint +import com.pubnub.internal.endpoints.objects.membership.ManageMembershipsEndpoint +import com.pubnub.internal.endpoints.objects.uuid.GetAllUUIDMetadataEndpoint +import com.pubnub.internal.endpoints.objects.uuid.GetUUIDMetadataEndpoint +import com.pubnub.internal.endpoints.objects.uuid.RemoveUUIDMetadataEndpoint +import com.pubnub.internal.endpoints.objects.uuid.SetUUIDMetadataEndpoint +import com.pubnub.internal.endpoints.presence.GetStateEndpoint +import com.pubnub.internal.endpoints.presence.HereNowEndpoint +import com.pubnub.internal.endpoints.presence.SetStateEndpoint +import com.pubnub.internal.endpoints.presence.WhereNowEndpoint +import com.pubnub.internal.endpoints.pubsub.PublishEndpoint +import com.pubnub.internal.endpoints.pubsub.SignalEndpoint +import com.pubnub.internal.endpoints.push.AddChannelsToPushEndpoint +import com.pubnub.internal.endpoints.push.ListPushProvisionsEndpoint +import com.pubnub.internal.endpoints.push.RemoveAllPushChannelsForDeviceEndpoint +import com.pubnub.internal.endpoints.push.RemoveChannelsFromPushEndpoint +import com.pubnub.internal.managers.BasePathManager +import com.pubnub.internal.managers.DuplicationManager +import com.pubnub.internal.managers.ListenerManager +import com.pubnub.internal.managers.MapperManager +import com.pubnub.internal.managers.PublishSequenceManager +import com.pubnub.internal.managers.RetrofitManager +import com.pubnub.internal.managers.TokenManager +import com.pubnub.internal.managers.TokenParser +import com.pubnub.internal.presence.Presence +import com.pubnub.internal.presence.eventengine.data.PresenceData +import com.pubnub.internal.presence.eventengine.effect.effectprovider.HeartbeatProviderImpl +import com.pubnub.internal.presence.eventengine.effect.effectprovider.LeaveProviderImpl +import com.pubnub.internal.subscribe.PRESENCE_CHANNEL_SUFFIX +import com.pubnub.internal.subscribe.Subscribe +import com.pubnub.internal.subscribe.eventengine.configuration.EventEnginesConf import com.pubnub.internal.v2.entities.ChannelGroupImpl import com.pubnub.internal.v2.entities.ChannelGroupName import com.pubnub.internal.v2.entities.ChannelImpl @@ -110,19 +161,84 @@ import com.pubnub.internal.v2.entities.ChannelName import com.pubnub.internal.v2.entities.UserMetadataImpl import com.pubnub.internal.v2.subscription.EmitterHelper import com.pubnub.internal.v2.subscription.SubscriptionImpl +import com.pubnub.internal.v2.subscription.SubscriptionInternal import com.pubnub.internal.v2.subscription.SubscriptionSetImpl +import com.pubnub.internal.workers.SubscribeMessageProcessor import com.pubnub.kmp.CustomObject import java.io.InputStream +import java.util.Date +import java.util.UUID +import java.util.concurrent.Executors +import java.util.concurrent.ScheduledExecutorService +import kotlin.time.Duration.Companion.seconds private const val PNSDK_PUBNUB_KOTLIN = "PubNub-Kotlin" -class PubNubImpl( - override val configuration: com.pubnub.api.v2.PNConfiguration, -) : BasePubNubImpl( - configuration, - PNSDK_PUBNUB_KOTLIN, - ), - PubNub { +open class PubNubImpl( + override val configuration: PNConfiguration, + val pnsdkName: String = PNSDK_PUBNUB_KOTLIN, + eventEnginesConf: EventEnginesConf = EventEnginesConf() +) : PubNub { + constructor(configuration: PNConfiguration) : this(configuration, PNSDK_PUBNUB_KOTLIN) + + val mapper = MapperManager() + + private val numberOfThreadsInPool = Integer.min(Runtime.getRuntime().availableProcessors(), 8) + internal val executorService: ScheduledExecutorService = Executors.newScheduledThreadPool(numberOfThreadsInPool) + val listenerManager: ListenerManager = ListenerManager(this) + private val basePathManager = BasePathManager(configuration) + internal val retrofitManager = RetrofitManager(this, configuration) + internal val publishSequenceManager = PublishSequenceManager(MAX_SEQUENCE) + internal val tokenManager: TokenManager = TokenManager() + private val tokenParser: TokenParser = TokenParser() + private val presenceData = PresenceData() + private val subscribe = + Subscribe.create( + this, + listenerManager, + eventEnginesConf, + SubscribeMessageProcessor(this, DuplicationManager(configuration)), + presenceData, + configuration.maintainPresenceState, + ) + + private val presence = + Presence.create( + heartbeatProvider = HeartbeatProviderImpl(this), + leaveProvider = LeaveProviderImpl(this), + heartbeatInterval = configuration.heartbeatInterval.seconds, + suppressLeaveEvents = configuration.suppressLeaveEvents, + heartbeatNotificationOptions = configuration.heartbeatNotificationOptions, + listenerManager = listenerManager, + eventEngineConf = eventEnginesConf.presence, + presenceData = presenceData, + sendStateWithHeartbeat = configuration.maintainPresenceState, + executorService = executorService, + ) + + /** + * Unique id of this PubNub instance. + * + * @see [PNConfiguration.includeInstanceIdentifier] + */ + val instanceId = UUID.randomUUID().toString() + + //region Internal + internal fun baseUrl() = basePathManager.basePath() + + internal fun requestId() = UUID.randomUUID().toString() + //endregion + + fun generatePnsdk(): String { + val joinedSuffixes = configuration.pnsdkSuffixes.toSortedMap().values.joinToString(" ") + return "$pnsdkName/$SDK_VERSION" + + if (joinedSuffixes.isNotBlank()) { + " $joinedSuffixes" + } else { + "" + } + } + private val emitterHelper = EmitterHelper(listenerManager) override var onMessage: ((PNMessageResult) -> Unit)? by emitterHelper::onMessage override var onPresence: ((PNPresenceEventResult) -> Unit)? by emitterHelper::onPresence @@ -131,168 +247,113 @@ class PubNubImpl( override var onObjects: ((PNObjectEventResult) -> Unit)? by emitterHelper::onObjects override var onFile: ((PNFileEventResult) -> Unit)? by emitterHelper::onFile + override val version: String + get() = SDK_VERSION + + override val timestamp: Int + get() = timestamp() + + override val baseUrl: String + get() = baseUrl() + + companion object { + internal const val TIMESTAMP_DIVIDER = 1000 + internal const val SDK_VERSION = PUBNUB_VERSION + internal const val MAX_SEQUENCE = 65535 + + @JvmStatic + fun timestamp() = (Date().time / TIMESTAMP_DIVIDER).toInt() + + /** + * Generates random UUID to use. You should set a unique UUID to identify the user or the device that connects to PubNub. + */ + @JvmStatic + fun generateUUID() = "pn-${UUID.randomUUID()}" + } + + override fun subscriptionSetOf( + channels: Set, + channelGroups: Set, + options: SubscriptionOptions, + ): SubscriptionSet { + val subscriptionSet = subscriptionSetOf(subscriptions = emptySet()) + channels.forEach { + subscriptionSet.add(channel(it).subscription(options)) + } + channelGroups.forEach { + subscriptionSet.add(channelGroup(it).subscription(options)) + } + return subscriptionSet + } + + override fun removeAllListeners() { + listenerManager.removeAllListeners() + } + override fun addListener(listener: SubscribeCallback) { - listenerManager.addListener(DelegatingSubscribeCallback(listener)) + listenerManager.addListener(listener) } override fun addListener(listener: StatusListener) { - listenerManager.addListener(DelegatingStatusListener(listener)) + listenerManager.addListener(listener) } override fun addListener(listener: EventListener) { - listenerManager.addListener(DelegatingEventListener(listener)) + listenerManager.addListener(listener) } override fun removeListener(listener: Listener) { - when (listener) { - is SubscribeCallback -> { - super.removeListener(DelegatingSubscribeCallback(listener)) - } - - is EventListener -> { - super.removeListener(DelegatingEventListener(listener)) - } - - else -> { - super.removeListener(listener) - } - } + listenerManager.removeListener(listener) } - /** - * Create a handle to a [BaseChannel] that can be used to obtain a [BaseSubscription]. - * - * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server - * state. It is therefore permitted to use this method whenever a representation of a channel is required. - * - * The returned [BaseChannel] holds a reference to this [PubNubImpl] instance internally. - * - * @param name the name of the channel to return. Supports wildcards by ending it with ".*". See more in the - * [documentation](https://www.pubnub.com/docs/general/channels/overview) - * - * @return a [BaseChannel] instance representing the channel with the given [name] - */ - override fun channel(name: String): Channel { + override fun channel(name: String): ChannelImpl { return ChannelImpl(this, ChannelName(name)) } - /** - * Create a handle to a [BaseChannelGroup] that can be used to obtain a [BaseSubscription]. - * - * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server - * state. It is therefore permitted to use this method whenever a representation of a channel group is required. - * - * The returned [BaseChannelGroup] holds a reference to this [PubNubImpl] instance internally. - * - * @param name the name of the channel group to return. See more in the - * [documentation](https://www.pubnub.com/docs/general/channels/subscribe#channel-groups) - * - * @return a [BaseChannelGroup] instance representing the channel group with the given [name] - */ override fun channelGroup(name: String): ChannelGroup { return ChannelGroupImpl(this, ChannelGroupName(name)) } - /** - * Create a handle to a [BaseChannelMetadata] object that can be used to obtain a [BaseSubscription] to metadata events. - * - * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server - * state. It is therefore permitted to use this method whenever a representation of a metadata channel is required. - * - * The returned [BaseChannelMetadata] holds a reference to this [PubNubImpl] instance internally. - * - * @param id the id of the channel metadata to return. See more in the - * [documentation](https://www.pubnub.com/docs/general/metadata/channel-metadata) - * - * @return a [BaseChannelMetadata] instance representing the channel metadata with the given [id] - */ override fun channelMetadata(id: String): ChannelMetadata { return ChannelMetadataImpl(this, ChannelName(id)) } - /** - * Create a handle to a [BaseUserMetadata] object that can be used to obtain a [BaseSubscription] to user metadata events. - * - * The function is cheap to call, and the returned object is lightweight, as it doesn't change any client or server - * state. It is therefore permitted to use this method whenever a representation of a user metadata is required. - * - * The returned [BaseUserMetadata] holds a reference to this [PubNubImpl] instance internally. - * - * @param id the id of the user. See more in the - * [documentation](https://www.pubnub.com/docs/general/metadata/users-metadata) - * - * @return a [BaseUserMetadata] instance representing the channel metadata with the given [id] - */ override fun userMetadata(id: String): UserMetadata { return UserMetadataImpl(this, ChannelName(id)) } - /** - * Create a [BaseSubscriptionSet] from the given [subscriptions]. - * - * @param subscriptions the subscriptions that will be added to the returned [BaseSubscriptionSet] - * @return a [BaseSubscriptionSet] containing all [subscriptions] - */ override fun subscriptionSetOf(subscriptions: Set): SubscriptionSet { - return SubscriptionSetImpl(pubNubCore, subscriptions as Set) - } - - /** - * Create a [BaseSubscriptionSet] containing [BaseSubscription] objects for the given sets of [channels] and - * [channelGroups]. - * - * Please note that the subscriptions are not active until you call [BaseSubscriptionSet.subscribe]. - * - * This is a convenience method, and it is equal to calling [PubNubImpl.channel] followed by [BaseChannel.subscription] for - * each channel, then creating a [subscriptionSetOf] using the returned [BaseSubscription] objects (and similarly for - * channel groups). - * - * @param channels the channels to create subscriptions for - * @param channelGroups the channel groups to create subscriptions for - * @param options the [SubscriptionOptions] to pass for each subscriptions. Refer to supported options in [BaseChannel] and - * [BaseChannelGroup] documentation. - * @return a [BaseSubscriptionSet] containing subscriptions for the given [channels] and [channelGroups] - */ - override fun subscriptionSetOf( - channels: Set, - channelGroups: Set, - options: SubscriptionOptions, - ): SubscriptionSet { - return super.subscriptionSetOf(channels, channelGroups, options) as SubscriptionSet + return SubscriptionSetImpl(this, subscriptions as Set) } override fun publish( channel: String, message: Any, meta: Any?, - shouldStore: Boolean, + shouldStore: Boolean?, usePost: Boolean, replicate: Boolean, ttl: Int?, - ): Publish { - return com.pubnub.internal.endpoints.pubsub.PublishImpl( - pubNubCore.publish( - channel, - message, - meta, - shouldStore, - usePost, - replicate, - ttl, - ), + ): Publish = + PublishEndpoint( + pubnub = this, + channel = channel, + message = message, + meta = meta, + shouldStore = shouldStore, + usePost = usePost, + replicate = replicate, + ttl = ttl, ) - } - override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean): Publish { - return com.pubnub.internal.endpoints.pubsub.PublishImpl( - pubNubCore.fire( - channel, - message, - meta, - usePost, - ), - ) - } + override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean): Publish = publish( + channel = channel, + message = message, + meta = meta, + shouldStore = false, + usePost = usePost, + replicate = false, + ) @Deprecated( "`fire()` never used the `ttl` parameter, please use the version without `ttl`.", @@ -309,49 +370,7 @@ class PubNubImpl( override fun signal( channel: String, message: Any, - ): Signal { - return com.pubnub.internal.endpoints.pubsub.SignalImpl(pubNubCore.signal(channel, message)) - } - - /** - * Unsubscribe from all channels and all channel groups - */ - override fun unsubscribeAll() { - pubNubCore.unsubscribeAll() - } - - override fun subscribe( - channels: List, - channelGroups: List, - withPresence: Boolean, - withTimetoken: Long, - ) { - pubNubCore.subscribe(channels, channelGroups, withPresence, withTimetoken) - } - - /** - * When subscribed to a single channel, this function causes the client to issue a leave from the channel - * and close any open socket to the PubNub Network. - * - * For multiplexed channels, the specified channel(s) will be removed and the socket remains open - * until there are no more channels remaining in the list. - * - * * **WARNING** - * Unsubscribing from all the channel(s) and then subscribing to a new channel Y isn't the same as - * Subscribing to channel Y and then unsubscribing from the previously subscribed channel(s). - * - * Unsubscribing from all the channels resets the timetoken and thus, - * there could be some gaps in the subscriptions that may lead to a message loss. - * - * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. - * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. - */ - override fun unsubscribe( - channels: List, - channelGroups: List, - ) { - pubNubCore.unsubscribe(channels, channelGroups) - } + ): Signal = SignalEndpoint(pubnub = this, channel = channel, message = message) override fun addPushNotificationsOnChannels( pushType: PNPushType, @@ -360,14 +379,13 @@ class PubNubImpl( topic: String?, environment: PNPushEnvironment, ): AddChannelsToPush { - return com.pubnub.internal.endpoints.push.AddChannelsToPushImpl( - pubNubCore.addPushNotificationsOnChannels( - pushType, - channels, - deviceId, - topic, - environment, - ), + return AddChannelsToPushEndpoint( + pubnub = this, + pushType = pushType, + channels = channels, + deviceId = deviceId, + topic = topic, + environment = environment, ) } @@ -377,13 +395,12 @@ class PubNubImpl( topic: String?, environment: PNPushEnvironment, ): ListPushProvisions { - return com.pubnub.internal.endpoints.push.ListPushProvisionsImpl( - pubNubCore.auditPushChannelProvisions( - pushType, - deviceId, - topic, - environment, - ), + return ListPushProvisionsEndpoint( + pubnub = this, + pushType = pushType, + deviceId = deviceId, + topic = topic, + environment = environment, ) } @@ -394,14 +411,13 @@ class PubNubImpl( topic: String?, environment: PNPushEnvironment, ): RemoveChannelsFromPush { - return com.pubnub.internal.endpoints.push.RemoveChannelsFromPushImpl( - pubNubCore.removePushNotificationsFromChannels( - pushType, - channels, - deviceId, - topic, - environment, - ), + return RemoveChannelsFromPushEndpoint( + pubnub = this, + pushType = pushType, + channels = channels, + deviceId = deviceId, + topic = topic, + environment = environment, ) } @@ -411,13 +427,12 @@ class PubNubImpl( topic: String?, environment: PNPushEnvironment, ): RemoveAllPushChannelsForDevice { - return com.pubnub.internal.endpoints.push.RemoveAllPushChannelsForDeviceImpl( - pubNubCore.removeAllPushNotificationsFromDeviceWithPushToken( - pushType, - deviceId, - topic, - environment, - ), + return RemoveAllPushChannelsForDeviceEndpoint( + pubnub = this, + pushType = pushType, + deviceId = deviceId, + topic = topic, + environment = environment, ) } @@ -430,16 +445,15 @@ class PubNubImpl( includeTimetoken: Boolean, includeMeta: Boolean, ): History { - return com.pubnub.internal.endpoints.HistoryImpl( - pubNubCore.history( - channel, - start, - end, - count, - reverse, - includeTimetoken, - includeMeta, - ), + return HistoryEndpoint( + pubnub = this, + channel = channel, + start = start, + end = end, + count = count, + reverse = reverse, + includeTimetoken = includeTimetoken, + includeMeta = includeMeta, ) } @@ -451,15 +465,14 @@ class PubNubImpl( includeMessageActions: Boolean, includeMessageType: Boolean, ): FetchMessages { - return com.pubnub.internal.endpoints.FetchMessagesImpl( - pubNubCore.fetchMessages( - channels, - page, - includeUUID, - includeMeta, - includeMessageActions, - includeMessageType, - ), + return FetchMessagesEndpoint( + pubnub = this, + channels = channels, + page = page, + includeUUID = includeUUID, + includeMeta = includeMeta, + includeMessageActions = includeMessageActions, + includeMessageType = includeMessageType, ) } @@ -468,25 +481,14 @@ class PubNubImpl( start: Long?, end: Long?, ): DeleteMessages { - return com.pubnub.internal.endpoints.DeleteMessagesImpl( - pubNubCore.deleteMessages( - channels, - start, - end, - ), - ) + return DeleteMessagesEndpoint(pubnub = this, channels = channels, start = start, end = end) } override fun messageCounts( channels: List, channelsTimetoken: List, ): MessageCounts { - return com.pubnub.internal.endpoints.MessageCountsImpl( - pubNubCore.messageCounts( - channels, - channelsTimetoken, - ), - ) + return MessageCountsEndpoint(pubnub = this, channels = channels, channelsTimetoken = channelsTimetoken) } override fun hereNow( @@ -495,18 +497,17 @@ class PubNubImpl( includeState: Boolean, includeUUIDs: Boolean, ): HereNow { - return com.pubnub.internal.endpoints.presence.HereNowImpl( - pubNubCore.hereNow( - channels, - channelGroups, - includeState, - includeUUIDs, - ), + return HereNowEndpoint( + pubnub = this, + channels = channels, + channelGroups = channelGroups, + includeState = includeState, + includeUUIDs = includeUUIDs, ) } override fun whereNow(uuid: String): WhereNow { - return com.pubnub.internal.endpoints.presence.WhereNowImpl(pubNubCore.whereNow(uuid)) + return WhereNowEndpoint(pubnub = this, uuid = uuid) } override fun setPresenceState( @@ -515,13 +516,13 @@ class PubNubImpl( state: Any, uuid: String, ): SetState { - return com.pubnub.internal.endpoints.presence.SetStateImpl( - pubNubCore.setPresenceState( - channels, - channelGroups, - state, - uuid, - ), + return SetStateEndpoint( + pubnub = this, + channels = channels, + channelGroups = channelGroups, + state = state, + uuid = uuid, + presenceData = presenceData, ) } @@ -530,13 +531,13 @@ class PubNubImpl( channelGroups: List, state: Any ): SetState { - return com.pubnub.internal.endpoints.presence.SetStateImpl( - pubNubCore.setPresenceState( - channels, - channelGroups, - state, - configuration.userId.value, - ), + return SetStateEndpoint( + pubnub = this, + channels = channels, + channelGroups = channelGroups, + state = state, + uuid = configuration.userId.value, + presenceData = presenceData, ) } @@ -545,25 +546,14 @@ class PubNubImpl( channelGroups: List, uuid: String, ): GetState { - return com.pubnub.internal.endpoints.presence.GetStateImpl( - pubNubCore.getPresenceState( - channels, - channelGroups, - uuid, - ), - ) + return GetStateEndpoint(pubnub = this, channels = channels, channelGroups = channelGroups, uuid = uuid) } override fun addMessageAction( channel: String, messageAction: PNMessageAction, ): AddMessageAction { - return com.pubnub.internal.endpoints.message_actions.AddMessageActionImpl( - pubNubCore.addMessageAction( - channel, - messageAction, - ), - ) + return AddMessageActionEndpoint(pubnub = this, channel = channel, messageAction = messageAction) } override fun removeMessageAction( @@ -571,12 +561,11 @@ class PubNubImpl( messageTimetoken: Long, actionTimetoken: Long, ): RemoveMessageAction { - return com.pubnub.internal.endpoints.message_actions.RemoveMessageActionImpl( - pubNubCore.removeMessageAction( - channel, - messageTimetoken, - actionTimetoken, - ), + return RemoveMessageActionEndpoint( + pubnub = this, + channel = channel, + messageTimetoken = messageTimetoken, + actionTimetoken = actionTimetoken, ) } @@ -584,48 +573,33 @@ class PubNubImpl( channel: String, page: PNBoundedPage, ): GetMessageActions { - return com.pubnub.internal.endpoints.message_actions.GetMessageActionsImpl( - pubNubCore.getMessageActions( - channel, - page, - ), - ) + return GetMessageActionsEndpoint(pubnub = this, channel = channel, page = page) } override fun addChannelsToChannelGroup( channels: List, channelGroup: String, ): AddChannelChannelGroup { - return com.pubnub.internal.endpoints.channel_groups.AddChannelChannelGroupImpl( - pubNubCore.addChannelsToChannelGroup(channels, channelGroup), - ) + return AddChannelChannelGroupEndpoint(pubnub = this, channels = channels, channelGroup = channelGroup) } override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { - return com.pubnub.internal.endpoints.channel_groups.AllChannelsChannelGroupImpl( - pubNubCore.listChannelsForChannelGroup(channelGroup), - ) + return AllChannelsChannelGroupEndpoint(pubnub = this, channelGroup = channelGroup) } override fun removeChannelsFromChannelGroup( channels: List, channelGroup: String, ): RemoveChannelChannelGroup { - return com.pubnub.internal.endpoints.channel_groups.RemoveChannelChannelGroupImpl( - pubNubCore.removeChannelsFromChannelGroup(channels, channelGroup), - ) + return RemoveChannelChannelGroupEndpoint(pubnub = this, channels = channels, channelGroup = channelGroup) } override fun listAllChannelGroups(): ListAllChannelGroup { - return com.pubnub.internal.endpoints.channel_groups.ListAllChannelGroupImpl(pubNubCore.listAllChannelGroups()) + return ListAllChannelGroupEndpoint(this) } override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { - return com.pubnub.internal.endpoints.channel_groups.DeleteChannelGroupImpl( - pubNubCore.deleteChannelGroup( - channelGroup, - ), - ) + return DeleteChannelGroupEndpoint(pubnub = this, channelGroup = channelGroup) } override fun grant( @@ -642,21 +616,20 @@ class PubNubImpl( channelGroups: List, uuids: List, ): Grant = - com.pubnub.internal.endpoints.access.GrantImpl( - pubNubCore.grant( - read, - write, - manage, - delete, - get, - update, - join, - ttl, - authKeys, - channels, - channelGroups, - uuids, - ), + GrantEndpoint( + pubnub = this, + read = read, + write = write, + manage = manage, + delete = delete, + get = get, + update = update, + join = join, + ttl = ttl, + authKeys = authKeys, + channels = channels, + channelGroups = channelGroups, + uuids = uuids, ) override fun grant( @@ -670,18 +643,17 @@ class PubNubImpl( channelGroups: List, uuids: List, ): Grant = - com.pubnub.internal.endpoints.access.GrantImpl( - pubNubCore.grant( - read, - write, - manage, - delete, - ttl, - authKeys, - channels, - channelGroups, - uuids, - ), + GrantEndpoint( + pubnub = this, + read = read, + write = write, + manage = manage, + delete = delete, + ttl = ttl, + authKeys = authKeys, + channels = channels, + channelGroups = channelGroups, + uuids = uuids, ) override fun grantToken( @@ -692,15 +664,14 @@ class PubNubImpl( channelGroups: List, uuids: List, ): GrantToken { - return com.pubnub.internal.endpoints.access.GrantTokenImpl( - pubNubCore.grantToken( - ttl, - meta, - authorizedUUID, - channels.toInternalChannelGrants(), - channelGroups.toInternalChannelGroupGrants(), - uuids.toInternalUuidGrants(), - ), + return GrantTokenEndpoint( + pubnub = this, + ttl = ttl, + meta = meta, + authorizedUUID = authorizedUUID, + channels = channels, + channelGroups = channelGroups, + uuids = uuids, ) } @@ -711,25 +682,26 @@ class PubNubImpl( spacesPermissions: List, usersPermissions: List, ): GrantToken { - return com.pubnub.internal.endpoints.access.GrantTokenImpl( - pubNubCore.grantToken( - ttl, - meta, - authorizedUserId, - spacesPermissions.toInternalSpacePermissions(), - usersPermissions.toInternalUserPermissions(), - ), + return GrantTokenEndpoint( + pubnub = this, + ttl = ttl, + meta = meta, + authorizedUUID = authorizedUserId?.value, + channels = spacesPermissions.map { spacePermissions -> spacePermissions.toChannelGrant() }, + channelGroups = emptyList(), + uuids = usersPermissions.map { userPermissions -> userPermissions.toUuidGrant() }, ) } override fun revokeToken(token: String): RevokeToken { - return com.pubnub.internal.endpoints.access.RevokeTokenImpl( - pubNubCore.revokeToken(token), + return RevokeTokenEndpoint( + pubnub = this, + token = token, ) } override fun time(): Time { - return com.pubnub.internal.endpoints.TimeImpl(pubNubCore.time()) + return TimeEndpoint(this) } override fun getAllChannelMetadata( @@ -740,15 +712,17 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, ): GetAllChannelMetadata { - return com.pubnub.internal.endpoints.objects.channel.GetAllChannelMetadataImpl( - pubNubCore.getAllChannelMetadata( - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - ), + return GetAllChannelMetadataEndpoint( + pubnub = this, + collectionQueryParameters = + CollectionQueryParameters( + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + ), + includeQueryParam = IncludeQueryParam(includeCustom = includeCustom), ) } @@ -756,8 +730,10 @@ class PubNubImpl( channel: String, includeCustom: Boolean, ): GetChannelMetadata { - return com.pubnub.internal.endpoints.objects.channel.GetChannelMetadataImpl( - pubNubCore.getChannelMetadata(channel, includeCustom), + return GetChannelMetadataEndpoint( + pubnub = this, + channel = channel, + includeQueryParam = IncludeQueryParam(includeCustom = includeCustom), ) } @@ -770,15 +746,20 @@ class PubNubImpl( type: String?, status: String?, ): SetChannelMetadata { - return com.pubnub.internal.endpoints.objects.channel.SetChannelMetadataImpl( - pubNubCore.setChannelMetadata(channel, name, description, custom, includeCustom, type, status), + return SetChannelMetadataEndpoint( + pubnub = this, + channel = channel, + name = name, + description = description, + custom = custom, + includeQueryParam = IncludeQueryParam(includeCustom = includeCustom), + type = type, + status = status, ) } override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { - return com.pubnub.internal.endpoints.objects.channel.RemoveChannelMetadataImpl( - pubNubCore.removeChannelMetadata(channel), - ) + return RemoveChannelMetadataEndpoint(this, channel = channel) } override fun getAllUUIDMetadata( @@ -789,15 +770,17 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, ): GetAllUUIDMetadata { - return com.pubnub.internal.endpoints.objects.uuid.GetAllUUIDMetadataImpl( - pubNubCore.getAllUUIDMetadata( - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - ), + return GetAllUUIDMetadataEndpoint( + pubnub = this, + collectionQueryParameters = + CollectionQueryParameters( + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + ), + withInclude = IncludeQueryParam(includeCustom = includeCustom), ) } @@ -805,8 +788,10 @@ class PubNubImpl( uuid: String?, includeCustom: Boolean, ): GetUUIDMetadata { - return com.pubnub.internal.endpoints.objects.uuid.GetUUIDMetadataImpl( - pubNubCore.getUUIDMetadata(uuid, includeCustom), + return GetUUIDMetadataEndpoint( + pubnub = this, + uuid = uuid ?: configuration.userId.value, + includeQueryParam = IncludeQueryParam(includeCustom = includeCustom), ) } @@ -821,25 +806,22 @@ class PubNubImpl( type: String?, status: String?, ): SetUUIDMetadata { - return com.pubnub.internal.endpoints.objects.uuid.SetUUIDMetadataImpl( - pubNubCore.setUUIDMetadata( - uuid, - name, - externalId, - profileUrl, - email, - custom, - includeCustom, - type, - status, - ), + return SetUUIDMetadataEndpoint( + pubnub = this, + uuid = uuid, + name = name, + externalId = externalId, + profileUrl = profileUrl, + email = email, + custom = custom, + withInclude = IncludeQueryParam(includeCustom = includeCustom), + type = type, + status = status, ) } override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { - return com.pubnub.internal.endpoints.objects.uuid.RemoveUUIDMetadataImpl( - pubNubCore.removeUUIDMetadata(uuid), - ) + return RemoveUUIDMetadataEndpoint(pubnub = this, uuid = uuid) } override fun getMemberships( @@ -853,18 +835,23 @@ class PubNubImpl( includeChannelDetails: PNChannelDetailsLevel?, includeType: Boolean, ): GetMemberships { - return com.pubnub.internal.endpoints.objects.membership.GetMembershipsImpl( - pubNubCore.getMemberships( - uuid, - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeChannelDetails.toInternal(), - includeType - ), + return GetMembershipsEndpoint( + pubnub = this, + uuid = uuid ?: configuration.userId.value, + collectionQueryParameters = + CollectionQueryParameters( + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + ), + includeQueryParam = + IncludeQueryParam( + includeCustom = includeCustom, + includeChannelDetails = includeChannelDetails, + includeChannelType = includeType, + ), ) } @@ -879,22 +866,19 @@ class PubNubImpl( includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel?, includeType: Boolean, - ): ManageMemberships { - return com.pubnub.internal.endpoints.objects.membership.ManageMembershipsImpl( - pubNubCore.setMemberships( - channels.toInternalChannelMemberships(), - uuid, - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeChannelDetails.toInternal(), - includeType - ), - ) - } + ): ManageMemberships = manageMemberships( + channelsToSet = channels, + channelsToRemove = listOf(), + uuid = uuid, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeChannelDetails = includeChannelDetails, + includeType = includeType + ) override fun removeMemberships( channels: List, @@ -907,22 +891,19 @@ class PubNubImpl( includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel?, includeType: Boolean, - ): ManageMemberships { - return com.pubnub.internal.endpoints.objects.membership.ManageMembershipsImpl( - pubNubCore.removeMemberships( - channels, - uuid, - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeChannelDetails.toInternal(), - includeType - ), - ) - } + ): ManageMemberships = manageMemberships( + channelsToSet = listOf(), + channelsToRemove = channels, + uuid = uuid, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeChannelDetails = includeChannelDetails, + includeType = includeType, + ) override fun manageMemberships( channelsToSet: List, @@ -937,20 +918,25 @@ class PubNubImpl( includeChannelDetails: PNChannelDetailsLevel?, includeType: Boolean, ): ManageMemberships { - return com.pubnub.internal.endpoints.objects.membership.ManageMembershipsImpl( - pubNubCore.manageMemberships( - channelsToSet.toInternalChannelMemberships(), - channelsToRemove, - uuid, - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeChannelDetails.toInternal(), - includeType - ), + return ManageMembershipsEndpoint( + pubnub = this, + channelsToSet = channelsToSet, + channelsToRemove = channelsToRemove, + uuid = uuid ?: configuration.userId.value, + collectionQueryParameters = + CollectionQueryParameters( + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + ), + includeQueryParam = + IncludeQueryParam( + includeCustom = includeCustom, + includeChannelDetails = includeChannelDetails, + includeChannelType = includeType, + ), ) } @@ -965,18 +951,23 @@ class PubNubImpl( includeUUIDDetails: PNUUIDDetailsLevel?, includeType: Boolean, ): GetChannelMembers { - return com.pubnub.internal.endpoints.objects.member.GetChannelMembersImpl( - pubNubCore.getChannelMembers( - channel, - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeUUIDDetails.toInternal(), - includeType - ), + return GetChannelMembersEndpoint( + pubnub = this, + channel = channel, + collectionQueryParameters = + CollectionQueryParameters( + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + ), + includeQueryParam = + IncludeQueryParam( + includeCustom = includeCustom, + includeUUIDDetails = includeUUIDDetails, + includeUuidType = includeType, + ), ) } @@ -999,19 +990,14 @@ class PubNubImpl( includeMeta: Boolean, includeMessageActions: Boolean, includeMessageType: Boolean, - ): FetchMessages { - return com.pubnub.internal.endpoints.FetchMessagesImpl( - pubNubCore.fetchMessages( - channels, - maximumPerChannel, - start, - end, - includeMeta, - includeMessageActions, - includeMessageType, - ), - ) - } + ): FetchMessages = fetchMessages( + channels = channels, + page = PNBoundedPage(start = start, end = end, limit = maximumPerChannel), + includeUUID = true, + includeMeta = includeMeta, + includeMessageActions = includeMessageActions, + includeMessageType = includeMessageType + ) @Deprecated( replaceWith = @@ -1028,9 +1014,7 @@ class PubNubImpl( end: Long?, limit: Int?, ): GetMessageActions { - return com.pubnub.internal.endpoints.message_actions.GetMessageActionsImpl( - pubNubCore.getMessageActions(channel, start, end, limit), - ) + return getMessageActions(channel = channel, page = PNBoundedPage(start = start, end = end, limit = limit)) } @Deprecated( @@ -1053,21 +1037,17 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeChannelDetails: PNChannelDetailsLevel?, - ): ManageMemberships { - return com.pubnub.internal.endpoints.objects.membership.ManageMembershipsImpl( - pubNubCore.addMemberships( - channels.toInternalChannelMemberships(), - uuid, - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeChannelDetails.toInternal(), - ), - ) - } + ): ManageMemberships = setMemberships( + channels = channels, + uuid = uuid ?: configuration.userId.value, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeChannelDetails = includeChannelDetails, + ) @Deprecated( "Use getChannelMembers instead", @@ -1088,20 +1068,16 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, - ): GetChannelMembers { - return com.pubnub.internal.endpoints.objects.member.GetChannelMembersImpl( - pubNubCore.getMembers( - channel, - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeUUIDDetails.toInternal(), - ), - ) - } + ): GetChannelMembers = getChannelMembers( + channel = channel, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeUUIDDetails = includeUUIDDetails, + ) @Deprecated( "Use setChannelMembers instead", @@ -1123,21 +1099,17 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, - ): ManageChannelMembers { - return com.pubnub.internal.endpoints.objects.member.ManageChannelMembersImpl( - pubNubCore.addMembers( - channel, - uuids.toInternalMemberInputs(), - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeUUIDDetails.toInternal(), - ), - ) - } + ): ManageChannelMembers = setChannelMembers( + channel = channel, + uuids = uuids, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeUUIDDetails = includeUUIDDetails, + ) override fun setChannelMembers( channel: String, @@ -1150,22 +1122,19 @@ class PubNubImpl( includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, includeType: Boolean, - ): ManageChannelMembers { - return com.pubnub.internal.endpoints.objects.member.ManageChannelMembersImpl( - pubNubCore.setChannelMembers( - channel, - uuids.toInternalMemberInputs(), - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeUUIDDetails.toInternal(), - includeType - ), - ) - } + ): ManageChannelMembers = manageChannelMembers( + channel = channel, + uuidsToSet = uuids, + uuidsToRemove = listOf(), + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeUUIDDetails = includeUUIDDetails, + includeUUIDType = includeType + ) @Deprecated( "Use removeChannelMembers instead", @@ -1187,21 +1156,17 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, - ): ManageChannelMembers { - return com.pubnub.internal.endpoints.objects.member.ManageChannelMembersImpl( - pubNubCore.removeMembers( - channel, - uuids, - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeUUIDDetails.toInternal(), - ), - ) - } + ): ManageChannelMembers = removeChannelMembers( + channel = channel, + uuids = uuids, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeUUIDDetails = includeUUIDDetails, + ) override fun removeChannelMembers( channel: String, @@ -1214,21 +1179,19 @@ class PubNubImpl( includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, includeType: Boolean, - ): ManageChannelMembers { - return com.pubnub.internal.endpoints.objects.member.ManageChannelMembersImpl( - pubNubCore.removeChannelMembers( - channel, - uuids, - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeUUIDDetails.toInternal(), - ), - ) - } + ): ManageChannelMembers = manageChannelMembers( + channel = channel, + uuidsToSet = listOf(), + uuidsToRemove = uuids, + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + includeCustom = includeCustom, + includeUUIDDetails = includeUUIDDetails, + includeUUIDType = includeType, + ) override fun manageChannelMembers( channel: String, @@ -1241,20 +1204,27 @@ class PubNubImpl( includeCount: Boolean, includeCustom: Boolean, includeUUIDDetails: PNUUIDDetailsLevel?, + includeUUIDType: Boolean, ): ManageChannelMembers { - return com.pubnub.internal.endpoints.objects.member.ManageChannelMembersImpl( - pubNubCore.manageChannelMembers( - channel, - uuidsToSet.toInternalMemberInputs(), - uuidsToRemove, - limit, - page, - filter, - sort.toInternalSortKeys(), - includeCount, - includeCustom, - includeUUIDDetails.toInternal(), - ), + return ManageChannelMembersEndpoint( + pubnub = this, + channel = channel, + uuidsToSet = uuidsToSet, + uuidsToRemove = uuidsToRemove, + collectionQueryParameters = + CollectionQueryParameters( + limit = limit, + page = page, + filter = filter, + sort = sort, + includeCount = includeCount, + ), + includeQueryParam = + IncludeQueryParam( + includeCustom = includeCustom, + includeUUIDDetails = includeUUIDDetails, + includeUuidType = includeUUIDType, + ), ) } @@ -1268,17 +1238,28 @@ class PubNubImpl( shouldStore: Boolean?, cipherKey: String?, ): SendFile { - return com.pubnub.internal.endpoints.files.SendFileImpl( - pubNubCore.sendFile( - channel, - fileName, - inputStream, - message, - meta, - ttl, - shouldStore, - cipherKey, - ), + val cryptoModule = + if (cipherKey != null) { + CryptoModule.createLegacyCryptoModule(cipherKey) + } else { + configuration.cryptoModule + } + return SendFileEndpoint( + channel = channel, + fileName = fileName, + inputStream = inputStream, + message = message, + meta = meta, + ttl = ttl, + shouldStore = shouldStore, + executorService = + retrofitManager.getTransactionClientExecutorService() + ?: Executors.newSingleThreadExecutor(), + fileMessagePublishRetryLimit = configuration.fileMessagePublishRetryLimit, + generateUploadUrlFactory = GenerateUploadUrlEndpoint.Factory(this), + publishFileMessageFactory = PublishFileMessageEndpoint.Factory(this), + sendFileToS3Factory = UploadFileEndpoint.Factory(this), + cryptoModule = cryptoModule, ) } @@ -1287,8 +1268,11 @@ class PubNubImpl( limit: Int?, next: PNPage.PNNext?, ): ListFiles { - return com.pubnub.internal.endpoints.files.ListFilesImpl( - pubNubCore.listFiles(channel, limit, next), + return ListFilesEndpoint( + pubNub = this, + channel = channel, + limit = limit, + next = next, ) } @@ -1297,8 +1281,11 @@ class PubNubImpl( fileName: String, fileId: String, ): GetFileUrl { - return com.pubnub.internal.endpoints.files.GetFileUrlImpl( - pubNubCore.getFileUrl(channel, fileName, fileId), + return GetFileUrlEndpoint( + pubNub = this, + channel = channel, + fileName = fileName, + fileId = fileId, ) } @@ -1308,8 +1295,18 @@ class PubNubImpl( fileId: String, cipherKey: String?, ): DownloadFile { - return com.pubnub.internal.endpoints.files.DownloadFileImpl( - pubNubCore.downloadFile(channel, fileName, fileId, cipherKey), + val cryptoModule = + if (cipherKey != null) { + CryptoModule.createLegacyCryptoModule(cipherKey) + } else { + configuration.cryptoModule + } + return DownloadFileEndpoint( + pubNub = this, + channel = channel, + fileName = fileName, + fileId = fileId, + cryptoModule = cryptoModule, ) } @@ -1318,8 +1315,11 @@ class PubNubImpl( fileName: String, fileId: String, ): DeleteFile { - return com.pubnub.internal.endpoints.files.DeleteFileImpl( - pubNubCore.deleteFile(channel, fileName, fileId), + return DeleteFileEndpoint( + pubNub = this, + channel = channel, + fileName = fileName, + fileId = fileId, ) } @@ -1332,111 +1332,349 @@ class PubNubImpl( ttl: Int?, shouldStore: Boolean?, ): PublishFileMessage { - return com.pubnub.internal.endpoints.files.PublishFileMessageImpl( - pubNubCore.publishFileMessage(channel, fileName, fileId, message, meta, ttl, shouldStore), + return PublishFileMessageEndpoint( + pubNub = this, + channel = channel, + fileName = fileName, + fileId = fileId, + message = message, + meta = meta, + ttl = ttl, + shouldStore = shouldStore, ) } - /** - * Queries the local subscribe loop for channels currently in the mix. - * - * @return A list of channels the client is currently subscribed to. - */ - override fun getSubscribedChannels(): List = pubNubCore.getSubscribedChannels() + override fun getSubscribedChannels() = subscribe.getSubscribedChannels() - /** - * Queries the local subscribe loop for channel groups currently in the mix. - * - * @return A list of channel groups the client is currently subscribed to. - */ - override fun getSubscribedChannelGroups(): List = pubNubCore.getSubscribedChannelGroups() + override fun getSubscribedChannelGroups() = subscribe.getSubscribedChannelGroups() - /** - * Track the online and offline status of users and devices in real time and store custom state information. - * When you have Presence enabled, PubNub automatically creates a presence channel for each channel. - * - * Subscribing to a presence channel or presence channel group will only return presence events - * - * @param channels Channels to subscribe/unsubscribe. Either `channel` or [channelGroups] are required. - * @param channelGroups Channel groups to subscribe/unsubscribe. Either `channelGroups` or [channels] are required. - */ override fun presence( channels: List, channelGroups: List, connected: Boolean, - ) = pubNubCore.presence(channels, channelGroups, connected) + ) = presence.presence( + channels = channels.toSet(), + channelGroups = channelGroups.toSet(), + connected = connected, + ) private fun getCryptoModuleOrThrow(cipherKey: String? = null): CryptoModule { - return cipherKey?.let { cipherKeyNotNull -> - (configuration as? PNConfiguration)?.let { - CryptoModule.createLegacyCryptoModule(cipherKeyNotNull, it.useRandomInitializationVector) - } ?: CryptoModule.createLegacyCryptoModule(cipherKeyNotNull) - } ?: configuration.cryptoModule ?: throw PubNubException("Crypto module is not initialized") + return cipherKey?.let { cipherKeyNotNull -> CryptoModule.createLegacyCryptoModule(cipherKeyNotNull) } + ?: configuration.cryptoModule ?: throw PubNubException("Crypto module is not initialized") } - /** - * Perform Cryptographic decryption of an input string using cipher key provided by [PNConfiguration.cipherKey]. - * - * @param inputString String to be decrypted. - * - * @return String containing the decryption of `inputString` using `cipherKey`. - * @throws PubNubException throws exception in case of failed decryption. - */ - override fun decrypt(inputString: String): String = pubNubCore.decrypt(inputString) + @Throws(PubNubException::class) + fun decrypt( + inputString: String, + cryptoModule: CryptoModule? = null, + ): String = getCryptoModuleOrThrow(cryptoModule).decryptString(inputString) + + @Throws(PubNubException::class) + override fun decrypt(inputString: String): String = decrypt(inputString, cipherKey = null) - /** - * Perform Cryptographic decryption of an input string using a cipher key. - * - * @param inputString String to be decrypted. - * @param cipherKey cipher key to be used for decryption. Default is [PNConfiguration.cipherKey] - * - * @return String containing the decryption of `inputString` using `cipherKey`. - * @throws PubNubException throws exception in case of failed decryption. - */ override fun decrypt( inputString: String, cipherKey: String?, - ): String = pubNubCore.decrypt(inputString, getCryptoModuleOrThrow(cipherKey)) + ): String = decrypt(inputString, getCryptoModuleOrThrow(cipherKey)) - /** - * Perform Cryptographic decryption of an input stream using provided cipher key. - * - * @param inputStream InputStream to be encrypted. - * @param cipherKey Cipher key to be used for decryption. - * - * @return InputStream containing the encryption of `inputStream` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed decryption. - */ override fun decryptInputStream( inputStream: InputStream, cipherKey: String?, - ): InputStream = pubNubCore.decryptInputStream(inputStream, getCryptoModuleOrThrow(cipherKey)) + ): InputStream = decryptInputStream(inputStream, getCryptoModuleOrThrow(cipherKey)) + + private fun decryptInputStream( + inputStream: InputStream, + cryptoModule: CryptoModule? = null, + ): InputStream = getCryptoModuleOrThrow(cryptoModule).decryptStream(inputStream) - /** - * Perform Cryptographic encryption of an input string and a cipher key. - * - * @param inputString String to be encrypted. - * @param cipherKey Cipher key to be used for encryption. Default is [PNConfiguration.cipherKey] - * - * @return String containing the encryption of `inputString` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed encryption. - */ override fun encrypt( inputString: String, cipherKey: String?, - ): String = pubNubCore.encrypt(inputString, getCryptoModuleOrThrow(cipherKey)) + ): String = encrypt(inputString, getCryptoModuleOrThrow(cipherKey)) + + @Throws(PubNubException::class) + private fun encrypt( + inputString: String, + cryptoModule: CryptoModule? = null, + ): String = getCryptoModuleOrThrow(cryptoModule).encryptString(inputString) - /** - * Perform Cryptographic encryption of an input stream using provided cipher key. - * - * @param inputStream InputStream to be encrypted. - * @param cipherKey Cipher key to be used for encryption. - * - * @return InputStream containing the encryption of `inputStream` using `cipherKey`. - * @throws PubNubException Throws exception in case of failed encryption. - */ override fun encryptInputStream( inputStream: InputStream, cipherKey: String?, - ): InputStream = pubNubCore.encryptInputStream(inputStream, getCryptoModuleOrThrow(cipherKey)) + ): InputStream = encryptInputStream(inputStream, getCryptoModuleOrThrow(cipherKey)) + + @Throws(PubNubException::class) + private fun encryptInputStream( + inputStream: InputStream, + cryptoModule: CryptoModule? = null, + ): InputStream = getCryptoModuleOrThrow(cryptoModule).encryptStream(inputStream) + + private fun subscribeInternal( + channels: List = emptyList(), + channelGroups: List = emptyList(), + withPresence: Boolean = false, + withTimetoken: Long = 0L, + ) { + subscribe.subscribe(channels.toSet(), channelGroups.toSet(), withPresence, withTimetoken) + if (!configuration.managePresenceListManually) { + presence.joined( + channels.filterNot { it.endsWith(PRESENCE_CHANNEL_SUFFIX) }.toSet(), + channelGroups.filterNot { it.endsWith(PRESENCE_CHANNEL_SUFFIX) }.toSet(), + ) + } + } + + private fun unsubscribeInternal( + channels: List = emptyList(), + channelGroups: List = emptyList(), + ) { + val channelSetWithoutPresence = channels.filter { !it.endsWith(PRESENCE_CHANNEL_SUFFIX) }.toSet() + val groupSetWithoutPresence = channelGroups.filter { !it.endsWith(PRESENCE_CHANNEL_SUFFIX) }.toSet() + subscribe.unsubscribe(channelSetWithoutPresence, groupSetWithoutPresence) + if (!configuration.managePresenceListManually) { + presence.left(channelSetWithoutPresence, groupSetWithoutPresence) + } + } + + override fun reconnect(timetoken: Long) { + subscribe.reconnect(timetoken) + presence.reconnect() + } + + override fun disconnect() { + subscribe.disconnect() + presence.disconnect() + } + + override fun destroy() { + subscribe.destroy() + presence.destroy() + + retrofitManager.destroy() + executorService.shutdown() + } + + override fun forceDestroy() { + subscribe.destroy() + presence.destroy() + + retrofitManager.destroy(true) + executorService.shutdownNow() + } + + override fun parseToken(token: String): PNToken { + return tokenParser.unwrapToken(token) + } + + override fun setToken(token: String?) { + return tokenManager.setToken(token) + } + + // internal + private val lockChannelsAndGroups = Any() + private val channelSubscriptions = mutableMapOf>() + private val channelGroupSubscriptions = mutableMapOf>() + + internal fun subscribe( + vararg subscriptions: SubscriptionInternal, + cursor: SubscriptionCursor, + ) { + synchronized(lockChannelsAndGroups) { + val channelsToSubscribe = mutableSetOf() + subscriptions.forEach { subscription -> + subscription.channels.forEach { channelName -> + channelSubscriptions.computeIfAbsent(channelName) { mutableSetOf() } + .also { set -> set.add(subscription) } + channelsToSubscribe.add(channelName) + } + } + val groupsToSubscribe = mutableSetOf() + subscriptions.forEach { subscription -> + subscription.channelGroups.forEach { channelGroupName -> + channelGroupSubscriptions.computeIfAbsent(channelGroupName) { mutableSetOf() } + .also { set -> set.add(subscription) } + groupsToSubscribe.add(channelGroupName) + } + } + + val (channelsWithPresence, channelsNoPresence) = + channelsToSubscribe.filter { !it.isPresence } + .partition { + channelsToSubscribe.contains(it.withPresence) + } + val (groupsWithPresence, groupsNoPresence) = + groupsToSubscribe.filter { !it.isPresence }.partition { + groupsToSubscribe.contains(it.withPresence) + } + if (channelsWithPresence.isNotEmpty() || groupsWithPresence.isNotEmpty()) { + subscribeInternal( + channels = channelsWithPresence.map(ChannelName::id), + channelGroups = groupsWithPresence.map(ChannelGroupName::id), + withPresence = true, + withTimetoken = cursor.timetoken, + ) + } + if (channelsNoPresence.isNotEmpty() || groupsNoPresence.isNotEmpty()) { + subscribeInternal( + channels = channelsNoPresence.map(ChannelName::id), + channelGroups = groupsNoPresence.map(ChannelGroupName::id), + withPresence = false, + withTimetoken = cursor.timetoken, + ) + } + } + } + + internal fun unsubscribe(vararg subscriptions: SubscriptionInternal) { + synchronized(lockChannelsAndGroups) { + val channelsToUnsubscribe = mutableSetOf() + subscriptions.forEach { subscription -> + subscription.channels.forEach { channelName -> + val set = channelSubscriptions[channelName] + set?.remove(subscription) + if (set != null && set.isEmpty()) { // there were mappings but there none now + channelsToUnsubscribe += channelName + channelSubscriptions.remove(channelName) + } + } + } + + val groupsToUnsubscribe = mutableSetOf() + subscriptions.forEach { subscription -> + subscription.channelGroups.forEach { channelGroupName -> + val set = channelGroupSubscriptions[channelGroupName] + set?.remove(subscription) + if (set != null && set.isEmpty()) { + groupsToUnsubscribe += channelGroupName + channelGroupSubscriptions.remove(channelGroupName) + } + } + } + if (channelsToUnsubscribe.isNotEmpty() || groupsToUnsubscribe.isNotEmpty()) { + unsubscribeInternal( + channels = channelsToUnsubscribe.map(ChannelName::id), + channelGroups = groupsToUnsubscribe.map(ChannelGroupName::id), + ) + } + } + } + + private val channelSubscriptionMap = mutableMapOf() + private val channelGroupSubscriptionMap = mutableMapOf() + + //region Subscribe + @Synchronized + override fun subscribe( + channels: List, + channelGroups: List, + withPresence: Boolean, + withTimetoken: Long, + ) { + val toSubscribe = mutableSetOf() + channels.filter { it.isNotEmpty() }.map { ChannelName(it) }.forEach { channelName -> + // if we are adding a NEW subscriptions in this step, this var will contain it: + var subscription: SubscriptionImpl? = null + channelSubscriptionMap.computeIfAbsent(channelName) { newChannelName -> + val channel = + ChannelImpl( + this, + newChannelName + ) + val options = + if (withPresence) { + SubscriptionOptions.receivePresenceEvents() + } else { + EmptyOptions + } + channel.subscription(options).also { sub -> + toSubscribe.add(sub) + subscription = sub + } + } + // make sure we are also subscribed and tracking the -pnpres channel if withPresence==true + if (withPresence) { + channelSubscriptionMap.computeIfAbsent(channelName.withPresence) { presenceChannelName -> + // this will either be the subscriptions we just created in the previous step, + // or if we were already subscribed to the channel WITHOUT presence, we need to create a new one + subscription ?: ChannelImpl( + this, + presenceChannelName + ).subscription().also { sub -> + toSubscribe.add(sub) + } + } + } + } + channelGroups.filter { it.isNotEmpty() }.map { ChannelGroupName(it) }.forEach { channelGroupName -> + var subscription: SubscriptionImpl? = null + + channelGroupSubscriptionMap.computeIfAbsent(channelGroupName) { newChannelGroupName -> + val channelGroup = ChannelGroupImpl(this, newChannelGroupName) + val options = + if (withPresence) { + SubscriptionOptions.receivePresenceEvents() + } else { + EmptyOptions + } + channelGroup.subscription(options).also { sub -> + toSubscribe.add(sub) + subscription = sub + } + } + // make sure we are also subscribed and tracking the -pnpres channel if withPresence==true + if (withPresence) { + channelGroupSubscriptionMap.computeIfAbsent(channelGroupName.withPresence) { presenceGroupName -> + // this will either be the subscriptions we just created in the previous step, + // or if we were already subscribed to the channel WITHOUT presence, we need to create a new one + subscription ?: ChannelGroupImpl(this, presenceGroupName) + .subscription().also { sub -> + toSubscribe.add(sub) + } + } + } + } + + // actually subscribe to all subscriptions created in this function and added to the set + subscribe(*toSubscribe.toTypedArray(), cursor = SubscriptionCursor(withTimetoken)) + } + + @Synchronized + override fun unsubscribe( + channels: List, + channelGroups: List, + ) { + val toUnsubscribe: MutableSet = mutableSetOf() + channels.filter { it.isNotEmpty() }.map { ChannelName(it) }.forEach { channelName -> + channelSubscriptionMap.remove(channelName)?.let { sub -> + toUnsubscribe.add(sub) + } + channelSubscriptionMap.remove(channelName.withPresence)?.let { sub -> + toUnsubscribe.add(sub) + } + } + channelGroups.filter { it.isNotEmpty() }.map { ChannelGroupName(it) }.forEach { groupName -> + channelGroupSubscriptionMap.remove(groupName)?.let { sub -> + toUnsubscribe.add(sub) + } + channelGroupSubscriptionMap.remove(groupName.withPresence)?.let { sub -> + toUnsubscribe.add(sub) + } + } + unsubscribe(*toUnsubscribe.toTypedArray()) + } + + @Synchronized + override fun unsubscribeAll() { + synchronized(lockChannelsAndGroups) { + channelSubscriptions.clear() + channelGroupSubscriptions.clear() + subscribe.unsubscribeAll() + presence.leftAll() + } + } + + @Throws(PubNubException::class) + private fun getCryptoModuleOrThrow(cryptoModule: CryptoModule? = null): CryptoModule { + return cryptoModule ?: configuration.cryptoModule ?: throw PubNubException("Crypto module is not initialized") + } } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubRetryableException.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubRetryableException.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubRetryableException.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubRetryableException.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubUtil.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubUtil.kt similarity index 97% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubUtil.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubUtil.kt index c531a1cc5..cf128d2bc 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/PubNubUtil.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/PubNubUtil.kt @@ -1,8 +1,8 @@ package com.pubnub.internal import com.pubnub.api.PubNubException -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.BasePNConfiguration.Companion.isValid +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.PNConfiguration.Companion.isValid import okhttp3.Request import okio.Buffer import org.slf4j.LoggerFactory @@ -59,7 +59,7 @@ internal object PubNubUtil { fun signRequest( originalRequest: Request, - pnConfiguration: BasePNConfiguration, + pnConfiguration: PNConfiguration, timestamp: Int, ): Request { // only sign if we have a secret key in place. @@ -81,7 +81,7 @@ internal object PubNubUtil { return originalRequest.newBuilder().url(rebuiltUrl).build() } - fun shouldSignRequest(configuration: BasePNConfiguration): Boolean { + fun shouldSignRequest(configuration: PNConfiguration): Boolean { return configuration.secretKey.isValid() } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/callbacks/ReconnectionCallback.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/callbacks/ReconnectionCallback.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/callbacks/ReconnectionCallback.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/callbacks/ReconnectionCallback.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/CryptoModuleImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/CryptoModuleImpl.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/CryptoModuleImpl.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/CryptoModuleImpl.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/AesCbcCryptor.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/AesCbcCryptor.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/AesCbcCryptor.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/AesCbcCryptor.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/CryptorHeader.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/CryptorHeader.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/CryptorHeader.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/CryptorHeader.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/CryptorHeaderVersion.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/CryptorHeaderVersion.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/CryptorHeaderVersion.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/CryptorHeaderVersion.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/HeaderParser.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/HeaderParser.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/HeaderParser.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/HeaderParser.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/InputStreamSeparator.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/InputStreamSeparator.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/InputStreamSeparator.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/InputStreamSeparator.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/LegacyCryptor.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/LegacyCryptor.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/LegacyCryptor.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/crypto/cryptor/LegacyCryptor.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesEndpoint.kt similarity index 91% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesEndpoint.kt index d18e15a71..b9132d07d 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesEndpoint.kt @@ -2,25 +2,26 @@ package com.pubnub.internal.endpoints import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.DeleteMessages import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.toCsv import retrofit2.Call import retrofit2.Response import java.util.Locale /** - * @see [PubNubCore.deleteMessages] + * @see [PubNubImpl.deleteMessages] */ class DeleteMessagesEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channels: List, override val start: Long? = null, override val end: Long? = null, -) : EndpointCore(pubnub), DeleteMessagesInterface { +) : EndpointCore(pubnub), DeleteMessages { override fun validateParams() { super.validateParams() if (channels.isEmpty()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesImpl.kt deleted file mode 100644 index 8e06ae815..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/DeleteMessagesImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints - -import com.pubnub.api.endpoints.DeleteMessages -import com.pubnub.api.models.consumer.history.PNDeleteMessagesResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.deleteMessages] - */ -class DeleteMessagesImpl internal constructor(deleteMessages: DeleteMessagesInterface) : - DeleteMessagesInterface by deleteMessages, - DeleteMessages, - EndpointImpl(deleteMessages) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesEndpoint.kt similarity index 97% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesEndpoint.kt index accca14de..9681b7371 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesEndpoint.kt @@ -2,6 +2,7 @@ package com.pubnub.internal.endpoints import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.FetchMessages import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.history.HistoryMessageType @@ -9,7 +10,7 @@ import com.pubnub.api.models.consumer.history.PNFetchMessageItem import com.pubnub.api.models.consumer.history.PNFetchMessagesResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.extension.limit import com.pubnub.internal.extension.nonPositiveToNull import com.pubnub.internal.extension.tryDecryptMessage @@ -20,17 +21,17 @@ import retrofit2.Response import java.util.Locale /** - * @see [PubNubCore.fetchMessages] + * @see [PubNubImpl.fetchMessages] */ class FetchMessagesEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channels: List, override val page: PNBoundedPage, override val includeUUID: Boolean, override val includeMeta: Boolean, override val includeMessageActions: Boolean, override val includeMessageType: Boolean, -) : EndpointCore(pubnub), FetchMessagesInterface { +) : EndpointCore(pubnub), FetchMessages { internal companion object { private const val SINGLE_CHANNEL_DEFAULT_MESSAGES = 100 private const val SINGLE_CHANNEL_MAX_MESSAGES = 100 diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesImpl.kt deleted file mode 100644 index 0d06be4b0..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/FetchMessagesImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints - -import com.pubnub.api.endpoints.FetchMessages -import com.pubnub.api.models.consumer.history.PNFetchMessagesResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.fetchMessages] - */ -class FetchMessagesImpl internal constructor(fetchMessages: FetchMessagesInterface) : - FetchMessagesInterface by fetchMessages, - FetchMessages, - EndpointImpl(fetchMessages) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryEndpoint.kt similarity index 95% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryEndpoint.kt index c139b040d..c869a3760 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryEndpoint.kt @@ -3,22 +3,23 @@ package com.pubnub.internal.endpoints import com.google.gson.JsonElement import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.History import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.history.PNHistoryItemResult import com.pubnub.api.models.consumer.history.PNHistoryResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.extension.tryDecryptMessage import retrofit2.Call import retrofit2.Response import java.util.Locale /** - * @see [PubNubCore.history] + * @see [PubNubImpl.history] */ class HistoryEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channel: String, override val start: Long? = null, override val end: Long? = null, @@ -26,7 +27,7 @@ class HistoryEndpoint internal constructor( override val reverse: Boolean, override val includeTimetoken: Boolean, override val includeMeta: Boolean, -) : EndpointCore(pubnub), HistoryInterface { +) : EndpointCore(pubnub), History { private val countParam: Int = if (count in 1..PNHistoryResult.MAX_COUNT) { count diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryImpl.kt deleted file mode 100644 index 23e3d30ed..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/HistoryImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints - -import com.pubnub.api.endpoints.History -import com.pubnub.api.models.consumer.history.PNHistoryResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.history] - */ -class HistoryImpl internal constructor(history: HistoryInterface) : - HistoryInterface by history, - History, - EndpointImpl(history) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsEndpoint.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsEndpoint.kt index bba91bb2b..ab8a7b8e0 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsEndpoint.kt @@ -3,23 +3,24 @@ package com.pubnub.internal.endpoints import com.google.gson.JsonElement import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.MessageCounts import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.history.PNMessageCountResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.toCsv import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.messageCounts] + * @see [PubNubImpl.messageCounts] */ class MessageCountsEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channels: List, override val channelsTimetoken: List, -) : EndpointCore(pubnub), MessageCountsInterface { +) : EndpointCore(pubnub), MessageCounts { override fun validateParams() { super.validateParams() if (channels.isEmpty()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsImpl.kt deleted file mode 100644 index 46cee4c6e..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/MessageCountsImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints - -import com.pubnub.api.endpoints.MessageCounts -import com.pubnub.api.models.consumer.history.PNMessageCountResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.messageCounts] - */ -class MessageCountsImpl internal constructor(messageCounts: MessageCountsInterface) : - MessageCountsInterface by messageCounts, - MessageCounts, - EndpointImpl(messageCounts) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeEndpoint.kt similarity index 86% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeEndpoint.kt index 8276059c4..edfee085c 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeEndpoint.kt @@ -1,18 +1,19 @@ package com.pubnub.internal.endpoints +import com.pubnub.api.endpoints.Time import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.PNTimeResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import retrofit2.Response /** - * @see [PubNubCore.time] + * @see [PubNubImpl.time] */ -class TimeEndpoint(pubnub: PubNubCore, private val excludeFromRetry: Boolean = false) : +class TimeEndpoint(pubnub: PubNubImpl, private val excludeFromRetry: Boolean = false) : EndpointCore, PNTimeResult>(pubnub), - TimeInterface { + Time { override fun getAffectedChannels() = emptyList() override fun getAffectedChannelGroups() = emptyList() diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeImpl.kt deleted file mode 100644 index 8f694ac10..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/TimeImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints - -import com.pubnub.api.endpoints.Time -import com.pubnub.api.models.consumer.PNTimeResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.time] - */ -class TimeImpl internal constructor(time: TimeInterface) : - TimeInterface by time, - Time, - EndpointImpl(time) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantEndpoint.kt similarity index 94% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantEndpoint.kt index 4b51a26bb..8210e8451 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantEndpoint.kt @@ -3,13 +3,14 @@ package com.pubnub.internal.endpoints.access import com.google.gson.JsonElement import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.access.Grant import com.pubnub.api.enums.PNOperationType +import com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult +import com.pubnub.api.models.consumer.access_manager.PNAccessManagerKeyData import com.pubnub.api.retry.RetryableEndpointGroup -import com.pubnub.api.v2.BasePNConfiguration.Companion.isValid +import com.pubnub.api.v2.PNConfiguration.Companion.isValid import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.models.consumer.access_manager.PNAccessManagerGrantResult -import com.pubnub.internal.models.consumer.access_manager.PNAccessManagerKeyData +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.Envelope import com.pubnub.internal.models.server.access_manager.AccessManagerGrantPayload import com.pubnub.internal.toCsv @@ -17,10 +18,10 @@ import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.grant] + * @see [PubNubImpl.grant] */ open class GrantEndpoint( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val read: Boolean = false, override val write: Boolean = false, override val manage: Boolean = false, @@ -33,7 +34,7 @@ open class GrantEndpoint( override val channels: List = emptyList(), override val channelGroups: List = emptyList(), override val uuids: List = emptyList(), -) : EndpointCore, PNAccessManagerGrantResult>(pubnub), GrantInterface { +) : EndpointCore, PNAccessManagerGrantResult>(pubnub), Grant { override fun validateParams() { super.validateParams() if (!pubnub.configuration.secretKey.isValid()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantImpl.kt deleted file mode 100644 index a564e474a..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantImpl.kt +++ /dev/null @@ -1,54 +0,0 @@ -package com.pubnub.internal.endpoints.access - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult -import com.pubnub.api.models.consumer.access_manager.PNAccessManagerKeyData -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.grant] - */ -class GrantImpl internal constructor(grant: GrantEndpoint) : - DelegatingEndpoint( - grant, - ), - GrantInterface by grant, - com.pubnub.api.endpoints.access.Grant { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction(remoteAction, ::from) - } - } - -fun from(result: com.pubnub.internal.models.consumer.access_manager.PNAccessManagerGrantResult): PNAccessManagerGrantResult { - with(result) { - return PNAccessManagerGrantResult( - level, - ttl, - subscribeKey, - channels.toApi(), - channelGroups.toApi(), - ) - } -} - -private fun Map?>.toApi(): Map?> { - return mapValues { - it.value?.mapValues { from(it.value) } - } -} - -fun from(value: com.pubnub.internal.models.consumer.access_manager.PNAccessManagerKeyData): PNAccessManagerKeyData { - return PNAccessManagerKeyData().apply { - this.readEnabled = value.readEnabled - this.manageEnabled = value.manageEnabled - this.writeEnabled = value.writeEnabled - this.deleteEnabled = value.deleteEnabled - this.getEnabled = value.getEnabled - this.updateEnabled = value.updateEnabled - this.joinEnabled = value.joinEnabled - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenEndpoint.kt similarity index 86% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenEndpoint.kt index 44888219f..19dc000e7 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenEndpoint.kt @@ -2,29 +2,30 @@ package com.pubnub.internal.endpoints.access import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.access.GrantToken import com.pubnub.api.enums.PNOperationType +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant import com.pubnub.api.retry.RetryableEndpointGroup -import com.pubnub.api.v2.BasePNConfiguration.Companion.isValid +import com.pubnub.api.v2.PNConfiguration.Companion.isValid import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant -import com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.access_manager.v3.GrantTokenRequestBody import com.pubnub.internal.models.server.access_manager.v3.GrantTokenResponse import retrofit2.Call import retrofit2.Response class GrantTokenEndpoint( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val ttl: Int, private val meta: Any?, private val authorizedUUID: String?, private val channels: List, private val channelGroups: List, private val uuids: List, -) : EndpointCore(pubnub), GrantTokenInterface { +) : EndpointCore(pubnub), GrantToken { override fun getAffectedChannels(): List = channels.map { it.id } override fun getAffectedChannelGroups(): List = channelGroups.map { it.id } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenImpl.kt deleted file mode 100644 index b573aab7f..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/GrantTokenImpl.kt +++ /dev/null @@ -1,10 +0,0 @@ -package com.pubnub.internal.endpoints.access - -import com.pubnub.api.endpoints.access.GrantToken -import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult -import com.pubnub.internal.EndpointImpl - -class GrantTokenImpl internal constructor(grantToken: GrantTokenInterface) : - EndpointImpl(grantToken), - GrantTokenInterface by grantToken, - GrantToken diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenEndpoint.kt similarity index 89% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenEndpoint.kt index 0fb4d368c..789e8f017 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenEndpoint.kt @@ -2,20 +2,21 @@ package com.pubnub.internal.endpoints.access import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.access.RevokeToken import com.pubnub.api.enums.PNOperationType import com.pubnub.api.retry.RetryableEndpointGroup -import com.pubnub.api.v2.BasePNConfiguration.Companion.isValid +import com.pubnub.api.v2.PNConfiguration.Companion.isValid import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.access_manager.v3.RevokeTokenResponse import retrofit2.Call import retrofit2.Response import java.net.URLEncoder class RevokeTokenEndpoint( - pubnub: PubNubCore, + pubnub: PubNubImpl, private val token: String, -) : EndpointCore(pubnub), RevokeTokenInterface { +) : EndpointCore(pubnub), RevokeToken { override fun validateParams() { super.validateParams() if (!pubnub.configuration.secretKey.isValid()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenImpl.kt deleted file mode 100644 index f9a20efcf..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/access/RevokeTokenImpl.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.pubnub.internal.endpoints.access - -import com.pubnub.api.endpoints.access.RevokeToken -import com.pubnub.internal.EndpointImpl - -class RevokeTokenImpl internal constructor(token: RevokeTokenInterface) : - RevokeTokenInterface by token, - RevokeToken, - EndpointImpl(token) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupEndpoint.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupEndpoint.kt index 2320e36dd..18550b48d 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupEndpoint.kt @@ -2,23 +2,24 @@ package com.pubnub.internal.endpoints.channel_groups import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.toCsv import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.addChannelsToChannelGroup] + * @see [PubNubImpl.addChannelsToChannelGroup] */ class AddChannelChannelGroupEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channelGroup: String, override val channels: List, -) : EndpointCore(pubnub), AddChannelChannelGroupInterface { +) : EndpointCore(pubnub), AddChannelChannelGroup { override fun getAffectedChannels() = channels override fun getAffectedChannelGroups() = listOf(channelGroup) diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupImpl.kt deleted file mode 100644 index 1ec2017e6..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AddChannelChannelGroupImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups - -import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.addChannelsToChannelGroup] - */ -class AddChannelChannelGroupImpl internal constructor(addChannelChannelGroup: AddChannelChannelGroupInterface) : - AddChannelChannelGroupInterface by addChannelChannelGroup, - AddChannelChannelGroup, - EndpointImpl(addChannelChannelGroup) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupEndpoint.kt similarity index 88% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupEndpoint.kt index 6570dad85..7c6c074cf 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupEndpoint.kt @@ -2,23 +2,24 @@ package com.pubnub.internal.endpoints.channel_groups import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.Envelope import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.listChannelsForChannelGroup] + * @see [PubNubImpl.listChannelsForChannelGroup] */ class AllChannelsChannelGroupEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channelGroup: String, ) : EndpointCore>, PNChannelGroupsAllChannelsResult>(pubnub), - AllChannelsChannelGroupInterface { + AllChannelsChannelGroup { override fun getAffectedChannelGroups() = listOf(channelGroup) override fun validateParams() { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt deleted file mode 100644 index ba95de1d6..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/AllChannelsChannelGroupImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups - -import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.listChannelsForChannelGroup] - */ -class AllChannelsChannelGroupImpl internal constructor(allChannelsChannelGroup: AllChannelsChannelGroupInterface) : - AllChannelsChannelGroupInterface by allChannelsChannelGroup, - AllChannelsChannelGroup, - EndpointImpl(allChannelsChannelGroup) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupEndpoint.kt similarity index 88% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupEndpoint.kt index 3d2cd27b8..f06ba172d 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupEndpoint.kt @@ -2,21 +2,22 @@ package com.pubnub.internal.endpoints.channel_groups import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.deleteChannelGroup] + * @see [PubNubImpl.deleteChannelGroup] */ class DeleteChannelGroupEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channelGroup: String, -) : EndpointCore(pubnub), DeleteChannelGroupInterface { +) : EndpointCore(pubnub), DeleteChannelGroup { override fun validateParams() { super.validateParams() if (channelGroup.isBlank()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupImpl.kt deleted file mode 100644 index 31f64fc06..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/DeleteChannelGroupImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups - -import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.deleteChannelGroup] - */ -class DeleteChannelGroupImpl internal constructor(deleteChannelGroup: DeleteChannelGroupInterface) : - DeleteChannelGroupInterface by deleteChannelGroup, - DeleteChannelGroup, - EndpointImpl(deleteChannelGroup) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupEndpoint.kt similarity index 87% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupEndpoint.kt index 97ca1f63b..d9bf4ec70 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupEndpoint.kt @@ -1,20 +1,21 @@ package com.pubnub.internal.endpoints.channel_groups +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.Envelope import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.listAllChannelGroups] + * @see [PubNubImpl.listAllChannelGroups] */ -class ListAllChannelGroupEndpoint internal constructor(pubnub: PubNubCore) : +class ListAllChannelGroupEndpoint internal constructor(pubnub: PubNubImpl) : EndpointCore>, PNChannelGroupsListAllResult>(pubnub), - ListAllChannelGroupInterface { + ListAllChannelGroup { override fun doWork(queryParams: HashMap): Call>> { return retrofitManager.channelGroupService .listAllChannelGroup( diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupImpl.kt deleted file mode 100644 index 19d87b2af..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/ListAllChannelGroupImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups - -import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.listAllChannelGroups] - */ -class ListAllChannelGroupImpl internal constructor(listAllChannelGroup: ListAllChannelGroupInterface) : - ListAllChannelGroupInterface by listAllChannelGroup, - ListAllChannelGroup, - EndpointImpl(listAllChannelGroup) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupEndpoint.kt similarity index 89% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupEndpoint.kt index f251e2925..2e9bda8b0 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupEndpoint.kt @@ -2,23 +2,24 @@ package com.pubnub.internal.endpoints.channel_groups import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.toCsv import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.removeChannelsFromChannelGroup] + * @see [PubNubImpl.removeChannelsFromChannelGroup] */ class RemoveChannelChannelGroupEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channelGroup: String, override val channels: List, -) : EndpointCore(pubnub), RemoveChannelChannelGroupInterface { +) : EndpointCore(pubnub), RemoveChannelChannelGroup { override fun getAffectedChannels() = channels override fun getAffectedChannelGroups() = listOf(channelGroup) diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt deleted file mode 100644 index 897cadc0a..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/channel_groups/RemoveChannelChannelGroupImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.channel_groups - -import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup -import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.removeChannelsFromChannelGroup] - */ -class RemoveChannelChannelGroupImpl internal constructor(removeChannelChannelGroup: RemoveChannelChannelGroupInterface) : - RemoveChannelChannelGroupInterface by removeChannelChannelGroup, - RemoveChannelChannelGroup, - EndpointImpl(removeChannelChannelGroup) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileEndpoint.kt similarity index 89% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileEndpoint.kt index 5d78d2f62..282f3d5c6 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileEndpoint.kt @@ -2,23 +2,24 @@ package com.pubnub.internal.endpoints.files import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.files.DeleteFile import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.files.PNDeleteFileResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.deleteFile] + * @see [PubNubImpl.deleteFile] */ class DeleteFileEndpoint( private val channel: String, private val fileName: String, private val fileId: String, - pubNub: PubNubCore, -) : EndpointCore(pubNub), DeleteFileInterface { + pubNub: PubNubImpl, +) : EndpointCore(pubNub), DeleteFile { @Throws(PubNubException::class) override fun validateParams() { if (channel.isEmpty()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileImpl.kt deleted file mode 100644 index 8cfcb6a3e..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DeleteFileImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.endpoints.files.DeleteFile -import com.pubnub.api.models.consumer.files.PNDeleteFileResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.deleteFile] - */ -class DeleteFileImpl internal constructor(deleteFile: DeleteFileInterface) : - DeleteFileInterface by deleteFile, - DeleteFile, - EndpointImpl(deleteFile) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileEndpoint.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileEndpoint.kt index 3403cfe39..1e51c78e4 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileEndpoint.kt @@ -3,25 +3,26 @@ package com.pubnub.internal.endpoints.files import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException import com.pubnub.api.crypto.CryptoModule +import com.pubnub.api.endpoints.files.DownloadFile import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.files.PNDownloadFileResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import okhttp3.ResponseBody import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.downloadFile] + * @see [PubNubImpl.downloadFile] */ class DownloadFileEndpoint( private val channel: String, private val fileName: String, private val fileId: String, private val cryptoModule: CryptoModule? = null, - pubNub: PubNubCore, -) : EndpointCore(pubNub), DownloadFileInterface { + pubNub: PubNubImpl, +) : EndpointCore(pubNub), DownloadFile { @Throws(PubNubException::class) override fun validateParams() { if (channel.isEmpty()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileImpl.kt deleted file mode 100644 index a8f8065ab..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/DownloadFileImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.endpoints.files.DownloadFile -import com.pubnub.api.models.consumer.files.PNDownloadFileResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.downloadFile] - */ -class DownloadFileImpl internal constructor(downloadFile: DownloadFileInterface) : - DownloadFileInterface by downloadFile, - DownloadFile, - EndpointImpl(downloadFile) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GenerateUploadUrlEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GenerateUploadUrlEndpoint.kt similarity index 96% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GenerateUploadUrlEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GenerateUploadUrlEndpoint.kt index 708ccbbc7..2d2056af1 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GenerateUploadUrlEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GenerateUploadUrlEndpoint.kt @@ -6,7 +6,7 @@ import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.enums.PNOperationType import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.files.FileUploadRequestDetails import com.pubnub.internal.models.server.files.FormField import com.pubnub.internal.models.server.files.GenerateUploadUrlPayload @@ -17,7 +17,7 @@ import retrofit2.Response internal class GenerateUploadUrlEndpoint( private val channel: String, private val fileName: String, - pubNub: PubNubCore, + pubNub: PubNubImpl, ) : EndpointCore(pubNub) { @Throws(PubNubException::class) override fun validateParams() { @@ -73,7 +73,7 @@ internal class GenerateUploadUrlEndpoint( override fun isPubKeyRequired(): Boolean = false - internal class Factory(private val pubNub: PubNubCore) { + internal class Factory(private val pubNub: PubNubImpl) { fun create( channel: String, fileName: String, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlEndpoint.kt similarity index 95% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlEndpoint.kt index 0fb790912..171ebc042 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlEndpoint.kt @@ -2,12 +2,13 @@ package com.pubnub.internal.endpoints.files import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.files.GetFileUrl import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.files.PNFileUrlResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.api.v2.callbacks.Result import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.PubNubUtil import okhttp3.ResponseBody import retrofit2.Call @@ -17,14 +18,14 @@ import java.util.concurrent.Executors import java.util.function.Consumer /** - * @see [PubNubCore.getFileUrl] + * @see [PubNubImpl.getFileUrl] */ class GetFileUrlEndpoint( private val channel: String, private val fileName: String, private val fileId: String, - pubNub: PubNubCore, -) : EndpointCore(pubNub), GetFileUrlInterface { + pubNub: PubNubImpl, +) : EndpointCore(pubNub), GetFileUrl { private lateinit var cachedCallback: Consumer> private val executorService: ExecutorService = retrofitManager.getTransactionClientExecutorService() ?: Executors.newSingleThreadExecutor() @@ -56,7 +57,7 @@ class GetFileUrlEndpoint( PubNubUtil.signRequest( call.request(), pubnub.configuration, - PubNubCore.timestamp(), + PubNubImpl.timestamp(), ) PNFileUrlResult(signedRequest.url.toString()) } catch (e: Exception) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlImpl.kt deleted file mode 100644 index 9b69dd6c1..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/GetFileUrlImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.endpoints.files.GetFileUrl -import com.pubnub.api.models.consumer.files.PNFileUrlResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.getFileUrl] - */ -class GetFileUrlImpl internal constructor(getFileUrl: GetFileUrlInterface) : - GetFileUrlInterface by getFileUrl, - GetFileUrl, - EndpointImpl(getFileUrl) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesEndpoint.kt similarity index 95% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesEndpoint.kt index 706b0900a..e5e9868c8 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesEndpoint.kt @@ -2,25 +2,26 @@ package com.pubnub.internal.endpoints.files import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.files.ListFiles import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.files.PNListFilesResult import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.files.ListFilesResult import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.listFiles] + * @see [PubNubImpl.listFiles] */ class ListFilesEndpoint( private val channel: String, private val limit: Int? = null, private val next: PNPage.PNNext? = null, - pubNub: PubNubCore, -) : EndpointCore(pubNub), ListFilesInterface { + pubNub: PubNubImpl, +) : EndpointCore(pubNub), ListFiles { @Throws(PubNubException::class) override fun validateParams() { if (channel.isEmpty()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesImpl.kt deleted file mode 100644 index 2cd6aca9c..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/ListFilesImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.endpoints.files.ListFiles -import com.pubnub.api.models.consumer.files.PNListFilesResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.listFiles] - */ -class ListFilesImpl internal constructor(listFiles: ListFilesInterface) : - ListFilesInterface by listFiles, - ListFiles, - EndpointImpl(listFiles) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageEndpoint.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageEndpoint.kt index 494fa32bc..db7c45f67 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageEndpoint.kt @@ -2,13 +2,14 @@ package com.pubnub.internal.endpoints.files import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.files.PublishFileMessage import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.files.PNBaseFile import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.crypto.encryptString import com.pubnub.internal.extension.numericString import com.pubnub.internal.extension.quoted @@ -17,7 +18,7 @@ import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.publishFileMessage] + * @see [PubNubImpl.publishFileMessage] */ open class PublishFileMessageEndpoint( private val channel: String, @@ -27,8 +28,8 @@ open class PublishFileMessageEndpoint( private val meta: Any? = null, private val ttl: Int? = null, private val shouldStore: Boolean? = null, - pubNub: PubNubCore, -) : EndpointCore, PNPublishFileMessageResult>(pubNub), PublishFileMessageInterface { + pubNub: PubNubImpl, +) : EndpointCore, PNPublishFileMessageResult>(pubNub), PublishFileMessage { private val pnFile = PNBaseFile(fileId, fileName) @Throws(PubNubException::class) @@ -78,7 +79,7 @@ open class PublishFileMessageEndpoint( override fun isPubKeyRequired(): Boolean = true - internal class Factory(private val pubNub: PubNubCore) { + internal class Factory(private val pubNub: PubNubImpl) { fun create( channel: String, fileName: String, diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageImpl.kt deleted file mode 100644 index bd9390952..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/PublishFileMessageImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.endpoints.files.PublishFileMessage -import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.publishFileMessage] - */ -class PublishFileMessageImpl internal constructor(publishFileMessage: PublishFileMessageInterface) : - PublishFileMessageInterface by publishFileMessage, - PublishFileMessage, - EndpointImpl(publishFileMessage) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileEndpoint.kt similarity index 97% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileEndpoint.kt index 5fe5fcc82..6bc5a2c05 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileEndpoint.kt @@ -3,6 +3,7 @@ package com.pubnub.internal.endpoints.files import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException import com.pubnub.api.crypto.CryptoModule +import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.remoteaction.ComposableRemoteAction import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.endpoints.remoteaction.map @@ -11,7 +12,7 @@ import com.pubnub.api.models.consumer.files.PNBaseFile import com.pubnub.api.models.consumer.files.PNFileUploadResult import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult import com.pubnub.api.v2.callbacks.Result -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.crypto.cryptor.InputStreamSeparator import com.pubnub.internal.endpoints.remoteaction.RetryingRemoteAction import com.pubnub.internal.models.server.files.FileUploadRequestDetails @@ -22,7 +23,7 @@ import java.util.concurrent.atomic.AtomicReference import java.util.function.Consumer /** - * @see [PubNubCore.sendFile] + * @see [PubNubImpl.sendFile] */ class SendFileEndpoint internal constructor( private val channel: String, @@ -38,7 +39,7 @@ class SendFileEndpoint internal constructor( publishFileMessageFactory: PublishFileMessageEndpoint.Factory, sendFileToS3Factory: UploadFileEndpoint.Factory, cryptoModule: CryptoModule? = null, -) : SendFileInterface { +) : SendFile { private val sendFileMultistepAction: ExtendedRemoteAction = sendFileComposedActions( generateUploadUrlFactory, diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileImpl.kt deleted file mode 100644 index 4f3dfed0d..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/SendFileImpl.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.pubnub.internal.endpoints.files - -import com.pubnub.api.endpoints.files.SendFile -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.sendFile] - */ -class SendFileImpl internal constructor(sendFile: SendFileInterface) : SendFileInterface by sendFile, SendFile diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/UploadFileEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/UploadFileEndpoint.kt similarity index 98% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/UploadFileEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/UploadFileEndpoint.kt index bc51f3392..b77373485 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/UploadFileEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/files/UploadFileEndpoint.kt @@ -5,7 +5,7 @@ import com.pubnub.api.PubNubException import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction import com.pubnub.api.enums.PNOperationType import com.pubnub.api.v2.callbacks.Result -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.files.FileUploadRequestDetails import com.pubnub.internal.models.server.files.FormField import com.pubnub.internal.services.S3Service @@ -169,7 +169,7 @@ internal class UploadFileEndpoint( return elements.item(0)?.firstChild?.nodeValue ?: "N/A" } - internal class Factory(private val pubNub: PubNubCore) { + internal class Factory(private val pubNub: PubNubImpl) { fun create( fileName: String, content: ByteArray, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionEndpoint.kt similarity index 91% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionEndpoint.kt index 21c09c68c..fec91da58 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionEndpoint.kt @@ -3,25 +3,26 @@ package com.pubnub.internal.endpoints.message_actions import com.google.gson.JsonObject import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.message_actions.AddMessageAction import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.objects_api.EntityEnvelope import retrofit2.Call import retrofit2.Response import java.util.Locale /** - * @see [PubNubCore.addMessageAction] + * @see [PubNubImpl.addMessageAction] */ class AddMessageActionEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channel: String, override val messageAction: PNMessageAction, -) : EndpointCore, PNAddMessageActionResult>(pubnub), AddMessageActionInterface { +) : EndpointCore, PNAddMessageActionResult>(pubnub), AddMessageAction { override fun validateParams() { super.validateParams() if (channel.isBlank()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionImpl.kt deleted file mode 100644 index 7e9b4a30a..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/AddMessageActionImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.message_actions - -import com.pubnub.api.endpoints.message_actions.AddMessageAction -import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.addMessageAction] - */ -class AddMessageActionImpl internal constructor(addMessageAction: AddMessageActionInterface) : - AddMessageActionInterface by addMessageAction, - AddMessageAction, - EndpointImpl(addMessageAction) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsEndpoint.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsEndpoint.kt index 68728efc6..07b3455ac 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsEndpoint.kt @@ -2,24 +2,25 @@ package com.pubnub.internal.endpoints.message_actions import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.message_actions.GetMessageActions import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import retrofit2.Call import retrofit2.Response import java.util.Locale /** - * @see [PubNubCore.getMessageActions] + * @see [PubNubImpl.getMessageActions] */ class GetMessageActionsEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channel: String, override val page: PNBoundedPage, -) : EndpointCore(pubnub), GetMessageActionsInterface { +) : EndpointCore(pubnub), GetMessageActions { override fun validateParams() { super.validateParams() if (channel.isBlank()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsImpl.kt deleted file mode 100644 index 0db56d267..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/GetMessageActionsImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.message_actions - -import com.pubnub.api.endpoints.message_actions.GetMessageActions -import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.getMessageActions] - */ -class GetMessageActionsImpl internal constructor(getMessageActions: GetMessageActionsInterface) : - GetMessageActionsInterface by getMessageActions, - GetMessageActions, - EndpointImpl(getMessageActions) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionEndpoint.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionEndpoint.kt index df47772d3..82126bb31 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionEndpoint.kt @@ -2,24 +2,25 @@ package com.pubnub.internal.endpoints.message_actions import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import retrofit2.Call import retrofit2.Response import java.util.Locale /** - * @see [PubNubCore.removeMessageAction] + * @see [PubNubImpl.removeMessageAction] */ class RemoveMessageActionEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channel: String, override val messageTimetoken: Long, override val actionTimetoken: Long, -) : EndpointCore(pubnub), RemoveMessageActionInterface { +) : EndpointCore(pubnub), RemoveMessageAction { override fun validateParams() { super.validateParams() if (channel.isBlank()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionImpl.kt deleted file mode 100644 index 847eb143b..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/message_actions/RemoveMessageActionImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.message_actions - -import com.pubnub.api.endpoints.message_actions.RemoveMessageAction -import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.removeMessageAction] - */ -class RemoveMessageActionImpl internal constructor(removeMessageAction: RemoveMessageActionInterface) : - RemoveMessageActionInterface by removeMessageAction, - RemoveMessageAction, - EndpointImpl(removeMessageAction) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataEndpoint.kt similarity index 87% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataEndpoint.kt index 801a72f25..064635fe4 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataEndpoint.kt @@ -1,27 +1,28 @@ package com.pubnub.internal.endpoints.objects.channel +import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataArrayResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.objects.internal.CollectionQueryParameters import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam -import com.pubnub.internal.models.consumer.objects.channel.PNChannelMetadataArrayResult import com.pubnub.internal.models.server.objects_api.EntityArrayEnvelope import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.getAllChannelMetadata] + * @see [PubNubImpl.getAllChannelMetadata] */ class GetAllChannelMetadataEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, private val collectionQueryParameters: CollectionQueryParameters, private val includeQueryParam: IncludeQueryParam, ) : EndpointCore, PNChannelMetadataArrayResult>(pubnub), - GetAllChannelMetadataInterface { + GetAllChannelMetadata { override fun doWork(queryParams: HashMap): Call> { val params = queryParams + collectionQueryParameters.createCollectionQueryParams() + includeQueryParam.createIncludeQueryParams() diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataImpl.kt deleted file mode 100644 index 307a457a5..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetAllChannelMetadataImpl.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.pubnub.internal.endpoints.objects.channel - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.models.consumer.objects.channel.PNChannelMetadataArrayResult - -/** - * @see [PubNubImpl.getAllChannelMetadata] - */ -class GetAllChannelMetadataImpl internal constructor(getAllChannelMetadata: GetAllChannelMetadataEndpoint) : - DelegatingEndpoint( - getAllChannelMetadata, - ), - GetAllChannelMetadataInterface by getAllChannelMetadata, - com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction( - remoteAction, - PNChannelMetadataArrayResult::toApi, - ) - } - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataEndpoint.kt similarity index 88% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataEndpoint.kt index bc4bba75d..e0b7ae22d 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataEndpoint.kt @@ -1,25 +1,25 @@ package com.pubnub.internal.endpoints.objects.channel +import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam import com.pubnub.internal.models.server.objects_api.EntityEnvelope import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.getChannelMetadata] + * @see [PubNubImpl.getChannelMetadata] */ class GetChannelMetadataEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, private val channel: String, private val includeQueryParam: IncludeQueryParam, -) : EndpointCore, PNChannelMetadataResult>(pubnub), - GetChannelMetadataInterface { +) : EndpointCore, PNChannelMetadataResult>(pubnub), GetChannelMetadata { override fun doWork(queryParams: HashMap): Call> { val params = queryParams + includeQueryParam.createIncludeQueryParams() return retrofitManager.objectsService.getChannelMetadata( diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataImpl.kt deleted file mode 100644 index 1bf7d44b5..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/GetChannelMetadataImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.objects.channel - -import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.getChannelMetadata] - */ -class GetChannelMetadataImpl internal constructor(getChannelMetadata: GetChannelMetadataInterface) : - GetChannelMetadata, - GetChannelMetadataInterface by getChannelMetadata, - EndpointImpl(getChannelMetadata) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataEndpoint.kt similarity index 82% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataEndpoint.kt index 2e59e074e..8e0c311bc 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataEndpoint.kt @@ -1,18 +1,19 @@ package com.pubnub.internal.endpoints.objects.channel +import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata import com.pubnub.api.enums.PNOperationType +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.models.consumer.objects.PNRemoveMetadataResult +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.objects_api.EntityEnvelope import retrofit2.Call import retrofit2.Response class RemoveChannelMetadataEndpoint( - pubnub: PubNubCore, + pubnub: PubNubImpl, private val channel: String, -) : EndpointCore, PNRemoveMetadataResult>(pubnub), RemoveChannelMetadataInterface { +) : EndpointCore, PNRemoveMetadataResult>(pubnub), RemoveChannelMetadata { override fun doWork(queryParams: HashMap): Call> { return retrofitManager.objectsService.deleteChannelMetadata( subKey = configuration.subscribeKey, diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataImpl.kt deleted file mode 100644 index 732ef8833..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/RemoveChannelMetadataImpl.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.pubnub.internal.endpoints.objects.channel - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.models.from - -class RemoveChannelMetadataImpl internal constructor(removeChannelMetadata: RemoveChannelMetadataEndpoint) : - DelegatingEndpoint( - removeChannelMetadata, - ), - RemoveChannelMetadataInterface by removeChannelMetadata, - com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction(remoteAction, ::from) - } - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataEndpoint.kt similarity index 91% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataEndpoint.kt index dbd6c5f30..1e9d8b497 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataEndpoint.kt @@ -1,11 +1,12 @@ package com.pubnub.internal.endpoints.objects.channel +import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam import com.pubnub.internal.models.server.objects_api.ChannelMetadataInput import com.pubnub.internal.models.server.objects_api.EntityEnvelope @@ -13,10 +14,10 @@ import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.setChannelMetadata] + * @see [PubNubImpl.setChannelMetadata] */ class SetChannelMetadataEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, private val name: String?, private val description: String?, private val custom: Any?, @@ -25,7 +26,7 @@ class SetChannelMetadataEndpoint internal constructor( private val type: String?, private val status: String?, ) : EndpointCore, PNChannelMetadataResult>(pubnub), - SetChannelMetadataInterface { + SetChannelMetadata { override fun doWork(queryParams: HashMap): Call> { val params = queryParams + includeQueryParam.createIncludeQueryParams() return retrofitManager.objectsService.setChannelMetadata( diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataImpl.kt deleted file mode 100644 index efda2fe09..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/channel/SetChannelMetadataImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.objects.channel - -import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata -import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadataResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.setChannelMetadata] - */ -class SetChannelMetadataImpl internal constructor(setChannelMetadata: SetChannelMetadataInterface) : - SetChannelMetadata, - SetChannelMetadataInterface by setChannelMetadata, - EndpointImpl(setChannelMetadata) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/CollectionQueryParameters.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/CollectionQueryParameters.kt similarity index 95% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/CollectionQueryParameters.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/CollectionQueryParameters.kt index 435359741..f6bb0b6ee 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/CollectionQueryParameters.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/CollectionQueryParameters.kt @@ -1,7 +1,7 @@ package com.pubnub.internal.endpoints.objects.internal import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.internal.models.consumer.objects.PNSortKey +import com.pubnub.api.models.consumer.objects.PNSortKey data class CollectionQueryParameters( private val limit: Int? = null, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/IncludeQueryParam.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/IncludeQueryParam.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/IncludeQueryParam.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/IncludeQueryParam.kt index 0e2c07575..8be289b8b 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/IncludeQueryParam.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/internal/IncludeQueryParam.kt @@ -1,7 +1,7 @@ package com.pubnub.internal.endpoints.objects.internal -import com.pubnub.internal.models.consumer.objects.member.PNUUIDDetailsLevel -import com.pubnub.internal.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel data class IncludeQueryParam( private val includeCustom: Boolean = false, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersEndpoint.kt similarity index 82% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersEndpoint.kt index 7cf3f9910..611bedbce 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersEndpoint.kt @@ -1,27 +1,28 @@ package com.pubnub.internal.endpoints.objects.member +import com.pubnub.api.endpoints.objects.member.GetChannelMembers import com.pubnub.api.enums.PNOperationType +import com.pubnub.api.models.consumer.objects.member.PNMember +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.objects.internal.CollectionQueryParameters import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam import com.pubnub.internal.extension.toPNMemberArrayResult -import com.pubnub.internal.models.consumer.objects.member.PNMember -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult import com.pubnub.internal.models.server.objects_api.EntityArrayEnvelope import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.getChannelMembers] + * @see [PubNubImpl.getChannelMembers] */ class GetChannelMembersEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, private val channel: String, private val collectionQueryParameters: CollectionQueryParameters, private val includeQueryParam: IncludeQueryParam, -) : EndpointCore, PNMemberArrayResult>(pubnub), GetChannelMembersInterface { +) : EndpointCore, PNMemberArrayResult>(pubnub), GetChannelMembers { override fun doWork(queryParams: HashMap): Call> { val params = queryParams + collectionQueryParameters.createCollectionQueryParams() + includeQueryParam.createIncludeQueryParams() diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersImpl.kt deleted file mode 100644 index 5b24553a6..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/GetChannelMembersImpl.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.pubnub.internal.endpoints.objects.member - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult -import com.pubnub.internal.models.from - -/** - * @see [PubNubImpl.getChannelMembers] - */ -class GetChannelMembersImpl internal constructor(getChannelMembers: GetChannelMembersEndpoint) : - DelegatingEndpoint( - getChannelMembers, - ), - GetChannelMembersInterface by getChannelMembers, - com.pubnub.api.endpoints.objects.member.GetChannelMembers { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction( - remoteAction, - ::from, - ) - } - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersEndpoint.kt similarity index 85% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersEndpoint.kt index 2b188278a..5dfc1080e 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersEndpoint.kt @@ -1,15 +1,16 @@ package com.pubnub.internal.endpoints.objects.member +import com.pubnub.api.endpoints.objects.member.ManageChannelMembers import com.pubnub.api.enums.PNOperationType +import com.pubnub.api.models.consumer.objects.member.MemberInput +import com.pubnub.api.models.consumer.objects.member.PNMember +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.objects.internal.CollectionQueryParameters import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam import com.pubnub.internal.extension.toPNMemberArrayResult -import com.pubnub.internal.models.consumer.objects.member.MemberInput -import com.pubnub.internal.models.consumer.objects.member.PNMember -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult import com.pubnub.internal.models.server.objects_api.ChangeMemberInput import com.pubnub.internal.models.server.objects_api.EntityArrayEnvelope import com.pubnub.internal.models.server.objects_api.ServerMemberInput @@ -18,16 +19,16 @@ import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.manageChannelMembers] + * @see [PubNubImpl.manageChannelMembers] */ class ManageChannelMembersEndpoint( - pubnub: PubNubCore, + pubnub: PubNubImpl, private val uuidsToSet: Collection, private val uuidsToRemove: Collection, private val channel: String, private val collectionQueryParameters: CollectionQueryParameters, private val includeQueryParam: IncludeQueryParam, -) : EndpointCore, PNMemberArrayResult>(pubnub), ManageChannelMembersInterface { +) : EndpointCore, PNMemberArrayResult>(pubnub), ManageChannelMembers { override fun doWork(queryParams: HashMap): Call> { val params = queryParams + collectionQueryParameters.createCollectionQueryParams() + includeQueryParam.createIncludeQueryParams() diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersImpl.kt deleted file mode 100644 index 582356e99..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/member/ManageChannelMembersImpl.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.pubnub.internal.endpoints.objects.member - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult -import com.pubnub.internal.models.from - -/** - * @see [PubNubImpl.manageChannelMembers] - */ -class ManageChannelMembersImpl internal constructor(manageChannelMembers: ManageChannelMembersEndpoint) : - DelegatingEndpoint( - manageChannelMembers, - ), - ManageChannelMembersInterface by manageChannelMembers, - com.pubnub.api.endpoints.objects.member.ManageChannelMembers { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction( - remoteAction, - ::from, - ) - } - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsEndpoint.kt similarity index 82% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsEndpoint.kt index b1028e816..a4e9b33ca 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsEndpoint.kt @@ -1,28 +1,29 @@ package com.pubnub.internal.endpoints.objects.membership +import com.pubnub.api.endpoints.objects.membership.GetMemberships import com.pubnub.api.enums.PNOperationType +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.objects.internal.CollectionQueryParameters import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam import com.pubnub.internal.extension.toPNChannelMembershipArrayResult -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult import com.pubnub.internal.models.server.objects_api.EntityArrayEnvelope import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.getMemberships] + * @see [PubNubImpl.getMemberships] */ class GetMembershipsEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, private val uuid: String, private val collectionQueryParameters: CollectionQueryParameters, private val includeQueryParam: IncludeQueryParam, ) : EndpointCore, PNChannelMembershipArrayResult>(pubnub), - GetMembershipsInterface { + GetMemberships { override fun doWork(queryParams: HashMap): Call> { val params = queryParams + collectionQueryParameters.createCollectionQueryParams() + includeQueryParam.createIncludeQueryParams() diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsImpl.kt deleted file mode 100644 index d5fedb403..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/GetMembershipsImpl.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.pubnub.internal.endpoints.objects.membership - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.models.toApi - -/** - * @see [PubNubImpl.getMemberships] - */ -class GetMembershipsImpl internal constructor(getMemberships: GetMembershipsEndpoint) : - DelegatingEndpoint( - getMemberships, - ), - GetMembershipsInterface by getMemberships, - com.pubnub.api.endpoints.objects.membership.GetMemberships { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction( - remoteAction, - com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult::toApi, - ) - } - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsEndpoint.kt similarity index 85% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsEndpoint.kt index c9a235990..f6bea51e8 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsEndpoint.kt @@ -1,15 +1,16 @@ package com.pubnub.internal.endpoints.objects.membership +import com.pubnub.api.endpoints.objects.membership.ManageMemberships import com.pubnub.api.enums.PNOperationType +import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.objects.internal.CollectionQueryParameters import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam import com.pubnub.internal.extension.toPNChannelMembershipArrayResult -import com.pubnub.internal.models.consumer.objects.membership.ChannelMembershipInput -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult import com.pubnub.internal.models.server.objects_api.ChangeMembershipInput import com.pubnub.internal.models.server.objects_api.ChannelId import com.pubnub.internal.models.server.objects_api.EntityArrayEnvelope @@ -18,17 +19,17 @@ import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.manageMemberships] + * @see [PubNubImpl.manageMemberships] */ class ManageMembershipsEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, private val channelsToSet: Collection, private val channelsToRemove: Collection, private val uuid: String, private val collectionQueryParameters: CollectionQueryParameters, private val includeQueryParam: IncludeQueryParam, ) : EndpointCore, PNChannelMembershipArrayResult>(pubnub), - ManageMembershipsInterface { + ManageMemberships { override fun doWork(queryParams: HashMap): Call> { val params = queryParams + collectionQueryParameters.createCollectionQueryParams() + diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsImpl.kt deleted file mode 100644 index 0cf63323d..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/membership/ManageMembershipsImpl.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.pubnub.internal.endpoints.objects.membership - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.models.toApi - -/** - * @see [PubNubImpl.manageMemberships] - */ -class ManageMembershipsImpl internal constructor(manageMemberships: ManageMembershipsEndpoint) : - DelegatingEndpoint( - manageMemberships, - ), - ManageMembershipsInterface by manageMemberships, - com.pubnub.api.endpoints.objects.membership.ManageMemberships { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction( - remoteAction, - com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult::toApi, - ) - } - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataEndpoint.kt similarity index 88% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataEndpoint.kt index daee77d83..33a715995 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataEndpoint.kt @@ -1,27 +1,28 @@ package com.pubnub.internal.endpoints.objects.uuid +import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.objects.PNPage import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.objects.internal.CollectionQueryParameters import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam -import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataArrayResult import com.pubnub.internal.models.server.objects_api.EntityArrayEnvelope import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.getAllUUIDMetadata] + * @see [PubNubImpl.getAllUUIDMetadata] */ class GetAllUUIDMetadataEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, private val collectionQueryParameters: CollectionQueryParameters, private val withInclude: IncludeQueryParam, ) : EndpointCore, PNUUIDMetadataArrayResult>(pubnub), - GetAllUUIDMetadataInterface { + GetAllUUIDMetadata { override fun doWork(queryParams: HashMap): Call> { val params = queryParams + collectionQueryParameters.createCollectionQueryParams() + withInclude.createIncludeQueryParams() diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt deleted file mode 100644 index 512cef1fe..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetAllUUIDMetadataImpl.kt +++ /dev/null @@ -1,27 +0,0 @@ -package com.pubnub.internal.endpoints.objects.uuid - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataArrayResult -import com.pubnub.internal.models.from - -/** - * @see [PubNubImpl.getAllUUIDMetadata] - */ -class GetAllUUIDMetadataImpl internal constructor(getAllUUIDMetadata: GetAllUUIDMetadataEndpoint) : - DelegatingEndpoint( - getAllUUIDMetadata, - ), - GetAllUUIDMetadataInterface by getAllUUIDMetadata, - com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction( - remoteAction, - ::from, - ) - } - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataEndpoint.kt similarity index 84% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataEndpoint.kt index f9d5d630b..c72bf298b 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataEndpoint.kt @@ -1,24 +1,25 @@ package com.pubnub.internal.endpoints.objects.uuid +import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam -import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.internal.models.server.objects_api.EntityEnvelope import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.getUUIDMetadata] + * @see [PubNubImpl.getUUIDMetadata] */ class GetUUIDMetadataEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val uuid: String, private val includeQueryParam: IncludeQueryParam, -) : EndpointCore, PNUUIDMetadataResult>(pubnub), GetUUIDMetadataInterface { +) : EndpointCore, PNUUIDMetadataResult>(pubnub), GetUUIDMetadata { override fun doWork(queryParams: HashMap): Call> { val params = queryParams + includeQueryParam.createIncludeQueryParams() return retrofitManager.objectsService.getUUIDMetadata( diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataImpl.kt deleted file mode 100644 index a294bc755..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/GetUUIDMetadataImpl.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.pubnub.internal.endpoints.objects.uuid - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.models.from -import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataResult as PNUUIDMetadataResultInternal - -/** - * @see [PubNubImpl.getUUIDMetadata] - */ -class GetUUIDMetadataImpl internal constructor(getUUIDMetadata: GetUUIDMetadataEndpoint) : - DelegatingEndpoint(getUUIDMetadata), - GetUUIDMetadataInterface by getUUIDMetadata, - com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction(remoteAction, ::from) - } - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataEndpoint.kt similarity index 82% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataEndpoint.kt index 7592e727c..45ef82e1c 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataEndpoint.kt @@ -1,18 +1,19 @@ package com.pubnub.internal.endpoints.objects.uuid +import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata import com.pubnub.api.enums.PNOperationType +import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.models.consumer.objects.PNRemoveMetadataResult +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.objects_api.EntityEnvelope import retrofit2.Call import retrofit2.Response class RemoveUUIDMetadataEndpoint( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val uuid: String? = null, -) : EndpointCore, PNRemoveMetadataResult>(pubnub), RemoveUUIDMetadataInterface { +) : EndpointCore, PNRemoveMetadataResult>(pubnub), RemoveUUIDMetadata { override fun doWork(queryParams: HashMap): Call> { return retrofitManager.objectsService.deleteUUIDMetadata( subKey = configuration.subscribeKey, diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt deleted file mode 100644 index 494bcd94f..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/RemoveUUIDMetadataImpl.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.pubnub.internal.endpoints.objects.uuid - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.models.from - -class RemoveUUIDMetadataImpl internal constructor(removeUUIDMetadata: RemoveUUIDMetadataEndpoint) : - DelegatingEndpoint( - removeUUIDMetadata, - ), - RemoveUUIDMetadataInterface by removeUUIDMetadata, - com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction(remoteAction, ::from) - } - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataEndpoint.kt similarity index 89% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataEndpoint.kt index 55b3b6340..375618ae5 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataEndpoint.kt @@ -1,22 +1,23 @@ package com.pubnub.internal.endpoints.objects.uuid +import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata +import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.objects.internal.IncludeQueryParam -import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataResult import com.pubnub.internal.models.server.objects_api.EntityEnvelope import com.pubnub.internal.models.server.objects_api.UUIDMetadataInput import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.setUUIDMetadata] + * @see [PubNubImpl.setUUIDMetadata] */ class SetUUIDMetadataEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, private val uuid: String?, private val name: String?, private val externalId: String?, @@ -26,7 +27,7 @@ class SetUUIDMetadataEndpoint internal constructor( private val withInclude: IncludeQueryParam, private val type: String?, private val status: String?, -) : EndpointCore, PNUUIDMetadataResult>(pubnub), SetUUIDMetadataInterface { +) : EndpointCore, PNUUIDMetadataResult>(pubnub), SetUUIDMetadata { override fun doWork(queryParams: HashMap): Call> { val params = queryParams + withInclude.createIncludeQueryParams() return retrofitManager.objectsService.setUUIDMetadata( diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataImpl.kt deleted file mode 100644 index 4d9c20c8c..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/objects/uuid/SetUUIDMetadataImpl.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.pubnub.internal.endpoints.objects.uuid - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataResult -import com.pubnub.internal.models.from - -/** - * @see [PubNubImpl.setUUIDMetadata] - */ -class SetUUIDMetadataImpl internal constructor(setUUIDMetadata: SetUUIDMetadataEndpoint) : - DelegatingEndpoint( - setUUIDMetadata, - ), - SetUUIDMetadataInterface by setUUIDMetadata, - com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction(remoteAction, ::from) - } - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateEndpoint.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateEndpoint.kt index ea5d5a813..dbf223682 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateEndpoint.kt @@ -3,25 +3,26 @@ package com.pubnub.internal.endpoints.presence import com.google.gson.JsonElement import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.presence.GetState import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.presence.PNGetStateResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.Envelope import com.pubnub.internal.toCsv import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.getPresenceState] + * @see [PubNubImpl.getPresenceState] */ class GetStateEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channels: List, override val channelGroups: List, override val uuid: String = pubnub.configuration.userId.value, -) : EndpointCore, PNGetStateResult>(pubnub), GetStateInterface { +) : EndpointCore, PNGetStateResult>(pubnub), GetState { override fun getAffectedChannels() = channels override fun getAffectedChannelGroups() = channelGroups diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateImpl.kt deleted file mode 100644 index e2969ffe0..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/GetStateImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.presence - -import com.pubnub.api.endpoints.presence.GetState -import com.pubnub.api.models.consumer.presence.PNGetStateResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.getPresenceState] - */ -class GetStateImpl internal constructor(getState: GetStateInterface) : - GetStateInterface by getState, - GetState, - EndpointImpl(getState) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HeartbeatEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HeartbeatEndpoint.kt similarity index 97% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HeartbeatEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HeartbeatEndpoint.kt index 9b4e199dc..875ca843f 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HeartbeatEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HeartbeatEndpoint.kt @@ -5,13 +5,13 @@ import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNOperationType import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.PubNubUtil import retrofit2.Call import retrofit2.Response class HeartbeatEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, val channels: List = listOf(), val channelGroups: List = listOf(), val state: Any? = null, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowEndpoint.kt similarity index 97% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowEndpoint.kt index 9ca11fde8..ba0d8ae30 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowEndpoint.kt @@ -1,28 +1,29 @@ package com.pubnub.internal.endpoints.presence import com.google.gson.JsonElement +import com.pubnub.api.endpoints.presence.HereNow import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.presence.PNHereNowChannelData import com.pubnub.api.models.consumer.presence.PNHereNowOccupantData import com.pubnub.api.models.consumer.presence.PNHereNowResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.Envelope import com.pubnub.internal.toCsv import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.hereNow] + * @see [PubNubImpl.hereNow] */ class HereNowEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channels: List = emptyList(), override val channelGroups: List = emptyList(), override val includeState: Boolean = false, override val includeUUIDs: Boolean = true, -) : EndpointCore, PNHereNowResult>(pubnub), HereNowInterface { +) : EndpointCore, PNHereNowResult>(pubnub), HereNow { private fun isGlobalHereNow() = channels.isEmpty() && channelGroups.isEmpty() override fun getAffectedChannels() = channels diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowImpl.kt deleted file mode 100644 index 70f99f62b..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/HereNowImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.presence - -import com.pubnub.api.endpoints.presence.HereNow -import com.pubnub.api.models.consumer.presence.PNHereNowResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.hereNow] - */ -class HereNowImpl internal constructor(hereNow: HereNowInterface) : - HereNowInterface by hereNow, - HereNow, - EndpointImpl(hereNow) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/LeaveEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/LeaveEndpoint.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/LeaveEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/LeaveEndpoint.kt index ae92b1062..0a2e3e374 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/LeaveEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/LeaveEndpoint.kt @@ -5,13 +5,13 @@ import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNOperationType import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.PubNubUtil import com.pubnub.internal.toCsv import retrofit2.Call import retrofit2.Response -class LeaveEndpoint internal constructor(pubnub: PubNubCore) : EndpointCore(pubnub) { +class LeaveEndpoint internal constructor(pubnub: PubNubImpl) : EndpointCore(pubnub) { var channels = emptyList() var channelGroups = emptyList() diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateEndpoint.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateEndpoint.kt index 802c4241b..063ef3cf2 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateEndpoint.kt @@ -4,11 +4,12 @@ import com.google.gson.JsonElement import com.google.gson.JsonNull import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.presence.SetState import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.presence.PNSetStateResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.Envelope import com.pubnub.internal.presence.eventengine.data.PresenceData import com.pubnub.internal.toCsv @@ -16,16 +17,16 @@ import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.setPresenceState] + * @see [PubNubImpl.setPresenceState] */ class SetStateEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channels: List, override val channelGroups: List, override val state: Any, override val uuid: String = pubnub.configuration.userId.value, private val presenceData: PresenceData, -) : EndpointCore, PNSetStateResult>(pubnub), SetStateInterface { +) : EndpointCore, PNSetStateResult>(pubnub), SetState { override fun getAffectedChannels() = channels override fun getAffectedChannelGroups() = channelGroups diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateImpl.kt deleted file mode 100644 index 2660976ed..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/SetStateImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.presence - -import com.pubnub.api.endpoints.presence.SetState -import com.pubnub.api.models.consumer.presence.PNSetStateResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.setPresenceState] - */ -class SetStateImpl internal constructor(setState: SetStateInterface) : - SetStateInterface by setState, - SetState, - EndpointImpl(setState) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowEndpoint.kt similarity index 83% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowEndpoint.kt index 66ac884f6..2f5268949 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowEndpoint.kt @@ -1,22 +1,23 @@ package com.pubnub.internal.endpoints.presence +import com.pubnub.api.endpoints.presence.WhereNow import com.pubnub.api.enums.PNOperationType +import com.pubnub.api.models.consumer.presence.PNWhereNowResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.models.consumer.presence.PNWhereNowResult +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.models.server.Envelope import com.pubnub.internal.models.server.presence.WhereNowPayload import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.whereNow] + * @see [PubNubImpl.whereNow] */ class WhereNowEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val uuid: String = pubnub.configuration.userId.value, -) : EndpointCore, PNWhereNowResult>(pubnub), WhereNowInterface { +) : EndpointCore, PNWhereNowResult>(pubnub), WhereNow { override fun doWork(queryParams: HashMap): Call> { return retrofitManager.presenceService.whereNow( configuration.subscribeKey, diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowImpl.kt deleted file mode 100644 index c082c914d..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/presence/WhereNowImpl.kt +++ /dev/null @@ -1,25 +0,0 @@ -package com.pubnub.internal.endpoints.presence - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.endpoints.remoteaction.MappingRemoteAction -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.models.consumer.presence.PNWhereNowResult -import com.pubnub.internal.models.toApi - -/** - * @see [PubNubImpl.whereNow] - */ -class WhereNowImpl internal constructor(whereNow: WhereNowEndpoint) : - DelegatingEndpoint(whereNow), - WhereNowInterface by whereNow, - com.pubnub.api.endpoints.presence.WhereNow { - override fun convertAction( - remoteAction: ExtendedRemoteAction, - ): ExtendedRemoteAction { - return MappingRemoteAction( - remoteAction, - PNWhereNowResult::toApi, - ) - } - } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishEndpoint.kt similarity index 94% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishEndpoint.kt index 1851ddd35..c1a6a9ab3 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishEndpoint.kt @@ -2,11 +2,12 @@ package com.pubnub.internal.endpoints.pubsub import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.pubsub.Publish import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.PNPublishResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.crypto.encryptString import com.pubnub.internal.extension.numericString import com.pubnub.internal.extension.quoted @@ -15,10 +16,10 @@ import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.publish] + * @see [PubNubImpl.publish] */ class PublishEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val message: Any, override val channel: String, override val meta: Any? = null, @@ -26,7 +27,7 @@ class PublishEndpoint internal constructor( override val usePost: Boolean = false, override val replicate: Boolean = true, override val ttl: Int? = null, -) : EndpointCore, PNPublishResult>(pubnub), PublishInterface { +) : EndpointCore, PNPublishResult>(pubnub), Publish { override fun validateParams() { super.validateParams() if (channel.isBlank()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishImpl.kt deleted file mode 100644 index 081c0522d..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/PublishImpl.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.pubnub.internal.endpoints.pubsub - -import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.publish] - */ -class PublishImpl internal constructor(publish: PublishEndpoint) : - com.pubnub.api.endpoints.pubsub.Publish, - PublishInterface by publish, - EndpointImpl(publish) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalEndpoint.kt similarity index 88% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalEndpoint.kt index 8d73e3a02..823c49b84 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalEndpoint.kt @@ -2,22 +2,23 @@ package com.pubnub.internal.endpoints.pubsub import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.pubsub.Signal import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.PNPublishResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import retrofit2.Call import retrofit2.Response /** - * @see [PubNubCore.signal] + * @see [PubNubImpl.signal] */ class SignalEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val channel: String, override val message: Any, -) : EndpointCore, PNPublishResult>(pubnub), SignalInterface { +) : EndpointCore, PNPublishResult>(pubnub), Signal { override fun validateParams() { super.validateParams() if (channel.isBlank()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalImpl.kt deleted file mode 100644 index 1a0834312..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SignalImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.pubsub - -import com.pubnub.api.endpoints.pubsub.Signal -import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.signal] - */ -class SignalImpl internal constructor(signal: SignalInterface) : - Signal, - SignalInterface by signal, - EndpointImpl(signal) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SubscribeEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SubscribeEndpoint.kt similarity index 95% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SubscribeEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SubscribeEndpoint.kt index 2d0f8b913..9e779eccb 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SubscribeEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/pubsub/SubscribeEndpoint.kt @@ -5,14 +5,14 @@ import com.pubnub.api.PubNubException import com.pubnub.api.enums.PNOperationType import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.PubNubUtil import com.pubnub.internal.models.server.SubscribeEnvelope import com.pubnub.internal.toCsv import retrofit2.Call import retrofit2.Response -class SubscribeEndpoint internal constructor(pubnub: PubNubCore) : EndpointCore(pubnub) { +class SubscribeEndpoint internal constructor(pubnub: PubNubImpl) : EndpointCore(pubnub) { var channels = emptyList() var channelGroups = emptyList() var timetoken: Long? = null diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushEndpoint.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushEndpoint.kt index d280395a4..f5eb81182 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushEndpoint.kt @@ -2,29 +2,30 @@ package com.pubnub.internal.endpoints.push import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.push.AddChannelsToPush import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushAddChannelResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.toCsv import retrofit2.Call import retrofit2.Response import java.util.Locale /** - * @see [PubNubCore.addPushNotificationsOnChannels] + * @see [PubNubImpl.addPushNotificationsOnChannels] */ class AddChannelsToPushEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val pushType: PNPushType, override val channels: List, override val deviceId: String, override val topic: String? = null, override val environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, -) : EndpointCore(pubnub), AddChannelsToPushInterface { +) : EndpointCore(pubnub), AddChannelsToPush { override fun getAffectedChannels() = channels override fun validateParams() { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushImpl.kt deleted file mode 100644 index bb852d2b6..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/AddChannelsToPushImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.push - -import com.pubnub.api.endpoints.push.AddChannelsToPush -import com.pubnub.api.models.consumer.push.PNPushAddChannelResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.addPushNotificationsOnChannels] - */ -class AddChannelsToPushImpl internal constructor(addChannelsToPush: AddChannelsToPushInterface) : - AddChannelsToPushInterface by addChannelsToPush, - AddChannelsToPush, - EndpointImpl(addChannelsToPush) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsEndpoint.kt similarity index 92% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsEndpoint.kt index c16e0e6ef..9033f4279 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsEndpoint.kt @@ -2,27 +2,28 @@ package com.pubnub.internal.endpoints.push import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.push.ListPushProvisions import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import retrofit2.Call import retrofit2.Response import java.util.Locale /** - * @see [PubNubCore.auditPushChannelProvisions] + * @see [PubNubImpl.auditPushChannelProvisions] */ class ListPushProvisionsEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val pushType: PNPushType, override val deviceId: String, override val topic: String? = null, override val environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, -) : EndpointCore, PNPushListProvisionsResult>(pubnub), ListPushProvisionsInterface { +) : EndpointCore, PNPushListProvisionsResult>(pubnub), ListPushProvisions { override fun validateParams() { super.validateParams() if (deviceId.isBlank()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsImpl.kt deleted file mode 100644 index c2f131687..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/ListPushProvisionsImpl.kt +++ /dev/null @@ -1,14 +0,0 @@ -package com.pubnub.internal.endpoints.push - -import com.pubnub.api.endpoints.push.ListPushProvisions -import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.auditPushChannelProvisions] - */ -class ListPushProvisionsImpl internal constructor(listPushProvisions: ListPushProvisionsInterface) : - ListPushProvisionsInterface by listPushProvisions, - ListPushProvisions, - EndpointImpl(listPushProvisions) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceEndpoint.kt similarity index 91% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceEndpoint.kt index 314337bc3..74bad7ee7 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceEndpoint.kt @@ -2,27 +2,28 @@ package com.pubnub.internal.endpoints.push import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import retrofit2.Call import retrofit2.Response import java.util.Locale /** - * @see [PubNubCore.removeAllPushNotificationsFromDeviceWithPushToken] + * @see [PubNubImpl.removeAllPushNotificationsFromDeviceWithPushToken] */ class RemoveAllPushChannelsForDeviceEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val pushType: PNPushType, override val deviceId: String, override val environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, override val topic: String? = null, -) : EndpointCore(pubnub), RemoveAllPushChannelsForDeviceInterface { +) : EndpointCore(pubnub), RemoveAllPushChannelsForDevice { override fun validateParams() { super.validateParams() if (deviceId.isBlank()) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt deleted file mode 100644 index 745cfeed6..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveAllPushChannelsForDeviceImpl.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.pubnub.internal.endpoints.push - -import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice -import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.removeAllPushNotificationsFromDeviceWithPushToken] - */ -class RemoveAllPushChannelsForDeviceImpl internal constructor( - removeAllPushChannelsForDevice: RemoveAllPushChannelsForDeviceInterface, -) : RemoveAllPushChannelsForDeviceInterface by removeAllPushChannelsForDevice, - RemoveAllPushChannelsForDevice, - EndpointImpl(removeAllPushChannelsForDevice) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushEndpoint.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushEndpoint.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushEndpoint.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushEndpoint.kt index dcba16a0d..5f4dbe477 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushEndpoint.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushEndpoint.kt @@ -2,29 +2,30 @@ package com.pubnub.internal.endpoints.push import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushEnvironment import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult import com.pubnub.api.retry.RetryableEndpointGroup import com.pubnub.internal.EndpointCore -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.toCsv import retrofit2.Call import retrofit2.Response import java.util.Locale /** - * @see [PubNubCore.removePushNotificationsFromChannels] + * @see [PubNubImpl.removePushNotificationsFromChannels] */ class RemoveChannelsFromPushEndpoint internal constructor( - pubnub: PubNubCore, + pubnub: PubNubImpl, override val pushType: PNPushType, override val channels: List, override val deviceId: String, override val topic: String? = null, override val environment: PNPushEnvironment = PNPushEnvironment.DEVELOPMENT, -) : EndpointCore(pubnub), RemoveChannelsFromPushInterface { +) : EndpointCore(pubnub), RemoveChannelsFromPush { override fun getAffectedChannels() = channels override fun validateParams() { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushImpl.kt deleted file mode 100644 index 01fb7e2e8..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/push/RemoveChannelsFromPushImpl.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.pubnub.internal.endpoints.push - -import com.pubnub.api.endpoints.push.RemoveChannelsFromPush -import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult -import com.pubnub.internal.EndpointImpl -import com.pubnub.internal.PubNubImpl - -/** - * @see [PubNubImpl.removePushNotificationsFromChannels] - */ -class RemoveChannelsFromPushImpl internal constructor( - removeChannelsFromPush: RemoveChannelsFromPushInterface, -) : RemoveChannelsFromPushInterface by removeChannelsFromPush, - RemoveChannelsFromPush, - EndpointImpl(removeChannelsFromPush) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/remoteaction/RetryingRemoteAction.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/remoteaction/RetryingRemoteAction.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/endpoints/remoteaction/RetryingRemoteAction.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/endpoints/remoteaction/RetryingRemoteAction.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/Effect.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/Effect.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/Effect.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/Effect.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectDispatcher.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectDispatcher.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectDispatcher.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectDispatcher.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectFactory.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectFactory.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectFactory.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectFactory.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectInvocation.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectInvocation.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectInvocation.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EffectInvocation.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/Event.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/Event.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/Event.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/Event.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngine.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngine.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngine.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngine.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngineConf.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngineConf.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngineConf.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngineConf.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngineManager.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngineManager.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngineManager.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/EventEngineManager.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/ManagedEffect.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/ManagedEffect.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/ManagedEffect.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/ManagedEffect.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/QueueSinkSource.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/QueueSinkSource.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/QueueSinkSource.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/QueueSinkSource.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/Sink.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/Sink.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/Sink.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/Sink.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/Source.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/Source.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/Source.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/Source.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/State.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/State.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/State.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/State.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/Transition.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/Transition.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/eventengine/Transition.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/eventengine/Transition.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/Boolean.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/Boolean.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/Boolean.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/Boolean.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/Int.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/Int.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/Int.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/Int.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/JsonElement.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/JsonElement.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/JsonElement.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/JsonElement.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/RetrofitResponse.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/RetrofitResponse.kt similarity index 77% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/RetrofitResponse.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/RetrofitResponse.kt index 35783c8fd..3dbe195e3 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/RetrofitResponse.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/RetrofitResponse.kt @@ -1,10 +1,10 @@ package com.pubnub.internal.extension import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.internal.models.consumer.objects.member.PNMember -import com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult +import com.pubnub.api.models.consumer.objects.member.PNMember +import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult import com.pubnub.internal.models.server.objects_api.EntityArrayEnvelope import retrofit2.Response diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/ScheduledExecutorService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/ScheduledExecutorService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/ScheduledExecutorService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/ScheduledExecutorService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/String.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/String.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/extension/String.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/extension/String.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/interceptor/SignatureInterceptor.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/interceptor/SignatureInterceptor.kt similarity index 50% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/interceptor/SignatureInterceptor.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/interceptor/SignatureInterceptor.kt index 28d36f795..c40722c33 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/interceptor/SignatureInterceptor.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/interceptor/SignatureInterceptor.kt @@ -1,15 +1,15 @@ package com.pubnub.internal.interceptor -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.internal.PubNubCore +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.PubNubUtil import okhttp3.Interceptor import okhttp3.Response -class SignatureInterceptor(private val basePNConfiguration: BasePNConfiguration) : Interceptor { +class SignatureInterceptor(private val configuration: PNConfiguration) : Interceptor { override fun intercept(chain: Interceptor.Chain): Response { val originalRequest = chain.request() - val request = PubNubUtil.signRequest(originalRequest, basePNConfiguration, PubNubCore.timestamp()) + val request = PubNubUtil.signRequest(originalRequest, configuration, PubNubImpl.timestamp()) return chain.proceed(request) } } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/BasePathManager.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/BasePathManager.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/BasePathManager.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/BasePathManager.kt index d8853401c..10a99980e 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/BasePathManager.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/BasePathManager.kt @@ -1,9 +1,9 @@ package com.pubnub.internal.managers -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.BasePNConfiguration.Companion.isValid +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.PNConfiguration.Companion.isValid -internal class BasePathManager(private val config: BasePNConfiguration) { +internal class BasePathManager(private val config: PNConfiguration) { /** * for cache busting, the current subdomain number used. */ diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/DuplicationManager.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/DuplicationManager.kt similarity index 85% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/DuplicationManager.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/DuplicationManager.kt index 15282cdc1..ed6a8637f 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/DuplicationManager.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/DuplicationManager.kt @@ -1,9 +1,9 @@ package com.pubnub.internal.managers -import com.pubnub.api.v2.BasePNConfiguration +import com.pubnub.api.v2.PNConfiguration import com.pubnub.internal.models.server.SubscribeMessage -internal class DuplicationManager(private val config: BasePNConfiguration) { +internal class DuplicationManager(private val config: PNConfiguration) { private val hashHistory: ArrayList = ArrayList() private fun getKey(message: SubscribeMessage) = diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/ListenerManager.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/ListenerManager.kt similarity index 81% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/ListenerManager.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/ListenerManager.kt index 2c4a54b94..107b3c7d0 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/ListenerManager.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/ListenerManager.kt @@ -1,7 +1,8 @@ package com.pubnub.internal.managers -import com.pubnub.api.BasePubNub +import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener +import com.pubnub.api.callbacks.SubscribeCallback import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNEvent import com.pubnub.api.models.consumer.pubsub.PNMessageResult @@ -9,21 +10,30 @@ import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.api.v2.callbacks.BaseEventEmitter -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.internal.callbacks.SubscribeCallback -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventEmitter +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.callbacks.StatusEmitter +import com.pubnub.api.v2.callbacks.StatusListener +import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.internal.subscribe.eventengine.effect.MessagesConsumer import com.pubnub.internal.subscribe.eventengine.effect.StatusConsumer -import com.pubnub.internal.v2.callbacks.EventListenerCore -import com.pubnub.internal.v2.callbacks.StatusListenerCore import java.util.concurrent.CopyOnWriteArrayList -class ListenerManager(val pubnub: BasePubNub<*, *, *, *, *, *, *, *>) : MessagesConsumer, StatusConsumer, BaseEventEmitter { +class ListenerManager(val pubnub: PubNub) : MessagesConsumer, StatusConsumer, EventEmitter, StatusEmitter { private val listeners = CopyOnWriteArrayList() - private val statusListeners get() = listeners.filterIsInstance() - private val eventListeners get() = listeners.filterIsInstance() + private val statusListeners get() = listeners.filterIsInstance() + private val eventListeners get() = listeners.filterIsInstance() + + /** + * Add a listener. + * + * @param listener The listener to be added. + */ + override fun addListener(listener: EventListener) { + listeners.add(listener) + } override fun removeListener(listener: Listener) { listeners.remove(listener) @@ -42,11 +52,7 @@ class ListenerManager(val pubnub: BasePubNub<*, *, *, *, *, *, *, *>) : Messages listeners.add(listener) } - fun addListener(listener: StatusListenerCore) { - listeners.add(listener) - } - - override fun addListener(listener: EventListenerCore) { + override fun addListener(listener: StatusListener) { listeners.add(listener) } @@ -108,7 +114,7 @@ class ListenerManager(val pubnub: BasePubNub<*, *, *, *, *, *, *, *>) : Messages data class AnnouncementEnvelope( val event: T, ) { - val acceptedBy = mutableSetOf>() + val acceptedBy = mutableSetOf() } interface AnnouncementCallback { @@ -117,32 +123,32 @@ interface AnnouncementCallback { val phase: Phase fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) fun objects( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) fun file( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/MapperManager.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/PresenceEventEngineManager.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/PresenceEventEngineManager.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/PresenceEventEngineManager.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/PresenceEventEngineManager.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/PublishSequenceManager.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/PublishSequenceManager.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/PublishSequenceManager.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/PublishSequenceManager.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/RetrofitManager.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/RetrofitManager.kt similarity index 97% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/RetrofitManager.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/RetrofitManager.kt index d744cfb69..93a78e190 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/RetrofitManager.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/RetrofitManager.kt @@ -1,8 +1,8 @@ package com.pubnub.internal.managers import com.pubnub.api.enums.PNLogVerbosity -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.internal.PubNubCore +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.interceptor.SignatureInterceptor import com.pubnub.internal.services.AccessManagerService import com.pubnub.internal.services.ChannelGroupService @@ -27,8 +27,8 @@ import java.util.concurrent.ExecutorService import java.util.concurrent.TimeUnit class RetrofitManager( - val pubnub: PubNubCore, - private val configuration: BasePNConfiguration, + val pubnub: PubNubImpl, + private val configuration: PNConfiguration, @get:TestOnly internal var transactionClientInstance: OkHttpClient? = null, @get:TestOnly internal var subscriptionClientInstance: OkHttpClient? = null, @get:TestOnly internal var noSignatureClientInstance: OkHttpClient? = null, @@ -53,7 +53,7 @@ class RetrofitManager( /** * Use to get a new RetrofitManager with shared OkHttpClients while overriding configuration values. */ - constructor(retrofitManager: RetrofitManager, configuration: BasePNConfiguration) : this( + constructor(retrofitManager: RetrofitManager, configuration: PNConfiguration) : this( retrofitManager.pubnub, configuration, retrofitManager.transactionClientInstance, @@ -147,7 +147,7 @@ class RetrofitManager( private fun createRetrofit(callFactory: Call.Factory?): Retrofit { val retrofitBuilder = Retrofit.Builder() - .baseUrl(pubnub.baseUrl()) + .baseUrl(pubnub.baseUrl) .addConverterFactory(pubnub.mapper.converterFactory) if (configuration.googleAppEngineNetworking) { diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/SubscribeEventEngineManager.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/SubscribeEventEngineManager.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/SubscribeEventEngineManager.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/SubscribeEventEngineManager.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/TokenManager.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/TokenManager.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/TokenManager.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/TokenManager.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/TokenParser.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/TokenParser.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/managers/TokenParser.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/managers/TokenParser.kt diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/Converters.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/Converters.kt deleted file mode 100644 index 14662b545..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/Converters.kt +++ /dev/null @@ -1,467 +0,0 @@ -@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") - -package com.pubnub.internal.models - -import com.pubnub.api.UserId -import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions -import com.pubnub.api.models.consumer.access_manager.sum.UserPermissions -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant -import com.pubnub.api.models.consumer.access_manager.v3.PNChannelPatternGrant -import com.pubnub.api.models.consumer.access_manager.v3.PNChannelResourceGrant -import com.pubnub.api.models.consumer.access_manager.v3.PNSpacePatternPermissionsGrant -import com.pubnub.api.models.consumer.access_manager.v3.PNSpacePermissionsGrant -import com.pubnub.api.models.consumer.access_manager.v3.PNUUIDPatternGrant -import com.pubnub.api.models.consumer.access_manager.v3.PNUUIDResourceGrant -import com.pubnub.api.models.consumer.access_manager.v3.PNUserPatternPermissionsGrant -import com.pubnub.api.models.consumer.access_manager.v3.PNUserPermissionsGrant -import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant -import com.pubnub.api.models.consumer.objects.PNKey -import com.pubnub.api.models.consumer.objects.PNMemberKey -import com.pubnub.api.models.consumer.objects.PNMembershipKey -import com.pubnub.api.models.consumer.objects.PNRemoveMetadataResult -import com.pubnub.api.models.consumer.objects.PNSortKey -import com.pubnub.api.models.consumer.objects.SortField -import com.pubnub.api.models.consumer.objects.member.MemberInput -import com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult -import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel -import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput -import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership -import com.pubnub.api.models.consumer.objects.membership.PNChannelMembershipArrayResult -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataArrayResult -import com.pubnub.api.models.consumer.presence.PNWhereNowResult -import com.pubnub.api.models.consumer.pubsub.BasePubSubResult -import com.pubnub.internal.SpaceId -import com.pubnub.internal.models.consumer.objects.member.PNMember -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteMembershipEvent -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetMembershipEvent -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetMembershipEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage - -internal fun PNObjectEventResult.toApi(): com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult { - return com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult( - BasePubSubResult( - channel = this.channel, - subscription = this.subscription, - timetoken = this.timetoken, - userMetadata = this.userMetadata, - publisher = this.publisher, - ), - this.extractedMessage.toApi(), - ) -} - -private fun PNObjectEventMessage.toApi(): com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventMessage { - return when (this) { - is PNSetChannelMetadataEventMessage -> { - com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage( - source = this.source, - version = this.version, - event = this.event, - type = this.type, - data = this.data, - ) - } - - is PNDeleteChannelMetadataEventMessage -> { - com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage( - source = this.source, - version = this.version, - event = this.event, - type = this.type, - channel = this.channel, - ) - } - - is PNDeleteMembershipEventMessage -> { - com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage( - source = this.source, - version = this.version, - event = this.event, - type = this.type, - data = this.data.toApi(), - ) - } - - is PNDeleteUUIDMetadataEventMessage -> { - com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage( - source = this.source, - version = this.version, - event = this.event, - type = this.type, - uuid = this.uuid, - ) - } - - is PNSetMembershipEventMessage -> { - com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage( - source = this.source, - version = this.version, - event = this.event, - type = this.type, - data = this.data.toApi(), - ) - } - - is PNSetUUIDMetadataEventMessage -> { - com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage( - source = this.source, - version = this.version, - event = this.event, - type = this.type, - data = this.data.toApi(), - ) - } - } -} - -private fun PNUUIDMetadata.toApi(): PNUUIDMetadata { - return PNUUIDMetadata( - id = this.id, - name = this.name, - externalId = this.externalId, - profileUrl = this.profileUrl, - email = this.email, - custom = this.custom, - updated = this.updated, - eTag = this.eTag, - type = this.type, - status = this.status, - ) -} - -private fun PNSetMembershipEvent.toApi(): com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent { - return com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent( - channel = this.channel, - uuid = this.uuid, - custom = this.custom, - eTag = this.eTag, - updated = this.updated, - status = this.status, - ) -} - -private fun PNDeleteMembershipEvent.toApi(): com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEvent { - return com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEvent(this.channelId, this.uuid) -} - -internal fun List.toInternalChannelGrants(): List { - return map { - it.toInternal() - } -} - -private fun ChannelGrant.toInternal(): com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant { - return when (this) { - is PNChannelResourceGrant -> { - com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant.name( - name = id, - read = read, - write = write, - manage = manage, - delete = delete, - create = create, - get = get, - join = join, - update = update, - ) - } - - is PNChannelPatternGrant -> { - com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant.pattern( - pattern = id, - read = read, - write = write, - manage = manage, - delete = delete, - create = create, - get = get, - join = join, - update = update, - ) - } - - else -> { - throw IllegalStateException("Should never happen.") - } - } -} - -internal fun List.toInternalChannelGroupGrants(): List { - return map { it.toInternal() } -} - -private fun ChannelGroupGrant.toInternal(): com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant { - return when (this) { - is com.pubnub.api.models.consumer.access_manager.v3.PNChannelGroupResourceGrant -> { - com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant.id( - id = id, - read = read, - manage = manage, - ) - } - - is com.pubnub.api.models.consumer.access_manager.v3.PNChannelGroupPatternGrant -> { - com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant.pattern( - pattern = id, - read = read, - manage = manage, - ) - } - - else -> { - throw IllegalStateException("Should never happen.") - } - } -} - -internal fun List.toInternalUuidGrants(): List { - return map { - it.toInternal() - } -} - -private fun UUIDGrant.toInternal(): com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant { - return when (this) { - is PNUUIDResourceGrant -> { - com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant.id( - id = id, - get = get, - update = update, - delete = delete, - ) - } - - is PNUUIDPatternGrant -> { - com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant.pattern( - pattern = id, - get = get, - update = update, - delete = delete, - ) - } - - else -> { - throw IllegalStateException("Should never happen.") - } - } -} - -internal fun List.toInternalSpacePermissions(): List { - return map { - it.toInternal() - } -} - -private fun SpacePermissions.toInternal(): com.pubnub.internal.models.consumer.access_manager.sum.SpacePermissions { - return when (this) { - is PNSpacePermissionsGrant -> { - com.pubnub.internal.models.consumer.access_manager.sum.SpacePermissions.id( - spaceId = SpaceId(id), - read = read, - write = write, - manage = manage, - delete = delete, - get = get, - join = join, - update = update, - ) - } - - is PNSpacePatternPermissionsGrant -> { - com.pubnub.internal.models.consumer.access_manager.sum.SpacePermissions.pattern( - pattern = id, - read = read, - write = write, - manage = manage, - delete = delete, - get = get, - join = join, - update = update, - ) - } - - else -> { - throw IllegalStateException("Should never happen.") - } - } -} - -internal fun List.toInternalUserPermissions(): List { - return map { - it.toInternal() - } -} - -private fun UserPermissions.toInternal(): com.pubnub.internal.models.consumer.access_manager.sum.UserPermissions { - return when (this) { - is PNUserPermissionsGrant -> { - com.pubnub.internal.models.consumer.access_manager.sum.UserPermissions.id( - userId = UserId(id), - get = get, - update = update, - delete = delete, - ) - } - - is PNUserPatternPermissionsGrant -> { - com.pubnub.internal.models.consumer.access_manager.sum.UserPermissions.pattern( - pattern = id, - get = get, - update = update, - delete = delete, - ) - } - - else -> { - throw IllegalStateException("Should never happen.") - } - } -} - -internal fun Collection>.toInternalSortKeys(): Collection> { - return map { - it.toInternal() - } -} - -private fun PNSortKey.toInternal(): com.pubnub.internal.models.consumer.objects.PNSortKey { - @Suppress("UNCHECKED_CAST") - val sortKey: T2 = - when (val key = this.key) { - is PNKey -> { - com.pubnub.internal.models.consumer.objects.PNKey.valueOf(key.name) as T2 - } - - is PNMembershipKey -> { - com.pubnub.internal.models.consumer.objects.PNMembershipKey.valueOf(key.name) as T2 - } - - is PNMemberKey -> { - com.pubnub.internal.models.consumer.objects.PNMemberKey.valueOf(key.name) as T2 - } - - else -> { - throw IllegalStateException("Should never happen.") - } - } - return when (this) { - is PNSortKey.PNAsc -> com.pubnub.internal.models.consumer.objects.PNSortKey.PNAsc(sortKey) - is PNSortKey.PNDesc -> com.pubnub.internal.models.consumer.objects.PNSortKey.PNDesc(sortKey) - } -} - -internal fun PNChannelDetailsLevel?.toInternal(): com.pubnub.internal.models.consumer.objects.membership.PNChannelDetailsLevel? { - if (this == null) { - return null - } - return com.pubnub.internal.models.consumer.objects.membership.PNChannelDetailsLevel.valueOf(this.name) -} - -internal fun PNUUIDDetailsLevel?.toInternal(): com.pubnub.internal.models.consumer.objects.member.PNUUIDDetailsLevel? { - if (this == null) { - return null - } - return com.pubnub.internal.models.consumer.objects.member.PNUUIDDetailsLevel.valueOf(this.name) -} - -internal fun List.toInternalChannelMemberships(): List { - return map { - it.toInternal() - } -} - -private fun ChannelMembershipInput.toInternal(): com.pubnub.internal.models.consumer.objects.membership.ChannelMembershipInput { - return com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership.Partial( - channelId = channel, - custom = custom, - status = status, - ) -} - -internal fun Collection.toInternalMemberInputs(): List { - return map { - it.toInternal() - } -} - -private fun MemberInput.toInternal(): com.pubnub.internal.models.consumer.objects.member.MemberInput { - return PNMember.Partial( - uuidId = this.uuid, - custom = custom, - status = status, - ) -} - -fun com.pubnub.internal.models.consumer.objects.membership.PNChannelMembershipArrayResult.toApi(): PNChannelMembershipArrayResult { - return PNChannelMembershipArrayResult( - status = status, - data = data.map(::from), - totalCount = totalCount, - next = next, - prev = prev, - ) -} - -fun com.pubnub.internal.models.consumer.presence.PNWhereNowResult.toApi(): PNWhereNowResult { - return PNWhereNowResult(channels) -} - -fun from(data: com.pubnub.internal.models.consumer.objects.PNRemoveMetadataResult): PNRemoveMetadataResult { - return PNRemoveMetadataResult(data.status) -} - -fun from(data: com.pubnub.internal.models.consumer.objects.member.PNMemberArrayResult): com.pubnub.api.models.consumer.objects.member.PNMemberArrayResult { - return PNMemberArrayResult( - data.status, - data.data.map(::from), - data.totalCount, - data.next, - data.prev, - ) -} - -fun from(data: com.pubnub.internal.models.consumer.objects.member.PNMember): com.pubnub.api.models.consumer.objects.member.PNMember { - return com.pubnub.api.models.consumer.objects.member.PNMember( - data.uuid, - data.custom, - data.updated, - data.eTag, - data.status, - ) -} - -fun from(data: com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership): PNChannelMembership { - return PNChannelMembership( - data.channel, - data.custom, - data.updated, - data.eTag, - data.status, - ) -} - -fun from(data: com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataArrayResult): PNUUIDMetadataArrayResult { - return PNUUIDMetadataArrayResult( - data.status, - data.data, - data.totalCount, - data.next, - data.prev, - ) -} - -fun from(data: com.pubnub.internal.models.consumer.objects.uuid.PNUUIDMetadataResult): com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult { - return com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadataResult( - data.status, - data.data, - ) -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt similarity index 55% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt index 860a9d5cc..38c20817e 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/consumer/pubsub/objects/PNObjectEventResult.kt @@ -5,17 +5,10 @@ import com.google.gson.annotations.JsonAdapter import com.google.gson.annotations.SerializedName import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -import com.pubnub.api.models.consumer.pubsub.BasePubSubResult -import com.pubnub.api.models.consumer.pubsub.PubSubResult import com.pubnub.api.utils.PatchValue import com.pubnub.internal.utils.PolymorphicDeserializer import com.pubnub.internal.utils.UnwrapSingleField -data class PNObjectEventResult( - private val result: BasePubSubResult, - val extractedMessage: PNObjectEventMessage, -) : PubSubResult by result - internal object ObjectExtractedMessageDeserializer : JsonDeserializer by PolymorphicDeserializer.dispatchByFieldsValues( fields = listOf("event", "type"), @@ -109,3 +102,82 @@ data class PNDeleteMembershipEvent( @JsonAdapter(UnwrapSingleField::class) val uuid: String, ) + +fun PNObjectEventMessage.toApi(): com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventMessage { + return when (this) { + is PNSetChannelMetadataEventMessage -> { + com.pubnub.api.models.consumer.pubsub.objects.PNSetChannelMetadataEventMessage( + source = this.source, + version = this.version, + event = this.event, + type = this.type, + data = this.data, + ) + } + + is PNDeleteChannelMetadataEventMessage -> { + com.pubnub.api.models.consumer.pubsub.objects.PNDeleteChannelMetadataEventMessage( + source = this.source, + version = this.version, + event = this.event, + type = this.type, + channel = this.channel, + ) + } + + is PNDeleteMembershipEventMessage -> { + com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEventMessage( + source = this.source, + version = this.version, + event = this.event, + type = this.type, + data = this.data.toApi(), + ) + } + + is PNDeleteUUIDMetadataEventMessage -> { + com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage( + source = this.source, + version = this.version, + event = this.event, + type = this.type, + uuid = this.uuid, + ) + } + + is PNSetMembershipEventMessage -> { + com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage( + source = this.source, + version = this.version, + event = this.event, + type = this.type, + data = this.data.toApi(), + ) + } + + is PNSetUUIDMetadataEventMessage -> { + com.pubnub.api.models.consumer.pubsub.objects.PNSetUUIDMetadataEventMessage( + source = this.source, + version = this.version, + event = this.event, + type = this.type, + data = this.data, + ) + } + } +} + +private fun PNSetMembershipEvent.toApi(): com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent { + return com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent( + channel = this.channel, + uuid = this.uuid, + custom = this.custom, + eTag = this.eTag, + updated = this.updated, + status = this.status, + ) +} + +private fun PNDeleteMembershipEvent.toApi(): com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEvent { + return com.pubnub.api.models.consumer.pubsub.objects.PNDeleteMembershipEvent(this.channelId, this.uuid) +} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/Envelope.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/Envelope.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/Envelope.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/Envelope.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/FetchMessagesEnvelope.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/FetchMessagesEnvelope.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/FetchMessagesEnvelope.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/FetchMessagesEnvelope.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/OriginationMetaData.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/OriginationMetaData.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/OriginationMetaData.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/OriginationMetaData.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/PresenceEnvelope.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/PresenceEnvelope.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/PresenceEnvelope.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/PresenceEnvelope.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/PublishMetaData.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/PublishMetaData.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/PublishMetaData.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/PublishMetaData.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeEnvelope.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeEnvelope.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeEnvelope.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeEnvelope.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeMessage.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeMessage.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeMessage.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeMessage.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeMetaData.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeMetaData.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeMetaData.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/SubscribeMetaData.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/AccessManagerGrantPayload.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/AccessManagerGrantPayload.kt similarity index 81% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/AccessManagerGrantPayload.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/AccessManagerGrantPayload.kt index f2c74d9b5..7bb7b97eb 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/AccessManagerGrantPayload.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/AccessManagerGrantPayload.kt @@ -2,8 +2,8 @@ package com.pubnub.internal.models.server.access_manager import com.google.gson.JsonElement import com.google.gson.annotations.SerializedName -import com.pubnub.internal.models.consumer.access_manager.PNAccessManagerKeyData -import com.pubnub.internal.models.consumer.access_manager.PNAccessManagerKeysData +import com.pubnub.api.models.consumer.access_manager.PNAccessManagerKeyData +import com.pubnub.api.models.consumer.access_manager.PNAccessManagerKeysData class AccessManagerGrantPayload { internal var level: String? = null diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenRequestBody.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenRequestBody.kt similarity index 87% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenRequestBody.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenRequestBody.kt index 9888020ad..d6ecc443b 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenRequestBody.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenRequestBody.kt @@ -2,11 +2,11 @@ package com.pubnub.internal.models.server.access_manager.v3 import com.pubnub.api.PubNubException import com.pubnub.api.models.TokenBitmask -import com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNPatternGrant -import com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNPatternGrant +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant data class GrantTokenRequestBody( val ttl: Int, @@ -61,7 +61,7 @@ data class GrantTokenRequestBody( private fun getPatterns(resources: List): Map { return resources - .filterIsInstance(PNPatternGrant::class.java) + .filterIsInstance() .associate { it.id to calculateBitmask(it) } } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenResponse.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenResponse.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenResponse.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/GrantTokenResponse.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/RevokeTokenResponse.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/RevokeTokenResponse.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/RevokeTokenResponse.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/access_manager/v3/RevokeTokenResponse.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FileUploadNotification.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FileUploadNotification.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FileUploadNotification.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FileUploadNotification.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FileUploadRequestDetails.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FileUploadRequestDetails.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FileUploadRequestDetails.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FileUploadRequestDetails.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FormField.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FormField.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FormField.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/FormField.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/GenerateUploadUrlPayload.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/GenerateUploadUrlPayload.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/GenerateUploadUrlPayload.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/GenerateUploadUrlPayload.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/GeneratedUploadUrlResponse.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/GeneratedUploadUrlResponse.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/GeneratedUploadUrlResponse.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/GeneratedUploadUrlResponse.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/ListFilesResult.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/ListFilesResult.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/files/ListFilesResult.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/files/ListFilesResult.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/history/ServerFetchMessageItem.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/history/ServerFetchMessageItem.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/history/ServerFetchMessageItem.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/history/ServerFetchMessageItem.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/history/ServerFetchMessagesResult.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/history/ServerFetchMessagesResult.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/history/ServerFetchMessagesResult.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/history/ServerFetchMessagesResult.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/message_actions/MessageActionsResponse.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/message_actions/MessageActionsResponse.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/message_actions/MessageActionsResponse.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/message_actions/MessageActionsResponse.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChangeMemberInput.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChangeMemberInput.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChangeMemberInput.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChangeMemberInput.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChangeMembershipInput.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChangeMembershipInput.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChangeMembershipInput.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChangeMembershipInput.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChannelMetadataInput.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChannelMetadataInput.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChannelMetadataInput.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ChannelMetadataInput.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityArrayEnvelope.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityArrayEnvelope.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityArrayEnvelope.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityArrayEnvelope.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityEnvelope.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityEnvelope.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityEnvelope.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/EntityEnvelope.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ServerMemberInput.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ServerMemberInput.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ServerMemberInput.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ServerMemberInput.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ServerMembershipInput.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ServerMembershipInput.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ServerMembershipInput.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/ServerMembershipInput.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/UUIDMetadataInput.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/UUIDMetadataInput.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/UUIDMetadataInput.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/objects_api/UUIDMetadataInput.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/presence/WhereNowPayload.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/presence/WhereNowPayload.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/models/server/presence/WhereNowPayload.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/models/server/presence/WhereNowPayload.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/Presence.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/Presence.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/Presence.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/Presence.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/PresenceEventEngine.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/PresenceEventEngine.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/PresenceEventEngine.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/PresenceEventEngine.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/data/PresenceData.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/data/PresenceData.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/data/PresenceData.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/data/PresenceData.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/HeartbeatEffect.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/HeartbeatEffect.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/HeartbeatEffect.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/HeartbeatEffect.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/LeaveEffect.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/LeaveEffect.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/LeaveEffect.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/LeaveEffect.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectFactory.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectFactory.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectFactory.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectFactory.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectInvocation.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectInvocation.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectInvocation.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectInvocation.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffect.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffect.kt similarity index 74% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffect.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffect.kt index bb59cc33a..e0c859fc3 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffect.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffect.kt @@ -5,6 +5,7 @@ import com.pubnub.internal.eventengine.Sink import com.pubnub.internal.extension.scheduleWithDelay import com.pubnub.internal.presence.eventengine.event.PresenceEvent import org.slf4j.LoggerFactory +import java.util.concurrent.RejectedExecutionException import java.util.concurrent.ScheduledExecutorService import java.util.concurrent.ScheduledFuture import kotlin.time.Duration @@ -29,10 +30,14 @@ internal class WaitEffect( return } - scheduled = - executorService.scheduleWithDelay(heartbeatInterval) { - presenceEventSink.add(PresenceEvent.TimesUp) - } + try { + scheduled = + executorService.scheduleWithDelay(heartbeatInterval) { + presenceEventSink.add(PresenceEvent.TimesUp) + } + } catch (_: RejectedExecutionException) { + log.trace("Unable to schedule retry, PubNub was likely already destroyed.") + } } @Synchronized diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProvider.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProvider.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProvider.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProvider.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProviderImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProviderImpl.kt similarity index 84% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProviderImpl.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProviderImpl.kt index 3e0644fe9..798e1b83a 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProviderImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/HeartbeatProviderImpl.kt @@ -1,10 +1,10 @@ package com.pubnub.internal.presence.eventengine.effect.effectprovider import com.pubnub.api.endpoints.remoteaction.RemoteAction -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.presence.HeartbeatEndpoint -internal class HeartbeatProviderImpl(val pubNub: PubNubCore) : HeartbeatProvider { +internal class HeartbeatProviderImpl(val pubNub: PubNubImpl) : HeartbeatProvider { override fun getHeartbeatRemoteAction( channels: Set, channelGroups: Set, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProvider.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProvider.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProvider.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProvider.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProviderImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProviderImpl.kt similarity index 83% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProviderImpl.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProviderImpl.kt index 75dcb69d3..09e0371ac 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProviderImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/effect/effectprovider/LeaveProviderImpl.kt @@ -1,10 +1,10 @@ package com.pubnub.internal.presence.eventengine.effect.effectprovider import com.pubnub.api.endpoints.remoteaction.RemoteAction -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.presence.LeaveEndpoint -internal class LeaveProviderImpl(val pubNub: PubNubCore) : LeaveProvider { +internal class LeaveProviderImpl(val pubNub: PubNubImpl) : LeaveProvider { override fun getLeaveRemoteAction( channels: Set, channelGroups: Set, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/event/PresenceEvent.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/event/PresenceEvent.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/event/PresenceEvent.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/event/PresenceEvent.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/state/PresenceState.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/state/PresenceState.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/state/PresenceState.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/presence/eventengine/state/PresenceState.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableBase.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableBase.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableBase.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableBase.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableCallback.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableCallback.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableCallback.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableCallback.kt index 34c57120c..19f8a6d69 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableCallback.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableCallback.kt @@ -7,6 +7,7 @@ import org.slf4j.LoggerFactory import retrofit2.Call import retrofit2.Callback import retrofit2.Response +import java.util.concurrent.RejectedExecutionException import java.util.concurrent.ScheduledExecutorService import kotlin.time.Duration import kotlin.time.Duration.Companion.milliseconds @@ -82,8 +83,12 @@ internal abstract class RetryableCallback( val effectiveDelay: Duration = delay + randomDelayInMillis.milliseconds log.trace("Added random delay so effective retry delay is ${effectiveDelay.inWholeMilliseconds} millis") // don't want to block the main thread in case of Android so using executorService - executorService.scheduleWithDelay(effectiveDelay) { - call.clone().enqueue(this) + try { + executorService.scheduleWithDelay(effectiveDelay) { + call.clone().enqueue(this) + } + } catch (_: RejectedExecutionException) { + log.trace("Unable to schedule retry, PubNub was likely already destroyed.") } } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableRestCaller.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableRestCaller.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableRestCaller.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/retry/RetryableRestCaller.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/AccessManagerService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/AccessManagerService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/AccessManagerService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/AccessManagerService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/ChannelGroupService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/ChannelGroupService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/ChannelGroupService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/ChannelGroupService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/FilesService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/FilesService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/FilesService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/FilesService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/HistoryService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/HistoryService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/HistoryService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/HistoryService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/MessageActionService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/MessageActionService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/MessageActionService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/MessageActionService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/ObjectsService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/ObjectsService.kt similarity index 96% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/ObjectsService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/ObjectsService.kt index 90709ac7d..b9d63b4fd 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/ObjectsService.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/ObjectsService.kt @@ -1,9 +1,9 @@ package com.pubnub.internal.services import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.objects.member.PNMember +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -import com.pubnub.internal.models.consumer.objects.member.PNMember -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership import com.pubnub.internal.models.server.objects_api.ChangeMemberInput import com.pubnub.internal.models.server.objects_api.ChangeMembershipInput import com.pubnub.internal.models.server.objects_api.ChannelMetadataInput diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/PresenceService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/PresenceService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/PresenceService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/PresenceService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/PublishService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/PublishService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/PublishService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/PublishService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/PushService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/PushService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/PushService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/PushService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/S3Service.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/S3Service.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/S3Service.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/S3Service.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/SignalService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/SignalService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/SignalService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/SignalService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/SubscribeService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/SubscribeService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/SubscribeService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/SubscribeService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/TimeService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/TimeService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/services/TimeService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/services/TimeService.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/Subscribe.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/Subscribe.kt similarity index 98% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/Subscribe.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/Subscribe.kt index 7b3ba3bc4..cd7b5c8d0 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/Subscribe.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/Subscribe.kt @@ -2,7 +2,7 @@ package com.pubnub.internal.subscribe import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.eventengine.EffectDispatcher import com.pubnub.internal.managers.ListenerManager import com.pubnub.internal.managers.SubscribeEventEngineManager @@ -28,7 +28,7 @@ internal class Subscribe( ) { companion object { internal fun create( - pubNub: PubNubCore, + pubNub: PubNubImpl, listenerManager: ListenerManager, eventEnginesConf: EventEnginesConf, messageProcessor: SubscribeMessageProcessor, @@ -49,7 +49,7 @@ internal class Subscribe( } private fun createAndStartSubscribeEventEngineManager( - pubNub: PubNubCore, + pubNub: PubNubImpl, messageProcessor: SubscribeMessageProcessor, eventEnginesConf: EventEnginesConf, listenerManager: ListenerManager, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/SubscribeEventEngine.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/SubscribeEventEngine.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/SubscribeEventEngine.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/SubscribeEventEngine.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/configuration/EventEnginesConf.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/configuration/EventEnginesConf.kt similarity index 91% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/configuration/EventEnginesConf.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/configuration/EventEnginesConf.kt index b288888cb..4e35dddb8 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/configuration/EventEnginesConf.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/configuration/EventEnginesConf.kt @@ -7,7 +7,8 @@ import com.pubnub.internal.presence.eventengine.event.PresenceEvent import com.pubnub.internal.subscribe.eventengine.effect.SubscribeEffectInvocation import com.pubnub.internal.subscribe.eventengine.event.SubscribeEvent -internal class EventEnginesConf( +@Suppress("EXPOSED_PARAMETER_TYPE") +class EventEnginesConf( val subscribe: EventEngineConf = QueueEventEngineConf(), val presence: EventEngineConf = QueueEventEngineConf(), ) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/data/SubscriptionData.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/data/SubscriptionData.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/data/SubscriptionData.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/data/SubscriptionData.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffect.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffect.kt similarity index 94% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffect.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffect.kt index 538571d70..90a4cc85f 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffect.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffect.kt @@ -6,8 +6,8 @@ import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.internal.eventengine.Effect -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult import org.slf4j.LoggerFactory internal class EmitMessagesEffect( diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitStatusEffect.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitStatusEffect.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitStatusEffect.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitStatusEffect.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/HandshakeEffect.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/HandshakeEffect.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/HandshakeEffect.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/HandshakeEffect.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/MessagesConsumer.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/MessagesConsumer.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/MessagesConsumer.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/MessagesConsumer.kt index 293cef2bc..32e0cc518 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/MessagesConsumer.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/MessagesConsumer.kt @@ -5,7 +5,7 @@ import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult internal interface MessagesConsumer { fun announce(message: PNMessageResult) diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReceiveMessagesEffect.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReceiveMessagesEffect.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReceiveMessagesEffect.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReceiveMessagesEffect.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReconnectionPolicy.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReconnectionPolicy.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReconnectionPolicy.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReconnectionPolicy.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/StatusConsumer.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/StatusConsumer.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/StatusConsumer.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/StatusConsumer.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectFactory.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectFactory.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectFactory.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectFactory.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectInvocation.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectInvocation.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectInvocation.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectInvocation.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProvider.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProvider.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProvider.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProvider.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProviderImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProviderImpl.kt similarity index 89% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProviderImpl.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProviderImpl.kt index bc85633ec..65356636c 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProviderImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/HandshakeProviderImpl.kt @@ -2,11 +2,11 @@ package com.pubnub.internal.subscribe.eventengine.effect.effectprovider import com.pubnub.api.endpoints.remoteaction.RemoteAction import com.pubnub.api.endpoints.remoteaction.map -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.pubsub.SubscribeEndpoint import com.pubnub.internal.subscribe.eventengine.event.SubscriptionCursor -internal class HandshakeProviderImpl(val pubNub: PubNubCore) : HandshakeProvider { +internal class HandshakeProviderImpl(val pubNub: PubNubImpl) : HandshakeProvider { override fun getHandshakeRemoteAction( channels: Set, channelGroups: Set, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProvider.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProvider.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProvider.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProvider.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProviderImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProviderImpl.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProviderImpl.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProviderImpl.kt index ae9df2d1f..f2bf97746 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProviderImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/effect/effectprovider/ReceiveMessagesProviderImpl.kt @@ -3,13 +3,13 @@ package com.pubnub.internal.subscribe.eventengine.effect.effectprovider import com.pubnub.api.endpoints.remoteaction.RemoteAction import com.pubnub.api.endpoints.remoteaction.map import com.pubnub.api.models.consumer.pubsub.PNEvent -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.pubsub.SubscribeEndpoint import com.pubnub.internal.subscribe.eventengine.effect.ReceiveMessagesResult import com.pubnub.internal.subscribe.eventengine.event.SubscriptionCursor import com.pubnub.internal.workers.SubscribeMessageProcessor -internal class ReceiveMessagesProviderImpl(val pubNub: PubNubCore, val messageProcessor: SubscribeMessageProcessor) : +internal class ReceiveMessagesProviderImpl(val pubNub: PubNubImpl, val messageProcessor: SubscribeMessageProcessor) : ReceiveMessagesProvider { override fun getReceiveMessagesRemoteAction( channels: Set, diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscribeEvent.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscribeEvent.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscribeEvent.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscribeEvent.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscriptionCursor.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscriptionCursor.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscriptionCursor.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscriptionCursor.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/state/SubscribeState.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/state/SubscribeState.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/state/SubscribeState.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/subscribe/eventengine/state/SubscribeState.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/utils/PolymorphicDeserializer.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/utils/PolymorphicDeserializer.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/utils/PolymorphicDeserializer.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/utils/PolymorphicDeserializer.kt diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/utils/UnwrapSingleField.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/utils/UnwrapSingleField.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/utils/UnwrapSingleField.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/utils/UnwrapSingleField.kt diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt index 8dab21e95..95897e815 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/PNConfigurationImpl.kt @@ -5,7 +5,6 @@ import com.pubnub.api.crypto.CryptoModule import com.pubnub.api.enums.PNHeartbeatNotificationOptions import com.pubnub.api.enums.PNLogVerbosity import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.api.v2.BasePNConfiguration import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.PNConfigurationOverride import okhttp3.Authenticator @@ -21,71 +20,81 @@ import javax.net.ssl.X509ExtendedTrustManager class PNConfigurationImpl( override val userId: UserId, - override val subscribeKey: String, - override val publishKey: String, - override val secretKey: String, - override val authKey: String, - override val cryptoModule: CryptoModule?, - override val origin: String, - override val secure: Boolean, - override val logVerbosity: PNLogVerbosity, - override val heartbeatNotificationOptions: PNHeartbeatNotificationOptions, - override val presenceTimeout: Int, - override val heartbeatInterval: Int, - override val subscribeTimeout: Int, - override val connectTimeout: Int, - override val nonSubscribeReadTimeout: Int, - override val cacheBusting: Boolean, - override val suppressLeaveEvents: Boolean, - override val maintainPresenceState: Boolean, - override val filterExpression: String, - override val includeInstanceIdentifier: Boolean, - override val includeRequestIdentifier: Boolean, - override val maximumConnections: Int?, - override val googleAppEngineNetworking: Boolean, - override val proxy: Proxy?, - override val proxySelector: ProxySelector?, - override val proxyAuthenticator: Authenticator?, - override val certificatePinner: CertificatePinner?, - override val httpLoggingInterceptor: HttpLoggingInterceptor?, - override val sslSocketFactory: SSLSocketFactory?, - override val x509ExtendedTrustManager: X509ExtendedTrustManager?, - override val connectionSpec: ConnectionSpec?, - override val hostnameVerifier: HostnameVerifier?, - override val fileMessagePublishRetryLimit: Int, - override val dedupOnSubscribe: Boolean, - override val maximumMessagesCacheSize: Int, - override val pnsdkSuffixes: Map, - override val retryConfiguration: RetryConfiguration, - override val managePresenceListManually: Boolean, -) : BasePNConfigurationImpl(userId), PNConfiguration, PNConfigurationOverride { - class Builder(defaultConfiguration: BasePNConfiguration) : - BasePNConfigurationImpl.Builder(defaultConfiguration), + override val subscribeKey: String = "", + override val publishKey: String = "", + override val secretKey: String = "", + override val authKey: String = "", + override val cryptoModule: CryptoModule? = null, + override val origin: String = "", + override val secure: Boolean = true, + override val logVerbosity: PNLogVerbosity = PNLogVerbosity.NONE, + override val heartbeatNotificationOptions: PNHeartbeatNotificationOptions = PNHeartbeatNotificationOptions.FAILURES, + override val presenceTimeout: Int = PRESENCE_TIMEOUT, + override val heartbeatInterval: Int = 0, + override val subscribeTimeout: Int = SUBSCRIBE_TIMEOUT, + override val connectTimeout: Int = CONNECT_TIMEOUT, + override val nonSubscribeReadTimeout: Int = NON_SUBSCRIBE_REQUEST_TIMEOUT, + override val cacheBusting: Boolean = false, + override val suppressLeaveEvents: Boolean = false, + override val maintainPresenceState: Boolean = true, + override val filterExpression: String = "", + override val includeInstanceIdentifier: Boolean = false, + override val includeRequestIdentifier: Boolean = true, + override val maximumConnections: Int? = null, + override val googleAppEngineNetworking: Boolean = false, + override val proxy: Proxy? = null, + override val proxySelector: ProxySelector? = null, + override val proxyAuthenticator: Authenticator? = null, + override val certificatePinner: CertificatePinner? = null, + override val httpLoggingInterceptor: HttpLoggingInterceptor? = null, + override val sslSocketFactory: SSLSocketFactory? = null, + override val x509ExtendedTrustManager: X509ExtendedTrustManager? = null, + override val connectionSpec: ConnectionSpec? = null, + override val hostnameVerifier: HostnameVerifier? = null, + override val fileMessagePublishRetryLimit: Int = 5, + override val dedupOnSubscribe: Boolean = false, + override val maximumMessagesCacheSize: Int = DEFAULT_DEDUPE_SIZE, + override val pnsdkSuffixes: Map = emptyMap(), + override val retryConfiguration: RetryConfiguration = RetryConfiguration.None, + override val managePresenceListManually: Boolean = false, +) : PNConfiguration, PNConfigurationOverride { + companion object { + const val DEFAULT_DEDUPE_SIZE = 100 + const val PRESENCE_TIMEOUT = 300 + const val MINIMUM_PRESENCE_TIMEOUT = 20 + const val NON_SUBSCRIBE_REQUEST_TIMEOUT = 10 + const val SUBSCRIBE_TIMEOUT = 310 + const val CONNECT_TIMEOUT = 5 + } + + class Builder(defaultConfiguration: PNConfiguration) : PNConfiguration.Builder, PNConfigurationOverride.Builder { + constructor(userId: UserId, subscribeKey: String) : this(PNConfigurationImpl(userId, subscribeKey)) + private val log = LoggerFactory.getLogger(this::class.simpleName) - override var userId: UserId = super.userId + override var userId: UserId = defaultConfiguration.userId - override var subscribeKey: String = super.subscribeKey + override var subscribeKey: String = defaultConfiguration.subscribeKey - override var publishKey: String = super.publishKey + override var publishKey: String = defaultConfiguration.publishKey - override var secretKey: String = super.secretKey + override var secretKey: String = defaultConfiguration.secretKey - override var authKey: String = super.authKey + override var authKey: String = defaultConfiguration.authKey - override var cryptoModule: CryptoModule? = super.cryptoModule + override var cryptoModule: CryptoModule? = defaultConfiguration.cryptoModule - override var origin: String = super.origin + override var origin: String = defaultConfiguration.origin - override var secure: Boolean = super.secure + override var secure: Boolean = defaultConfiguration.secure - override var logVerbosity: PNLogVerbosity = super.logVerbosity + override var logVerbosity: PNLogVerbosity = defaultConfiguration.logVerbosity - override var heartbeatNotificationOptions: PNHeartbeatNotificationOptions = super.heartbeatNotificationOptions + override var heartbeatNotificationOptions: PNHeartbeatNotificationOptions = defaultConfiguration.heartbeatNotificationOptions - override var presenceTimeout: Int = super.presenceTimeout + override var presenceTimeout: Int = defaultConfiguration.presenceTimeout set(value) { field = if (value < MINIMUM_PRESENCE_TIMEOUT) { @@ -97,11 +106,11 @@ class PNConfigurationImpl( heartbeatInterval = (presenceTimeout / 2) - 1 } - override var heartbeatInterval: Int = super.heartbeatInterval + override var heartbeatInterval: Int = defaultConfiguration.heartbeatInterval - override var subscribeTimeout: Int = super.subscribeTimeout + override var subscribeTimeout: Int = defaultConfiguration.subscribeTimeout - override var connectTimeout: Int = super.connectTimeout + override var connectTimeout: Int = defaultConfiguration.connectTimeout @Deprecated( "This setting relates to *read* timeout and was renamed to `nonSubscribeReadTimeout`", @@ -113,50 +122,50 @@ class PNConfigurationImpl( nonSubscribeReadTimeout = value } - override var nonSubscribeReadTimeout: Int = super.nonSubscribeReadTimeout + override var nonSubscribeReadTimeout: Int = defaultConfiguration.nonSubscribeReadTimeout - override var cacheBusting: Boolean = super.cacheBusting + override var cacheBusting: Boolean = defaultConfiguration.cacheBusting - override var suppressLeaveEvents: Boolean = super.suppressLeaveEvents + override var suppressLeaveEvents: Boolean = defaultConfiguration.suppressLeaveEvents - override var maintainPresenceState: Boolean = super.maintainPresenceState + override var maintainPresenceState: Boolean = defaultConfiguration.maintainPresenceState - override var filterExpression: String = super.filterExpression + override var filterExpression: String = defaultConfiguration.filterExpression - override var includeInstanceIdentifier: Boolean = super.includeInstanceIdentifier + override var includeInstanceIdentifier: Boolean = defaultConfiguration.includeInstanceIdentifier - override var includeRequestIdentifier: Boolean = super.includeRequestIdentifier + override var includeRequestIdentifier: Boolean = defaultConfiguration.includeRequestIdentifier - override var maximumConnections: Int? = super.maximumConnections + override var maximumConnections: Int? = defaultConfiguration.maximumConnections - override var googleAppEngineNetworking: Boolean = super.googleAppEngineNetworking + override var googleAppEngineNetworking: Boolean = defaultConfiguration.googleAppEngineNetworking - override var proxy: Proxy? = super.proxy + override var proxy: Proxy? = defaultConfiguration.proxy - override var proxySelector: ProxySelector? = super.proxySelector + override var proxySelector: ProxySelector? = defaultConfiguration.proxySelector - override var proxyAuthenticator: Authenticator? = super.proxyAuthenticator + override var proxyAuthenticator: Authenticator? = defaultConfiguration.proxyAuthenticator - override var certificatePinner: CertificatePinner? = super.certificatePinner + override var certificatePinner: CertificatePinner? = defaultConfiguration.certificatePinner - override var httpLoggingInterceptor: HttpLoggingInterceptor? = super.httpLoggingInterceptor + override var httpLoggingInterceptor: HttpLoggingInterceptor? = defaultConfiguration.httpLoggingInterceptor - override var sslSocketFactory: SSLSocketFactory? = super.sslSocketFactory + override var sslSocketFactory: SSLSocketFactory? = defaultConfiguration.sslSocketFactory - override var x509ExtendedTrustManager: X509ExtendedTrustManager? = super.x509ExtendedTrustManager + override var x509ExtendedTrustManager: X509ExtendedTrustManager? = defaultConfiguration.x509ExtendedTrustManager - override var connectionSpec: ConnectionSpec? = super.connectionSpec + override var connectionSpec: ConnectionSpec? = defaultConfiguration.connectionSpec - override var hostnameVerifier: HostnameVerifier? = super.hostnameVerifier + override var hostnameVerifier: HostnameVerifier? = defaultConfiguration.hostnameVerifier - override var fileMessagePublishRetryLimit: Int = super.fileMessagePublishRetryLimit - override var dedupOnSubscribe: Boolean = super.dedupOnSubscribe - override var maximumMessagesCacheSize: Int = super.maximumMessagesCacheSize - override var pnsdkSuffixes: Map = super.pnsdkSuffixes + override var fileMessagePublishRetryLimit: Int = defaultConfiguration.fileMessagePublishRetryLimit + override var dedupOnSubscribe: Boolean = defaultConfiguration.dedupOnSubscribe + override var maximumMessagesCacheSize: Int = defaultConfiguration.maximumMessagesCacheSize + override var pnsdkSuffixes: Map = defaultConfiguration.pnsdkSuffixes - override var retryConfiguration: RetryConfiguration = super.retryConfiguration + override var retryConfiguration: RetryConfiguration = defaultConfiguration.retryConfiguration - override var managePresenceListManually: Boolean = super.managePresenceListManually + override var managePresenceListManually: Boolean = defaultConfiguration.managePresenceListManually override fun build(): PNConfiguration { return PNConfigurationImpl( diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListener.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListener.kt deleted file mode 100644 index 712a85ecc..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListener.kt +++ /dev/null @@ -1,74 +0,0 @@ -package com.pubnub.internal.v2.callbacks - -import com.pubnub.api.BasePubNub -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -import com.pubnub.api.models.consumer.pubsub.PNSignalResult -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.models.toApi - -open class DelegatingEventListener(private val listener: EventListener) : EventListenerCore { - override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNMessageResult, - ) { - listener.message(pubnub as PubNubImpl, event) - } - - override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNPresenceEventResult, - ) { - listener.presence(pubnub as PubNubImpl, event) - } - - override fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNSignalResult, - ) { - listener.signal(pubnub as PubNubImpl, event) - } - - override fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNMessageActionResult, - ) { - listener.messageAction(pubnub as PubNubImpl, event) - } - - override fun objects( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult, - ) { - listener.objects(pubnub as PubNubImpl, event.toApi()) - } - - override fun file( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNFileEventResult, - ) { - listener.file(pubnub as PubNubImpl, event) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - if (other !is DelegatingEventListener) { - return false - } - - if (listener != other.listener) { - return false - } - - return true - } - - override fun hashCode(): Int { - return listener.hashCode() - } -} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingStatusListener.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingStatusListener.kt deleted file mode 100644 index b1bb41d4a..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingStatusListener.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.pubnub.internal.v2.callbacks - -import com.pubnub.api.BasePubNub -import com.pubnub.api.PubNub -import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.api.v2.callbacks.StatusListener - -data class DelegatingStatusListener(private val listener: StatusListener) : com.pubnub.internal.v2.callbacks.StatusListenerCore { - override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - status: PNStatus, - ) { - listener.status(pubnub as PubNub, status) - } -} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallback.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallback.kt deleted file mode 100644 index 4ff169223..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallback.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.pubnub.internal.v2.callbacks - -import com.pubnub.api.BasePubNub -import com.pubnub.api.PubNub -import com.pubnub.api.callbacks.SubscribeCallback -import com.pubnub.api.models.consumer.PNStatus - -data class DelegatingSubscribeCallback(private val listener: SubscribeCallback) : - DelegatingEventListener(listener), - com.pubnub.internal.callbacks.SubscribeCallback { - override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - status: PNStatus, - ) { - listener.status(pubnub as PubNub, status) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImpl.kt similarity index 76% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImpl.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImpl.kt index 7ae454479..6d77ccaa6 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImpl.kt @@ -1,6 +1,6 @@ package com.pubnub.internal.v2.callbacks -import com.pubnub.api.BasePubNub +import com.pubnub.api.PubNub import com.pubnub.api.callbacks.Listener import com.pubnub.api.models.consumer.pubsub.PNEvent import com.pubnub.api.models.consumer.pubsub.PNMessageResult @@ -8,21 +8,22 @@ import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.api.v2.callbacks.BaseEventEmitter +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventEmitter +import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.internal.managers.AnnouncementCallback import com.pubnub.internal.managers.AnnouncementEnvelope -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult import org.jetbrains.annotations.TestOnly import java.util.concurrent.CopyOnWriteArraySet class EventEmitterImpl( override val phase: AnnouncementCallback.Phase, private val accepts: (AnnouncementEnvelope) -> Boolean = { true }, -) : BaseEventEmitter, AnnouncementCallback { +) : EventEmitter, AnnouncementCallback { @get:TestOnly - val listeners = CopyOnWriteArraySet() + val listeners = CopyOnWriteArraySet() - override fun addListener(listener: EventListenerCore) { + override fun addListener(listener: EventListener) { listeners.add(listener) } @@ -36,7 +37,7 @@ class EventEmitterImpl( // EventEmitter fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { listeners.forEach { @@ -45,7 +46,7 @@ class EventEmitterImpl( } fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { listeners.forEach { @@ -54,7 +55,7 @@ class EventEmitterImpl( } fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnSignalResult: PNSignalResult, ) { listeners.forEach { @@ -63,7 +64,7 @@ class EventEmitterImpl( } fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageActionResult: PNMessageActionResult, ) { listeners.forEach { @@ -72,7 +73,7 @@ class EventEmitterImpl( } fun objects( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, objectEvent: PNObjectEventResult, ) { listeners.forEach { @@ -81,7 +82,7 @@ class EventEmitterImpl( } fun file( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnFileEventResult: PNFileEventResult, ) { listeners.forEach { @@ -92,7 +93,7 @@ class EventEmitterImpl( // AnnouncementCallback override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) { if (accepts(envelope)) { @@ -101,7 +102,7 @@ class EventEmitterImpl( } override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) { if (accepts(envelope)) { @@ -110,7 +111,7 @@ class EventEmitterImpl( } override fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) { if (accepts(envelope)) { @@ -119,7 +120,7 @@ class EventEmitterImpl( } override fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) { if (accepts(envelope)) { @@ -128,7 +129,7 @@ class EventEmitterImpl( } override fun objects( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) { if (accepts(envelope)) { @@ -137,7 +138,7 @@ class EventEmitterImpl( } override fun file( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, envelope: AnnouncementEnvelope, ) { if (accepts(envelope)) { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelGroupImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelGroupImpl.kt index ae5f572ef..2b61f7762 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelGroupImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelGroupImpl.kt @@ -1,15 +1,60 @@ package com.pubnub.internal.v2.entities -import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.entities.ChannelGroup -import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.ReceivePresenceEventsImpl +import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.subscribe.PRESENCE_CHANNEL_SUFFIX import com.pubnub.internal.v2.subscription.SubscriptionImpl -class ChannelGroupImpl(pubnub: PubNubImpl, channelGroupName: ChannelGroupName) : - BaseChannelGroupImpl( - pubnub.pubNubCore, - channelGroupName, - { channels, channelGroups, options -> SubscriptionImpl(pubnub, channels, channelGroups, options) }, - ), - ChannelGroup +open class ChannelGroupImpl(val pubnub: PubNubImpl, val channelGroupName: ChannelGroupName) : ChannelGroup { + override val name: String = channelGroupName.id + + override fun subscription(options: SubscriptionOptions): SubscriptionImpl { + val channelGroups = + buildSet { + add(channelGroupName) + if (options.allOptions.filterIsInstance().isNotEmpty()) { + add(channelGroupName.withPresence) + } + } + return SubscriptionImpl( + pubnub, + emptySet(), + channelGroups, + SubscriptionOptions.filter { result -> + channelGroups.any { it.id == result.subscription } + } + options, + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + if (other !is ChannelGroupImpl) { + return false + } + + if (pubnub != other.pubnub) { + return false + } + if (name != other.name) { + return false + } + + return true + } + + override fun hashCode(): Int { + var result = pubnub.hashCode() + result = 31 * result + name.hashCode() + return result + } +} + +@JvmInline +value class ChannelGroupName(val id: String) { + val withPresence get() = ChannelGroupName("${this.id}$PRESENCE_CHANNEL_SUFFIX") + val isPresence get() = id.endsWith(PRESENCE_CHANNEL_SUFFIX) +} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt index 56df3191c..b1889522c 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelImpl.kt @@ -4,21 +4,72 @@ import com.pubnub.api.endpoints.files.DeleteFile import com.pubnub.api.endpoints.files.SendFile import com.pubnub.api.endpoints.pubsub.Publish import com.pubnub.api.endpoints.pubsub.Signal -import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.entities.Channel -import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.ReceivePresenceEventsImpl +import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.subscribe.PRESENCE_CHANNEL_SUFFIX import com.pubnub.internal.v2.subscription.SubscriptionImpl import java.io.InputStream -class ChannelImpl(pubnub: PubNubImpl, channelName: ChannelName) : - BaseChannelImpl( - pubnub.pubNubCore, - channelName, - { channels, channelGroups, options -> SubscriptionImpl(pubnub, channels, channelGroups, options) }, - ), - Channel { - private val pubNubImpl: PubNubImpl = pubnub +open class ChannelImpl(val pubNubImpl: PubNubImpl, val channelName: ChannelName) : Channel { + override val name: String = channelName.id + + override fun subscription(options: SubscriptionOptions): SubscriptionImpl { + val channels = + buildSet { + add(channelName) + if (options.allOptions.filterIsInstance().isNotEmpty()) { + add(channelName.withPresence) + } + } + return SubscriptionImpl( + pubNubImpl, + channels, + emptySet(), + SubscriptionOptions.filter { result -> + // simple channel name or presence channel + if (channels.any { it.id == result.channel }) { + return@filter true + } + + // wildcard channels + if (name.endsWith(".*") && + ( + result.subscription == name || + result.channel.startsWith(name.substringBeforeLast("*")) + ) + ) { + return@filter true + } + return@filter false + } + options, + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + if (other !is ChannelImpl) { + return false + } + + if (pubNubImpl != other.pubNubImpl) { + return false + } + if (name != other.name) { + return false + } + + return true + } + + override fun hashCode(): Int { + var result = pubNubImpl.hashCode() + result = 31 * result + name.hashCode() + return result + } override fun publish( message: Any, @@ -58,3 +109,9 @@ class ChannelImpl(pubnub: PubNubImpl, channelName: ChannelName) : return pubNubImpl.deleteFile(channelName.id, fileName, fileId) } } + +@JvmInline +value class ChannelName(val id: String) { + val withPresence get() = ChannelName("${this.id}$PRESENCE_CHANNEL_SUFFIX") + val isPresence get() = id.endsWith(PRESENCE_CHANNEL_SUFFIX) +} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelMetadataImpl.kt index e2a90e1ca..5d304340c 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/ChannelMetadataImpl.kt @@ -1,15 +1,47 @@ package com.pubnub.internal.v2.entities -import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.entities.ChannelMetadata -import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.internal.PubNubImpl import com.pubnub.internal.v2.subscription.SubscriptionImpl -class ChannelMetadataImpl(pubnub: PubNubImpl, channelName: ChannelName) : - BaseChannelMetadataImpl( - pubnub.pubNubCore, - channelName, - { channels, channelGroups, options -> SubscriptionImpl(pubnub, channels, channelGroups, options) }, - ), - ChannelMetadata +open class ChannelMetadataImpl(val pubnub: PubNubImpl, val channelName: ChannelName) : ChannelMetadata { + override val id: String = channelName.id + + override fun subscription(options: SubscriptionOptions): SubscriptionImpl { + val channels = setOf(channelName) + return SubscriptionImpl( + pubnub, + channels, + emptySet(), + SubscriptionOptions.filter { result -> + // simple channel name or presence channel + channels.any { it.id == result.channel } + } + options, + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + if (other !is ChannelMetadataImpl) { + return false + } + + if (pubnub != other.pubnub) { + return false + } + if (id != other.id) { + return false + } + + return true + } + + override fun hashCode(): Int { + var result = pubnub.hashCode() + result = 31 * result + id.hashCode() + return result + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/UserMetadataImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/UserMetadataImpl.kt index 7dada194c..20beeee72 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/UserMetadataImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/entities/UserMetadataImpl.kt @@ -1,15 +1,47 @@ package com.pubnub.internal.v2.entities -import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.entities.UserMetadata -import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.internal.PubNubImpl import com.pubnub.internal.v2.subscription.SubscriptionImpl -class UserMetadataImpl(pubnub: PubNubImpl, channelName: ChannelName) : - BaseUserMetadataImpl( - pubnub.pubNubCore, - channelName, - { channels, channelGroups, options -> SubscriptionImpl(pubnub, channels, channelGroups, options) }, - ), - UserMetadata +open class UserMetadataImpl(val pubnub: PubNubImpl, val channelName: ChannelName) : UserMetadata { + override val id: String = channelName.id + + override fun subscription(options: SubscriptionOptions): SubscriptionImpl { + val channels = setOf(channelName) + return SubscriptionImpl( + pubnub, + channels, + emptySet(), + SubscriptionOptions.filter { result -> + // simple channel name or presence channel + channels.any { it.id == result.channel } + } + options, + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + if (other !is UserMetadataImpl) { + return false + } + + if (pubnub != other.pubnub) { + return false + } + if (id != other.id) { + return false + } + + return true + } + + override fun hashCode(): Int { + var result = pubnub.hashCode() + result = 31 * result + id.hashCode() + return result + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImpl.kt new file mode 100644 index 000000000..8cef50268 --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImpl.kt @@ -0,0 +1,96 @@ +package com.pubnub.internal.v2.subscription + +import com.pubnub.api.callbacks.Listener +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult +import com.pubnub.api.models.consumer.pubsub.PNSignalResult +import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult +import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventEmitter +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.api.v2.subscriptions.SubscribeCapable +import com.pubnub.api.v2.subscriptions.SubscriptionCursor +import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.managers.AnnouncementCallback +import com.pubnub.internal.managers.AnnouncementEnvelope +import com.pubnub.internal.v2.callbacks.EventEmitterImpl +import java.util.concurrent.CopyOnWriteArraySet + +abstract class BaseSubscriptionSetImpl( + val pubnub: PubNubImpl, + initialSubscriptions: Set, +) : EventEmitter, SubscribeCapable, AutoCloseable { + protected val subscriptionsInternal: CopyOnWriteArraySet = CopyOnWriteArraySet() + abstract val subscriptions: Set + + private val eventEmitter = EventEmitterImpl(AnnouncementCallback.Phase.SET, ::accepts) + + private fun accepts(envelope: AnnouncementEnvelope<*>) = subscriptionsInternal.any { subscription -> subscription in envelope.acceptedBy } + + init { + require(initialSubscriptions.all { it.pubnub == pubnub }) { ERROR_WRONG_PUBNUB_INSTANCE } + subscriptionsInternal.addAll(initialSubscriptions) + pubnub.listenerManager.addAnnouncementCallback(eventEmitter) + } + + fun add(subscription: SubscriptionT) { + require(subscription is SubscriptionInternal) { ERROR_SUBSCRIPTION_WRONG_CLASS } + require(subscription.pubnub == pubnub) { ERROR_WRONG_PUBNUB_INSTANCE } + subscriptionsInternal.add(subscription) + } + + fun remove(subscription: SubscriptionT) { + require(subscription is SubscriptionInternal) { ERROR_SUBSCRIPTION_WRONG_CLASS } + subscriptionsInternal.remove(subscription) + } + + override fun subscribe(cursor: SubscriptionCursor) { + subscriptionsInternal.forEach { it.onSubscriptionActive(cursor) } + pubnub.subscribe(*subscriptionsInternal.toTypedArray(), cursor = cursor) + } + + override fun unsubscribe() { + subscriptionsInternal.forEach { it.onSubscriptionInactive() } + pubnub.unsubscribe(*subscriptionsInternal.toTypedArray()) + } + + override fun close() { + unsubscribe() + pubnub.listenerManager.removeAnnouncementCallback(eventEmitter) + } + + override fun addListener(listener: EventListener) { + eventEmitter.addListener(listener) + } + + override fun removeListener(listener: Listener) { + eventEmitter.removeListener(listener) + } + + override fun removeAllListeners() { + eventEmitter.removeAllListeners() + } + + operator fun plusAssign(subscription: SubscriptionT) { + add(subscription) + } + + operator fun minusAssign(subscription: SubscriptionT) { + remove(subscription) + } + + private val emitterHelper = EmitterHelper(eventEmitter) + override var onMessage: ((PNMessageResult) -> Unit)? by emitterHelper::onMessage + override var onPresence: ((PNPresenceEventResult) -> Unit)? by emitterHelper::onPresence + override var onSignal: ((PNSignalResult) -> Unit)? by emitterHelper::onSignal + override var onMessageAction: ((PNMessageActionResult) -> Unit)? by emitterHelper::onMessageAction + override var onObjects: ((PNObjectEventResult) -> Unit)? by emitterHelper::onObjects + override var onFile: ((PNFileEventResult) -> Unit)? by emitterHelper::onFile +} + +private const val ERROR_SUBSCRIPTION_WRONG_CLASS = + "Only Subscriptions returned from objects created" + + "through the PubNub instance and their methods, such as channel(...).subscriptions() are supported." +private const val ERROR_WRONG_PUBNUB_INSTANCE = + "Adding Subscriptions from another PubNub instance to a SubscriptionSet is not allowed." diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/EmitterHelper.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/EmitterHelper.kt index c669c0a09..56cd346e5 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/EmitterHelper.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/EmitterHelper.kt @@ -7,59 +7,55 @@ import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.api.v2.callbacks.BaseEventEmitter +import com.pubnub.api.v2.callbacks.EventEmitter import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.internal.v2.callbacks.DelegatingEventListener -import com.pubnub.internal.v2.callbacks.EventListenerCore -class EmitterHelper(eventEmitter: BaseEventEmitter) { +class EmitterHelper(eventEmitter: EventEmitter) { init { eventEmitter.addListener( - DelegatingEventListener( - object : EventListener { - override fun message( - pubnub: PubNub, - result: PNMessageResult, - ) { - onMessage?.invoke(result) - } + object : EventListener { + override fun message( + pubnub: PubNub, + result: PNMessageResult, + ) { + onMessage?.invoke(result) + } - override fun presence( - pubnub: PubNub, - result: PNPresenceEventResult, - ) { - onPresence?.invoke(result) - } + override fun presence( + pubnub: PubNub, + result: PNPresenceEventResult, + ) { + onPresence?.invoke(result) + } - override fun signal( - pubnub: PubNub, - result: PNSignalResult, - ) { - onSignal?.invoke(result) - } + override fun signal( + pubnub: PubNub, + result: PNSignalResult, + ) { + onSignal?.invoke(result) + } - override fun messageAction( - pubnub: PubNub, - result: PNMessageActionResult, - ) { - onMessageAction?.invoke(result) - } + override fun messageAction( + pubnub: PubNub, + result: PNMessageActionResult, + ) { + onMessageAction?.invoke(result) + } - override fun objects( - pubnub: PubNub, - result: PNObjectEventResult, - ) { - onObjects?.invoke(result) - } + override fun objects( + pubnub: PubNub, + result: PNObjectEventResult, + ) { + onObjects?.invoke(result) + } - override fun file( - pubnub: PubNub, - result: PNFileEventResult, - ) { - onFile?.invoke(result) - } - }, - ), + override fun file( + pubnub: PubNub, + result: PNFileEventResult, + ) { + onFile?.invoke(result) + } + }, ) } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/SubscriptionImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/SubscriptionImpl.kt index d86084c71..0107f4cef 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/SubscriptionImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/SubscriptionImpl.kt @@ -1,7 +1,7 @@ package com.pubnub.internal.v2.subscription import com.pubnub.api.callbacks.Listener -import com.pubnub.api.callbacks.SubscribeCallback +import com.pubnub.api.models.consumer.pubsub.PNEvent import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult @@ -9,41 +9,120 @@ import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.subscriptions.BaseSubscription -import com.pubnub.api.v2.subscriptions.BaseSubscriptionSet +import com.pubnub.api.v2.subscriptions.EmptyOptions +import com.pubnub.api.v2.subscriptions.FilterImpl import com.pubnub.api.v2.subscriptions.Subscription +import com.pubnub.api.v2.subscriptions.SubscriptionCursor import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.internal.PubNubImpl -import com.pubnub.internal.v2.callbacks.DelegatingEventListener -import com.pubnub.internal.v2.callbacks.DelegatingSubscribeCallback +import com.pubnub.internal.managers.AnnouncementCallback +import com.pubnub.internal.managers.AnnouncementEnvelope +import com.pubnub.internal.v2.callbacks.EventEmitterImpl import com.pubnub.internal.v2.entities.ChannelGroupName import com.pubnub.internal.v2.entities.ChannelName -class SubscriptionImpl( - private val pubnub: PubNubImpl, - channels: Set, - channelGroups: Set, - options: SubscriptionOptions, -) : Subscription, BaseSubscriptionImpl(pubnub.pubNubCore, channels, channelGroups, options) { - override fun addListener(listener: EventListener) { - addListener(DelegatingEventListener(listener)) - } +interface SubscriptionInternal : Subscription { + val pubnub: PubNubImpl - override fun removeListener(listener: Listener) { - when (listener) { - is SubscribeCallback -> { - super.removeListener(DelegatingSubscribeCallback(listener)) - } + fun onSubscriptionActive(cursor: SubscriptionCursor) - is EventListener -> { - super.removeListener(DelegatingEventListener(listener)) - } + fun onSubscriptionInactive() - else -> { - super.removeListener(listener) + val channels: Set + val channelGroups: Set +} + +open class SubscriptionImpl( + override val pubnub: PubNubImpl, + channels: Set = emptySet(), + channelGroups: Set = emptySet(), + val options: SubscriptionOptions = EmptyOptions, + eventEmitterFactory: (SubscriptionImpl) -> EventEmitterImpl = { subscriptionImpl -> + EventEmitterImpl(AnnouncementCallback.Phase.SUBSCRIPTION, subscriptionImpl::accepts) + } +) : SubscriptionInternal { + @Volatile + var isActive = false + @Synchronized + set(newValue) { + if (!field && newValue) { // wasn't active && is now active + pubnub.listenerManager.addAnnouncementCallback(eventEmitter) + } else if (field && !newValue) { // was active && no longer active + pubnub.listenerManager.removeAnnouncementCallback(eventEmitter) } + field = newValue } + + override val channels: Set = channels.toSet() + override val channelGroups: Set = channelGroups.toSet() + + private val filters: List = options.allOptions.filterIsInstance() + + /** + * To ensure that events are delivered with timestamps growing monotonically, + * we will set this to the highest received timestamp and compare incoming messages against it. + * + * This will be reset on subscribe(cursor) with the value from the SubscriptionCursor. + */ + private var lastTimetoken: Long = 0L + + protected val eventEmitter = eventEmitterFactory(this) + + fun accepts(envelope: AnnouncementEnvelope): Boolean { + val event = envelope.event + val accepted = isActive && filters.all { filter -> filter.predicate(event) } && checkAndUpdateTimetoken(event) + if (accepted) { + envelope.acceptedBy += this@SubscriptionImpl + } + return accepted + } + + private fun checkAndUpdateTimetoken(result: PNEvent): Boolean { + result.timetoken?.let { resultTimetoken -> + if (resultTimetoken <= lastTimetoken) { + return false + } else { + lastTimetoken = resultTimetoken + return true + } + } ?: return false + } + + override fun subscribe(cursor: SubscriptionCursor) { + onSubscriptionActive(cursor) + pubnub.subscribe(this, cursor = cursor) + } + + override fun onSubscriptionActive(cursor: SubscriptionCursor) { + lastTimetoken = cursor.timetoken + isActive = true + } + + override fun unsubscribe() { + onSubscriptionInactive() + pubnub.unsubscribe(this) + } + + override fun onSubscriptionInactive() { + lastTimetoken = 0L + isActive = false + } + + override fun close() { + unsubscribe() + } + + override fun addListener(listener: EventListener) { + eventEmitter.addListener(listener) + } + + override fun removeAllListeners() { + eventEmitter.removeAllListeners() + } + + override fun removeListener(listener: Listener) { + eventEmitter.removeListener(listener) } private val emitterHelper = EmitterHelper(eventEmitter) @@ -54,11 +133,6 @@ class SubscriptionImpl( override var onObjects: ((PNObjectEventResult) -> Unit)? by emitterHelper::onObjects override var onFile: ((PNFileEventResult) -> Unit)? by emitterHelper::onFile - /** - * Create a [BaseSubscriptionSet] that contains both subscriptions. - * - * @param subscription the other [BaseSubscription] to add to the [BaseSubscriptionSet] - */ override fun plus(subscription: Subscription): SubscriptionSet { return pubnub.subscriptionSetOf(setOf(this, subscription)) } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImpl.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImpl.kt index c783d87f7..5719e2ab2 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImpl.kt @@ -1,57 +1,12 @@ package com.pubnub.internal.v2.subscription -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.callbacks.SubscribeCallback -import com.pubnub.api.models.consumer.pubsub.PNMessageResult -import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult -import com.pubnub.api.models.consumer.pubsub.PNSignalResult -import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.subscriptions.Subscription import com.pubnub.api.v2.subscriptions.SubscriptionSet -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.v2.callbacks.DelegatingEventListener -import com.pubnub.internal.v2.callbacks.DelegatingSubscribeCallback +import com.pubnub.internal.PubNubImpl class SubscriptionSetImpl( - pubnub: PubNubCore, - initialSubscriptions: Set, -) : SubscriptionSet, BaseSubscriptionSetImpl(pubnub, initialSubscriptions) { - override operator fun plusAssign(subscription: Subscription) { - add(subscription) - } - - override fun minusAssign(subscription: Subscription) { - remove(subscription) - } - - override fun addListener(listener: EventListener) { - addListener(DelegatingEventListener(listener)) - } - - override fun removeListener(listener: Listener) { - when (listener) { - is SubscribeCallback -> { - super.removeListener(DelegatingSubscribeCallback(listener)) - } - - is EventListener -> { - super.removeListener(DelegatingEventListener(listener)) - } - - else -> { - super.removeListener(listener) - } - } - } - - private val emitterHelper = EmitterHelper(eventEmitter) - override var onMessage: ((PNMessageResult) -> Unit)? by emitterHelper::onMessage - override var onPresence: ((PNPresenceEventResult) -> Unit)? by emitterHelper::onPresence - override var onSignal: ((PNSignalResult) -> Unit)? by emitterHelper::onSignal - override var onMessageAction: ((PNMessageActionResult) -> Unit)? by emitterHelper::onMessageAction - override var onObjects: ((PNObjectEventResult) -> Unit)? by emitterHelper::onObjects - override var onFile: ((PNFileEventResult) -> Unit)? by emitterHelper::onFile + pubnub: PubNubImpl, + initialSubscriptions: Set, +) : BaseSubscriptionSetImpl(pubnub, initialSubscriptions), SubscriptionSet { + override val subscriptions: Set get() = subscriptionsInternal.toSet() as Set } diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/vendor/FileEncryptionUtil.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/vendor/FileEncryptionUtil.kt similarity index 97% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/vendor/FileEncryptionUtil.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/vendor/FileEncryptionUtil.kt index fa3de719b..d3c923549 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/vendor/FileEncryptionUtil.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/vendor/FileEncryptionUtil.kt @@ -1,7 +1,7 @@ package com.pubnub.internal.vendor import com.pubnub.api.PubNubException -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import java.io.ByteArrayInputStream import java.io.ByteArrayOutputStream import java.io.IOException @@ -26,7 +26,7 @@ object FileEncryptionUtil { const val CIPHER_TRANSFORMATION = "AES/CBC/PKCS5Padding" /** - * @see [PubNubCore.encryptInputStream] + * @see [PubNubImpl.encryptInputStream] */ @Throws(PubNubException::class) fun encrypt( @@ -37,7 +37,7 @@ object FileEncryptionUtil { } /** - * @see [PubNubCore.decryptInputStream] + * @see [PubNubImpl.decryptInputStream] */ @Throws(PubNubException::class) fun decrypt( diff --git a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessor.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessor.kt similarity index 95% rename from pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessor.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessor.kt index 8ed6304ce..ffcc1e328 100644 --- a/pubnub-core/pubnub-core-impl/src/main/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessor.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/main/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessor.kt @@ -12,14 +12,15 @@ import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult import com.pubnub.api.models.consumer.pubsub.objects.ObjectPayload -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.BasePNConfiguration.Companion.isValid -import com.pubnub.internal.PubNubCore +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.api.v2.PNConfiguration.Companion.isValid +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.PubNubUtil import com.pubnub.internal.extension.tryDecryptMessage import com.pubnub.internal.managers.DuplicationManager import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.internal.models.consumer.pubsub.objects.toApi import com.pubnub.internal.models.server.PresenceEnvelope import com.pubnub.internal.models.server.SubscribeMessage import com.pubnub.internal.models.server.files.FileUploadNotification @@ -28,7 +29,7 @@ import com.pubnub.internal.subscribe.PRESENCE_CHANNEL_SUFFIX import org.slf4j.LoggerFactory internal class SubscribeMessageProcessor( - private val pubnub: PubNubCore, + private val pubnub: PubNubImpl, private val duplicationManager: DuplicationManager, ) { private val log = LoggerFactory.getLogger("SubscribeMessageProcessor") @@ -123,7 +124,7 @@ internal class SubscribeMessageProcessor( pubnub.mapper.convertValue( extractedMessage, PNObjectEventMessage::class.java, - ), + ).toApi(), ) } @@ -199,7 +200,7 @@ internal class SubscribeMessageProcessor( } if (PubNubUtil.shouldSignRequest(pubnub.configuration)) { - val timestamp: Int = PubNubCore.timestamp() + val timestamp: Int = PubNubImpl.timestamp() val signature: String = generateSignature(pubnub.configuration, basePath, authKey, timestamp) queryParams.add(PubNubUtil.TIMESTAMP_QUERY_PARAM_NAME + "=" + timestamp) queryParams.add(PubNubUtil.SIGNATURE_QUERY_PARAM_NAME + "=" + signature) @@ -215,7 +216,7 @@ internal class SubscribeMessageProcessor( } private fun generateSignature( - configuration: BasePNConfiguration, + configuration: PNConfiguration, url: String, authKey: String?, timestamp: Int, diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/BasePNConfigurationImplTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/BasePNConfigurationImplTest.kt new file mode 100644 index 000000000..77490bffe --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/BasePNConfigurationImplTest.kt @@ -0,0 +1,16 @@ +package com.pubnub.api + +import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.v2.PNConfigurationImpl +import org.junit.Assert.assertEquals +import org.junit.Test + +class PNConfigurationImplTest { + @Test + fun testDefaultTimeoutValues() { + val p = PubNubImpl(PNConfigurationImpl(userId = UserId(PubNubImpl.generateUUID()))) + assertEquals(300, p.configuration.presenceTimeout) + assertEquals(0, p.configuration.heartbeatInterval) + p.forceDestroy() + } +} diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/Keys.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/Keys.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/Keys.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/Keys.kt diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/PNConfigurationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/PNConfigurationTest.kt deleted file mode 100644 index ebfc3ff30..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/PNConfigurationTest.kt +++ /dev/null @@ -1,124 +0,0 @@ -package com.pubnub.api - -import com.pubnub.api.crypto.CryptoModule -import com.pubnub.api.enums.PNReconnectionPolicy -import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.api.v2.PNConfigurationOverride -import com.pubnub.internal.BasePubNubImpl -import org.junit.Assert -import org.junit.Test - -class PNConfigurationTest { - @Suppress("DEPRECATION") - @Test(expected = PubNubException::class) - fun setUUIDToEmptyString() { - PNConfiguration("") - } - - @Suppress("DEPRECATION") - @Test(expected = PubNubException::class) - fun resetUUIDToEmptyString() { - val config = PNConfiguration(BasePubNubImpl.generateUUID()) - config.uuid = "" - } - - @Suppress("DEPRECATION") - @Test - fun resetUUIDToNonEmptyString() { - val config = PNConfiguration(BasePubNubImpl.generateUUID()) - val newUUID = BasePubNubImpl.generateUUID() - config.uuid = newUUID - - Assert.assertEquals(newUUID, config.userId.value) - } - - @Test - fun testDefaultTimeoutValues() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - Assert.assertEquals(300, config.presenceTimeout) - Assert.assertEquals(0, config.heartbeatInterval) - } - - @Test - fun testCustomTimeoutValues1() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - config.presenceTimeout = 100 - Assert.assertEquals(100, config.presenceTimeout) - Assert.assertEquals(49, config.heartbeatInterval) - } - - @Test - fun testCustomTimeoutValues2() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - config.heartbeatInterval = 100 - Assert.assertEquals(300, config.presenceTimeout) - Assert.assertEquals(100, config.heartbeatInterval) - } - - @Test - fun testCustomTimeoutValues3() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - config.heartbeatInterval = 40 - config.presenceTimeout = 50 - Assert.assertEquals(50, config.presenceTimeout) - Assert.assertEquals(24, config.heartbeatInterval) - } - - @Test - fun `reconnection policy should set retry configuration`() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - config.reconnectionPolicy = PNReconnectionPolicy.NONE - Assert.assertTrue(config.retryConfiguration is RetryConfiguration.None) - - config.reconnectionPolicy = PNReconnectionPolicy.LINEAR - Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Linear) - - config.reconnectionPolicy = PNReconnectionPolicy.EXPONENTIAL - Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Exponential) - } - - @Test - fun `maximumReconnectionRetries policy should reset retry configuration`() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - - config.reconnectionPolicy = PNReconnectionPolicy.LINEAR - config.maximumReconnectionRetries = 5 - Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Linear) - Assert.assertEquals(5, (config.retryConfiguration as RetryConfiguration.Linear).maxRetryNumber) - - config.maximumReconnectionRetries = 10 - Assert.assertTrue(config.retryConfiguration is RetryConfiguration.Linear) - Assert.assertEquals(10, (config.retryConfiguration as RetryConfiguration.Linear).maxRetryNumber) - } - - @Test - fun `cryptomodule uses cipherKey when cryptomodule is not set`() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - - config.cryptoModule = null - config.cipherKey = "enigma" - Assert.assertNotNull(config.cryptoModule) - } - - @Test - fun `cryptomodule uses cryptomodule when cryptomodule is set`() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())) - val expectedCryptoModule = CryptoModule.createAesCbcCryptoModule("cipher") - config.cryptoModule = expectedCryptoModule - config.cipherKey = "enigma" - - Assert.assertEquals(expectedCryptoModule, config.cryptoModule) - } - - @Test - fun `create config override from existing config`() { - val config = PNConfiguration(UserId(BasePubNubImpl.generateUUID())).apply { - subscribeKey = "expectedSubscribe" - } - val override = PNConfigurationOverride.from(config).apply { - userId = UserId("override") - }.build() - Assert.assertEquals("override", override.userId.value) - Assert.assertEquals("expectedSubscribe", override.subscribeKey) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/PubNubUtilTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/PubNubUtilTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/PubNubUtilTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/PubNubUtilTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/UserIdTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/UserIdTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/UserIdTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/UserIdTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/crypto/CryptoModuleTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/crypto/CryptoModuleTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/crypto/CryptoModuleTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/crypto/CryptoModuleTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/crypto/algorithm/AesCBCCryptorTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/crypto/algorithm/AesCBCCryptorTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/crypto/algorithm/AesCBCCryptorTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/crypto/algorithm/AesCBCCryptorTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/crypto/algorithm/LegacyCryptorTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/crypto/algorithm/LegacyCryptorTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/crypto/algorithm/LegacyCryptorTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/crypto/algorithm/LegacyCryptorTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/crypto/cryptor/HeaderParserTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/crypto/cryptor/HeaderParserTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/crypto/cryptor/HeaderParserTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/crypto/cryptor/HeaderParserTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/endpoints/access/GrantTokenTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/endpoints/access/GrantTokenTest.kt similarity index 91% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/endpoints/access/GrantTokenTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/endpoints/access/GrantTokenTest.kt index ab4378e42..19be22388 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/endpoints/access/GrantTokenTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/endpoints/access/GrantTokenTest.kt @@ -1,18 +1,17 @@ package com.pubnub.api.endpoints.access +import com.pubnub.api.SpaceId import com.pubnub.api.UserId +import com.pubnub.api.models.consumer.access_manager.sum.SpacePermissions import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.SpaceId -import com.pubnub.internal.TestPubNub +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.access.GrantTokenEndpoint import com.pubnub.internal.managers.RetrofitManager -import com.pubnub.internal.models.consumer.access_manager.sum.SpacePermissions import com.pubnub.internal.models.server.access_manager.v3.GrantTokenData import com.pubnub.internal.models.server.access_manager.v3.GrantTokenRequestBody import com.pubnub.internal.models.server.access_manager.v3.GrantTokenResponse import com.pubnub.internal.services.AccessManagerService -import com.pubnub.internal.v2.BasePNConfigurationImpl +import com.pubnub.internal.v2.PNConfigurationImpl import io.mockk.MockKAnnotations import io.mockk.every import io.mockk.impl.annotations.MockK @@ -26,18 +25,18 @@ import retrofit2.Call import retrofit2.Response internal class GrantTokenTest { - private lateinit var pubnub: PubNubCore + private lateinit var pubnub: PubNubImpl @BeforeEach internal fun setUp() { MockKAnnotations.init(this) val pnConfiguration = - BasePNConfigurationImpl( + PNConfigurationImpl( userId = UserId("myUserId"), subscribeKey = "something", secretKey = "something", ) - pubnub = spyk(TestPubNub(configuration = pnConfiguration).pubNubCore) + pubnub = spyk(PubNubImpl(configuration = pnConfiguration)) } @MockK diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/endpoints/pubsub/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/endpoints/pubsub/PublishTest.kt similarity index 87% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/endpoints/pubsub/PublishTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/endpoints/pubsub/PublishTest.kt index 543c15d8e..2af305d68 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/endpoints/pubsub/PublishTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/endpoints/pubsub/PublishTest.kt @@ -2,12 +2,11 @@ package com.pubnub.api.endpoints.pubsub import com.pubnub.api.UserId import com.pubnub.api.crypto.CryptoModule -import com.pubnub.internal.BasePubNubImpl -import com.pubnub.internal.TestPubNub +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.pubsub.PublishEndpoint import com.pubnub.internal.managers.RetrofitManager import com.pubnub.internal.services.PublishService -import com.pubnub.internal.v2.BasePNConfigurationImpl +import com.pubnub.internal.v2.PNConfigurationImpl import io.mockk.every import io.mockk.mockk import io.mockk.slot @@ -30,22 +29,22 @@ private const val CIPHER_KEY = "enigma" class PublishTest { private val pnConfigurationHardcodedIV = - BasePNConfigurationImpl( - userId = UserId(BasePubNubImpl.generateUUID()), + PNConfigurationImpl( + userId = UserId(PubNubImpl.generateUUID()), subscribeKey = TEST_SUBKEY, publishKey = TEST_PUBKEY, cryptoModule = CryptoModule.createLegacyCryptoModule(CIPHER_KEY, false), ) private val pnConfigurationRandomIV = - BasePNConfigurationImpl( - userId = UserId(BasePubNubImpl.generateUUID()), + PNConfigurationImpl( + userId = UserId(PubNubImpl.generateUUID()), subscribeKey = TEST_SUBKEY, publishKey = TEST_PUBKEY, cryptoModule = CryptoModule.createLegacyCryptoModule(CIPHER_KEY, true), ) - private val pubNubHardcodedIVMock = spyk(TestPubNub(pnConfigurationHardcodedIV).pubNubCore) - private val pubNubRandomIVMock = spyk(TestPubNub(pnConfigurationRandomIV).pubNubCore) + private val pubNubHardcodedIVMock = spyk(PubNubImpl(pnConfigurationHardcodedIV)) + private val pubNubRandomIVMock = spyk(PubNubImpl(pnConfigurationRandomIV)) private val retrofitManagerMock = mockk() private val publishServiceMock = mockk() diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt similarity index 75% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt index 81ce046aa..f7175fd02 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt @@ -5,11 +5,9 @@ import com.github.tomakehurst.wiremock.client.WireMock import com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig import com.pubnub.api.UserId import com.pubnub.api.enums.PNLogVerbosity -import com.pubnub.internal.BasePubNubImpl -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.TestPubNub +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.internal.PubNubImpl import com.pubnub.test.CommonUtils.defaultListenDuration -import com.pubnub.test.TestPNConfigurationImpl import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import org.junit.After import org.junit.Assert.assertTrue @@ -17,13 +15,10 @@ import org.junit.Before abstract class BaseTest { lateinit var wireMockServer: WireMockServer - protected val pubnubBase: TestPubNub by lazy { - TestPubNub(config.build()) + protected val pubnub: PubNubImpl by lazy { + PubNubImpl(config.build()) } - protected val pubnub: PubNubCore by lazy { - pubnubBase.pubNubCore - } - protected lateinit var config: TestPNConfigurationImpl.Builder private set + protected lateinit var config: PNConfiguration.Builder private set @Before open fun beforeEach() { @@ -63,7 +58,7 @@ abstract class BaseTest { } fun createConfiguration() = - TestPNConfigurationImpl.Builder(userId = UserId("myUUID")).apply { + PNConfiguration.builder(userId = UserId("myUUID"), "") { subscribeKey = "mySubscribeKey" publishKey = "myPublishKey" origin = wireMockServer.baseUrl().toHttpUrlOrNull()!!.run { "$host:$port" } @@ -72,6 +67,6 @@ abstract class BaseTest { } fun clearConfiguration() { - config = TestPNConfigurationImpl.Builder(userId = UserId(BasePubNubImpl.generateUUID())) + config = PNConfiguration.builder(userId = UserId(PubNubImpl.generateUUID()), "") } } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt similarity index 77% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt index 5f414f7ab..124ebacc2 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt @@ -2,14 +2,12 @@ package com.pubnub.api.legacy import com.pubnub.api.crypto.CryptoModule import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.TestPubNub -import com.pubnub.internal.managers.ListenerManager +import com.pubnub.internal.PubNubImpl import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test -class PubNubCoreTest : BaseTest() { +class PubNubImplTest : BaseTest() { override fun onBefore() { clearConfiguration() } @@ -20,14 +18,6 @@ class PubNubCoreTest : BaseTest() { assertEquals("https://ps.pndsn.com", pubnub.baseUrl()) } - @Test - fun testEncryptCustomKey() { - assertEquals( - "iALQtn3PfIXe74CT/wrS7g==", - pubnub.encrypt("test1", CryptoModule.createLegacyCryptoModule("cipherKey", false)).trim(), - ) - } - @Test fun testEncryptConfigurationKey() { config.cryptoModule = CryptoModule.createLegacyCryptoModule("cipherKey", false) @@ -64,8 +54,8 @@ class PubNubCoreTest : BaseTest() { @Test fun getVersionAndTimeStamp() { - val version = PubNubCore.SDK_VERSION - val timeStamp = PubNubCore.timestamp() + val version = PubNubImpl.SDK_VERSION + val timeStamp = PubNubImpl.timestamp() assertEquals("9.2.3", version) assertTrue(timeStamp > 0) } @@ -85,16 +75,15 @@ class PubNubCoreTest : BaseTest() { } val generatedPnsdk = pubnub.generatePnsdk() - assertEquals("PubNub-Test/${PubNubCore.SDK_VERSION} $suffix11 $suffix2", generatedPnsdk) + assertEquals("PubNub-Kotlin/${PubNubImpl.SDK_VERSION} $suffix11 $suffix2", generatedPnsdk) } @Test fun pnGeneratesPnsdkWithPnsdkName() { - val pubNubCore = PubNubCore( + val pubNubCore = PubNubImpl( config.build(), - ListenerManager(TestPubNub(config.build())), pnsdkName = "PubNub-ABC", ) - assertEquals(pubNubCore.generatePnsdk(), "PubNub-ABC/${PubNubCore.SDK_VERSION}") + assertEquals(pubNubCore.generatePnsdk(), "PubNub-ABC/${PubNubImpl.SDK_VERSION}") } } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/DeleteMessagesCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/DeleteMessagesCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/DeleteMessagesCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/DeleteMessagesCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/EndpointCoreTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/EndpointCoreTest.kt similarity index 96% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/EndpointCoreTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/EndpointCoreTest.kt index 9bcbd9210..ec24775cf 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/EndpointCoreTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/EndpointCoreTest.kt @@ -12,9 +12,9 @@ import com.pubnub.api.UserId import com.pubnub.api.enums.PNOperationType import com.pubnub.api.legacy.BaseTest import com.pubnub.api.retry.RetryableEndpointGroup -import com.pubnub.internal.BasePubNubImpl import com.pubnub.internal.EndpointCore -import com.pubnub.internal.v2.BasePNConfigurationImpl +import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.v2.PNConfigurationImpl import com.pubnub.test.listen import okhttp3.Request import okio.Timeout @@ -103,8 +103,8 @@ class EndpointCoreTest : BaseTest() { assertNull(it["instanceid"]) assertNull(it["requestid"]) }.apply { - overrideConfiguration( - BasePNConfigurationImpl( + overrideConfigurationInternal( + PNConfigurationImpl( userId = config.userId, includeRequestIdentifier = false, includeInstanceIdentifier = false, @@ -115,7 +115,7 @@ class EndpointCoreTest : BaseTest() { @Test fun testUuid() { - val expectedUuid = UserId(BasePubNubImpl.generateUUID()) + val expectedUuid = UserId(PubNubImpl.generateUUID()) config.userId = expectedUuid // initPubNub() @@ -126,13 +126,13 @@ class EndpointCoreTest : BaseTest() { @Test fun testOverrideConfiguration_Uuid() { - val expectedUuid = UserId(BasePubNubImpl.generateUUID()) + val expectedUuid = UserId(PubNubImpl.generateUUID()) config.userId = UserId("someOtherUUID") fakeEndpoint { assertEquals(expectedUuid.value, it["uuid"]) }.apply { - overrideConfiguration(BasePNConfigurationImpl(userId = expectedUuid)) + overrideConfigurationInternal(PNConfigurationImpl(userId = expectedUuid)) }.sync() } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/HeartbeatCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/HeartbeatCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/HeartbeatCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/HeartbeatCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/access/GrantEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/access/GrantEndpointTest.kt similarity index 99% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/access/GrantEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/access/GrantEndpointTest.kt index 5126b54a0..a42900d8d 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/access/GrantEndpointTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/access/GrantEndpointTest.kt @@ -11,7 +11,7 @@ import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException import com.pubnub.api.legacy.BaseTest -import com.pubnub.internal.models.consumer.access_manager.PNAccessManagerKeyData +import com.pubnub.api.models.consumer.access_manager.PNAccessManagerKeyData import com.pubnub.test.CommonUtils.assertPnException import com.pubnub.test.CommonUtils.failTest import com.pubnub.test.SignatureUtils.decomposeAndVerifySignature diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/AddChannelBaseChannelGroupCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/AddChannelBaseChannelGroupCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/AddChannelBaseChannelGroupCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/AddChannelBaseChannelGroupCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/AllChannelsBaseChannelGroupCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/AllChannelsBaseChannelGroupCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/AllChannelsBaseChannelGroupCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/AllChannelsBaseChannelGroupCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/DeleteBaseChannelGroupCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/DeleteBaseChannelGroupCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/DeleteBaseChannelGroupCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/DeleteBaseChannelGroupCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/ListAllBaseChannelGroupCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/ListAllBaseChannelGroupCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/ListAllBaseChannelGroupCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/ListAllBaseChannelGroupCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/RemoveChannelBaseChannelGroupCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/RemoveChannelBaseChannelGroupCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/RemoveChannelBaseChannelGroupCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/channel_groups/RemoveChannelBaseChannelGroupCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/GetFileUrlTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/GetFileUrlTest.kt similarity index 77% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/GetFileUrlTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/GetFileUrlTest.kt index 20896f147..d7d89823f 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/GetFileUrlTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/GetFileUrlTest.kt @@ -3,27 +3,25 @@ package com.pubnub.api.legacy.endpoints.files import com.pubnub.api.PubNubException import com.pubnub.api.UserId import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.internal.BasePubNubImpl -import com.pubnub.internal.TestPubNub -import com.pubnub.test.TestPNConfigurationImpl +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.internal.PubNubImpl import okhttp3.HttpUrl.Companion.toHttpUrl import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers import org.junit.Assert import org.junit.Test -import java.util.Arrays class GetFileUrlTest { private val channel = "channel" private val fileName = "fileName" private val fileId = "fileId" - private val defaultQueryParams: Set = HashSet(Arrays.asList("pnsdk", "requestid", "uuid")) + private val defaultQueryParams: Set = HashSet(listOf("pnsdk", "requestid", "uuid")) @Test @Throws(PubNubException::class) fun noAdditionalQueryParamsWhenNotSecretNorAuth() { // given - val pubnub = TestPubNub(config().build()).pubNubCore + val pubnub = PubNubImpl(config().build()) // when val url = @@ -43,7 +41,7 @@ class GetFileUrlTest { @Throws(PubNubException::class) fun signatureAndTimestampQueryParamsAreSetWhenSecret() { // given - val pubnub = TestPubNub(withSecret(config()).build()).pubNubCore + val pubnub = PubNubImpl(withSecret(config()).build()) // when val url = @@ -63,7 +61,7 @@ class GetFileUrlTest { @Throws(PubNubException::class) fun authQueryParamIsSetWhenAuth() { // given - val pubnub = TestPubNub(withAuth(config()).build()).pubNubCore + val pubnub = PubNubImpl(withAuth(config()).build()) // when val url = @@ -83,7 +81,7 @@ class GetFileUrlTest { @Throws(PubNubException::class) fun signatureAndTimestampAndAuthQueryParamsAreSetWhenSecretAndAuth() { // given - val pubnub = TestPubNub(withSecret(withAuth(config())).build()).pubNubCore + val pubnub = PubNubImpl(withSecret(withAuth(config())).build()) // when val url = @@ -103,20 +101,20 @@ class GetFileUrlTest { ) } - private fun config(): TestPNConfigurationImpl.Builder { - val config = TestPNConfigurationImpl.Builder(userId = UserId(BasePubNubImpl.generateUUID())) + private fun config(): PNConfiguration.Builder { + val config = PNConfiguration.builder(userId = UserId(PubNubImpl.generateUUID()), "") config.publishKey = "pk" config.subscribeKey = "sk" config.retryConfiguration = RetryConfiguration.Linear(delayInSec = 4, maxRetryNumber = 3) return config } - private fun withSecret(config: TestPNConfigurationImpl.Builder): TestPNConfigurationImpl.Builder { + private fun withSecret(config: PNConfiguration.Builder): PNConfiguration.Builder { config.secretKey = "secK" return config } - private fun withAuth(config: TestPNConfigurationImpl.Builder): TestPNConfigurationImpl.Builder { + private fun withAuth(config: PNConfiguration.Builder): PNConfiguration.Builder { config.authKey = "ak" return config } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/SendFileTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/SendFileTest.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/SendFileTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/SendFileTest.kt index 692449bb8..7bf735c51 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/SendFileTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/SendFileTest.kt @@ -6,10 +6,9 @@ import com.pubnub.api.models.consumer.files.PNBaseFile import com.pubnub.api.models.consumer.files.PNFileUploadResult import com.pubnub.api.models.consumer.files.PNPublishFileMessageResult import com.pubnub.api.retry.RetryConfiguration -import com.pubnub.api.v2.BasePNConfiguration +import com.pubnub.api.v2.PNConfiguration import com.pubnub.api.v2.callbacks.Result -import com.pubnub.internal.PubNubCore -import com.pubnub.internal.TestPubNub +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.endpoints.files.GenerateUploadUrlEndpoint import com.pubnub.internal.endpoints.files.PublishFileMessageEndpoint import com.pubnub.internal.endpoints.files.SendFileEndpoint @@ -203,27 +202,25 @@ class SendFileTest : TestsWithFiles { ) } - private fun getPubNubMock(): TestPubNub { - val mockConfig = mockk() - val mockPubNub = mockk() - val mockPubNubImpl = mockk() + private fun getPubNubMock(): PubNubImpl { + val mockConfig = mockk() + val mockPubNub = mockk() val retryConfiguration = RetryConfiguration.None every { mockConfig.retryConfiguration } returns retryConfiguration - every { mockPubNub.pubNubCore } returns mockPubNubImpl - every { mockPubNubImpl.configuration } returns mockConfig + every { mockPubNub.configuration } returns mockConfig return mockPubNub } internal class FailingPublishFileMessage( private val result: PNPublishFileMessageResult, private val numberOfFailsBeforeSuccess: Int, - pubNub: TestPubNub, + pubNub: PubNubImpl, ) : PublishFileMessageEndpoint( channel = "channel", fileName = "fileName", fileId = "fileId", - pubNub = pubNub.pubNubCore, + pubNub = pubNub, ) { private val numberOfFails = AtomicInteger(0) @@ -247,7 +244,7 @@ class SendFileTest : TestsWithFiles { fun create( result: PNPublishFileMessageResult, numberOfFailsBeforeSuccess: Int, - pubNub: TestPubNub, + pubNub: PubNubImpl, ): PublishFileMessageEndpoint { return FailingPublishFileMessage( result, @@ -260,13 +257,13 @@ class SendFileTest : TestsWithFiles { internal class AlwaysSuccessfulPublishFileMessage( private val result: PNPublishFileMessageResult, - pubNub: TestPubNub, + pubNub: PubNubImpl, ) : PublishFileMessageEndpoint( channel = "channel", fileName = "fileName", fileId = "fileId", - pubNub = pubNub.pubNubCore, + pubNub = pubNub, ) { @Throws(PubNubException::class) override fun sync(): PNPublishFileMessageResult { @@ -280,7 +277,7 @@ class SendFileTest : TestsWithFiles { companion object { fun create( result: PNPublishFileMessageResult, - pubNub: TestPubNub, + pubNub: PubNubImpl, ): PublishFileMessageEndpoint { return AlwaysSuccessfulPublishFileMessage(result, pubNub) } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/TestsWithFiles.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/TestsWithFiles.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/TestsWithFiles.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/TestsWithFiles.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/UploadFileTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/UploadFileTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/UploadFileTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/files/UploadFileTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/FetchMessagesCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/FetchMessagesCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/FetchMessagesCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/FetchMessagesCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/HistoryCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/HistoryCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/HistoryCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/HistoryCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/MessageCountTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/MessageCountTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/MessageCountTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/history/MessageCountTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/AddMessageActionCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/AddMessageActionCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/AddMessageActionCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/AddMessageActionCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/GetMessageActionCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/GetMessageActionCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/GetMessageActionCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/GetMessageActionCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/ReceiveMessageActions.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/ReceiveMessageActions.kt similarity index 89% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/ReceiveMessageActions.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/ReceiveMessageActions.kt index 9b12782af..45b7dc3c0 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/ReceiveMessageActions.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/ReceiveMessageActions.kt @@ -4,14 +4,14 @@ import com.github.tomakehurst.wiremock.client.WireMock.aResponse import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo -import com.pubnub.api.BasePubNub +import com.pubnub.api.PubNub +import com.pubnub.api.callbacks.SubscribeCallback import com.pubnub.api.legacy.BaseTest import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.internal.callbacks.SubscribeCallback import com.pubnub.test.CommonUtils.failTest import com.pubnub.test.listen import org.junit.Assert.assertEquals @@ -65,37 +65,37 @@ class ReceiveMessageActions : BaseTest() { val success = AtomicBoolean() - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { } override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { failTest() } override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { failTest() } override fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnSignalResult: PNSignalResult, ) { failTest() } override fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageActionResult: PNMessageActionResult, ) { assertEquals(pnMessageActionResult.channel, "coolChannel") @@ -185,16 +185,16 @@ class ReceiveMessageActions : BaseTest() { val count = AtomicInteger() val success = AtomicBoolean() - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { } override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { failTest() @@ -202,21 +202,21 @@ class ReceiveMessageActions : BaseTest() { } override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { failTest() } override fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnSignalResult: PNSignalResult, ) { failTest() } override fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageActionResult: PNMessageActionResult, ) { count.incrementAndGet() diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/RemoveMessageActionCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/RemoveMessageActionCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/RemoveMessageActionCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/message_actions/RemoveMessageActionCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/GetStateCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/GetStateCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/GetStateCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/GetStateCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/HereNowCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/HereNowCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/HereNowCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/HereNowCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/LeaveTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/LeaveTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/LeaveTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/LeaveTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/StateSetCoreEndpointEETest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/StateSetCoreEndpointEETest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/StateSetCoreEndpointEETest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/StateSetCoreEndpointEETest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/StateSetCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/StateSetCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/StateSetCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/StateSetCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/WhereNowCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/WhereNowCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/WhereNowCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/presence/WhereNowCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/PublishTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/PublishTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/PublishTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/PublishTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SignalTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SignalTest.kt similarity index 92% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SignalTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SignalTest.kt index 988016b4b..35e34a551 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SignalTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SignalTest.kt @@ -6,16 +6,16 @@ import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.client.WireMock.urlMatching -import com.pubnub.api.BasePubNub +import com.pubnub.api.PubNub import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.callbacks.SubscribeCallback import com.pubnub.api.legacy.BaseTest import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.internal.callbacks.SubscribeCallback import com.pubnub.test.CommonUtils.assertPnException import com.pubnub.test.listen import okhttp3.HttpUrl.Companion.toHttpUrlOrNull @@ -135,10 +135,10 @@ class SignalTest : BaseTest() { val success = AtomicBoolean() - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnSignalResult: PNSignalResult, ) { assertEquals("coolChannel", pnSignalResult.channel) @@ -148,22 +148,22 @@ class SignalTest : BaseTest() { } override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) {} override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) {} override fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageActionResult: PNMessageActionResult, ) {} }, diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SubscribeCoreEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SubscribeCoreEndpointTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SubscribeCoreEndpointTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/pubsub/SubscribeCoreEndpointTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/AddChannelsToPushTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/AddChannelsToPushTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/AddChannelsToPushTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/AddChannelsToPushTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/ListPushProvisionsTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/ListPushProvisionsTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/ListPushProvisionsTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/ListPushProvisionsTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/PushPayloadHelperHelperTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/RemoveAllPushChannelsForDeviceTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/RemoveAllPushChannelsForDeviceTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/RemoveAllPushChannelsForDeviceTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/RemoveAllPushChannelsForDeviceTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/RemoveChannelsFromPushTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/RemoveChannelsFromPushTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/RemoveChannelsFromPushTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/push/RemoveChannelsFromPushTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/CancellableRemoteAction.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/CancellableRemoteAction.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/CancellableRemoteAction.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/CancellableRemoteAction.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/ComposableRemoteActionTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/ComposableRemoteActionTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/ComposableRemoteActionTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/ComposableRemoteActionTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/RetryingRemoteActionTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/RetryingRemoteActionTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/RetryingRemoteActionTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/RetryingRemoteActionTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/TestRemoteAction.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/TestRemoteAction.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/TestRemoteAction.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/endpoints/remoteaction/TestRemoteAction.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/managers/BasePathManagerTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/managers/BasePathManagerTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/managers/BasePathManagerTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/managers/BasePathManagerTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/managers/PublishSequenceManagerTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/managers/PublishSequenceManagerTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/managers/PublishSequenceManagerTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/managers/PublishSequenceManagerTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/managers/SubscriptionManagerTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/managers/SubscriptionManagerTest.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/managers/SubscriptionManagerTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/managers/SubscriptionManagerTest.kt index 85f32051b..cb51d3699 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/managers/SubscriptionManagerTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/managers/SubscriptionManagerTest.kt @@ -12,7 +12,8 @@ import com.github.tomakehurst.wiremock.client.WireMock.urlMatching import com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching import com.github.tomakehurst.wiremock.matching.UrlPathPattern import com.google.gson.reflect.TypeToken -import com.pubnub.api.BasePubNub +import com.pubnub.api.PubNub +import com.pubnub.api.callbacks.SubscribeCallback import com.pubnub.api.crypto.CryptoModule import com.pubnub.api.enums.PNHeartbeatNotificationOptions import com.pubnub.api.enums.PNStatusCategory @@ -22,7 +23,7 @@ import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.retry.RetryConfiguration import com.pubnub.internal.PubNubUtil -import com.pubnub.internal.callbacks.SubscribeCallback +import com.pubnub.internal.managers.MapperManager import com.pubnub.internal.toCsv import com.pubnub.test.CommonUtils.emptyJson import org.awaitility.Awaitility @@ -137,24 +138,24 @@ class SubscriptionManagerTest : BaseTest() { channels = listOf(""), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { gotMessages.addAndGet(1) } override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { gotMessages.addAndGet(1) } override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { gotMessages.addAndGet(1) @@ -208,24 +209,24 @@ class SubscriptionManagerTest : BaseTest() { channelGroups = listOf(""), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { gotMessages.addAndGet(1) } override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { gotMessages.addAndGet(1) } override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { gotMessages.addAndGet(1) @@ -353,10 +354,10 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNConnectedCategory) { @@ -365,12 +366,12 @@ class SubscriptionManagerTest : BaseTest() { } override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*"))) assertTrue(requests.size > 0) - assertEquals("Message", pubnubBase.pubNubCore.mapper.elementToString(pnMessageResult.message, "text")) + assertEquals("Message", MapperManager().elementToString(pnMessageResult.message, "text")) assertEquals("coolChannel", pnMessageResult.channel) assertEquals(null, pnMessageResult.subscription) assertEquals("Publisher-A", pnMessageResult.publisher) @@ -461,17 +462,17 @@ class SubscriptionManagerTest : BaseTest() { .willReturn(emptyJson()), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { gotMessages.addAndGet(1) } override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} }, @@ -556,15 +557,15 @@ class SubscriptionManagerTest : BaseTest() { .willReturn(emptyJson()), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { gotMessages.addAndGet(1) @@ -672,15 +673,15 @@ class SubscriptionManagerTest : BaseTest() { .willReturn(notFound()), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { gotMessages.addAndGet(1) @@ -727,10 +728,10 @@ class SubscriptionManagerTest : BaseTest() { ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNConnectionError && pnStatus.exception?.statusCode == 403) { @@ -789,10 +790,10 @@ class SubscriptionManagerTest : BaseTest() { ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNConnectedCategory) { @@ -802,12 +803,12 @@ class SubscriptionManagerTest : BaseTest() { } override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*"))) assertTrue(requests.size > 0) - assertEquals("Message", pubnubBase.pubNubCore.mapper.elementToString(pnMessageResult.message, "text")) + assertEquals("Message", MapperManager().elementToString(pnMessageResult.message, "text")) assertEquals("coolChannel", pnMessageResult.channel) assertEquals("coolChannelGroup", pnMessageResult.subscription) gotMessage.set(true) @@ -862,10 +863,10 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNConnectedCategory) { @@ -874,7 +875,7 @@ class SubscriptionManagerTest : BaseTest() { } override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { val requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*"))) @@ -939,10 +940,10 @@ class SubscriptionManagerTest : BaseTest() { ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNConnectedCategory) { @@ -951,7 +952,7 @@ class SubscriptionManagerTest : BaseTest() { } override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { val requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*"))) @@ -1089,16 +1090,16 @@ class SubscriptionManagerTest : BaseTest() { .willReturn(emptyJson()), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { } override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { println("--==" + pnMessageResult.message) @@ -1172,15 +1173,15 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*"))) @@ -1243,15 +1244,15 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*"))) @@ -1335,10 +1336,10 @@ class SubscriptionManagerTest : BaseTest() { config.heartbeatNotificationOptions = PNHeartbeatNotificationOptions.ALL config.maintainPresenceState = true - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { // do nothing @@ -1438,15 +1439,15 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*"))) @@ -1504,15 +1505,15 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*"))) @@ -1591,15 +1592,15 @@ class SubscriptionManagerTest : BaseTest() { .willReturn(notFound()), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = @@ -1650,20 +1651,20 @@ class SubscriptionManagerTest : BaseTest() { ), ) config.cryptoModule = CryptoModule.createLegacyCryptoModule("hello", false) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*"))) assertTrue(requests.size > 0) - assertEquals("hey", pubnubBase.pubNubCore.mapper.elementToString(pnMessageResult.message, "text")) + assertEquals("hey", MapperManager().elementToString(pnMessageResult.message, "text")) atomic.addAndGet(1) } }, @@ -1715,15 +1716,15 @@ class SubscriptionManagerTest : BaseTest() { config.cryptoModule = CryptoModule.createLegacyCryptoModule("hello", false) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*"))) @@ -1781,15 +1782,15 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = @@ -1852,15 +1853,15 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { if (atomic.get() == 0) { @@ -1922,15 +1923,15 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { if (atomic.get() == 0) { @@ -1996,15 +1997,15 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { if (atomic.get() == 0) { @@ -2070,15 +2071,15 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { if (atomic.get() == 0) { @@ -2144,15 +2145,15 @@ class SubscriptionManagerTest : BaseTest() { ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { if (atomic.get() == 0) { @@ -2233,15 +2234,15 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { if (pnPresenceEventResult.event == "state-change") { @@ -2303,15 +2304,15 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) {} override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = findAll(getRequestedFor(urlMatching("/v2/subscribe.*"))) @@ -2342,31 +2343,31 @@ class SubscriptionManagerTest : BaseTest() { val atomic = AtomicInteger(0) val sub1: SubscribeCallback = - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { atomic.addAndGet(1) } override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { atomic.addAndGet(1) } override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { atomic.addAndGet(1) } } - pubnubBase.addListener(sub1) - pubnubBase.removeListener(sub1) + pubnub.addListener(sub1) + pubnub.removeListener(sub1) pubnub.subscribe( channels = listOf("ch1", "ch2"), @@ -2462,13 +2463,13 @@ class SubscriptionManagerTest : BaseTest() { ), ) val sub1: SubscribeCallback = - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNConnectedCategory) { - pubnubBase.pubNubCore.unsubscribe( + pubnub.unsubscribe( channels = listOf("ch1"), ) } else if (pnStatus.category == PNStatusCategory.PNDisconnectedCategory || @@ -2480,7 +2481,7 @@ class SubscriptionManagerTest : BaseTest() { } override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { val requests = @@ -2494,7 +2495,7 @@ class SubscriptionManagerTest : BaseTest() { } } } - pubnubBase.addListener(sub1) + pubnub.addListener(sub1) pubnub.subscribe( channels = listOf("ch1", "ch2"), @@ -2571,9 +2572,9 @@ class SubscriptionManagerTest : BaseTest() { ), ) val sub1: SubscribeCallback = - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNHeartbeatSuccess) { @@ -2581,7 +2582,7 @@ class SubscriptionManagerTest : BaseTest() { } } } - pubnubBase.addListener(sub1) + pubnub.addListener(sub1) pubnub.subscribe( channels = listOf("ch1", "ch2"), @@ -2615,9 +2616,9 @@ class SubscriptionManagerTest : BaseTest() { ), ) val sub1: SubscribeCallback = - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNHeartbeatSuccess) { @@ -2626,7 +2627,7 @@ class SubscriptionManagerTest : BaseTest() { } } assertNotNull(sub1) - pubnubBase.addListener(sub1) + pubnub.addListener(sub1) pubnub.presence( channels = listOf("ch1", "ch2"), @@ -2663,9 +2664,9 @@ class SubscriptionManagerTest : BaseTest() { ), ) val sub1: SubscribeCallback = - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { println(pnStatus) @@ -2676,7 +2677,7 @@ class SubscriptionManagerTest : BaseTest() { } } - pubnubBase.addListener(sub1) + pubnub.addListener(sub1) pubnub.presence( channels = listOf("ch1", "ch2"), @@ -2740,9 +2741,9 @@ class SubscriptionManagerTest : BaseTest() { ) val sub1: SubscribeCallback = - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNHeartbeatFailed) { @@ -2751,7 +2752,7 @@ class SubscriptionManagerTest : BaseTest() { } } - pubnubBase.addListener(sub1) + pubnub.addListener(sub1) pubnub.subscribe( channels = listOf("ch1", "ch2"), @@ -2818,9 +2819,9 @@ class SubscriptionManagerTest : BaseTest() { ) val sub1: SubscribeCallback = - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNHeartbeatFailed) { @@ -2828,7 +2829,7 @@ class SubscriptionManagerTest : BaseTest() { } } } - pubnubBase.addListener(sub1) + pubnub.addListener(sub1) pubnub.subscribe( channels = listOf("ch1", "ch2"), @@ -2878,9 +2879,9 @@ class SubscriptionManagerTest : BaseTest() { ) val sub1: SubscribeCallback = - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNHeartbeatSuccess) { @@ -2889,7 +2890,7 @@ class SubscriptionManagerTest : BaseTest() { } } - pubnubBase.addListener(sub1) + pubnub.addListener(sub1) pubnub.subscribe( channels = listOf("ch1", "ch2"), @@ -2957,9 +2958,9 @@ class SubscriptionManagerTest : BaseTest() { ) val sub1: SubscribeCallback = - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category != PNStatusCategory.PNHeartbeatSuccess) { @@ -2967,7 +2968,7 @@ class SubscriptionManagerTest : BaseTest() { } } } - pubnubBase.addListener(sub1) + pubnub.addListener(sub1) pubnub.subscribe( channels = listOf("ch1", "ch2"), @@ -3024,10 +3025,10 @@ class SubscriptionManagerTest : BaseTest() { ), ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNConnectedCategory) { @@ -3094,10 +3095,10 @@ class SubscriptionManagerTest : BaseTest() { ), ) - pubnubBase.addListener( - object : SubscribeCallback { + pubnub.addListener( + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNConnectedCategory) { @@ -3238,20 +3239,20 @@ class SubscriptionManagerTest : BaseTest() { ) val sub1: SubscribeCallback = - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { if (pnStatus.category == PNStatusCategory.PNConnectedCategory) { - pubnubBase.pubNubCore.unsubscribe( + pubnub.unsubscribe( channels = listOf("ch1"), ) } if (pnStatus.category == PNStatusCategory.PNSubscriptionChanged) { if ("ch1" !in pnStatus.affectedChannels) { - pubnubBase.pubNubCore.unsubscribe( + pubnub.unsubscribe( channels = listOf("ch2"), ) } @@ -3263,7 +3264,7 @@ class SubscriptionManagerTest : BaseTest() { } } - pubnubBase.addListener(sub1) + pubnub.addListener(sub1) pubnub.subscribe( channels = listOf("ch1", "ch2"), diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/vendor/EncryptDecryptTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/vendor/EncryptDecryptTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/vendor/EncryptDecryptTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/vendor/EncryptDecryptTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/retry/RetryConfigurationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/retry/RetryConfigurationTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/retry/RetryConfigurationTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/retry/RetryConfigurationTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/ContractTestConfig.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/ContractTestConfig.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/ContractTestConfig.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/ContractTestConfig.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/Hooks.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/Hooks.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/Hooks.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/Hooks.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/MockPubnubService.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/MockPubnubService.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/MockPubnubService.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/MockPubnubService.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/RunMainCucumberTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/RunMainCucumberTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/RunMainCucumberTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/RunMainCucumberTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/Utils.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/Utils.kt similarity index 88% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/Utils.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/Utils.kt index e19107bf8..f991e20d9 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/Utils.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/Utils.kt @@ -2,9 +2,9 @@ package com.pubnub.contract import com.google.gson.Gson import com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata +import com.pubnub.api.models.consumer.objects.member.PNMember +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership import com.pubnub.api.models.consumer.objects.uuid.PNUUIDMetadata -import com.pubnub.internal.models.consumer.objects.member.PNMember -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership import java.io.File import java.nio.file.Files import java.nio.file.Paths diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/parameter/PermissionType.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/parameter/PermissionType.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/parameter/PermissionType.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/parameter/PermissionType.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/parameter/ResourceType.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/parameter/ResourceType.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/parameter/ResourceType.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/parameter/ResourceType.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/parameter/TTLType.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/parameter/TTLType.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/parameter/TTLType.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/parameter/TTLType.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/state/GrantTokenState.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/state/GrantTokenState.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/state/GrantTokenState.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/state/GrantTokenState.kt index f556db656..2ab21d487 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/state/GrantTokenState.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/state/GrantTokenState.kt @@ -1,8 +1,8 @@ package com.pubnub.contract.access.state +import com.pubnub.api.models.consumer.access_manager.v3.PNGrant import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult import com.pubnub.api.models.consumer.access_manager.v3.PNToken -import com.pubnub.internal.models.consumer.access_manager.v3.PNGrant class GrantTokenState { var parsedToken: PNToken? = null diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/step/GivenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/step/GivenSteps.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/step/GivenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/step/GivenSteps.kt index 5d914ab7f..7a02014b5 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/step/GivenSteps.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/step/GivenSteps.kt @@ -1,20 +1,22 @@ +@file:Suppress("INVISIBLE_REFERENCE") + package com.pubnub.contract.access.step +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNChannelGroupPatternGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNChannelGroupResourceGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNChannelPatternGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNChannelResourceGrant import com.pubnub.api.models.consumer.access_manager.v3.PNGrantTokenResult +import com.pubnub.api.models.consumer.access_manager.v3.PNUUIDPatternGrant +import com.pubnub.api.models.consumer.access_manager.v3.PNUUIDResourceGrant +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant import com.pubnub.contract.access.parameter.PermissionType import com.pubnub.contract.access.parameter.ResourceType import com.pubnub.contract.access.state.FutureCallGrant import com.pubnub.contract.access.state.GrantTokenState import com.pubnub.contract.state.World -import com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNChannelGroupPatternGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNChannelGroupResourceGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNChannelPatternGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNChannelResourceGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNUUIDPatternGrant -import com.pubnub.internal.models.consumer.access_manager.v3.PNUUIDResourceGrant -import com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant import io.cucumber.java.en.And import io.cucumber.java.en.Given import kotlin.random.Random diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/step/ThenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/step/ThenSteps.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/step/ThenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/step/ThenSteps.kt index 698fb2fdc..d70300ee3 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/step/ThenSteps.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/step/ThenSteps.kt @@ -29,21 +29,21 @@ class ThenSteps( @Then("the token contains the authorized UUID {string}") fun the_token_contains_the_authorized_uuid(uuid: String) { val result = grantTokenState.result!! - val parsedToken = world.pubnub.pubNubCore.parseToken(result.token) + val parsedToken = world.pubnub.parseToken(result.token) MatcherAssert.assertThat(parsedToken.authorizedUUID, Matchers.`is`(uuid)) } @Then("the token contains the TTL {ttl}") fun the_token_contains_the_ttl(ttl: Long) { val result = grantTokenState.result!! - val token = world.pubnub.pubNubCore.parseToken(result.token) + val token = world.pubnub.parseToken(result.token) MatcherAssert.assertThat(token.ttl, Matchers.`is`(ttl)) } @Then("the token does not contain an authorized uuid") fun the_token_does_not_contain_an_authorized_uuid() { val result = grantTokenState.result!! - val token = world.pubnub.pubNubCore.parseToken(result.token) + val token = world.pubnub.parseToken(result.token) MatcherAssert.assertThat(token.authorizedUUID, Matchers.nullValue()) } @@ -107,6 +107,6 @@ class ThenSteps( private fun parsedToken(): PNToken? { return grantTokenState.parsedToken - ?: grantTokenState.result?.let { world.pubnub.pubNubCore.parseToken(it.token) } + ?: grantTokenState.result?.let { world.pubnub.parseToken(it.token) } } } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/step/WhenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/step/WhenSteps.kt similarity index 78% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/step/WhenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/step/WhenSteps.kt index c249346fc..d035b57c2 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/access/step/WhenSteps.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/access/step/WhenSteps.kt @@ -1,11 +1,11 @@ package com.pubnub.contract.access.step import com.pubnub.api.PubNubException +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant +import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant +import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant import com.pubnub.contract.access.state.GrantTokenState import com.pubnub.contract.state.World -import com.pubnub.internal.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.internal.models.consumer.access_manager.v3.ChannelGroupGrant -import com.pubnub.internal.models.consumer.access_manager.v3.UUIDGrant import io.cucumber.java.en.When import org.junit.Assert @@ -18,7 +18,7 @@ class WhenSteps( val definedGrants = grantTokenState.definedGrants.map { it.evaluate() } @Suppress("DEPRECATION") grantTokenState.result = - world.pubnub.pubNubCore.grantToken( + world.pubnub.grantToken( ttl = grantTokenState.TTL?.toInt() ?: throw RuntimeException("TTL expected"), authorizedUUID = grantTokenState.authorizedUUID, channels = definedGrants.filterIsInstance(ChannelGrant::class.java), @@ -43,13 +43,13 @@ class WhenSteps( @When("I parse the token") fun i_parse_the_token() { - grantTokenState.parsedToken = world.pubnub.pubNubCore.parseToken(grantTokenState.result?.token!!) + grantTokenState.parsedToken = world.pubnub.parseToken(grantTokenState.result?.token!!) } @When("I revoke a token") fun i_revoke_the_token() { try { - world.pubnub.pubNubCore.revokeToken(world.tokenString!!).sync() + world.pubnub.revokeToken(world.tokenString!!).sync() } catch (e: PubNubException) { world.pnException = e } @@ -57,8 +57,8 @@ class WhenSteps( @When("I publish a message using that auth token with channel {string}") fun i_publish_a_message_using_that_auth_token_with_channel(channel: String) { - world.pubnub.pubNubCore.setToken(world.tokenString) - world.pubnub.pubNubCore.publish( + world.pubnub.setToken(world.tokenString) + world.pubnub.publish( channel = channel, message = "Message", ).sync() @@ -66,10 +66,10 @@ class WhenSteps( @When("I attempt to publish a message using that auth token with channel {string}") fun i_attempt_to_publish_a_message_using_that_auth_token_with_channel(channel: String) { - world.pubnub.pubNubCore.setToken(world.tokenString) + world.pubnub.setToken(world.tokenString) try { - world.pubnub.pubNubCore.publish( + world.pubnub.publish( channel = channel, message = "Message", ).sync() diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/state/ChannelMetadataState.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/state/ChannelMetadataState.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/state/ChannelMetadataState.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/state/ChannelMetadataState.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/GivenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/GivenSteps.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/GivenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/GivenSteps.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/ThenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/ThenSteps.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/ThenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/ThenSteps.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/WhenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/WhenSteps.kt similarity index 84% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/WhenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/WhenSteps.kt index de57d3909..b3f63ac57 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/WhenSteps.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/channelmetadata/step/WhenSteps.kt @@ -10,7 +10,7 @@ class WhenSteps( ) { @When("I get the channel metadata") fun i_get_the_channel_metadata() { - world.pubnub.pubNubCore.getChannelMetadata(channel = channelMetadataState.channelId).sync()?.let { + world.pubnub.getChannelMetadata(channel = channelMetadataState.channelId).sync()?.let { channelMetadataState.channelMetadata = it.data world.responseStatus = it.status } @@ -19,7 +19,7 @@ class WhenSteps( @When("I set the channel metadata") fun i_set_the_channel_metadata() { val channelMetadata = channelMetadataState.channelMetadata!! - world.pubnub.pubNubCore.setChannelMetadata( + world.pubnub.setChannelMetadata( channel = channelMetadata.id, name = channelMetadata.name?.value, description = channelMetadata.description?.value, @@ -34,7 +34,7 @@ class WhenSteps( @When("I get the channel metadata with custom") fun i_get_the_channel_metadata_with_custom() { - world.pubnub.pubNubCore.getChannelMetadata( + world.pubnub.getChannelMetadata( channel = channelMetadataState.channelId, includeCustom = true, ).sync().let { @@ -46,14 +46,14 @@ class WhenSteps( @When("I remove the channel metadata") fun i_remove_the_channel_metadata() { world.responseStatus = - world.pubnub.pubNubCore.removeChannelMetadata( + world.pubnub.removeChannelMetadata( channel = channelMetadataState.channelId, ).sync().status } @When("I get all channel metadata") fun i_get_all_channel_metadata() { - world.pubnub.pubNubCore.getAllChannelMetadata().sync().let { + world.pubnub.getAllChannelMetadata().sync().let { channelMetadataState.channelMetadatas = it.data world.responseStatus = it.status } @@ -61,7 +61,7 @@ class WhenSteps( @When("I get all channel metadata with custom") fun i_get_all_channel_metadata_with_custom() { - world.pubnub.pubNubCore.getAllChannelMetadata( + world.pubnub.getAllChannelMetadata( includeCustom = true, ).sync().let { channelMetadataState.channelMetadatas = it.data diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/crypto/CryptoModuleState.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/crypto/CryptoModuleState.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/crypto/CryptoModuleState.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/crypto/CryptoModuleState.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/crypto/CryptoModuleSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/crypto/CryptoModuleSteps.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/crypto/CryptoModuleSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/crypto/CryptoModuleSteps.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/member/state/MemberState.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/member/state/MemberState.kt similarity index 87% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/member/state/MemberState.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/member/state/MemberState.kt index efcdbf56a..fa1f6f701 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/member/state/MemberState.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/member/state/MemberState.kt @@ -1,7 +1,7 @@ package com.pubnub.contract.member.state +import com.pubnub.api.models.consumer.objects.member.PNMember import com.pubnub.contract.channelmetadata.state.ChannelMetadataState -import com.pubnub.internal.models.consumer.objects.member.PNMember class MemberState( private val channelMetadataState: ChannelMetadataState, diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/member/step/GivenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/member/step/GivenSteps.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/member/step/GivenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/member/step/GivenSteps.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/member/step/ThenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/member/step/ThenSteps.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/member/step/ThenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/member/step/ThenSteps.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/member/step/WhenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/member/step/WhenSteps.kt similarity index 76% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/member/step/WhenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/member/step/WhenSteps.kt index 708a95319..7afd542c2 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/member/step/WhenSteps.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/member/step/WhenSteps.kt @@ -1,9 +1,9 @@ package com.pubnub.contract.member.step +import com.pubnub.api.models.consumer.objects.member.PNMember +import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel import com.pubnub.contract.member.state.MemberState import com.pubnub.contract.state.World -import com.pubnub.internal.models.consumer.objects.member.PNMember -import com.pubnub.internal.models.consumer.objects.member.PNUUIDDetailsLevel import io.cucumber.java.en.When class WhenSteps( @@ -12,7 +12,7 @@ class WhenSteps( ) { @When("I get the channel members") fun i_get_the_channel_members() { - world.pubnub.pubNubCore.getChannelMembers(channel = memberState.channelId()).sync()?.let { + world.pubnub.getChannelMembers(channel = memberState.channelId()).sync().let { memberState.returnedMembers = it.data world.responseStatus = it.status } @@ -21,12 +21,12 @@ class WhenSteps( @When("I set a channel member including custom and UUID with custom") fun i_set_a_channel_member_including_custom_and_uuid_with_custom() { val uuids = memberState.members.map { PNMember.Partial(uuidId = it.uuid?.id!!) } - world.pubnub.pubNubCore.setChannelMembers( + world.pubnub.setChannelMembers( channel = memberState.channelId(), includeCustom = true, includeUUIDDetails = PNUUIDDetailsLevel.UUID_WITH_CUSTOM, uuids = uuids, - ).sync()?.let { + ).sync().let { memberState.returnedMembers = it.data world.responseStatus = it.status } @@ -34,11 +34,11 @@ class WhenSteps( @When("I get the channel members including custom and UUID custom information") fun i_get_the_channel_members_including_custom_and_uuid_custom_information() { - world.pubnub.pubNubCore.getChannelMembers( + world.pubnub.getChannelMembers( channel = memberState.channelId(), includeCustom = true, includeUUIDDetails = PNUUIDDetailsLevel.UUID_WITH_CUSTOM, - ).sync()?.let { + ).sync().let { memberState.returnedMembers = it.data world.responseStatus = it.status } @@ -46,11 +46,11 @@ class WhenSteps( @When("I set a channel member") fun i_set_a_channel_member() { - val uuids = memberState.members.map { PNMember.Partial(uuidId = it.uuid?.id!!) } - world.pubnub.pubNubCore.setChannelMembers( + val uuids = memberState.members.map { PNMember.Partial(uuidId = it.uuid.id) } + world.pubnub.setChannelMembers( channel = memberState.channelId(), uuids = uuids, - ).sync()?.let { + ).sync().let { memberState.returnedMembers = it.data world.responseStatus = it.status } @@ -58,11 +58,11 @@ class WhenSteps( @When("I remove a channel member") fun i_remove_a_channel_member() { - val uuids = memberState.membersToRemove.map { it.uuid?.id!! } - world.pubnub.pubNubCore.removeChannelMembers( + val uuids = memberState.membersToRemove.map { it.uuid.id } + world.pubnub.removeChannelMembers( channel = memberState.channelId(), uuids = uuids, - ).sync()?.let { + ).sync().let { memberState.returnedMembers = it.data world.responseStatus = it.status } @@ -70,13 +70,13 @@ class WhenSteps( @When("I manage channel members") fun i_manage_channel_members() { - val uuidsToSet = memberState.members.map { PNMember.Partial(uuidId = it.uuid?.id!!) } - val uuidsToRemove = memberState.membersToRemove.map { it.uuid?.id!! } - world.pubnub.pubNubCore.manageChannelMembers( + val uuidsToSet = memberState.members.map { PNMember.Partial(uuidId = it.uuid.id) } + val uuidsToRemove = memberState.membersToRemove.map { it.uuid.id } + world.pubnub.manageChannelMembers( channel = memberState.channelId(), uuidsToSet = uuidsToSet, uuidsToRemove = uuidsToRemove, - ).sync()?.let { + ).sync().let { memberState.returnedMembers = it.data world.responseStatus = it.status } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/state/MembershipState.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/membership/state/MembershipState.kt similarity index 83% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/state/MembershipState.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/membership/state/MembershipState.kt index 092b5f236..3526b05ba 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/state/MembershipState.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/membership/state/MembershipState.kt @@ -1,6 +1,6 @@ package com.pubnub.contract.uuidmetadata.state -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership class MembershipState( private val uuidMetadataState: UUIDMetadataState, diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/GivenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/membership/step/GivenSteps.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/GivenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/membership/step/GivenSteps.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/ThenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/membership/step/ThenSteps.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/ThenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/membership/step/ThenSteps.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt similarity index 85% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt index b9056a3a4..483e5529a 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/membership/step/WhenSteps.kt @@ -1,9 +1,9 @@ package com.pubnub.contract.membership.step +import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel +import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership import com.pubnub.contract.state.World import com.pubnub.contract.uuidmetadata.state.MembershipState -import com.pubnub.internal.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.internal.models.consumer.objects.membership.PNChannelMembership import io.cucumber.java.en.When class WhenSteps( @@ -12,7 +12,7 @@ class WhenSteps( ) { @When("I get the memberships") fun i_get_the_memberships() { - world.pubnub.pubNubCore.getMemberships(uuid = membershipState.uuid()).sync().let { + world.pubnub.getMemberships(uuid = membershipState.uuid()).sync().let { membershipState.returnedMemberships = it.data world.responseStatus = it.status } @@ -20,7 +20,7 @@ class WhenSteps( @When("I get the memberships for current user") fun i_get_the_memberships_for_current_user() { - world.pubnub.pubNubCore.getMemberships().sync().let { + world.pubnub.getMemberships().sync().let { membershipState.returnedMemberships = it.data world.responseStatus = it.status } @@ -28,7 +28,7 @@ class WhenSteps( @When("I get the memberships including custom and channel custom information") fun i_get_the_memberships_including_custom_and_channel_custom_information() { - world.pubnub.pubNubCore.getMemberships( + world.pubnub.getMemberships( uuid = membershipState.uuid(), includeCustom = true, includeChannelDetails = PNChannelDetailsLevel.CHANNEL_WITH_CUSTOM, @@ -49,7 +49,7 @@ class WhenSteps( ) } - world.pubnub.pubNubCore.setMemberships( + world.pubnub.setMemberships( uuid = membershipState.uuid(), channels = channels, ).sync().let { @@ -69,7 +69,7 @@ class WhenSteps( ) } - world.pubnub.pubNubCore.setMemberships( + world.pubnub.setMemberships( channels = channels, ).sync().let { world.responseStatus = it.status @@ -80,7 +80,7 @@ class WhenSteps( @When("I remove the membership") fun i_remove_the_membership() { val channels = membershipState.memberships.map { it.channel.id } - world.pubnub.pubNubCore.removeMemberships( + world.pubnub.removeMemberships( uuid = membershipState.uuid(), channels = channels, ).sync().let { @@ -92,7 +92,7 @@ class WhenSteps( @When("I remove the membership for current user") fun i_remove_the_membership_for_current_user() { val channels = membershipState.memberships.map { it.channel.id } - world.pubnub.pubNubCore.removeMemberships( + world.pubnub.removeMemberships( channels = channels, ).sync().let { world.responseStatus = it.status @@ -111,7 +111,7 @@ class WhenSteps( ) } val channelsToRemove = membershipState.membershipsToRemove.map { it.channel.id } - world.pubnub.pubNubCore.manageMemberships( + world.pubnub.manageMemberships( channelsToSet = channelsToSet, channelsToRemove = channelsToRemove, uuid = membershipState.uuid(), diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/parameter/SpaceIdType.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/parameter/SpaceIdType.kt similarity index 83% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/parameter/SpaceIdType.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/parameter/SpaceIdType.kt index 845b7bd36..3c02addea 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/parameter/SpaceIdType.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/parameter/SpaceIdType.kt @@ -1,6 +1,6 @@ package com.pubnub.contract.parameter -import com.pubnub.internal.SpaceId +import com.pubnub.api.SpaceId import io.cucumber.java.ParameterType @ParameterType("'(.*)'") diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/presence/eventEngine/step/PresenceEventEngineSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/presence/eventEngine/step/PresenceEventEngineSteps.kt similarity index 89% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/presence/eventEngine/step/PresenceEventEngineSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/presence/eventEngine/step/PresenceEventEngineSteps.kt index 8c1163648..a15e4ce0f 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/presence/eventEngine/step/PresenceEventEngineSteps.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/presence/eventEngine/step/PresenceEventEngineSteps.kt @@ -1,10 +1,10 @@ package com.pubnub.contract.presence.eventEngine.step -import com.pubnub.api.BasePubNub +import com.pubnub.api.PubNub +import com.pubnub.api.callbacks.SubscribeCallback import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.contract.subscribe.eventEngine.state.EventEngineState -import com.pubnub.internal.callbacks.SubscribeCallback import io.cucumber.datatable.DataTable import io.cucumber.java.en.Given import io.cucumber.java.en.Then @@ -37,7 +37,7 @@ class PresenceEventEngineSteps(private val state: EventEngineState) { secondChannel: String, thirdChannel: String, ) { - state.pubnub.pubNubCore.subscribe(channels = listOf(firstChannel, secondChannel, thirdChannel)) + state.pubnub.subscribe(channels = listOf(firstChannel, secondChannel, thirdChannel)) } @When("I join {string}, {string}, {string} channels with presence") @@ -46,7 +46,7 @@ class PresenceEventEngineSteps(private val state: EventEngineState) { secondChannel: String, thirdChannel: String, ) { - state.pubnub.pubNubCore.subscribe( + state.pubnub.subscribe( channels = listOf(firstChannel, secondChannel, thirdChannel), withPresence = true, ) @@ -66,16 +66,16 @@ class PresenceEventEngineSteps(private val state: EventEngineState) { fun I_wait_for_getting_Presence_joined_events() { val atomic = AtomicInteger(0) state.pubnub.addListener( - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { // do nothing } override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { if (pnPresenceEventResult.event == "join" && (pnPresenceEventResult.channel == "first" || pnPresenceEventResult.channel == "second" || pnPresenceEventResult.channel == "third")) { @@ -102,7 +102,7 @@ class PresenceEventEngineSteps(private val state: EventEngineState) { firstChannel: String, secondChannel: String, ) { - state.pubnub.pubNubCore.unsubscribe(channels = listOf(firstChannel, secondChannel)) + state.pubnub.unsubscribe(channels = listOf(firstChannel, secondChannel)) } @Then("I observe the following Events and Invocations of the Presence EE:") @@ -132,6 +132,6 @@ class PresenceEventEngineSteps(private val state: EventEngineState) { firstChannel: String, secondChannel: String, ) { - state.pubnub.pubNubCore.unsubscribe(channels = listOf(firstChannel, secondChannel)) + state.pubnub.unsubscribe(channels = listOf(firstChannel, secondChannel)) } } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/state/World.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/state/World.kt similarity index 60% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/state/World.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/state/World.kt index f3134e9f2..391cfd2cc 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/state/World.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/state/World.kt @@ -3,27 +3,26 @@ package com.pubnub.contract.state import com.pubnub.api.PubNubException import com.pubnub.api.UserId import com.pubnub.api.enums.PNLogVerbosity +import com.pubnub.api.v2.PNConfiguration import com.pubnub.contract.ContractTestConfig -import com.pubnub.internal.BasePubNubImpl -import com.pubnub.internal.TestPubNub -import com.pubnub.test.TestPNConfigurationImpl +import com.pubnub.internal.PubNubImpl interface WorldState { - val configuration: TestPNConfigurationImpl.Builder + val configuration: PNConfiguration.Builder var pnException: PubNubException? var tokenString: String? var responseStatus: Int? } class World : WorldState { - override val configuration: TestPNConfigurationImpl.Builder = - TestPNConfigurationImpl.Builder(userId = UserId(BasePubNubImpl.generateUUID())).apply { + override val configuration: PNConfiguration.Builder = + PNConfiguration.builder(userId = UserId(PubNubImpl.generateUUID()), "").apply { origin = ContractTestConfig.serverHostPort secure = false logVerbosity = PNLogVerbosity.BODY } - val pubnub: TestPubNub by lazy { TestPubNub(configuration.build()) } + val pubnub: PubNubImpl by lazy { PubNubImpl(configuration.build()) } override var pnException: PubNubException? = null override var tokenString: String? = null override var responseStatus: Int? = null diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/step/ErrorMessageAndDetailsStep.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/step/ErrorMessageAndDetailsStep.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/step/ErrorMessageAndDetailsStep.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/step/ErrorMessageAndDetailsStep.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/step/KeysetStep.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/step/KeysetStep.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/step/KeysetStep.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/step/KeysetStep.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/step/ThenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/step/ThenSteps.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/step/ThenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/step/ThenSteps.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/EventEngineState.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/EventEngineState.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/EventEngineState.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/EventEngineState.kt index c84bf310b..9db409156 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/EventEngineState.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/EventEngineState.kt @@ -4,7 +4,7 @@ import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNEvent import com.pubnub.contract.state.World import com.pubnub.contract.state.WorldState -import com.pubnub.internal.TestPubNub +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.eventengine.QueueEventEngineConf import com.pubnub.internal.subscribe.eventengine.configuration.EventEnginesConf import java.util.concurrent.CopyOnWriteArrayList @@ -23,8 +23,8 @@ class EventEngineState(world: World) : WorldState by world { val channelName: String = "MyChannel_01" val messagesList: MutableList = CopyOnWriteArrayList() val statusesList: MutableList = CopyOnWriteArrayList() - val pubnub: TestPubNub by lazy { - TestPubNub( + val pubnub: PubNubImpl by lazy { + PubNubImpl( configuration.build(), eventEnginesConf = testEventEnginesConf(subscribeQueuedElements, presenceQueuedElements), ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/TestSinkSource.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/TestSinkSource.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/TestSinkSource.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/state/TestSinkSource.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/step/EventEngineSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/step/EventEngineSteps.kt similarity index 81% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/step/EventEngineSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/step/EventEngineSteps.kt index 2b21d1f35..c74890edb 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/step/EventEngineSteps.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/subscribe/eventEngine/step/EventEngineSteps.kt @@ -1,16 +1,16 @@ package com.pubnub.contract.subscribe.eventEngine.step -import com.pubnub.api.BasePubNub +import com.pubnub.api.PubNub +import com.pubnub.api.callbacks.SubscribeCallback import com.pubnub.api.models.consumer.PNStatus import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult import com.pubnub.api.retry.RetryConfiguration import com.pubnub.contract.subscribe.eventEngine.state.EventEngineState -import com.pubnub.internal.callbacks.SubscribeCallback -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult import io.cucumber.datatable.DataTable import io.cucumber.java.en.Given import io.cucumber.java.en.Then @@ -33,51 +33,51 @@ class EventEngineSteps(private val state: EventEngineState) { @When("I subscribe") fun i_subscribe() { state.pubnub.addListener( - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { state.statusesList.add(pnStatus) } override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { state.messagesList.add(pnMessageResult) } override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { state.messagesList.add(pnPresenceEventResult) } override fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnSignalResult: PNSignalResult, ) { state.messagesList.add(pnSignalResult) } override fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageActionResult: PNMessageActionResult, ) { state.messagesList.add(pnMessageActionResult) } override fun objects( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, objectEvent: PNObjectEventResult, ) { state.messagesList.add(objectEvent) } override fun file( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnFileEventResult: PNFileEventResult, ) { state.messagesList.add(pnFileEventResult) @@ -85,57 +85,57 @@ class EventEngineSteps(private val state: EventEngineState) { }, ) - state.pubnub.pubNubCore.subscribe(channels = listOf(state.channelName)) + state.pubnub.subscribe(channels = listOf(state.channelName)) } @When("I subscribe with timetoken {long}") fun i_subscribe_with_timetoken(timetoken: Long) { state.pubnub.addListener( - object : SubscribeCallback { + object : SubscribeCallback() { override fun status( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnStatus: PNStatus, ) { state.statusesList.add(pnStatus) } override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageResult: PNMessageResult, ) { state.messagesList.add(pnMessageResult) } override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnPresenceEventResult: PNPresenceEventResult, ) { state.messagesList.add(pnPresenceEventResult) } override fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnSignalResult: PNSignalResult, ) { state.messagesList.add(pnSignalResult) } override fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnMessageActionResult: PNMessageActionResult, ) { state.messagesList.add(pnMessageActionResult) } override fun objects( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, objectEvent: PNObjectEventResult, ) { state.messagesList.add(objectEvent) } override fun file( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, pnFileEventResult: PNFileEventResult, ) { state.messagesList.add(pnFileEventResult) @@ -143,7 +143,7 @@ class EventEngineSteps(private val state: EventEngineState) { }, ) - state.pubnub.pubNubCore.subscribe( + state.pubnub.subscribe( channels = listOf(state.channelName), withTimetoken = timetoken, ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/state/UUIDMetadataState.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/state/UUIDMetadataState.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/state/UUIDMetadataState.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/state/UUIDMetadataState.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/GivenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/GivenSteps.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/GivenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/GivenSteps.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/ThenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/ThenSteps.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/ThenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/ThenSteps.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/WhenSteps.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/WhenSteps.kt similarity index 76% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/WhenSteps.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/WhenSteps.kt index 8e045606b..a9f20c82b 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/WhenSteps.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/contract/uuidmetadata/step/WhenSteps.kt @@ -10,7 +10,7 @@ class WhenSteps( ) { @When("I get the UUID metadata") fun i_get_uuid_metadata() { - world.pubnub.pubNubCore.getUUIDMetadata(uuid = uuidMetadataState.uuid).sync()?.let { + world.pubnub.getUUIDMetadata(uuid = uuidMetadataState.uuid).sync()?.let { uuidMetadataState.uuidMetadata = it.data world.responseStatus = it.status } @@ -18,7 +18,7 @@ class WhenSteps( @When("I get the UUID metadata with custom for current user") fun i_get_uuid_metadata_with_custom_for_current_user() { - world.pubnub.pubNubCore.getUUIDMetadata(includeCustom = true).sync()?.let { + world.pubnub.getUUIDMetadata(includeCustom = true).sync()?.let { uuidMetadataState.uuidMetadata = it.data world.responseStatus = it.status } @@ -27,7 +27,7 @@ class WhenSteps( @When("I set the UUID metadata") fun i_set_the_uuid_metadata() { val uuidMetadata = uuidMetadataState.uuidMetadata!! - world.pubnub.pubNubCore.setUUIDMetadata( + world.pubnub.setUUIDMetadata( uuid = uuidMetadata.id, custom = uuidMetadata.custom, externalId = uuidMetadata.externalId?.value, @@ -44,17 +44,17 @@ class WhenSteps( @When("I remove the UUID metadata") fun i_remove_uuid_metadata_for_id() { - world.responseStatus = world.pubnub.pubNubCore.removeUUIDMetadata(uuid = uuidMetadataState.uuid).sync()?.status + world.responseStatus = world.pubnub.removeUUIDMetadata(uuid = uuidMetadataState.uuid).sync()?.status } @When("I remove the UUID metadata for current user") fun i_remove_uuid_metadata_of_current_user() { - world.responseStatus = world.pubnub.pubNubCore.removeUUIDMetadata().sync()?.status + world.responseStatus = world.pubnub.removeUUIDMetadata().sync()?.status } @When("I get all UUID metadata") fun i_get_all_uuid_metadata() { - world.pubnub.pubNubCore.getAllUUIDMetadata().sync()?.let { + world.pubnub.getAllUUIDMetadata().sync()?.let { uuidMetadataState.uuidMetadatas = it.data world.responseStatus = it.status } @@ -62,7 +62,7 @@ class WhenSteps( @When("I get all UUID metadata with custom") fun i_get_all_uuid_metadata_with_custom() { - world.pubnub.pubNubCore.getAllUUIDMetadata(includeCustom = true).sync()?.let { + world.pubnub.getAllUUIDMetadata(includeCustom = true).sync()?.let { uuidMetadataState.uuidMetadatas = it.data world.responseStatus = it.status } diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/endpoints/DelegatingEndpointTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/endpoints/DelegatingEndpointTest.kt deleted file mode 100644 index 060b513b1..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/endpoints/DelegatingEndpointTest.kt +++ /dev/null @@ -1,94 +0,0 @@ -package com.pubnub.internal.endpoints - -import com.pubnub.api.endpoints.remoteaction.ExtendedRemoteAction -import com.pubnub.api.enums.PNOperationType -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.api.v2.callbacks.Result -import com.pubnub.api.v2.callbacks.getOrThrow -import com.pubnub.internal.DelegatingEndpoint -import com.pubnub.internal.EndpointInterface -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertTrue -import org.junit.jupiter.api.BeforeEach -import org.junit.jupiter.api.Test -import java.util.function.Consumer - -internal class DelegatingEndpointTest { - private lateinit var delegatingEndpoint: DelegatingEndpoint - - var silentCancelCalled = false - var retryCalled = false - - val action = - object : EndpointInterface { - override fun operationType(): PNOperationType { - return PNOperationType.FileOperation - } - - override fun retry() { - retryCalled = true - } - - override fun sync(): Boolean { - return true - } - - override fun silentCancel() { - silentCancelCalled = true - } - - override fun overrideConfiguration(configuration: BasePNConfiguration) { - TODO("Not yet implemented") - } - - override val configuration: BasePNConfiguration - get() = TODO("Not yet implemented") - - override fun async(callback: Consumer>) { - callback.accept(Result.success(true)) - } - } - - @BeforeEach - fun setUp() { - silentCancelCalled = false - retryCalled = false - delegatingEndpoint = - object : DelegatingEndpoint(action) { - override fun convertAction(remoteAction: ExtendedRemoteAction): ExtendedRemoteAction { - return remoteAction - } - } - } - - @Test - fun sync() { - val result = delegatingEndpoint.sync() - assertTrue(result) - } - - @Test - fun async() { - delegatingEndpoint.async { result -> - assertTrue(result.isSuccess) - assertTrue(result.getOrThrow()) - } - } - - @Test - fun retry() { - delegatingEndpoint.retry() - assertTrue(retryCalled) - } - - @Test - fun silentCancel() { - delegatingEndpoint.silentCancel() - assertTrue(silentCancelCalled) - } - - @Test - fun operationType() { - assertEquals(PNOperationType.FileOperation, delegatingEndpoint.operationType()) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/eventengine/EffectDispatcherTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/eventengine/EffectDispatcherTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/eventengine/EffectDispatcherTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/eventengine/EffectDispatcherTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/eventengine/EventEngineManagerTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/eventengine/EventEngineManagerTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/eventengine/EventEngineManagerTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/eventengine/EventEngineManagerTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/eventengine/EventEngineTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/eventengine/EventEngineTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/eventengine/EventEngineTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/eventengine/EventEngineTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/extension/JsonElementTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/extension/JsonElementTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/extension/JsonElementTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/extension/JsonElementTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/managers/MapperManagerTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/RetrofitManagerTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/managers/RetrofitManagerTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/RetrofitManagerTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/managers/RetrofitManagerTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/TokenParserTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/managers/TokenParserTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/managers/TokenParserTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/managers/TokenParserTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/PresenceTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/PresenceTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/PresenceTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/PresenceTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/HeartbeatEffectTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/HeartbeatEffectTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/HeartbeatEffectTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/HeartbeatEffectTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/LeaveEffectTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/LeaveEffectTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/LeaveEffectTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/LeaveEffectTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectFactoryTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectFactoryTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectFactoryTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/PresenceEffectFactoryTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffectTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffectTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffectTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/effect/WaitEffectTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/event/PresenceEventTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/event/PresenceEventTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/event/PresenceEventTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/event/PresenceEventTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatCooldownStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatCooldownStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatCooldownStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatCooldownStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatFailedStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatFailedStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatFailedStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatFailedStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatInactiveStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatInactiveStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatInactiveStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatInactiveStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatStoppedStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatStoppedStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatStoppedStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatStoppedStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatingStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatingStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatingStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/presence/eventengine/state/transition/TransitionFromHeartbeatingStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableCallbackTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableCallbackTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableCallbackTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableCallbackTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableRestCallerTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableRestCallerTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableRestCallerTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/retry/RetryableRestCallerTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/SubscribeTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/SubscribeTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/SubscribeTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/SubscribeTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffectTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffectTest.kt similarity index 97% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffectTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffectTest.kt index 06e29cd98..9b43d703c 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffectTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitMessagesEffectTest.kt @@ -10,9 +10,9 @@ import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetMembershipEvent -import com.pubnub.internal.models.consumer.pubsub.objects.PNSetMembershipEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEvent +import com.pubnub.api.models.consumer.pubsub.objects.PNSetMembershipEventMessage import io.mockk.every import io.mockk.mockk import io.mockk.slot diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitStatusEffectTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitStatusEffectTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitStatusEffectTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/EmitStatusEffectTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/HandshakeEffectTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/HandshakeEffectTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/HandshakeEffectTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/HandshakeEffectTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReceiveMessagesEffectTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReceiveMessagesEffectTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReceiveMessagesEffectTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/ReceiveMessagesEffectTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectFactoryTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectFactoryTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectFactoryTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/effect/SubscribeEffectFactoryTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscribeEventTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscribeEventTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscribeEventTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/event/SubscribeEventTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/SubscribeEventConsumerWorkerTransitionFunctionTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/SubscribeEventConsumerWorkerTransitionFunctionTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/SubscribeEventConsumerWorkerTransitionFunctionTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/SubscribeEventConsumerWorkerTransitionFunctionTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakeFailedStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakeFailedStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakeFailedStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakeFailedStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakeStoppedStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakeStoppedStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakeStoppedStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakeStoppedStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakingStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakingStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakingStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromHandshakingStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceiveFailedStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceiveFailedStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceiveFailedStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceiveFailedStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceiveStoppedStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceiveStoppedStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceiveStoppedStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceiveStoppedStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceivingStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceivingStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceivingStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromReceivingStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromUnsubscribedStateTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromUnsubscribedStateTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromUnsubscribedStateTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/subscribe/eventengine/worker/TransitionFromUnsubscribedStateTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/CoreEndpointTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/CoreEndpointTestSuite.kt similarity index 98% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/CoreEndpointTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/CoreEndpointTestSuite.kt index adf582cd4..58c8ddb9a 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/CoreEndpointTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/CoreEndpointTestSuite.kt @@ -10,11 +10,11 @@ import com.github.tomakehurst.wiremock.client.WireMock.noContent import com.github.tomakehurst.wiremock.client.WireMock.stubFor import com.github.tomakehurst.wiremock.client.WireMock.urlMatching import com.github.tomakehurst.wiremock.stubbing.StubMapping +import com.pubnub.api.Endpoint import com.pubnub.api.PubNubError import com.pubnub.api.enums.PNOperationType import com.pubnub.api.legacy.BaseTest import com.pubnub.api.v2.callbacks.getOrThrow -import com.pubnub.internal.EndpointCore import com.pubnub.test.CommonUtils.assertPnException import com.pubnub.test.CommonUtils.emptyJson import com.pubnub.test.CommonUtils.failTest @@ -27,7 +27,7 @@ import org.junit.Test typealias AsyncCheck = (result: com.pubnub.api.v2.callbacks.Result) -> Unit -abstract class CoreEndpointTestSuite, R> : BaseTest() { +abstract class CoreEndpointTestSuite, R> : BaseTest() { private lateinit var expectedStub: StubMapping abstract fun pnOperation(): PNOperationType diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/TimeTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/TimeTestSuite.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/TimeTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/TimeTestSuite.kt index 90811ac3f..24c708e18 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/TimeTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/TimeTestSuite.kt @@ -2,20 +2,20 @@ package com.pubnub.internal.suite import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.Time import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.PNTimeResult import com.pubnub.api.v2.callbacks.getOrThrow -import com.pubnub.internal.endpoints.TimeEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue -class TimeTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class TimeTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNTimeOperation override fun requiredKeys() = 0 - override fun snippet(): TimeEndpoint { + override fun snippet(): Time { return pubnub.time() } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AddChannelChannelGroupTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AddChannelChannelGroupTestSuite.kt similarity index 88% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AddChannelChannelGroupTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AddChannelChannelGroupTestSuite.kt index 6c3cf793f..a5d3608da 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AddChannelChannelGroupTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AddChannelChannelGroupTestSuite.kt @@ -4,17 +4,17 @@ import com.github.tomakehurst.wiremock.client.MappingBuilder import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAddChannelResult -import com.pubnub.internal.endpoints.channel_groups.AddChannelChannelGroupEndpoint class AddChannelChannelGroupTestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNAddChannelsToGroupOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): AddChannelChannelGroupEndpoint { + override fun snippet(): AddChannelChannelGroup { return pubnub.addChannelsToChannelGroup( channelGroup = "cg1", channels = listOf("ch1", "ch2"), diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AllChannelsChannelGroupTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AllChannelsChannelGroupTestSuite.kt similarity index 94% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AllChannelsChannelGroupTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AllChannelsChannelGroupTestSuite.kt index 626db1206..ae08f453c 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AllChannelsChannelGroupTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/AllChannelsChannelGroupTestSuite.kt @@ -4,21 +4,21 @@ import com.github.tomakehurst.wiremock.client.MappingBuilder import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo import com.pubnub.api.PubNubError +import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsAllChannelsResult import com.pubnub.api.v2.callbacks.getOrThrow -import com.pubnub.internal.endpoints.channel_groups.AllChannelsChannelGroupEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue class AllChannelsChannelGroupTestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNChannelsForGroupOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): AllChannelsChannelGroupEndpoint { + override fun snippet(): AllChannelsChannelGroup { return pubnub.listChannelsForChannelGroup( channelGroup = "cg1", ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/DeleteChannelGroupTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/DeleteChannelGroupTestSuite.kt similarity index 88% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/DeleteChannelGroupTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/DeleteChannelGroupTestSuite.kt index 92b7f0f01..b30137a8b 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/DeleteChannelGroupTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/DeleteChannelGroupTestSuite.kt @@ -3,17 +3,17 @@ package com.pubnub.internal.suite.channel_groups import com.github.tomakehurst.wiremock.client.MappingBuilder import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsDeleteGroupResult -import com.pubnub.internal.endpoints.channel_groups.DeleteChannelGroupEndpoint class DeleteChannelGroupTestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNRemoveGroupOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): DeleteChannelGroupEndpoint { + override fun snippet(): DeleteChannelGroup { return pubnub.deleteChannelGroup( channelGroup = "cg1", ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/ListAllChannelGroupTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/ListAllChannelGroupTestSuite.kt similarity index 92% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/ListAllChannelGroupTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/ListAllChannelGroupTestSuite.kt index 92e995086..ae63bd6d1 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/ListAllChannelGroupTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/ListAllChannelGroupTestSuite.kt @@ -3,21 +3,21 @@ package com.pubnub.internal.suite.channel_groups import com.github.tomakehurst.wiremock.client.MappingBuilder import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsListAllResult import com.pubnub.api.v2.callbacks.getOrThrow -import com.pubnub.internal.endpoints.channel_groups.ListAllChannelGroupEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue class ListAllChannelGroupTestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNChannelGroupsOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): ListAllChannelGroupEndpoint { + override fun snippet(): ListAllChannelGroup { return pubnub.listAllChannelGroups() } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/RemoveChannelChannelGroupTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/RemoveChannelChannelGroupTestSuite.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/RemoveChannelChannelGroupTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/RemoveChannelChannelGroupTestSuite.kt index c89ac1e62..7215254cf 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/RemoveChannelChannelGroupTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/channel_groups/RemoveChannelChannelGroupTestSuite.kt @@ -4,18 +4,18 @@ import com.github.tomakehurst.wiremock.client.MappingBuilder import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.channel_group.PNChannelGroupsRemoveChannelResult -import com.pubnub.internal.endpoints.channel_groups.RemoveChannelChannelGroupEndpoint import org.junit.Assert.assertTrue class RemoveChannelChannelGroupTestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNRemoveChannelsFromGroupOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): RemoveChannelChannelGroupEndpoint { + override fun snippet(): RemoveChannelChannelGroup { return pubnub.removeChannelsFromChannelGroup( channelGroup = "cg1", channels = listOf("ch1", "ch2"), diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/grant/GrantTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/grant/GrantTestSuite.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/grant/GrantTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/grant/GrantTestSuite.kt index d108f57fb..fa07ef409 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/grant/GrantTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/grant/GrantTestSuite.kt @@ -5,12 +5,12 @@ import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.matching import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.access.Grant import com.pubnub.api.enums.PNOperationType -import com.pubnub.internal.endpoints.access.GrantEndpoint -import com.pubnub.internal.models.consumer.access_manager.PNAccessManagerGrantResult +import com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult import org.junit.Assert.assertEquals -class GrantTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class GrantTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun onBefore() { super.onBefore() config.secretKey = "mySecretKey" @@ -20,7 +20,7 @@ class GrantTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class DeleteMessagesTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNDeleteMessagesOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): DeleteMessagesEndpoint = + override fun snippet(): DeleteMessages = pubnub.deleteMessages( channels = listOf("ch1"), ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/counts/MessageCountsTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/counts/MessageCountsTestSuite.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/counts/MessageCountsTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/counts/MessageCountsTestSuite.kt index 2e02f9474..0b6a48872 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/counts/MessageCountsTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/counts/MessageCountsTestSuite.kt @@ -4,17 +4,17 @@ import com.github.tomakehurst.wiremock.client.MappingBuilder import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.MessageCounts import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.history.PNMessageCountResult -import com.pubnub.internal.endpoints.MessageCountsEndpoint import org.junit.Assert.assertEquals -class MessageCountsTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class MessageCountsTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNMessageCountOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): MessageCountsEndpoint = + override fun snippet(): MessageCounts = pubnub.messageCounts( channels = listOf("ch1"), channelsTimetoken = listOf(1588284000000), diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryMetaTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryMetaTestSuite.kt similarity index 95% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryMetaTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryMetaTestSuite.kt index 022b3bc35..b9625a7cd 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryMetaTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryMetaTestSuite.kt @@ -8,18 +8,18 @@ import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.History import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.history.PNHistoryResult -import com.pubnub.internal.endpoints.HistoryEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue -class HistoryMetaTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class HistoryMetaTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNHistoryOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): HistoryEndpoint = + override fun snippet(): History = pubnub.history( channel = "ch1", includeMeta = true, diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryTestSuite.kt similarity index 94% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryTestSuite.kt index 9bf9e3d49..507ff55be 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v2/HistoryTestSuite.kt @@ -6,19 +6,19 @@ import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.History import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.history.PNHistoryResult -import com.pubnub.internal.endpoints.HistoryEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Assert.assertTrue -class HistoryTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class HistoryTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNHistoryOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): HistoryEndpoint = + override fun snippet(): History = pubnub.history( channel = "ch1", ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesMetaActionsTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesMetaActionsTestSuite.kt similarity index 96% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesMetaActionsTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesMetaActionsTestSuite.kt index 7c3487b03..07610a259 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesMetaActionsTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesMetaActionsTestSuite.kt @@ -6,19 +6,19 @@ import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo import com.google.gson.JsonObject import com.pubnub.api.PubNubError +import com.pubnub.api.endpoints.FetchMessages import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.history.PNFetchMessagesResult -import com.pubnub.internal.endpoints.FetchMessagesEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue class FetchMessagesMetaActionsTestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNFetchMessagesOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): FetchMessagesEndpoint = + override fun snippet(): FetchMessages = pubnub.fetchMessages( channels = listOf("ch1"), includeMeta = true, diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesTestSuite.kt similarity index 94% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesTestSuite.kt index 6ca0a747c..7331c8319 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/history/v3/FetchMessagesTestSuite.kt @@ -6,19 +6,19 @@ import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo import com.pubnub.api.PubNubError +import com.pubnub.api.endpoints.FetchMessages import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.history.PNFetchMessagesResult -import com.pubnub.internal.endpoints.FetchMessagesEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Assert.assertTrue -class FetchMessagesTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class FetchMessagesTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNFetchMessagesOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): FetchMessagesEndpoint = + override fun snippet(): FetchMessages = pubnub.fetchMessages( channels = listOf("ch1"), ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/AddMessageActionTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/AddMessageActionTestSuite.kt similarity index 92% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/AddMessageActionTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/AddMessageActionTestSuite.kt index 7f6cb863a..e465579c8 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/AddMessageActionTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/AddMessageActionTestSuite.kt @@ -3,19 +3,19 @@ package com.pubnub.internal.suite.message_actions import com.github.tomakehurst.wiremock.client.WireMock.equalToJson import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.urlMatching +import com.pubnub.api.endpoints.message_actions.AddMessageAction import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.message_actions.PNAddMessageActionResult import com.pubnub.api.models.consumer.message_actions.PNMessageAction -import com.pubnub.internal.endpoints.message_actions.AddMessageActionEndpoint import org.junit.Assert.assertEquals class AddMessageActionTestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNAddMessageAction override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): AddMessageActionEndpoint = + override fun snippet(): AddMessageAction = pubnub.addMessageAction( channel = "ch1", messageAction = diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsMultipleTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsMultipleTestSuite.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsMultipleTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsMultipleTestSuite.kt index 80f75c783..0ebf3f6d7 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsMultipleTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsMultipleTestSuite.kt @@ -3,19 +3,19 @@ package com.pubnub.internal.suite.message_actions import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.message_actions.GetMessageActions import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.PNBoundedPage import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult -import com.pubnub.internal.endpoints.message_actions.GetMessageActionsEndpoint import org.junit.Assert.assertEquals class GetMessageActionsMultipleTestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNGetMessageActions override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): GetMessageActionsEndpoint = + override fun snippet(): GetMessageActions = pubnub.getMessageActions( channel = "ch1", page = diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsTestSuite.kt similarity index 91% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsTestSuite.kt index 5c238598b..74f8477d5 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/GetMessageActionsTestSuite.kt @@ -3,18 +3,18 @@ package com.pubnub.internal.suite.message_actions import com.github.tomakehurst.wiremock.client.WireMock.absent import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.message_actions.GetMessageActions import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.message_actions.PNGetMessageActionsResult -import com.pubnub.internal.endpoints.message_actions.GetMessageActionsEndpoint import org.junit.Assert.assertEquals class GetMessageActionsTestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNGetMessageActions override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): GetMessageActionsEndpoint = + override fun snippet(): GetMessageActions = pubnub.getMessageActions( channel = "ch1", ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/RemoveMessageActionsTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/RemoveMessageActionsTestSuite.kt similarity index 87% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/RemoveMessageActionsTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/RemoveMessageActionsTestSuite.kt index 248049c51..de8263a9b 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/RemoveMessageActionsTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/message_actions/RemoveMessageActionsTestSuite.kt @@ -2,17 +2,17 @@ package com.pubnub.internal.suite.message_actions import com.github.tomakehurst.wiremock.client.WireMock.delete import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.message_actions.RemoveMessageAction import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.message_actions.PNRemoveMessageActionResult -import com.pubnub.internal.endpoints.message_actions.RemoveMessageActionEndpoint class RemoveMessageActionsTestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNDeleteMessageAction override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): RemoveMessageActionEndpoint { + override fun snippet(): RemoveMessageAction { return pubnub.removeMessageAction( channel = "ch1", messageTimetoken = 100, diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/GetStateTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/GetStateTestSuite.kt similarity index 94% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/GetStateTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/GetStateTestSuite.kt index 968dfad85..4089ed183 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/GetStateTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/GetStateTestSuite.kt @@ -5,19 +5,19 @@ import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo import com.google.gson.JsonNull import com.google.gson.JsonObject +import com.pubnub.api.endpoints.presence.GetState import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.presence.PNGetStateResult import com.pubnub.api.v2.callbacks.getOrThrow -import com.pubnub.internal.endpoints.presence.GetStateEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse -class GetStateTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class GetStateTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNGetState override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): GetStateEndpoint = + override fun snippet(): GetState = pubnub.getPresenceState( channels = listOf("ch1"), ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/HeartbeatTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/HeartbeatTestSuite.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/HeartbeatTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/HeartbeatTestSuite.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/HereNowTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/HereNowTestSuite.kt similarity index 92% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/HereNowTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/HereNowTestSuite.kt index c04bbefae..9381acd7f 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/HereNowTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/HereNowTestSuite.kt @@ -3,17 +3,17 @@ package com.pubnub.internal.suite.presence import com.github.tomakehurst.wiremock.client.WireMock.absent import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.presence.HereNow import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.presence.PNHereNowResult -import com.pubnub.internal.endpoints.presence.HereNowEndpoint import org.junit.Assert.assertEquals -class HereNowTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class HereNowTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNHereNowOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): HereNowEndpoint = + override fun snippet(): HereNow = pubnub.hereNow( channels = listOf("ch1"), ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/LeaveTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/LeaveTestSuite.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/LeaveTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/LeaveTestSuite.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/StateSetTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/StateSetTestSuite.kt similarity index 94% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/StateSetTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/StateSetTestSuite.kt index 18af82f74..c3d12802f 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/StateSetTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/StateSetTestSuite.kt @@ -5,20 +5,20 @@ import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo import com.google.gson.JsonObject +import com.pubnub.api.endpoints.presence.SetState import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.presence.PNSetStateResult import com.pubnub.api.v2.callbacks.getOrThrow -import com.pubnub.internal.endpoints.presence.SetStateEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue -class StateSetTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class StateSetTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNSetStateOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): SetStateEndpoint = + override fun snippet(): SetState = pubnub.setPresenceState( channels = listOf("ch1"), state = mapOf("text" to "hello"), diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/WhereNowTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/WhereNowTestSuite.kt similarity index 85% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/WhereNowTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/WhereNowTestSuite.kt index 1c9cf182f..c229c1037 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/presence/WhereNowTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/presence/WhereNowTestSuite.kt @@ -2,17 +2,17 @@ package com.pubnub.internal.suite.presence import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.presence.WhereNow import com.pubnub.api.enums.PNOperationType -import com.pubnub.internal.endpoints.presence.WhereNowEndpoint -import com.pubnub.internal.models.consumer.presence.PNWhereNowResult +import com.pubnub.api.models.consumer.presence.PNWhereNowResult import org.junit.Assert.assertEquals -class WhereNowTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class WhereNowTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNWhereNowOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): WhereNowEndpoint { + override fun snippet(): WhereNow { return pubnub.whereNow().apply { } } diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishGetTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishGetTestSuite.kt similarity index 91% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishGetTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishGetTestSuite.kt index 791c1bd3a..6e0d79d88 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishGetTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishGetTestSuite.kt @@ -4,19 +4,19 @@ import com.github.tomakehurst.wiremock.client.MappingBuilder import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo import com.google.gson.Gson +import com.pubnub.api.endpoints.pubsub.Publish import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.internal.endpoints.pubsub.PublishEndpoint import org.junit.Assert.assertEquals import java.net.URLEncoder import java.nio.charset.StandardCharsets -class PublishGetTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class PublishGetTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNPublishOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.PUB + com.pubnub.internal.suite.AUTH - override fun snippet(): PublishEndpoint { + override fun snippet(): Publish { return pubnub.publish( channel = "ch1", message = "ch2", diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishPostTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishPostTestSuite.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishPostTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishPostTestSuite.kt index c3d54cc1c..ddff0ec77 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishPostTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/PublishPostTestSuite.kt @@ -5,18 +5,18 @@ import com.github.tomakehurst.wiremock.client.WireMock.equalToJson import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo import com.google.gson.Gson +import com.pubnub.api.endpoints.pubsub.Publish import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.internal.endpoints.pubsub.PublishEndpoint import org.json.JSONObject import org.junit.Assert.assertEquals -class PublishPostTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class PublishPostTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNPublishOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.PUB + com.pubnub.internal.suite.AUTH - override fun snippet(): PublishEndpoint { + override fun snippet(): Publish { return pubnub.publish( channel = "ch1", message = diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/SignalTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/SignalTestSuite.kt similarity index 91% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/SignalTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/SignalTestSuite.kt index 3db8a399d..a6d726d7c 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/SignalTestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/SignalTestSuite.kt @@ -4,19 +4,19 @@ import com.github.tomakehurst.wiremock.client.MappingBuilder import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo import com.google.gson.Gson +import com.pubnub.api.endpoints.pubsub.Signal import com.pubnub.api.enums.PNOperationType import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.internal.endpoints.pubsub.SignalEndpoint import org.junit.Assert.assertEquals import java.net.URLEncoder import java.nio.charset.StandardCharsets -class SignalTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { +class SignalTestSuite : com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNSignalOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.PUB + com.pubnub.internal.suite.AUTH - override fun snippet(): SignalEndpoint { + override fun snippet(): Signal { return pubnub.signal( channel = "ch1", message = "ch2", diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/SubscribeTestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/SubscribeTestSuite.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/SubscribeTestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/pubsub/SubscribeTestSuite.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV1TestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV1TestSuite.kt similarity index 94% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV1TestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV1TestSuite.kt index a6169b429..80b091f32 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV1TestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV1TestSuite.kt @@ -6,20 +6,20 @@ import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException +import com.pubnub.api.endpoints.push.AddChannelsToPush import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushAddChannelResult -import com.pubnub.internal.endpoints.push.AddChannelsToPushEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue class AddChannelsToPushV1TestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNAddPushNotificationsOnChannelsOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): AddChannelsToPushEndpoint { + override fun snippet(): AddChannelsToPush { return pubnub.addPushNotificationsOnChannels( pushType = PNPushType.FCM, channels = listOf("ch1", "ch2"), diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV2TestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV2TestSuite.kt similarity index 91% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV2TestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV2TestSuite.kt index e24a2c9e1..6c7d09d12 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV2TestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/add/AddChannelsToPushV2TestSuite.kt @@ -4,18 +4,18 @@ import com.github.tomakehurst.wiremock.client.WireMock.absent import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.push.AddChannelsToPush import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushAddChannelResult -import com.pubnub.internal.endpoints.push.AddChannelsToPushEndpoint class AddChannelsToPushV2TestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNAddPushNotificationsOnChannelsOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): AddChannelsToPushEndpoint { + override fun snippet(): AddChannelsToPush { return pubnub.addPushNotificationsOnChannels( pushType = PNPushType.APNS2, channels = listOf("ch1", "ch2"), diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV1TestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV1TestSuite.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV1TestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV1TestSuite.kt index d547aaf5d..7701e1b1f 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV1TestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV1TestSuite.kt @@ -4,21 +4,21 @@ import com.github.tomakehurst.wiremock.client.WireMock.absent import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.push.ListPushProvisions import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult import com.pubnub.api.v2.callbacks.getOrThrow -import com.pubnub.internal.endpoints.push.ListPushProvisionsEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse class ListPushProvisionsV1TestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNPushNotificationEnabledChannelsOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): ListPushProvisionsEndpoint { + override fun snippet(): ListPushProvisions { return pubnub.auditPushChannelProvisions( pushType = PNPushType.FCM, deviceId = "12345", diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV2TestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV2TestSuite.kt similarity index 93% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV2TestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV2TestSuite.kt index e07c63fab..2425f4374 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV2TestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/list/ListPushProvisionsV2TestSuite.kt @@ -4,21 +4,21 @@ import com.github.tomakehurst.wiremock.client.WireMock.absent import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.push.ListPushProvisions import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushListProvisionsResult import com.pubnub.api.v2.callbacks.getOrThrow -import com.pubnub.internal.endpoints.push.ListPushProvisionsEndpoint import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse class ListPushProvisionsV2TestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNPushNotificationEnabledChannelsOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): ListPushProvisionsEndpoint { + override fun snippet(): ListPushProvisions { return pubnub.auditPushChannelProvisions( pushType = PNPushType.APNS2, deviceId = "12345", diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV1TestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV1TestSuite.kt similarity index 88% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV1TestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV1TestSuite.kt index 764cfb343..93b6b9b8b 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV1TestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV1TestSuite.kt @@ -4,18 +4,18 @@ import com.github.tomakehurst.wiremock.client.WireMock.absent import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult -import com.pubnub.internal.endpoints.push.RemoveAllPushChannelsForDeviceEndpoint class RemoveAllFromPushV1TestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNRemoveAllPushNotificationsOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): RemoveAllPushChannelsForDeviceEndpoint { + override fun snippet(): RemoveAllPushChannelsForDevice { return pubnub.removeAllPushNotificationsFromDeviceWithPushToken( pushType = PNPushType.FCM, deviceId = "12345", diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV2TestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV2TestSuite.kt similarity index 88% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV2TestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV2TestSuite.kt index 72897aa8b..b73aad59c 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV2TestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveAllFromPushV2TestSuite.kt @@ -4,18 +4,18 @@ import com.github.tomakehurst.wiremock.client.WireMock.absent import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveAllChannelsResult -import com.pubnub.internal.endpoints.push.RemoveAllPushChannelsForDeviceEndpoint class RemoveAllFromPushV2TestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNRemoveAllPushNotificationsOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): RemoveAllPushChannelsForDeviceEndpoint { + override fun snippet(): RemoveAllPushChannelsForDevice { return pubnub.removeAllPushNotificationsFromDeviceWithPushToken( pushType = PNPushType.APNS2, deviceId = "12345", diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV1TestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV1TestSuite.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV1TestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV1TestSuite.kt index e6923dbc4..ab9eb582e 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV1TestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV1TestSuite.kt @@ -4,18 +4,18 @@ import com.github.tomakehurst.wiremock.client.WireMock.absent import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult -import com.pubnub.internal.endpoints.push.RemoveChannelsFromPushEndpoint class RemoveChannelsFromPushV1TestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNRemovePushNotificationsFromChannelsOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): RemoveChannelsFromPushEndpoint { + override fun snippet(): RemoveChannelsFromPush { return pubnub.removePushNotificationsFromChannels( pushType = PNPushType.FCM, channels = listOf("ch1", "ch2"), diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV2TestSuite.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV2TestSuite.kt similarity index 90% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV2TestSuite.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV2TestSuite.kt index ff16c2f65..285a9afa9 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV2TestSuite.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/suite/push/remove/RemoveChannelsFromPushV2TestSuite.kt @@ -4,18 +4,18 @@ import com.github.tomakehurst.wiremock.client.WireMock.absent import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.get import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo +import com.pubnub.api.endpoints.push.RemoveChannelsFromPush import com.pubnub.api.enums.PNOperationType import com.pubnub.api.enums.PNPushType import com.pubnub.api.models.consumer.push.PNPushRemoveChannelResult -import com.pubnub.internal.endpoints.push.RemoveChannelsFromPushEndpoint class RemoveChannelsFromPushV2TestSuite : - com.pubnub.internal.suite.CoreEndpointTestSuite() { + com.pubnub.internal.suite.CoreEndpointTestSuite() { override fun pnOperation() = PNOperationType.PNRemovePushNotificationsFromChannelsOperation override fun requiredKeys() = com.pubnub.internal.suite.SUB + com.pubnub.internal.suite.AUTH - override fun snippet(): RemoveChannelsFromPushEndpoint { + override fun snippet(): RemoveChannelsFromPush { return pubnub.removePushNotificationsFromChannels( pushType = PNPushType.APNS2, channels = listOf("ch1", "ch2"), diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/utils/PolymorphicDeserializerTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/utils/PolymorphicDeserializerTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/utils/PolymorphicDeserializerTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/utils/PolymorphicDeserializerTest.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/utils/UnwrapSingleFieldTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/utils/UnwrapSingleFieldTest.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/utils/UnwrapSingleFieldTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/utils/UnwrapSingleFieldTest.kt diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/PNConfigurationImplTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/PNConfigurationImplTest.kt index c8f9ffff0..857ddd20e 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/PNConfigurationImplTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/PNConfigurationImplTest.kt @@ -1,12 +1,14 @@ package com.pubnub.internal.v2 +import com.pubnub.api.PubNubException import com.pubnub.api.UserId import com.pubnub.api.crypto.CryptoModule import com.pubnub.api.enums.PNHeartbeatNotificationOptions import com.pubnub.api.enums.PNLogVerbosity import com.pubnub.api.retry.RetryConfiguration import com.pubnub.api.v2.PNConfiguration -import com.pubnub.internal.BasePubNubImpl +import com.pubnub.api.v2.PNConfigurationOverride +import com.pubnub.internal.PubNubImpl import io.mockk.mockk import okhttp3.Authenticator import okhttp3.CertificatePinner @@ -22,16 +24,46 @@ import java.net.Proxy import javax.net.ssl.X509ExtendedTrustManager class PNConfigurationImplTest { + @Test(expected = PubNubException::class) + fun setUUIDToEmptyString() { + PNConfiguration.builder(UserId(""), "") + } + + @Test(expected = PubNubException::class) + fun resetUUIDToEmptyString() { + val config = PNConfiguration.builder(UserId(PubNubImpl.generateUUID()), "") + config.userId = UserId("") + } + + @Test + fun resetUUIDToNonEmptyString() { + val config = PNConfiguration.builder(UserId(PubNubImpl.generateUUID()), "") + val newUUID = PubNubImpl.generateUUID() + config.userId = UserId(newUUID) + + assertEquals(newUUID, config.userId.value) + } + + @Test + fun `create config override from existing config`() { + val config = PNConfiguration.builder(UserId(PubNubImpl.generateUUID()), "expectedSubscribe").build() + val override = PNConfigurationOverride.from(config).apply { + userId = UserId("override") + }.build() + assertEquals("override", override.userId.value) + assertEquals("expectedSubscribe", override.subscribeKey) + } + @Test fun testDefaultTimeoutValues() { - val config = PNConfiguration.builder(UserId(BasePubNubImpl.generateUUID()), "demo") + val config = PNConfiguration.builder(UserId(PubNubImpl.generateUUID()), "demo") assertEquals(300, config.presenceTimeout) assertEquals(0, config.heartbeatInterval) } @Test fun testCustomTimeoutValues1() { - val config = PNConfiguration.builder(UserId(BasePubNubImpl.generateUUID()), "demo") + val config = PNConfiguration.builder(UserId(PubNubImpl.generateUUID()), "demo") config.presenceTimeout = 100 assertEquals(100, config.presenceTimeout) assertEquals(49, config.heartbeatInterval) @@ -39,7 +71,7 @@ class PNConfigurationImplTest { @Test fun testCustomTimeoutValues2() { - val config = PNConfiguration.builder(UserId(BasePubNubImpl.generateUUID()), "demo") + val config = PNConfiguration.builder(UserId(PubNubImpl.generateUUID()), "demo") config.heartbeatInterval = 100 assertEquals(300, config.presenceTimeout) assertEquals(100, config.heartbeatInterval) @@ -47,7 +79,7 @@ class PNConfigurationImplTest { @Test fun testCustomTimeoutValues3() { - val config = PNConfiguration.builder(UserId(BasePubNubImpl.generateUUID()), "demo") + val config = PNConfiguration.builder(UserId(PubNubImpl.generateUUID()), "demo") config.heartbeatInterval = 40 config.presenceTimeout = 50 assertEquals(50, config.presenceTimeout) @@ -56,7 +88,7 @@ class PNConfigurationImplTest { @Test fun `build uses all values from Builder`() { - val expectedUserId = UserId(BasePubNubImpl.generateUUID()) + val expectedUserId = UserId(PubNubImpl.generateUUID()) val expectedCryptoModule = CryptoModule.createAesCbcCryptoModule("cipher") val expectedProxy = Proxy(Proxy.Type.HTTP, InetSocketAddress(80)) val expectedProxySelector = DefaultProxySelector() @@ -150,10 +182,10 @@ class PNConfigurationImplTest { } @Test - fun `builder has all default values from BasePNConfiguration`() { - val expectedUserId = UserId(BasePubNubImpl.generateUUID()) + fun `builder has all default values from PNConfiguration`() { + val expectedUserId = UserId(PubNubImpl.generateUUID()) val builder = PNConfiguration.builder(expectedUserId, "subKey") - val expectedDefaults = BasePNConfigurationImpl(expectedUserId) + val expectedDefaults = PNConfigurationImpl(expectedUserId) assertEquals(expectedUserId, builder.userId) assertEquals("subKey", builder.subscribeKey) @@ -197,7 +229,7 @@ class PNConfigurationImplTest { @Test fun `can reset userId and subscribeKey`() { - val expectedUserId = UserId(BasePubNubImpl.generateUUID()) + val expectedUserId = UserId(PubNubImpl.generateUUID()) val expectedSubKey = "expectedSubKey" val config = PNConfiguration.builder(UserId("aaa"), "subKey") { diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt deleted file mode 100644 index 3810b49b3..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingEventListenerTest.kt +++ /dev/null @@ -1,23 +0,0 @@ -package com.pubnub.internal.v2.callbacks - -import com.pubnub.api.v2.callbacks.EventListener -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test - -internal class DelegatingEventListenerTest { - @Test - fun testEquals() { - val eventListener = object : EventListener {} - val otherEventListener = object : EventListener {} - val delegating1 = DelegatingEventListener(eventListener) - val delegating2 = DelegatingEventListener(eventListener) - val otherDelegating = DelegatingEventListener(otherEventListener) - - Assertions.assertEquals(delegating1, delegating2) - Assertions.assertEquals(delegating2, delegating1) - Assertions.assertNotEquals(delegating1, otherDelegating) - Assertions.assertNotEquals(delegating2, otherDelegating) - Assertions.assertNotEquals(otherDelegating, delegating1) - Assertions.assertNotEquals(otherDelegating, delegating2) - } -} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingStatusListenerTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingStatusListenerTest.kt deleted file mode 100644 index dc5006a48..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingStatusListenerTest.kt +++ /dev/null @@ -1,37 +0,0 @@ -package com.pubnub.internal.v2.callbacks - -import com.pubnub.api.PubNub -import com.pubnub.api.models.consumer.PNStatus -import com.pubnub.api.v2.callbacks.StatusListener -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test - -internal class DelegatingStatusListenerTest { - @Test - fun testEquals() { - val statusListener = - object : StatusListener { - override fun status( - pubnub: PubNub, - status: PNStatus, - ) {} - } - val otherStatusListener = - object : StatusListener { - override fun status( - pubnub: PubNub, - status: PNStatus, - ) {} - } - val delegating1 = DelegatingStatusListener(statusListener) - val delegating2 = DelegatingStatusListener(statusListener) - val otherDelegating = DelegatingStatusListener(otherStatusListener) - - Assertions.assertEquals(delegating1, delegating2) - Assertions.assertEquals(delegating2, delegating1) - Assertions.assertNotEquals(delegating1, otherDelegating) - Assertions.assertNotEquals(delegating2, otherDelegating) - Assertions.assertNotEquals(otherDelegating, delegating1) - Assertions.assertNotEquals(otherDelegating, delegating2) - } -} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt deleted file mode 100644 index c0f0923cf..000000000 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/DelegatingSubscribeCallbackTest.kt +++ /dev/null @@ -1,38 +0,0 @@ -package com.pubnub.internal.v2.callbacks - -import com.pubnub.api.PubNub -import com.pubnub.api.callbacks.SubscribeCallback -import com.pubnub.api.models.consumer.PNStatus -import org.junit.jupiter.api.Assertions -import org.junit.jupiter.api.Test - -internal class DelegatingSubscribeCallbackTest { - @Test - fun testEquals() { - val statusListener = - object : SubscribeCallback() { - override fun status( - pubnub: PubNub, - status: PNStatus, - ) {} - } - val otherStatusListener = - object : SubscribeCallback() { - override fun status( - pubnub: PubNub, - status: PNStatus, - ) {} - } - - val delegating1 = DelegatingSubscribeCallback(statusListener) - val delegating2 = DelegatingSubscribeCallback(statusListener) - val otherDelegating = DelegatingSubscribeCallback(otherStatusListener) - - Assertions.assertEquals(delegating1, delegating2) - Assertions.assertEquals(delegating2, delegating1) - Assertions.assertNotEquals(delegating1, otherDelegating) - Assertions.assertNotEquals(delegating2, otherDelegating) - Assertions.assertNotEquals(otherDelegating, delegating1) - Assertions.assertNotEquals(otherDelegating, delegating2) - } -} diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImplTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImplTest.kt similarity index 80% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImplTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImplTest.kt index 7ea9e98bb..965bb1258 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImplTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/callbacks/EventEmitterImplTest.kt @@ -1,7 +1,7 @@ package com.pubnub.internal.v2.callbacks import com.google.gson.JsonPrimitive -import com.pubnub.api.BasePubNub +import com.pubnub.api.PubNub import com.pubnub.api.UserId import com.pubnub.api.models.consumer.files.PNDownloadableFile import com.pubnub.api.models.consumer.message_actions.PNMessageAction @@ -11,12 +11,13 @@ import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult import com.pubnub.api.models.consumer.pubsub.PNSignalResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult import com.pubnub.api.models.consumer.pubsub.message_actions.PNMessageActionResult -import com.pubnub.internal.TestPubNub +import com.pubnub.api.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage +import com.pubnub.api.models.consumer.pubsub.objects.PNObjectEventResult +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.managers.AnnouncementCallback import com.pubnub.internal.managers.AnnouncementEnvelope -import com.pubnub.internal.models.consumer.pubsub.objects.PNDeleteUUIDMetadataEventMessage -import com.pubnub.internal.models.consumer.pubsub.objects.PNObjectEventResult -import com.pubnub.internal.v2.BasePNConfigurationImpl +import com.pubnub.internal.v2.PNConfigurationImpl import org.junit.jupiter.api.Assertions.assertFalse import org.junit.jupiter.api.Assertions.assertTrue import org.junit.jupiter.api.BeforeEach @@ -24,7 +25,7 @@ import org.junit.jupiter.api.Test class EventEmitterImplTest { lateinit var emitterImpl: EventEmitterImpl - val testPubNub = TestPubNub(BasePNConfigurationImpl(UserId("aa"))) + val testPubNub = PubNubImpl(PNConfigurationImpl(UserId("aa"))) val basePubSubResult = BasePubSubResult("a", null, null, null, null) val message = JsonPrimitive(1) @@ -35,7 +36,7 @@ class EventEmitterImplTest { @Test fun `can add listener`() { - val listener = object : EventListenerCore { } + val listener = object : EventListener { } emitterImpl.addListener(listener) @@ -44,7 +45,7 @@ class EventEmitterImplTest { @Test fun `can remove listener`() { - val listener = object : EventListenerCore { } + val listener = object : EventListener { } emitterImpl.addListener(listener) assertTrue(emitterImpl.listeners.contains(listener)) @@ -55,9 +56,9 @@ class EventEmitterImplTest { @Test fun `can remove all listeners`() { - emitterImpl.addListener(object : EventListenerCore { }) - emitterImpl.addListener(object : EventListenerCore { }) - emitterImpl.addListener(object : EventListenerCore { }) + emitterImpl.addListener(object : EventListener { }) + emitterImpl.addListener(object : EventListener { }) + emitterImpl.addListener(object : EventListener { }) assertTrue(emitterImpl.listeners.size == 3) emitterImpl.removeAllListeners() @@ -69,9 +70,9 @@ class EventEmitterImplTest { fun `message is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNMessageResult, ) { success = true @@ -86,9 +87,9 @@ class EventEmitterImplTest { fun `message announcement is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNMessageResult, ) { success = true @@ -103,9 +104,9 @@ class EventEmitterImplTest { fun `presence event is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNPresenceEventResult, ) { success = true @@ -122,9 +123,9 @@ class EventEmitterImplTest { fun `presence announcement is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun presence( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNPresenceEventResult, ) { success = true @@ -141,9 +142,9 @@ class EventEmitterImplTest { fun `signal is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNSignalResult, ) { success = true @@ -160,9 +161,9 @@ class EventEmitterImplTest { fun `signal announcement is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun signal( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNSignalResult, ) { success = true @@ -179,9 +180,9 @@ class EventEmitterImplTest { fun `messageAction is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNMessageActionResult, ) { success = true @@ -198,9 +199,9 @@ class EventEmitterImplTest { fun `messageAction announcement is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun messageAction( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNMessageActionResult, ) { success = true @@ -217,9 +218,9 @@ class EventEmitterImplTest { fun `object is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun objects( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNObjectEventResult, ) { success = true @@ -236,9 +237,9 @@ class EventEmitterImplTest { fun `objects announcement is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun objects( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNObjectEventResult, ) { success = true @@ -258,9 +259,9 @@ class EventEmitterImplTest { fun `file is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun file( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNFileEventResult, ) { success = true @@ -277,9 +278,9 @@ class EventEmitterImplTest { fun `file announcement is delivered`() { var success = false emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun file( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNFileEventResult, ) { success = true @@ -303,9 +304,9 @@ class EventEmitterImplTest { envelope.event.channel == "acceptedChannel" } emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNMessageResult, ) { success = true @@ -327,9 +328,9 @@ class EventEmitterImplTest { envelope.event.channel == "acceptedChannel" } emitterImpl.addListener( - object : EventListenerCore { + object : EventListener { override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, + pubnub: PubNub, event: PNMessageResult, ) { success = true diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelGroupImplTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelGroupImplTest.kt similarity index 65% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelGroupImplTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelGroupImplTest.kt index 7d3be8ab8..c186572a1 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelGroupImplTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelGroupImplTest.kt @@ -1,30 +1,24 @@ package com.pubnub.internal.v2.entities import com.pubnub.api.UserId -import com.pubnub.api.v2.callbacks.BaseEventListener import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.TestPubNub -import com.pubnub.internal.v2.BasePNConfigurationImpl -import com.pubnub.internal.v2.subscription.BaseSubscriptionImpl +import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.v2.PNConfigurationImpl import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class BaseChannelGroupImplTest { - private lateinit var pn: TestPubNub - private lateinit var channelGrp: BaseChannelGroupImpl> + private lateinit var pn: PubNubImpl + private lateinit var channelGrp: ChannelGroupImpl private val channelGroupname = "myChannelGroup" @BeforeEach fun setUp() { - pn = TestPubNub(BasePNConfigurationImpl(UserId("uuid"))) + pn = PubNubImpl(PNConfigurationImpl(UserId("uuid"))) channelGrp = - BaseChannelGroupImpl(pn.pubNubCore, ChannelGroupName(channelGroupname)) { channels, channelGroups, options -> - object : BaseSubscriptionImpl(pn.pubNubCore, channels, channelGroups, options) { - override fun addListener(listener: BaseEventListener) { } - } - } + ChannelGroupImpl(pn, ChannelGroupName(channelGroupname)) } @AfterEach diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelImplTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelImplTest.kt similarity index 64% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelImplTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelImplTest.kt index 5cbf11352..d2caa6290 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelImplTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/entities/BaseChannelImplTest.kt @@ -1,30 +1,23 @@ package com.pubnub.internal.v2.entities import com.pubnub.api.UserId -import com.pubnub.api.v2.callbacks.BaseEventListener import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.TestPubNub -import com.pubnub.internal.v2.BasePNConfigurationImpl -import com.pubnub.internal.v2.subscription.BaseSubscriptionImpl +import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.v2.PNConfigurationImpl import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class BaseChannelImplTest { - private lateinit var pn: TestPubNub - private lateinit var channel: BaseChannelImpl> + private lateinit var pn: PubNubImpl + private lateinit var channel: ChannelImpl private val channelName = "myChannel" @BeforeEach fun setUp() { - pn = TestPubNub(BasePNConfigurationImpl(UserId("uuid"))) - channel = - BaseChannelImpl(pn.pubNubCore, ChannelName(channelName)) { channels, channelGroups, options -> - object : BaseSubscriptionImpl(pn.pubNubCore, channels, channelGroups, options) { - override fun addListener(listener: BaseEventListener) { } - } - } + pn = PubNubImpl(PNConfigurationImpl(UserId("uuid"))) + channel = ChannelImpl(pn, ChannelName(channelName)) } @AfterEach diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionImplTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionImplTest.kt similarity index 54% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionImplTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionImplTest.kt index 07eb80fca..6015d88d2 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionImplTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionImplTest.kt @@ -1,45 +1,30 @@ package com.pubnub.internal.v2.subscriptions import com.google.gson.JsonNull -import com.pubnub.api.BasePubNub +import com.pubnub.api.PubNub import com.pubnub.api.UserId import com.pubnub.api.models.consumer.pubsub.BasePubSubResult import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.v2.callbacks.EventListener import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.TestEventListener -import com.pubnub.internal.TestPubNub -import com.pubnub.internal.v2.BasePNConfigurationImpl -import com.pubnub.internal.v2.callbacks.EventListenerCore +import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.v2.PNConfigurationImpl import com.pubnub.internal.v2.entities.ChannelName -import com.pubnub.internal.v2.subscription.BaseSubscriptionImpl +import com.pubnub.internal.v2.subscription.SubscriptionImpl import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Assertions.assertEquals import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test class BaseSubscriptionImplTest { - private lateinit var pubnub: TestPubNub - private lateinit var subscription: BaseSubscriptionImpl + private lateinit var pubnub: PubNubImpl + private lateinit var subscription: SubscriptionImpl private val channelName = "myChannel" @BeforeEach fun setUp() { - pubnub = TestPubNub(BasePNConfigurationImpl(UserId("uuid"))) - subscription = - object : BaseSubscriptionImpl(pubnub.pubNubCore, setOf(ChannelName(channelName))) { - override fun addListener(listener: TestEventListener) { - addListener( - object : EventListenerCore { - override fun message( - pubnub: BasePubNub<*, *, *, *, *, *, *, *>, - event: PNMessageResult, - ) { - listener.message(event) - } - }, - ) - } - } + pubnub = PubNubImpl(PNConfigurationImpl(UserId("uuid"))) + subscription = SubscriptionImpl(pubnub, setOf(ChannelName(channelName))) } @AfterEach @@ -54,8 +39,8 @@ class BaseSubscriptionImplTest { subscription.subscribe() // then - assertEquals(listOf(channelName), pubnub.pubNubCore.getSubscribedChannels()) - assertEquals(emptyList(), pubnub.pubNubCore.getSubscribedChannelGroups()) + assertEquals(listOf(channelName), pubnub.getSubscribedChannels()) + assertEquals(emptyList(), pubnub.getSubscribedChannelGroups()) } @Test @@ -67,15 +52,19 @@ class BaseSubscriptionImplTest { subscription.unsubscribe() // then - assertEquals(emptyList(), pubnub.pubNubCore.getSubscribedChannels()) - assertEquals(emptyList(), pubnub.pubNubCore.getSubscribedChannelGroups()) + assertEquals(emptyList(), pubnub.getSubscribedChannels()) + assertEquals(emptyList(), pubnub.getSubscribedChannelGroups()) } @Test fun `close stops the subscription`() { // given subscription.subscribe() - subscription.addListener(TestEventListener { throw IllegalStateException("We should not get a message after close!") }) + subscription.addListener(object : EventListener { + override fun message(pubnub: PubNub, result: PNMessageResult) { + throw IllegalStateException("We should not get a message after close!") + } + }) // when subscription.close() @@ -89,16 +78,16 @@ class BaseSubscriptionImplTest { // then // no exception from listener - assertEquals(emptyList(), pubnub.pubNubCore.getSubscribedChannels()) - assertEquals(emptyList(), pubnub.pubNubCore.getSubscribedChannelGroups()) + assertEquals(emptyList(), pubnub.getSubscribedChannels()) + assertEquals(emptyList(), pubnub.getSubscribedChannelGroups()) } @Test fun `subscriptions with filter doesn't deliver filtered messages`() { // given val subWithFilter = - object : BaseSubscriptionImpl( - pubnub.pubNubCore, + SubscriptionImpl( + pubnub, setOf( ChannelName(channelName), ), @@ -106,11 +95,7 @@ class BaseSubscriptionImplTest { SubscriptionOptions.filter { it !is PNMessageResult }, - ) { - override fun addListener(listener: TestEventListener) { - TODO("Not yet implemented") - } - } + ) // when subWithFilter.subscribe() @@ -129,7 +114,11 @@ class BaseSubscriptionImplTest { fun `subscription doesn't get events until subscribe is called`() { // given subscription.addListener( - TestEventListener { throw IllegalStateException("Message should not be received without subscribe call!") }, + object : EventListener { + override fun message(pubnub: PubNub, result: PNMessageResult) { + throw IllegalStateException("Message should not be received without subscribe call!") + } + } ) // when diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImplTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImplTest.kt new file mode 100644 index 000000000..734f800ab --- /dev/null +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/BaseSubscriptionSetImplTest.kt @@ -0,0 +1,121 @@ +package com.pubnub.internal.v2.subscriptions + +import com.google.gson.JsonNull +import com.pubnub.api.PubNub +import com.pubnub.api.UserId +import com.pubnub.api.models.consumer.pubsub.BasePubSubResult +import com.pubnub.api.models.consumer.pubsub.PNMessageResult +import com.pubnub.api.v2.callbacks.EventListener +import com.pubnub.internal.PubNubImpl +import com.pubnub.internal.v2.PNConfigurationImpl +import com.pubnub.internal.v2.entities.ChannelName +import com.pubnub.internal.v2.subscription.SubscriptionImpl +import com.pubnub.internal.v2.subscription.SubscriptionSetImpl +import org.junit.jupiter.api.AfterEach +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Assertions.assertFalse +import org.junit.jupiter.api.Assertions.assertTrue +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test + +class BaseSubscriptionSetImplTest { + private lateinit var pubnub: PubNubImpl + private lateinit var subscriptionSet: SubscriptionSetImpl + private lateinit var anotherSubscription: SubscriptionImpl + private val channelName = "myChannel" + + @BeforeEach + fun setUp() { + pubnub = PubNubImpl(PNConfigurationImpl(UserId("uuid"))) + subscriptionSet = SubscriptionSetImpl(pubnub, setOf()) + + subscriptionSet.add( + SubscriptionImpl(pubnub, setOf(ChannelName(channelName))) + ) + + anotherSubscription = SubscriptionImpl(pubnub, setOf(ChannelName("anotherChannel"))) + } + + @AfterEach + fun teardown() { + subscriptionSet.close() + anotherSubscription.close() + pubnub.destroy() + } + + @Test + fun add() { + // given + + // when + subscriptionSet.add(anotherSubscription) + subscriptionSet.subscribe() + + // then + assertTrue(subscriptionSet.subscriptions.contains(anotherSubscription)) + assertEquals(setOf(channelName, "anotherChannel"), pubnub.getSubscribedChannels().toSet()) + } + + @Test + fun remove() { + // given + subscriptionSet.add(anotherSubscription) + + // when + subscriptionSet.remove(anotherSubscription) + subscriptionSet.subscribe() + + // then + assertFalse(subscriptionSet.subscriptions.contains(anotherSubscription)) + assertEquals(setOf(channelName), pubnub.getSubscribedChannels().toSet()) + } + + @Test + fun subscribe() { + // when + subscriptionSet.subscribe() + + // then + assertEquals(setOf(channelName), pubnub.getSubscribedChannels().toSet()) + } + + @Test + fun unsubscribe() { + // given + subscriptionSet.subscribe() + + // when + subscriptionSet.unsubscribe() + + // then + assertEquals(emptyList(), pubnub.getSubscribedChannels()) + } + + @Test + fun close() { + // given + subscriptionSet.subscribe() + subscriptionSet.addListener( + object : EventListener { + override fun message(pubnub: PubNub, result: PNMessageResult) { + throw IllegalStateException("We should not get a message after close!") + } + }, + ) + + // when + subscriptionSet.close() + + pubnub.listenerManager.announce( + PNMessageResult( + BasePubSubResult(channelName, null, null, null, null), + JsonNull.INSTANCE, + ), + ) + + // then + // no exception from listener + assertEquals(emptyList(), pubnub.getSubscribedChannels()) + assertEquals(emptyList(), pubnub.getSubscribedChannelGroups()) + } +} diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImplTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImplTest.kt index 3b6cdba68..6b54812a6 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImplTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/v2/subscription/SubscriptionSetImplTest.kt @@ -2,7 +2,6 @@ package com.pubnub.internal.v2.subscription import com.pubnub.api.v2.subscriptions.EmptyOptions import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.internal.PubNubCore import com.pubnub.internal.PubNubImpl import com.pubnub.internal.managers.ListenerManager import com.pubnub.internal.v2.entities.ChannelGroupName @@ -17,7 +16,6 @@ import org.junit.jupiter.api.Test class SubscriptionSetImplTest { private lateinit var objectUnderTest: SubscriptionSetImpl - private val pubNubCore: PubNubCore = mockk() private val pubNubImpl: PubNubImpl = mockk() private val channel = setOf(ChannelName("Channel2")) @@ -26,10 +24,9 @@ class SubscriptionSetImplTest { @BeforeEach fun setUp() { val listenerManager = ListenerManager(pubNubImpl) - every { pubNubCore.listenerManager } returns listenerManager - every { pubNubImpl.pubNubCore } returns pubNubCore + every { pubNubImpl.listenerManager } returns listenerManager - objectUnderTest = SubscriptionSetImpl(pubNubCore, emptySet()) + objectUnderTest = SubscriptionSetImpl(pubNubImpl, emptySet()) } @Test diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessorTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessorTest.kt similarity index 89% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessorTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessorTest.kt index d5ac123df..992c9a6a7 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessorTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/internal/workers/SubscribeMessageProcessorTest.kt @@ -12,12 +12,12 @@ import com.pubnub.api.UserId import com.pubnub.api.crypto.CryptoModule import com.pubnub.api.models.consumer.pubsub.PNMessageResult import com.pubnub.api.models.consumer.pubsub.files.PNFileEventResult -import com.pubnub.api.v2.BasePNConfiguration -import com.pubnub.internal.TestPubNub +import com.pubnub.api.v2.PNConfiguration +import com.pubnub.internal.PubNubImpl import com.pubnub.internal.crypto.encryptString import com.pubnub.internal.managers.DuplicationManager import com.pubnub.internal.models.server.SubscribeMessage -import com.pubnub.test.TestPNConfigurationImpl +import com.pubnub.internal.v2.PNConfigurationImpl import org.hamcrest.MatcherAssert.assertThat import org.hamcrest.Matchers.isA import org.junit.Test @@ -109,7 +109,7 @@ class SubscribeMessageProcessorTest( fun testProcessMessageEncryptedWithCrypto() { // given val gson = Gson() - val config: BasePNConfiguration = config { cryptoModule = CryptoModule.createAesCbcCryptoModule("enigma", false) } + val config: PNConfiguration = config { cryptoModule = CryptoModule.createAesCbcCryptoModule("enigma", false) } val subscribeMessageProcessor = messageProcessor(config) val messageEncrypted = config.cryptoModule!!.encryptString(messageJson.toString()) @@ -132,7 +132,7 @@ class SubscribeMessageProcessorTest( fun testProcessMessageUnencryptedWithCrypto() { // given val gson = Gson() - val config: BasePNConfiguration = config { cryptoModule = CryptoModule.createAesCbcCryptoModule("enigma", false) } + val config: PNConfiguration = config { cryptoModule = CryptoModule.createAesCbcCryptoModule("enigma", false) } val subscribeMessageProcessor = messageProcessor(config) @@ -154,7 +154,7 @@ class SubscribeMessageProcessorTest( fun testProcessMessageWithPnOtherEncryptedWithCrypto() { // given val gson = Gson() - val config: BasePNConfiguration = config { cryptoModule = CryptoModule.createAesCbcCryptoModule("enigma", false) } + val config: PNConfiguration = config { cryptoModule = CryptoModule.createAesCbcCryptoModule("enigma", false) } val subscribeMessageProcessor = messageProcessor(config) val message = "Hello world." @@ -181,13 +181,13 @@ class SubscribeMessageProcessorTest( } private fun config( - action: TestPNConfigurationImpl.Builder.() -> Unit = { + action: PNConfigurationImpl.Builder.() -> Unit = { }, - ) = TestPNConfigurationImpl.Builder(userId = UserId("test")).apply(action).build() + ) = PNConfigurationImpl.Builder(userId = UserId("test"), "").apply(action).build() - private fun messageProcessor(configuration: BasePNConfiguration) = + private fun messageProcessor(configuration: PNConfiguration) = SubscribeMessageProcessor( - pubnub = TestPubNub(configuration).pubNubCore, + pubnub = PubNubImpl(configuration), duplicationManager = DuplicationManager(configuration), ) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/CommonUtils.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/test/CommonUtils.kt similarity index 98% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/CommonUtils.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/test/CommonUtils.kt index 9a9267ad8..b829d50e0 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/CommonUtils.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/test/CommonUtils.kt @@ -7,7 +7,7 @@ import com.google.gson.reflect.TypeToken import com.pubnub.api.PubNubError import com.pubnub.api.PubNubException import com.pubnub.api.models.consumer.PNPublishResult -import com.pubnub.internal.PubNubCore +import com.pubnub.internal.PubNubImpl import okhttp3.logging.HttpLoggingInterceptor import org.awaitility.Awaitility import org.awaitility.Durations @@ -127,7 +127,7 @@ object CommonUtils { } fun publishMixed( - pubnub: PubNubCore, + pubnub: PubNubImpl, count: Int, channel: String, ): List { @@ -157,7 +157,7 @@ object CommonUtils { } } - fun generateMessage(pubnub: PubNubCore): JsonObject { + fun generateMessage(pubnub: PubNubImpl): JsonObject { return JsonObject().apply { addProperty("publisher", pubnub.configuration.userId.value) addProperty("text", randomValue()) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/Extensions.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/test/Extensions.kt similarity index 96% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/Extensions.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/test/Extensions.kt index 3fccb924f..cc1f0e8a5 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/Extensions.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/test/Extensions.kt @@ -1,5 +1,6 @@ package com.pubnub.test +import com.pubnub.api.Endpoint import com.pubnub.api.v2.callbacks.Result import com.pubnub.internal.EndpointCore import org.awaitility.Awaitility @@ -12,7 +13,7 @@ import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicInteger -fun EndpointCore.await(function: (result: Result) -> Unit) { +fun Endpoint.await(function: (result: Result) -> Unit) { val success = AtomicBoolean() async { result -> function.invoke(result) diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/Keys.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/test/Keys.kt similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/Keys.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/test/Keys.kt diff --git a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/SignatureUtils.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/test/SignatureUtils.kt similarity index 96% rename from pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/SignatureUtils.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/test/SignatureUtils.kt index af39800dd..9545c0ffc 100644 --- a/pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/test/SignatureUtils.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/test/SignatureUtils.kt @@ -1,7 +1,7 @@ package com.pubnub.test import com.github.tomakehurst.wiremock.verification.LoggedRequest -import com.pubnub.api.v2.BasePNConfiguration +import com.pubnub.api.v2.PNConfiguration import okhttp3.HttpUrl.Companion.toHttpUrlOrNull import okhttp3.Request import okio.Buffer @@ -19,7 +19,7 @@ import javax.crypto.spec.SecretKeySpec object SignatureUtils { fun decomposeAndVerifySignature( - configuration: BasePNConfiguration, + configuration: PNConfiguration, request: LoggedRequest, ) { decomposeAndVerifySignature( @@ -31,7 +31,7 @@ object SignatureUtils { } fun decomposeAndVerifySignature( - configuration: BasePNConfiguration, + configuration: PNConfiguration, request: Request, ) { decomposeAndVerifySignature( @@ -43,7 +43,7 @@ object SignatureUtils { } private fun decomposeAndVerifySignature( - configuration: BasePNConfiguration, + configuration: PNConfiguration, url: String, method: String, body: String = "", diff --git a/pubnub-core/pubnub-core-impl/src/test/resources/entityTooLarge.xml b/pubnub-kotlin/pubnub-kotlin-impl/src/test/resources/entityTooLarge.xml similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/resources/entityTooLarge.xml rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/resources/entityTooLarge.xml diff --git a/pubnub-core/pubnub-core-impl/src/test/resources/junit-platform.properties b/pubnub-kotlin/pubnub-kotlin-impl/src/test/resources/junit-platform.properties similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/resources/junit-platform.properties rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/resources/junit-platform.properties diff --git a/pubnub-core/pubnub-core-impl/src/test/resources/logback.xml b/pubnub-kotlin/pubnub-kotlin-impl/src/test/resources/logback.xml similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/resources/logback.xml rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/resources/logback.xml diff --git a/pubnub-core/pubnub-core-impl/src/test/resources/special_chars.json b/pubnub-kotlin/pubnub-kotlin-impl/src/test/resources/special_chars.json similarity index 100% rename from pubnub-core/pubnub-core-impl/src/test/resources/special_chars.json rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/resources/special_chars.json diff --git a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts index 287854eb3..7c5d49d9b 100644 --- a/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-test/build.gradle.kts @@ -7,12 +7,10 @@ import java.util.Properties plugins { alias(libs.plugins.benmanes.versions) + alias(libs.plugins.codingfeline.buildkonfig) id("pubnub.shared") id("pubnub.ios-simulator-test") -// id("pubnub.multiplatform") kotlin("multiplatform") - - id("com.codingfeline.buildkonfig") version "0.15.1" } kotlin { @@ -37,7 +35,6 @@ kotlin { val commonMain by getting { dependencies { api(project(":pubnub-kotlin:pubnub-kotlin-api")) - api(project(":pubnub-core:pubnub-core-api")) api(kotlin("test")) api(libs.coroutines.test) } diff --git a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt b/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt deleted file mode 100644 index 7f7831328..000000000 --- a/pubnub-kotlin/pubnub-kotlin-test/src/commonMain/kotlin/com.pubnub.test/FakePubNub.kt +++ /dev/null @@ -1,509 +0,0 @@ -package com.pubnub.test - -import com.pubnub.api.PubNub -import com.pubnub.api.callbacks.Listener -import com.pubnub.api.endpoints.DeleteMessages -import com.pubnub.api.endpoints.FetchMessages -import com.pubnub.api.endpoints.MessageCounts -import com.pubnub.api.endpoints.Time -import com.pubnub.api.endpoints.access.GrantToken -import com.pubnub.api.endpoints.access.RevokeToken -import com.pubnub.api.endpoints.channel_groups.AddChannelChannelGroup -import com.pubnub.api.endpoints.channel_groups.AllChannelsChannelGroup -import com.pubnub.api.endpoints.channel_groups.DeleteChannelGroup -import com.pubnub.api.endpoints.channel_groups.ListAllChannelGroup -import com.pubnub.api.endpoints.channel_groups.RemoveChannelChannelGroup -import com.pubnub.api.endpoints.files.DeleteFile -import com.pubnub.api.endpoints.files.DownloadFile -import com.pubnub.api.endpoints.files.GetFileUrl -import com.pubnub.api.endpoints.files.ListFiles -import com.pubnub.api.endpoints.files.PublishFileMessage -import com.pubnub.api.endpoints.files.SendFile -import com.pubnub.api.endpoints.message_actions.AddMessageAction -import com.pubnub.api.endpoints.message_actions.GetMessageActions -import com.pubnub.api.endpoints.message_actions.RemoveMessageAction -import com.pubnub.api.endpoints.objects.channel.GetAllChannelMetadata -import com.pubnub.api.endpoints.objects.channel.GetChannelMetadata -import com.pubnub.api.endpoints.objects.channel.RemoveChannelMetadata -import com.pubnub.api.endpoints.objects.channel.SetChannelMetadata -import com.pubnub.api.endpoints.objects.member.GetChannelMembers -import com.pubnub.api.endpoints.objects.member.ManageChannelMembers -import com.pubnub.api.endpoints.objects.membership.GetMemberships -import com.pubnub.api.endpoints.objects.membership.ManageMemberships -import com.pubnub.api.endpoints.objects.uuid.GetAllUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.GetUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.RemoveUUIDMetadata -import com.pubnub.api.endpoints.objects.uuid.SetUUIDMetadata -import com.pubnub.api.endpoints.presence.GetState -import com.pubnub.api.endpoints.presence.HereNow -import com.pubnub.api.endpoints.presence.SetState -import com.pubnub.api.endpoints.presence.WhereNow -import com.pubnub.api.endpoints.pubsub.Publish -import com.pubnub.api.endpoints.pubsub.Signal -import com.pubnub.api.endpoints.push.AddChannelsToPush -import com.pubnub.api.endpoints.push.ListPushProvisions -import com.pubnub.api.endpoints.push.RemoveAllPushChannelsForDevice -import com.pubnub.api.endpoints.push.RemoveChannelsFromPush -import com.pubnub.api.enums.PNPushEnvironment -import com.pubnub.api.enums.PNPushType -import com.pubnub.api.models.consumer.PNBoundedPage -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGrant -import com.pubnub.api.models.consumer.access_manager.v3.ChannelGroupGrant -import com.pubnub.api.models.consumer.access_manager.v3.UUIDGrant -import com.pubnub.api.models.consumer.message_actions.PNMessageAction -import com.pubnub.api.models.consumer.objects.PNKey -import com.pubnub.api.models.consumer.objects.PNMemberKey -import com.pubnub.api.models.consumer.objects.PNMembershipKey -import com.pubnub.api.models.consumer.objects.PNPage -import com.pubnub.api.models.consumer.objects.PNSortKey -import com.pubnub.api.models.consumer.objects.member.MemberInput -import com.pubnub.api.models.consumer.objects.member.PNUUIDDetailsLevel -import com.pubnub.api.models.consumer.objects.membership.ChannelMembershipInput -import com.pubnub.api.models.consumer.objects.membership.PNChannelDetailsLevel -import com.pubnub.api.v2.PNConfiguration -import com.pubnub.api.v2.callbacks.EventListener -import com.pubnub.api.v2.callbacks.StatusListener -import com.pubnub.api.v2.entities.Channel -import com.pubnub.api.v2.entities.ChannelGroup -import com.pubnub.api.v2.entities.ChannelMetadata -import com.pubnub.api.v2.entities.UserMetadata -import com.pubnub.api.v2.subscriptions.Subscription -import com.pubnub.api.v2.subscriptions.SubscriptionOptions -import com.pubnub.api.v2.subscriptions.SubscriptionSet -import com.pubnub.kmp.CustomObject -import com.pubnub.kmp.Uploadable - -private fun notImplemented(): Nothing = TODO("Not implemented") - -abstract class FakePubNub( - override val configuration: PNConfiguration, - private val addListener: (EventListener) -> Unit = { notImplemented() }, -) : PubNub { - override fun addListener(listener: EventListener) = addListener.invoke(listener) - - override fun addListener(listener: StatusListener) { - TODO("Not yet implemented") - } - - override fun removeListener(listener: Listener) { - TODO("Not yet implemented") - } - - override fun removeAllListeners() { - TODO("Not yet implemented") - } - - override fun publish( - channel: String, - message: Any, - meta: Any?, - shouldStore: Boolean, - usePost: Boolean, - replicate: Boolean, - ttl: Int?, - ): Publish { - TODO("Not yet implemented") - } - - override fun fire(channel: String, message: Any, meta: Any?, usePost: Boolean): Publish { - TODO("Not yet implemented") - } - - override fun signal(channel: String, message: Any): Signal { - TODO("Not yet implemented") - } - - override fun getSubscribedChannels(): List { - TODO("Not yet implemented") - } - - override fun getSubscribedChannelGroups(): List { - TODO("Not yet implemented") - } - - override fun addPushNotificationsOnChannels( - pushType: PNPushType, - channels: List, - deviceId: String, - topic: String?, - environment: PNPushEnvironment, - ): AddChannelsToPush { - TODO("Not yet implemented") - } - - override fun auditPushChannelProvisions( - pushType: PNPushType, - deviceId: String, - topic: String?, - environment: PNPushEnvironment, - ): ListPushProvisions { - TODO("Not yet implemented") - } - - override fun removePushNotificationsFromChannels( - pushType: PNPushType, - channels: List, - deviceId: String, - topic: String?, - environment: PNPushEnvironment, - ): RemoveChannelsFromPush { - TODO("Not yet implemented") - } - - override fun removeAllPushNotificationsFromDeviceWithPushToken( - pushType: PNPushType, - deviceId: String, - topic: String?, - environment: PNPushEnvironment, - ): RemoveAllPushChannelsForDevice { - TODO("Not yet implemented") - } - - override fun fetchMessages( - channels: List, - page: PNBoundedPage, - includeUUID: Boolean, - includeMeta: Boolean, - includeMessageActions: Boolean, - includeMessageType: Boolean, - ): FetchMessages { - TODO("Not yet implemented") - } - - override fun deleteMessages(channels: List, start: Long?, end: Long?): DeleteMessages { - TODO("Not yet implemented") - } - - override fun messageCounts(channels: List, channelsTimetoken: List): MessageCounts { - TODO("Not yet implemented") - } - - override fun hereNow( - channels: List, - channelGroups: List, - includeState: Boolean, - includeUUIDs: Boolean, - ): HereNow { - TODO("Not yet implemented") - } - - override fun whereNow(uuid: String): WhereNow { - TODO("Not yet implemented") - } - - override fun setPresenceState(channels: List, channelGroups: List, state: Any): SetState { - TODO("Not yet implemented") - } - - override fun getPresenceState(channels: List, channelGroups: List, uuid: String): GetState { - TODO("Not yet implemented") - } - - override fun presence(channels: List, channelGroups: List, connected: Boolean) { - TODO("Not yet implemented") - } - - override fun addMessageAction(channel: String, messageAction: PNMessageAction): AddMessageAction { - TODO("Not yet implemented") - } - - override fun removeMessageAction( - channel: String, - messageTimetoken: Long, - actionTimetoken: Long, - ): RemoveMessageAction { - TODO("Not yet implemented") - } - - override fun getMessageActions(channel: String, page: PNBoundedPage): GetMessageActions { - TODO("Not yet implemented") - } - - override fun addChannelsToChannelGroup(channels: List, channelGroup: String): AddChannelChannelGroup { - TODO("Not yet implemented") - } - - override fun listChannelsForChannelGroup(channelGroup: String): AllChannelsChannelGroup { - TODO("Not yet implemented") - } - - override fun removeChannelsFromChannelGroup( - channels: List, - channelGroup: String, - ): RemoveChannelChannelGroup { - TODO("Not yet implemented") - } - - override fun listAllChannelGroups(): ListAllChannelGroup { - TODO("Not yet implemented") - } - - override fun deleteChannelGroup(channelGroup: String): DeleteChannelGroup { - TODO("Not yet implemented") - } - - override fun grantToken( - ttl: Int, - meta: CustomObject?, - authorizedUUID: String?, - channels: List, - channelGroups: List, - uuids: List, - ): GrantToken { - TODO("Not yet implemented") - } - - override fun revokeToken(token: String): RevokeToken { - TODO("Not yet implemented") - } - - override fun time(): Time { - TODO("Not yet implemented") - } - - override fun getAllChannelMetadata( - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - ): GetAllChannelMetadata { - TODO("Not yet implemented") - } - - override fun getChannelMetadata(channel: String, includeCustom: Boolean): GetChannelMetadata { - TODO("Not yet implemented") - } - - override fun setChannelMetadata( - channel: String, - name: String?, - description: String?, - custom: CustomObject?, - includeCustom: Boolean, - type: String?, - status: String?, - ): SetChannelMetadata { - TODO("Not yet implemented") - } - - override fun removeChannelMetadata(channel: String): RemoveChannelMetadata { - TODO("Not yet implemented") - } - - override fun getAllUUIDMetadata( - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - ): GetAllUUIDMetadata { - TODO("Not yet implemented") - } - - override fun getUUIDMetadata(uuid: String?, includeCustom: Boolean): GetUUIDMetadata { - TODO("Not yet implemented") - } - - override fun setUUIDMetadata( - uuid: String?, - name: String?, - externalId: String?, - profileUrl: String?, - email: String?, - custom: CustomObject?, - includeCustom: Boolean, - type: String?, - status: String?, - ): SetUUIDMetadata { - TODO("Not yet implemented") - } - - override fun removeUUIDMetadata(uuid: String?): RemoveUUIDMetadata { - TODO("Not yet implemented") - } - - override fun getMemberships( - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel?, - includeType: Boolean, - ): GetMemberships { - TODO("Not yet implemented") - } - - override fun setMemberships( - channels: List, - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel?, - includeType: Boolean, - ): ManageMemberships { - TODO("Not yet implemented") - } - - override fun removeMemberships( - channels: List, - uuid: String?, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeChannelDetails: PNChannelDetailsLevel?, - includeType: Boolean, - ): ManageMemberships { - TODO("Not yet implemented") - } - - override fun getChannelMembers( - channel: String, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel?, - includeType: Boolean, - ): GetChannelMembers { - TODO("Not yet implemented") - } - - override fun setChannelMembers( - channel: String, - uuids: List, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel?, - includeType: Boolean, - ): ManageChannelMembers { - TODO("Not yet implemented") - } - - override fun removeChannelMembers( - channel: String, - uuids: List, - limit: Int?, - page: PNPage?, - filter: String?, - sort: Collection>, - includeCount: Boolean, - includeCustom: Boolean, - includeUUIDDetails: PNUUIDDetailsLevel?, - includeType: Boolean, - ): ManageChannelMembers { - TODO("Not yet implemented") - } - - override fun listFiles(channel: String, limit: Int?, next: PNPage.PNNext?): ListFiles { - TODO("Not yet implemented") - } - - override fun getFileUrl(channel: String, fileName: String, fileId: String): GetFileUrl { - TODO("Not yet implemented") - } - - override fun sendFile( - channel: String, - fileName: String, - inputStream: Uploadable, - message: Any?, - meta: Any?, - ttl: Int?, - shouldStore: Boolean?, - cipherKey: String?, - ): SendFile { - TODO("Not yet implemented") - } - - override fun downloadFile(channel: String, fileName: String, fileId: String, cipherKey: String?): DownloadFile { - TODO("Not yet implemented") - } - - override fun deleteFile(channel: String, fileName: String, fileId: String): DeleteFile { - TODO("Not yet implemented") - } - - override fun publishFileMessage( - channel: String, - fileName: String, - fileId: String, - message: Any?, - meta: Any?, - ttl: Int?, - shouldStore: Boolean?, - ): PublishFileMessage { - TODO("Not yet implemented") - } - - override fun subscribe( - channels: List, - channelGroups: List, - withPresence: Boolean, - withTimetoken: Long, - ) { - TODO("Not yet implemented") - } - - override fun unsubscribe(channels: List, channelGroups: List) { - TODO("Not yet implemented") - } - - override fun unsubscribeAll() { - TODO("Not yet implemented") - } - - override fun setToken(token: String?) { - TODO("Not yet implemented") - } - - override fun destroy() { - TODO("Not yet implemented") - } - - override fun channel(name: String): Channel { - TODO("Not yet implemented") - } - - override fun channelGroup(name: String): ChannelGroup { - TODO("Not yet implemented") - } - - override fun channelMetadata(id: String): ChannelMetadata { - TODO("Not yet implemented") - } - - override fun userMetadata(id: String): UserMetadata { - TODO("Not yet implemented") - } - - override fun subscriptionSetOf(subscriptions: Set): SubscriptionSet { - TODO("Not yet implemented") - } - - override fun subscriptionSetOf( - channels: Set, - channelGroups: Set, - options: SubscriptionOptions, - ): SubscriptionSet { - TODO("Not yet implemented") - } -} diff --git a/settings.gradle.kts b/settings.gradle.kts index 74449c59f..17cd29489 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,8 +13,8 @@ dependencyResolutionManagement { } rootProject.name = "pubnub" -include("pubnub-core:pubnub-core-api") -include("pubnub-core:pubnub-core-impl") +//include("pubnub-core:pubnub-core-api") +//include("pubnub-core:pubnub-core-impl") include("pubnub-kotlin") include("pubnub-kotlin:pubnub-kotlin-api") include("pubnub-kotlin:pubnub-kotlin-impl") From c05c3370291ecd45cfc23e078cbc6c4165607e92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Mon, 16 Sep 2024 16:33:18 +0200 Subject: [PATCH 58/62] Small fixes after merge --- .github/workflows/release/versions.json | 2 +- pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts | 11 ----------- .../pubnub-kotlin-api/pubnub_kotlin_api.podspec | 2 +- .../legacy/{PubNubCoreTest.kt => PubNubImplTest.kt} | 0 settings.gradle.kts | 2 -- 5 files changed, 2 insertions(+), 15 deletions(-) rename pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/{PubNubCoreTest.kt => PubNubImplTest.kt} (100%) diff --git a/.github/workflows/release/versions.json b/.github/workflows/release/versions.json index 8eba2045c..5d3a2e13d 100644 --- a/.github/workflows/release/versions.json +++ b/.github/workflows/release/versions.json @@ -54,7 +54,7 @@ "clearedSuffix": false } ], - "pubnub-core/pubnub-core-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt": [ + "pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubImplTest.kt": [ { "pattern": "assertEquals\\(\"(v?(\\d+\\.?){2,}([a-zA-Z0-9-]+(\\.?\\d+)?)?)\", version\\)$", "clearedPrefix": true, diff --git a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts index c9f60d159..86d562b29 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts +++ b/pubnub-kotlin/pubnub-kotlin-api/build.gradle.kts @@ -1,6 +1,4 @@ -import com.pubnub.gradle.enableAnyIosTarget import com.pubnub.gradle.enableJsTarget -import org.jetbrains.kotlin.gradle.plugin.cocoapods.CocoapodsExtension plugins { alias(libs.plugins.benmanes.versions) @@ -14,14 +12,12 @@ kotlin { sourceSets { val commonMain by getting { dependencies { -// api(project(":pubnub-core:pubnub-core-api")) implementation(libs.kotlinx.atomicfu) } } val jvmMain by getting { dependencies { -// implementation(project(":pubnub-core:pubnub-core-impl")) api(libs.retrofit2) api(libs.okhttp) api(libs.okhttp.logging) @@ -54,11 +50,4 @@ kotlin { } } } - if (enableAnyIosTarget) { - (this as ExtensionAware).extensions.configure { - framework { -// export(project(":pubnub-core:pubnub-core-api")) - } - } - } } diff --git a/pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec b/pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec index 1f06b55b0..0eb8f35a9 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec +++ b/pubnub-kotlin/pubnub-kotlin-api/pubnub_kotlin_api.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'pubnub_kotlin_api' - spec.version = '9.2.3' + spec.version = '9.2.4' spec.homepage = '' spec.source = { :http=> ''} spec.authors = '' diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubImplTest.kt similarity index 100% rename from pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubCoreTest.kt rename to pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/PubNubImplTest.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index 17cd29489..77fa4b7b5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,8 +13,6 @@ dependencyResolutionManagement { } rootProject.name = "pubnub" -//include("pubnub-core:pubnub-core-api") -//include("pubnub-core:pubnub-core-impl") include("pubnub-kotlin") include("pubnub-kotlin:pubnub-kotlin-api") include("pubnub-kotlin:pubnub-kotlin-impl") From e6ce060f152ba4f7daffb45b82619fc77001cbf0 Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:23:44 +0200 Subject: [PATCH 59/62] Updating swift submodule (#278) * Uploading swift submodule with recent changes from master * Setting uuid field in KMPPresenceChange.swift --- swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swift b/swift index 73803fb25..725893b39 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit 73803fb25f374a01a9d1350725fcf23e1fc11516 +Subproject commit 725893b39e128db689f79ff2fa08d246f8c3530b From 0d6b7eff83e691e0b864cc75c8ceb2861897737e Mon Sep 17 00:00:00 2001 From: jguz-pubnub <102806147+jguz-pubnub@users.noreply.github.com> Date: Thu, 19 Sep 2024 18:09:51 +0200 Subject: [PATCH 60/62] Added @ObjCName annotation and helper constructor (iOS) (#280) --- .../src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt | 6 ++++++ .../src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt | 3 +++ swift | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt index 24503d37b..845dec771 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/iosMain/kotlin/com/pubnub/api/PubNubImpl.kt @@ -152,6 +152,12 @@ class PubNubImpl(private val pubNubObjC: KMPPubNub) : PubNub { ) ) + companion object { + fun create(kmpPubNub: Any): PubNubImpl { + return PubNubImpl(kmpPubNub as KMPPubNub) + } + } + override val configuration: PNConfiguration = createPNConfiguration( UserId(pubNubObjC.configObjC().userId()), "", // todo diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt b/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt index 587bfeb9f..15d6dee02 100644 --- a/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt +++ b/pubnub-kotlin/pubnub-kotlin-api/src/nonJvm/kotlin/com/pubnub/api/PubNub.nonJvm.kt @@ -72,7 +72,10 @@ import com.pubnub.api.v2.subscriptions.SubscriptionOptions import com.pubnub.api.v2.subscriptions.SubscriptionSet import com.pubnub.kmp.CustomObject import com.pubnub.kmp.Uploadable +import kotlin.experimental.ExperimentalObjCName +@OptIn(ExperimentalObjCName::class) +@ObjCName("PubNubInterface") actual interface PubNub { actual val configuration: PNConfiguration diff --git a/swift b/swift index 725893b39..59ce8fe77 160000 --- a/swift +++ b/swift @@ -1 +1 @@ -Subproject commit 725893b39e128db689f79ff2fa08d246f8c3530b +Subproject commit 59ce8fe77aad1747208864e6eafba353a1a15199 From 88e29b1625f84694f25eef291326c86ff12200d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojtek=20Kalici=C5=84ski?= <146713236+wkal-pubnub@users.noreply.github.com> Date: Fri, 20 Sep 2024 12:50:18 +0200 Subject: [PATCH 61/62] Add PatchValue to Java API (#281) * Add PatchValue to Java API * Change custom Object to Map in Java --- .../models/consumer/objects_api/PNObject.java | 10 ++++-- .../channel/PNChannelMetadata.java | 31 ++++++++-------- .../objects_api/member/PNMembers.java | 10 +++--- .../objects_api/membership/PNMembership.java | 10 +++--- .../objects_api/uuid/PNUUIDMetadata.java | 36 ++++++++++--------- .../objects/channel/ChannelMetadataIT.java | 18 +++++----- .../objects/members/ChannelMembersIT.java | 12 ++++--- .../CustomMetadataInMembersPropagationIT.java | 17 ++++----- ...stomMetadataInMembershipPropagationIT.java | 9 ++--- .../objects/memberships/MembershipIT.java | 4 +-- .../objects/uuid/UUIDMetadataIT.java | 18 +++++----- .../java/v2/callbacks/Converters.java | 4 +-- .../callbacks/DelegatingEventListenerTest.kt | 36 +++++++++---------- .../kotlin/com/pubnub/kmp/Optional.kt | 17 --------- .../api/integration/BaseIntegrationTest.kt | 2 +- 15 files changed, 118 insertions(+), 116 deletions(-) delete mode 100644 pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/PNObject.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/PNObject.java index 3038a46a5..668bdb05a 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/PNObject.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/PNObject.java @@ -1,10 +1,14 @@ package com.pubnub.api.java.models.consumer.objects_api; +import com.pubnub.api.utils.PatchValue; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; import lombok.experimental.Accessors; +import org.jetbrains.annotations.Nullable; + +import java.util.Map; @Getter @Accessors(chain = true) @@ -16,13 +20,13 @@ public class PNObject { protected String id; @Setter - protected Object custom; + protected PatchValue<@Nullable Map> custom; @Setter - protected String updated; + protected PatchValue<@Nullable String> updated; @Setter - protected String eTag; + protected PatchValue<@Nullable String> eTag; protected PNObject(String id) { this.id = id; diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNChannelMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNChannelMetadata.java index 5b775dc36..a62937e1e 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNChannelMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/channel/PNChannelMetadata.java @@ -1,16 +1,19 @@ package com.pubnub.api.java.models.consumer.objects_api.channel; import com.pubnub.api.java.models.consumer.objects_api.PNObject; +import com.pubnub.api.utils.PatchValue; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.ToString; import lombok.experimental.Accessors; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; @Getter @Setter @@ -18,23 +21,23 @@ @EqualsAndHashCode(callSuper = true) @ToString(callSuper = true) public class PNChannelMetadata extends PNObject { - private String name; - private String description; - private String type; - private String status; + private PatchValue<@Nullable String> name; + private PatchValue<@Nullable String> description; + private PatchValue<@Nullable String> type; + private PatchValue<@Nullable String> status; - public PNChannelMetadata(String id, String name, String description) { + public PNChannelMetadata(String id, PatchValue<@Nullable String> name, PatchValue<@Nullable String> description) { super(id); this.name = name; this.description = description; } - public PNChannelMetadata(String id, String name) { + public PNChannelMetadata(String id, PatchValue<@Nullable String> name) { this(id, name, null); } @Override - public PNChannelMetadata setCustom(Object custom) { + public PNChannelMetadata setCustom(PatchValue<@Nullable Map> custom) { super.setCustom(custom); return this; } @@ -43,14 +46,14 @@ public PNChannelMetadata setCustom(Object custom) { public static PNChannelMetadata from(@NotNull com.pubnub.api.models.consumer.objects.channel.PNChannelMetadata data) { PNChannelMetadata newData = new PNChannelMetadata( data.getId(), - data.getName() != null ? data.getName().getValue() : null, - data.getDescription() != null ? data.getDescription().getValue() : null + data.getName(), + data.getDescription() ); - newData.setETag(data.getETag() != null ? data.getETag().getValue() : null); - newData.setType(data.getType() != null ? data.getType().getValue() : null); - newData.setStatus(data.getStatus() != null ? data.getStatus().getValue() : null); - newData.setCustom(data.getCustom() != null ? data.getCustom().getValue() : null); - newData.setUpdated(data.getUpdated() != null ? data.getUpdated().getValue() : null); + newData.setETag(data.getETag()); + newData.setType(data.getType()); + newData.setStatus(data.getStatus()); + newData.setCustom(data.getCustom()); + newData.setUpdated(data.getUpdated()); return newData; } diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNMembers.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNMembers.java index c4c9bc2ef..3f4b231f0 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNMembers.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/member/PNMembers.java @@ -2,6 +2,7 @@ import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadata; import com.pubnub.api.models.consumer.objects.member.PNMember; +import com.pubnub.api.utils.PatchValue; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -13,6 +14,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; @Getter @Setter @@ -23,11 +25,11 @@ public class PNMembers { private PNUUIDMetadata uuid; - protected Object custom; + protected PatchValue<@Nullable Map> custom; protected String updated; protected String eTag; - protected String status; + protected PatchValue<@Nullable String> status; @Nullable public static PNMembers from(@Nullable PNMember member) { @@ -36,10 +38,10 @@ public static PNMembers from(@Nullable PNMember member) { } return new PNMembers() .setUuid(PNUUIDMetadata.from(member.getUuid())) - .setCustom(member.getCustom() != null ? member.getCustom().getValue() : null) + .setCustom(member.getCustom()) .setUpdated(member.getUpdated()) .setETag(member.getETag()) - .setStatus(member.getStatus() != null ? member.getStatus().getValue() : null); + .setStatus(member.getStatus()); } public static List from(Collection members) { diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNMembership.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNMembership.java index eb11e37df..e2a6e5aab 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNMembership.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/membership/PNMembership.java @@ -2,6 +2,7 @@ import com.pubnub.api.java.models.consumer.objects_api.channel.PNChannelMetadata; import com.pubnub.api.models.consumer.objects.membership.PNChannelMembership; +import com.pubnub.api.utils.PatchValue; import lombok.Data; import lombok.NonNull; import lombok.experimental.Accessors; @@ -11,6 +12,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; @Data @Accessors(chain = true) @@ -20,11 +22,11 @@ public PNMembership(@NotNull PNChannelMetadata channel) { } @NonNull private PNChannelMetadata channel; - private Object custom; + private PatchValue<@Nullable Map> custom; private String uuid; private String updated; private String eTag; - private String status; + private PatchValue<@Nullable String> status; public static List from(Collection members) { ArrayList list = new ArrayList<>(members.size()); @@ -41,11 +43,11 @@ public static PNMembership from(@Nullable PNChannelMembership data) { } PNChannelMetadata metadata = PNChannelMetadata.from(data.getChannel()); PNMembership newData = new PNMembership(metadata); - newData.setCustom(data.getCustom() != null ? data.getCustom().getValue() : null); + newData.setCustom(data.getCustom()); // newData.setUuid(data.get) //TODO where to get this? does it even exist in server responses? newData.setUpdated(data.getUpdated()); newData.setETag(data.getETag()); - newData.setStatus(data.getStatus() != null ? data.getStatus().getValue() : null); + newData.setStatus(data.getStatus()); return newData; } } diff --git a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNUUIDMetadata.java b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNUUIDMetadata.java index cec764261..eb9bcfc43 100644 --- a/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNUUIDMetadata.java +++ b/pubnub-gson/pubnub-gson-api/src/main/java/com/pubnub/api/java/models/consumer/objects_api/uuid/PNUUIDMetadata.java @@ -1,6 +1,7 @@ package com.pubnub.api.java.models.consumer.objects_api.uuid; import com.pubnub.api.java.models.consumer.objects_api.PNObject; +import com.pubnub.api.utils.PatchValue; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; @@ -12,6 +13,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; @Getter @Setter @@ -20,20 +22,20 @@ @ToString(callSuper = true) @NoArgsConstructor public class PNUUIDMetadata extends PNObject { - private String name; - private String email; - private String externalId; - private String profileUrl; - private String type; - private String status; + private PatchValue<@Nullable String> name; + private PatchValue<@Nullable String> email; + private PatchValue<@Nullable String> externalId; + private PatchValue<@Nullable String> profileUrl; + private PatchValue<@Nullable String> type; + private PatchValue<@Nullable String> status; - public PNUUIDMetadata(String id, String name) { + public PNUUIDMetadata(String id, PatchValue<@Nullable String> name) { super(id); this.name = name; } @Override - public PNUUIDMetadata setCustom(Object custom) { + public PNUUIDMetadata setCustom(PatchValue<@Nullable Map> custom) { super.setCustom(custom); return this; } @@ -51,16 +53,16 @@ public static PNUUIDMetadata from(com.pubnub.api.models.consumer.objects.uuid.PN if (data == null) { return null; } - PNUUIDMetadata newData = new PNUUIDMetadata(data.getId(), data.getName() != null ? data.getName().getValue() : null) - .setProfileUrl(data.getProfileUrl() != null ? data.getProfileUrl().getValue() : null) - .setEmail(data.getEmail() != null ? data.getEmail().getValue() : null) - .setExternalId(data.getExternalId() != null ? data.getExternalId().getValue() : null) - .setStatus(data.getStatus() != null ? data.getStatus().getValue() : null) - .setType(data.getType() != null ? data.getType().getValue() : null) - .setCustom(data.getCustom() != null ? data.getCustom().getValue() : null); + PNUUIDMetadata newData = new PNUUIDMetadata(data.getId(), data.getName()) + .setProfileUrl(data.getProfileUrl()) + .setEmail(data.getEmail()) + .setExternalId(data.getExternalId()) + .setStatus(data.getStatus()) + .setType(data.getType()) + .setCustom(data.getCustom()); - newData.setETag(data.getETag() != null ? data.getETag().getValue() : null); - newData.setUpdated(data.getUpdated() != null ? data.getUpdated().getValue() : null); + newData.setETag(data.getETag()); + newData.setUpdated(data.getUpdated()); return newData; } } diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/channel/ChannelMetadataIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/channel/ChannelMetadataIT.java index 0ec0178cd..72cdde6a4 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/channel/ChannelMetadataIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/channel/ChannelMetadataIT.java @@ -67,11 +67,11 @@ public void setChannelHappyPath() throws PubNubException { assertEquals(HttpStatus.SC_OK, setChannelMetadataResult.getStatus()); createdChannelMetadataList.add(setChannelMetadataResult); assertEquals(randomChannelMetadataId, setChannelMetadataResult.getData().getId()); - assertEquals(setChannelMetadataResult.getData().getDescription(), - setChannelMetadataResult.getData().getDescription()); - assertNotNull(setChannelMetadataResult.getData().getCustom()); - assertEquals(statusValue, setChannelMetadataResult.getData().getStatus()); - assertEquals(typeValue, setChannelMetadataResult.getData().getType()); + assertEquals(randomDescription, + setChannelMetadataResult.getData().getDescription().getValue()); + assertNotNull(setChannelMetadataResult.getData().getCustom().getValue()); + assertEquals(statusValue, setChannelMetadataResult.getData().getStatus().getValue()); + assertEquals(typeValue, setChannelMetadataResult.getData().getType().getValue()); } @Test @@ -102,10 +102,10 @@ public void getChannelHappyPath() throws PubNubException { assertEquals(setChannelMetadataResult.getData().getDescription(), getChannelMetadataResult.getData().getDescription()); assertNotNull(setChannelMetadataResult.getData().getCustom()); - assertEquals(statusValue, setChannelMetadataResult.getData().getStatus()); - assertEquals(typeValue, setChannelMetadataResult.getData().getType()); - assertEquals(statusValue, getChannelMetadataResult.getData().getStatus()); - assertEquals(typeValue, getChannelMetadataResult.getData().getType()); + assertEquals(statusValue, setChannelMetadataResult.getData().getStatus().getValue()); + assertEquals(typeValue, setChannelMetadataResult.getData().getType().getValue()); + assertEquals(statusValue, getChannelMetadataResult.getData().getStatus().getValue()); + assertEquals(typeValue, getChannelMetadataResult.getData().getType().getValue()); } @Test diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/ChannelMembersIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/ChannelMembersIT.java index 416b8b39a..9d4e8a6dd 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/ChannelMembersIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/ChannelMembersIT.java @@ -9,7 +9,9 @@ import com.pubnub.api.java.models.consumer.objects_api.member.PNSetChannelMembersResult; import com.pubnub.api.java.models.consumer.objects_api.member.PNUUID; import com.pubnub.api.java.models.consumer.objects_api.uuid.PNUUIDMetadata; +import com.pubnub.api.utils.PatchValue; import org.apache.http.HttpStatus; +import org.jetbrains.annotations.Nullable; import org.junit.After; import org.junit.Test; import org.slf4j.Logger; @@ -87,8 +89,8 @@ public void addChannelMembersHappyPath() throws PubNubException { final List receivedCustomObjects = new ArrayList<>(); for (final PNMembers it : setChannelMembersResult.getData()) { - final Object custom = it.getCustom(); - if (custom != null) { + PatchValue<@Nullable Map> custom = it.getCustom(); + if (custom != null && custom.getValue() != null) { receivedCustomObjects.add(custom); } } @@ -96,6 +98,7 @@ public void addChannelMembersHappyPath() throws PubNubException { List actualStatusList = setChannelMembersResult.getData() .stream() .map(PNMembers::getStatus) + .map(PatchValue::getValue) .filter(Objects::nonNull) .collect(Collectors.toList()); @@ -146,8 +149,8 @@ public void getChannelMembersHappyPath() throws PubNubException { } final List receivedCustomObjects = new ArrayList<>(); for (final PNMembers it : setChannelMembersResult.getData()) { - final Object custom = it.getCustom(); - if (custom != null) { + PatchValue<@Nullable Map> custom = it.getCustom(); + if (custom != null && custom.getValue() != null) { receivedCustomObjects.add(custom); } } @@ -155,6 +158,7 @@ public void getChannelMembersHappyPath() throws PubNubException { List actualStatusList = setChannelMembersResult.getData() .stream() .map(PNMembers::getStatus) + .map(PatchValue::getValue) .filter(Objects::nonNull) .collect(Collectors.toList()); diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/CustomMetadataInMembersPropagationIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/CustomMetadataInMembersPropagationIT.java index 84fdaba00..0f47f80c3 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/CustomMetadataInMembersPropagationIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/members/CustomMetadataInMembersPropagationIT.java @@ -6,6 +6,7 @@ import com.pubnub.api.java.models.consumer.objects_api.member.PNSetChannelMembersResult; import com.pubnub.api.java.models.consumer.objects_api.member.PNUUID; import com.pubnub.api.java.models.consumer.objects_api.uuid.PNSetUUIDMetadataResult; +import com.pubnub.api.utils.PatchValue; import org.junit.After; import org.junit.Test; @@ -84,10 +85,10 @@ public void setMembersCustomHappyPath() throws PubNubException { hasProperty("uuid", allOf( allOf( hasProperty("id", is(testUUID)), - hasProperty("name", is(testName)), - hasProperty("email", is(testEmail)), - hasProperty("externalId", is(testExternalId)), - hasProperty("profileUrl", is(testProfileUrl)), + hasProperty("name", is(PatchValue.of(testName))), + hasProperty("email", is(PatchValue.of(testEmail))), + hasProperty("externalId", is(PatchValue.of(testExternalId))), + hasProperty("profileUrl", is(PatchValue.of(testProfileUrl))), hasProperty("custom", notNullValue())))))))); assertThat(getChannelMembersResult, hasProperty("data", hasItem( @@ -96,10 +97,10 @@ public void setMembersCustomHappyPath() throws PubNubException { hasProperty("uuid", allOf( allOf( hasProperty("id", is(testUUID)), - hasProperty("name", is(testName)), - hasProperty("email", is(testEmail)), - hasProperty("externalId", is(testExternalId)), - hasProperty("profileUrl", is(testProfileUrl)), + hasProperty("name", is(PatchValue.of(testName))), + hasProperty("email", is(PatchValue.of(testEmail))), + hasProperty("externalId", is(PatchValue.of(testExternalId))), + hasProperty("profileUrl", is(PatchValue.of(testProfileUrl))), hasProperty("custom", nullValue())))))))); } diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/CustomMetadataInMembershipPropagationIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/CustomMetadataInMembershipPropagationIT.java index bbb444130..aaf0288d2 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/CustomMetadataInMembershipPropagationIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/CustomMetadataInMembershipPropagationIT.java @@ -10,6 +10,7 @@ import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembershipResult; import com.pubnub.api.java.models.consumer.objects_api.membership.PNSetMembershipResult; import com.pubnub.api.models.consumer.PNStatus; +import com.pubnub.api.utils.PatchValue; import org.awaitility.core.ThrowingRunnable; import org.jetbrains.annotations.NotNull; import org.junit.After; @@ -106,8 +107,8 @@ public void setMembershipCustomHappyPath() throws PubNubException { hasProperty("channel", allOf( allOf( hasProperty("id", is(testChannelMetadataId)), - hasProperty("name", is(testChannelName)), - hasProperty("description", is(testDescription)), + hasProperty("name", is(PatchValue.of(testChannelName))), + hasProperty("description", is(PatchValue.of(testDescription))), hasProperty("custom", notNullValue())))))))); assertThat(getMembershipsResult, hasProperty("data", hasItem( @@ -116,8 +117,8 @@ public void setMembershipCustomHappyPath() throws PubNubException { hasProperty("channel", allOf( allOf( hasProperty("id", is(testChannelMetadataId)), - hasProperty("name", is(testChannelName)), - hasProperty("description", is(testDescription)), + hasProperty("name", is(PatchValue.of(testChannelName))), + hasProperty("description", is(PatchValue.of(testDescription))), hasProperty("custom", nullValue())))))))); String userIdValue = pubNubUnderTest.getConfiguration().getUserId().getValue(); diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/MembershipIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/MembershipIT.java index a2be42abd..984b118e3 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/MembershipIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/memberships/MembershipIT.java @@ -8,6 +8,7 @@ import com.pubnub.api.java.models.consumer.objects_api.membership.PNMembership; import com.pubnub.api.java.models.consumer.objects_api.membership.PNRemoveMembershipResult; import com.pubnub.api.java.models.consumer.objects_api.membership.PNSetMembershipResult; +import com.pubnub.api.utils.PatchValue; import org.apache.http.HttpStatus; import org.junit.After; import org.junit.Test; @@ -30,7 +31,6 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; public class MembershipIT extends ObjectsApiBaseIT { private static final Logger LOG = LoggerFactory.getLogger(MembershipIT.class); @@ -70,7 +70,7 @@ public void setMembershipsHappyPath() throws PubNubException { allOf( hasProperty(CHANNEL, hasProperty("id", is(testChannelId1))), - hasProperty("custom", nullValue())))), + hasProperty("custom", is(PatchValue.of(null)))))), hasProperty("data", hasItem( allOf( diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/uuid/UUIDMetadataIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/uuid/UUIDMetadataIT.java index 368914757..556aff093 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/uuid/UUIDMetadataIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/objects/uuid/UUIDMetadataIT.java @@ -70,13 +70,13 @@ public void setUUIDHappyPath() throws PubNubException { assertEquals(HttpStatus.SC_OK, setUUIDMetadataResult.getStatus()); createdUUIDMetadataList.add(setUUIDMetadataResult); assertEquals(randomTestUUID, setUUIDMetadataResult.getData().getId()); - assertEquals(randomName, setUUIDMetadataResult.getData().getName()); - assertEquals(randomEmail, setUUIDMetadataResult.getData().getEmail()); - assertEquals(randomProfileUrl, setUUIDMetadataResult.getData().getProfileUrl()); - assertEquals(randomExternalId, setUUIDMetadataResult.getData().getExternalId()); - assertNotNull(setUUIDMetadataResult.getData().getCustom()); - assertEquals(statusValue, setUUIDMetadataResult.getData().getStatus()); - assertEquals(typeValue, setUUIDMetadataResult.getData().getType()); + assertEquals(randomName, setUUIDMetadataResult.getData().getName().getValue()); + assertEquals(randomEmail, setUUIDMetadataResult.getData().getEmail().getValue()); + assertEquals(randomProfileUrl, setUUIDMetadataResult.getData().getProfileUrl().getValue()); + assertEquals(randomExternalId, setUUIDMetadataResult.getData().getExternalId().getValue()); + assertNotNull(setUUIDMetadataResult.getData().getCustom().getValue()); + assertEquals(statusValue, setUUIDMetadataResult.getData().getStatus().getValue()); + assertEquals(typeValue, setUUIDMetadataResult.getData().getType().getValue()); } @Test @@ -111,8 +111,8 @@ public void getUUIDHappyPath() throws PubNubException { assertEquals(setUUIDMetadataResult.getData().getProfileUrl(), getUUIDMetadataResult.getData().getProfileUrl()); assertEquals(setUUIDMetadataResult.getData().getExternalId(), getUUIDMetadataResult.getData().getExternalId()); assertNotNull(getUUIDMetadataResult.getData().getCustom()); - assertEquals(statusValue, getUUIDMetadataResult.getData().getStatus()); - assertEquals(typeValue, getUUIDMetadataResult.getData().getType()); + assertEquals(statusValue, getUUIDMetadataResult.getData().getStatus().getValue()); + assertEquals(typeValue, getUUIDMetadataResult.getData().getType().getValue()); } @Test diff --git a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/Converters.java b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/Converters.java index d1929ef81..45f74c985 100644 --- a/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/Converters.java +++ b/pubnub-gson/pubnub-gson-impl/src/main/java/com/pubnub/internal/java/v2/callbacks/Converters.java @@ -150,8 +150,8 @@ static PNMembershipResult getSetMembershipResult(@NotNull PNObjectEventResult ob new PNChannelMetadata(data.getChannel(), null) ); membership.setUuid(data.getUuid()); - membership.setCustom(data.getCustom() != null ? data.getCustom().getValue() : null); - membership.setStatus(data.getStatus() != null ? data.getStatus().getValue() : null); + membership.setCustom(data.getCustom()); + membership.setStatus(data.getStatus()); membership.setUpdated(data.getUpdated()); membership.setETag(data.getETag()); return new PNMembershipResult( diff --git a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/callbacks/DelegatingEventListenerTest.kt b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/callbacks/DelegatingEventListenerTest.kt index b8c05a707..073b42510 100644 --- a/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/callbacks/DelegatingEventListenerTest.kt +++ b/pubnub-gson/pubnub-gson-impl/src/test/kotlin/com/pubnub/internal/java/v2/callbacks/DelegatingEventListenerTest.kt @@ -167,15 +167,15 @@ internal class DelegatingEventListenerTest { Assertions.assertEquals(event, result.event) result.data.let { data -> Assertions.assertEquals(id, data.id) - Assertions.assertEquals(name, data.name) - Assertions.assertEquals(externalId, data.externalId) - Assertions.assertEquals(profileUrl, data.profileUrl) - Assertions.assertEquals(email, data.email) - Assertions.assertEquals(custom, data.custom) - Assertions.assertEquals(updated, data.updated) - Assertions.assertEquals(eTag, data.eTag) - Assertions.assertEquals(type, data.type) - Assertions.assertEquals(status, data.status) + Assertions.assertEquals(name, data.name.value) + Assertions.assertEquals(externalId, data.externalId.value) + Assertions.assertEquals(profileUrl, data.profileUrl.value) + Assertions.assertEquals(email, data.email.value) + Assertions.assertEquals(custom, data.custom.value) + Assertions.assertEquals(updated, data.updated.value) + Assertions.assertEquals(eTag, data.eTag.value) + Assertions.assertEquals(type, data.type.value) + Assertions.assertEquals(status, data.status.value) } Assertions.assertEquals(channel, result.channel) Assertions.assertEquals(subscription, result.subscription) @@ -231,13 +231,13 @@ internal class DelegatingEventListenerTest { Assertions.assertEquals(event, result.event) result.data.let { data -> Assertions.assertEquals(id, data.id) - Assertions.assertEquals(name, data.name) - Assertions.assertEquals(description, data.description) - Assertions.assertEquals(custom, data.custom) - Assertions.assertEquals(updated, data.updated) - Assertions.assertEquals(eTag, data.eTag) - Assertions.assertEquals(type, data.type) - Assertions.assertEquals(status, data.status) + Assertions.assertEquals(name, data.name.value) + Assertions.assertEquals(description, data.description.value) + Assertions.assertEquals(custom, data.custom.value) + Assertions.assertEquals(updated, data.updated.value) + Assertions.assertEquals(eTag, data.eTag.value) + Assertions.assertEquals(type, data.type.value) + Assertions.assertEquals(status, data.status.value) } Assertions.assertEquals(channel, result.channel) Assertions.assertEquals(subscription, result.subscription) @@ -307,10 +307,10 @@ internal class DelegatingEventListenerTest { result.data.let { data -> Assertions.assertEquals(channel, data.channel.id) Assertions.assertEquals(uuid, data.uuid) - Assertions.assertEquals(custom, data.custom) + Assertions.assertEquals(custom, data.custom.value) Assertions.assertEquals(updated, data.updated) Assertions.assertEquals(eTag, data.eTag) - Assertions.assertEquals(status, data.status) + Assertions.assertEquals(status, data.status.value) } Assertions.assertEquals(channel, result.channel) Assertions.assertEquals(subscription, result.subscription) diff --git a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt b/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt deleted file mode 100644 index 02d4476ff..000000000 --- a/pubnub-kotlin/pubnub-kotlin-api/src/commonMain/kotlin/com/pubnub/kmp/Optional.kt +++ /dev/null @@ -1,17 +0,0 @@ -package com.pubnub.kmp - -sealed interface Optional { - class Value(val value: T) : Optional - - class Absent : Optional - - fun onValue(action: (T) -> Unit): Optional = this.apply { (this as? Value)?.let { action(it.value) } } - - fun onAbsent(action: () -> Unit): Optional = this.apply { - if (this is Absent) { - action() - } - } -} - -fun T?.toOptional(): Optional = this?.let { Optional.Value(it) } ?: Optional.Absent() diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/BaseIntegrationTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/BaseIntegrationTest.kt index 49bf58ad7..9d30e9240 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/BaseIntegrationTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/integrationTest/kotlin/com/pubnub/api/integration/BaseIntegrationTest.kt @@ -67,7 +67,7 @@ abstract class BaseIntegrationTest { // return pubNub // } - private fun createServer(action: PNConfiguration.Builder.() -> Unit = {}): PubNub { + protected fun createServer(action: PNConfiguration.Builder.() -> Unit = {}): PubNub { val pubNub = PubNub.create(getServerPnConfiguration(action)) registerGuestClient(pubNub) return pubNub From 16a9de953afec120efb261fe4cbb0b0221041ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Fri, 20 Sep 2024 14:17:01 +0200 Subject: [PATCH 62/62] Formatting --- .../managers/subscription/AbstractReconnectionProblemIT.java | 2 -- .../src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java index d7db55d2d..61c5e4152 100644 --- a/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java +++ b/pubnub-gson/pubnub-gson-impl/src/integrationTest/java/com/pubnub/api/integration/managers/subscription/AbstractReconnectionProblemIT.java @@ -205,7 +205,6 @@ private com.pubnub.api.java.PubNub adminPubNub() { @Ignore("This test should be fixed")// To SubscribeEffectInvocation.EmitStatus in is SubscribeEvent.HandshakeFailure add affectedChannels and affectedChannelGroups @Test - @Ignore public void alwaysContinueSubscriptionToChannelGroupIfNoActionTaken() throws PubNubException, InterruptedException { final String channelGroup = "chg-1-" + randomId(); @@ -227,7 +226,6 @@ public void alwaysContinueSubscriptionToChannelGroupIfNoActionTaken() throws Pub @Ignore("This test should be fixed")// 1. To SubscribeEffectInvocation.EmitStatus in is SubscribeEvent.HandshakeFailure add affectedChannels and affectedChannelGroups @Test - @Ignore public void alwaysContinueSubscriptionIfNoActionTaken() throws InterruptedException { final String channel = "ch-" + randomId(); diff --git a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt index f7175fd02..7fdc2734d 100644 --- a/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt +++ b/pubnub-kotlin/pubnub-kotlin-impl/src/test/kotlin/com/pubnub/api/legacy/BaseTest.kt @@ -5,6 +5,7 @@ import com.github.tomakehurst.wiremock.client.WireMock import com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig import com.pubnub.api.UserId import com.pubnub.api.enums.PNLogVerbosity +import com.pubnub.api.retry.RetryConfiguration import com.pubnub.api.v2.PNConfiguration import com.pubnub.internal.PubNubImpl import com.pubnub.test.CommonUtils.defaultListenDuration @@ -64,6 +65,7 @@ abstract class BaseTest { origin = wireMockServer.baseUrl().toHttpUrlOrNull()!!.run { "$host:$port" } secure = false logVerbosity = PNLogVerbosity.BODY + retryConfiguration = RetryConfiguration.None } fun clearConfiguration() {