diff --git a/build.gradle b/build.gradle index 465b677..913d0eb 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,6 @@ archivesBaseName = 'kintone-java-client' description = 'API client library for Kintone REST APIs on Java.' repositories { - jcenter() mavenCentral() } diff --git a/src/main/java/com/kintone/client/AppClient.java b/src/main/java/com/kintone/client/AppClient.java index 170969a..5e3d188 100644 --- a/src/main/java/com/kintone/client/AppClient.java +++ b/src/main/java/com/kintone/client/AppClient.java @@ -1,108 +1,10 @@ package com.kintone.client; -import com.kintone.client.api.app.AddAppRequest; -import com.kintone.client.api.app.AddAppResponseBody; -import com.kintone.client.api.app.AddFormFieldsRequest; -import com.kintone.client.api.app.AddFormFieldsResponseBody; -import com.kintone.client.api.app.DeleteFormFieldsRequest; -import com.kintone.client.api.app.DeleteFormFieldsResponseBody; -import com.kintone.client.api.app.DeployAppRequest; -import com.kintone.client.api.app.DeployAppResponseBody; -import com.kintone.client.api.app.EvaluateRecordAclRequest; -import com.kintone.client.api.app.EvaluateRecordAclResponseBody; -import com.kintone.client.api.app.GetAppAclPreviewRequest; -import com.kintone.client.api.app.GetAppAclPreviewResponseBody; -import com.kintone.client.api.app.GetAppAclRequest; -import com.kintone.client.api.app.GetAppAclResponseBody; -import com.kintone.client.api.app.GetAppActionsPreviewRequest; -import com.kintone.client.api.app.GetAppActionsPreviewResponseBody; -import com.kintone.client.api.app.GetAppActionsRequest; -import com.kintone.client.api.app.GetAppActionsResponseBody; -import com.kintone.client.api.app.GetAppCustomizePreviewRequest; -import com.kintone.client.api.app.GetAppCustomizePreviewResponseBody; -import com.kintone.client.api.app.GetAppCustomizeRequest; -import com.kintone.client.api.app.GetAppCustomizeResponseBody; -import com.kintone.client.api.app.GetAppRequest; -import com.kintone.client.api.app.GetAppResponseBody; -import com.kintone.client.api.app.GetAppSettingsPreviewRequest; -import com.kintone.client.api.app.GetAppSettingsPreviewResponseBody; -import com.kintone.client.api.app.GetAppSettingsRequest; -import com.kintone.client.api.app.GetAppSettingsResponseBody; -import com.kintone.client.api.app.GetAppsRequest; -import com.kintone.client.api.app.GetAppsResponseBody; -import com.kintone.client.api.app.GetDeployStatusRequest; -import com.kintone.client.api.app.GetDeployStatusResponseBody; -import com.kintone.client.api.app.GetFieldAclPreviewRequest; -import com.kintone.client.api.app.GetFieldAclPreviewResponseBody; -import com.kintone.client.api.app.GetFieldAclRequest; -import com.kintone.client.api.app.GetFieldAclResponseBody; -import com.kintone.client.api.app.GetFormFieldsPreviewRequest; -import com.kintone.client.api.app.GetFormFieldsPreviewResponseBody; -import com.kintone.client.api.app.GetFormFieldsRequest; -import com.kintone.client.api.app.GetFormFieldsResponseBody; -import com.kintone.client.api.app.GetFormLayoutPreviewRequest; -import com.kintone.client.api.app.GetFormLayoutPreviewResponseBody; -import com.kintone.client.api.app.GetFormLayoutRequest; -import com.kintone.client.api.app.GetFormLayoutResponseBody; -import com.kintone.client.api.app.GetGeneralNotificationsPreviewRequest; -import com.kintone.client.api.app.GetGeneralNotificationsPreviewResponseBody; -import com.kintone.client.api.app.GetGeneralNotificationsRequest; -import com.kintone.client.api.app.GetGeneralNotificationsResponseBody; -import com.kintone.client.api.app.GetPerRecordNotificationsPreviewRequest; -import com.kintone.client.api.app.GetPerRecordNotificationsPreviewResponseBody; -import com.kintone.client.api.app.GetPerRecordNotificationsRequest; -import com.kintone.client.api.app.GetPerRecordNotificationsResponseBody; -import com.kintone.client.api.app.GetProcessManagementPreviewRequest; -import com.kintone.client.api.app.GetProcessManagementPreviewResponseBody; -import com.kintone.client.api.app.GetProcessManagementRequest; -import com.kintone.client.api.app.GetProcessManagementResponseBody; -import com.kintone.client.api.app.GetRecordAclPreviewRequest; -import com.kintone.client.api.app.GetRecordAclPreviewResponseBody; -import com.kintone.client.api.app.GetRecordAclRequest; -import com.kintone.client.api.app.GetRecordAclResponseBody; -import com.kintone.client.api.app.GetReminderNotificationsPreviewRequest; -import com.kintone.client.api.app.GetReminderNotificationsPreviewResponseBody; -import com.kintone.client.api.app.GetReminderNotificationsRequest; -import com.kintone.client.api.app.GetReminderNotificationsResponseBody; -import com.kintone.client.api.app.GetReportsPreviewRequest; -import com.kintone.client.api.app.GetReportsPreviewResponseBody; -import com.kintone.client.api.app.GetReportsRequest; -import com.kintone.client.api.app.GetReportsResponseBody; -import com.kintone.client.api.app.GetViewsPreviewRequest; -import com.kintone.client.api.app.GetViewsPreviewResponseBody; -import com.kintone.client.api.app.GetViewsRequest; -import com.kintone.client.api.app.GetViewsResponseBody; -import com.kintone.client.api.app.UpdateAppAclRequest; -import com.kintone.client.api.app.UpdateAppAclResponseBody; -import com.kintone.client.api.app.UpdateAppActionsRequest; -import com.kintone.client.api.app.UpdateAppActionsResponseBody; -import com.kintone.client.api.app.UpdateAppCustomizeRequest; -import com.kintone.client.api.app.UpdateAppCustomizeResponseBody; -import com.kintone.client.api.app.UpdateAppSettingsRequest; -import com.kintone.client.api.app.UpdateAppSettingsResponseBody; -import com.kintone.client.api.app.UpdateFieldAclRequest; -import com.kintone.client.api.app.UpdateFieldAclResponseBody; -import com.kintone.client.api.app.UpdateFormFieldsRequest; -import com.kintone.client.api.app.UpdateFormFieldsResponseBody; -import com.kintone.client.api.app.UpdateFormLayoutRequest; -import com.kintone.client.api.app.UpdateFormLayoutResponseBody; -import com.kintone.client.api.app.UpdateGeneralNotificationsRequest; -import com.kintone.client.api.app.UpdateGeneralNotificationsResponseBody; -import com.kintone.client.api.app.UpdatePerRecordNotificationsRequest; -import com.kintone.client.api.app.UpdatePerRecordNotificationsResponseBody; -import com.kintone.client.api.app.UpdateProcessManagementRequest; -import com.kintone.client.api.app.UpdateProcessManagementResponseBody; -import com.kintone.client.api.app.UpdateRecordAclRequest; -import com.kintone.client.api.app.UpdateRecordAclResponseBody; -import com.kintone.client.api.app.UpdateReminderNotificationsRequest; -import com.kintone.client.api.app.UpdateReminderNotificationsResponseBody; -import com.kintone.client.api.app.UpdateReportsRequest; -import com.kintone.client.api.app.UpdateReportsResponseBody; -import com.kintone.client.api.app.UpdateViewsRequest; -import com.kintone.client.api.app.UpdateViewsResponseBody; +import com.kintone.client.api.app.*; import com.kintone.client.model.app.ActionId; import com.kintone.client.model.app.App; import com.kintone.client.model.app.AppAction; +import com.kintone.client.model.app.AppPlugin; import com.kintone.client.model.app.AppRightEntity; import com.kintone.client.model.app.DeployApp; import com.kintone.client.model.app.DeployStatus; @@ -235,6 +137,32 @@ public AddFormFieldsResponseBody addFormFields(AddFormFieldsRequest request) { return client.call(KintoneApi.ADD_FORM_FIELDS, request, handlers); } + /** + * Adds Plug-ins to an App. This API updates the pre-live settings. After using this API, use the + * Deploy App Settings API to deploy the settings to the live App. + * + * @param app the App ID + * @param ids the Plug-in IDs that will be added to the App + * @return the revision number of the App settings + */ + public long addPlugins(long app, List ids) { + AddAppPluginsRequest req = new AddAppPluginsRequest(); + req.setApp(app); + req.setIds(ids); + return addPlugins(req).getRevision(); + } + + /** + * Adds Plug-ins to an App. This API updates the pre-live settings. After using this API, use the + * Deploy App Settings API to deploy the settings to the live App. + * + * @param request the request parameters. See {@link AddAppPluginsRequest} + * @return the response data. See {@link AddAppPluginsResponseBody} + */ + public AddAppPluginsResponseBody addPlugins(AddAppPluginsRequest request) { + return client.call(KintoneApi.ADD_APP_PLUGINS, request, handlers); + } + /** * Deletes fields from a form of an App. This API updates the pre-live settings. After using this * API, use the Deploy App Settings API to deploy the settings to the live App. @@ -362,6 +290,53 @@ public EvaluateRecordAclResponseBody evaluateRecordAcl(EvaluateRecordAclRequest return client.call(KintoneApi.EVALUATE_RECORD_ACL, request, handlers); } + /** + * Gets notes for app administrators and their settings. + * + * @param app the App ID + * @return the response data. See {@link GetAdminNotesResponseBody} + */ + public GetAdminNotesResponseBody getAdminNotes(long app) { + GetAdminNotesRequest req = new GetAdminNotesRequest(); + req.setApp(app); + return this.getAdminNotes(req); + } + + /** + * Gets notes for app administrators and their settings. + * + * @param request the request parameters. See {@link GetAdminNotesRequest} + * @return the response data. See {@link GetAdminNotesResponseBody} + */ + public GetAdminNotesResponseBody getAdminNotes(GetAdminNotesRequest request) { + return client.call(KintoneApi.GET_APP_ADMIN_NOTES, request, handlers); + } + + /** + * Gets notes for app administrators and their settings. This API retrieves the pre-live settings + * that have not yet been deployed to the live App. + * + * @param app the App ID + * @return the response data. See {@link GetAdminNotesPreviewResponseBody} + */ + public GetAdminNotesPreviewResponseBody getAdminNotesPreview(long app) { + GetAdminNotesPreviewRequest req = new GetAdminNotesPreviewRequest(); + req.setApp(app); + return this.getAdminNotesPreview(req); + } + + /** + * Gets notes for app administrators and their settings. This API retrieves the pre-live settings + * that have not yet been deployed to the live App. + * + * @param request the request parameters. See {@link GetAdminNotesPreviewRequest} + * @return the response data. See {@link GetAdminNotesPreviewResponseBody} + */ + public GetAdminNotesPreviewResponseBody getAdminNotesPreview( + GetAdminNotesPreviewRequest request) { + return client.call(KintoneApi.GET_APP_ADMIN_NOTES_PREVIEW, request, handlers); + } + /** * Gets general information of an App, including the name, description, related Space, creator and * updater information. @@ -988,6 +963,77 @@ public GetPerRecordNotificationsPreviewResponseBody getPerRecordNotificationsPre return client.call(KintoneApi.GET_PRE_RECORD_NOTIFICATIONS_PREVIEW, request, handlers); } + /** + * Gets the list of Plug-ins added to an App. + * + * @param app the App ID + * @return a list of AppPlugin objects. + */ + public List getPlugins(long app) { + return getPlugins(app, null); + } + + /** + * Gets the list of Plug-ins added to an App. + * + * @param app the App ID + * @param lang the localization language setting + * @return a list of AppPlugin objects. + */ + public List getPlugins(long app, String lang) { + GetAppPluginsRequest req = new GetAppPluginsRequest(); + req.setApp(app); + req.setLang(lang); + return getPlugins(req).getPlugins(); + } + + /** + * Gets the list of Plug-ins added to an App. + * + * @param request the request parameters. See {@link GetAppPluginsRequest} + * @return the response data. See {@link GetAppPluginsResponseBody} + */ + public GetAppPluginsResponseBody getPlugins(GetAppPluginsRequest request) { + return client.call(KintoneApi.GET_APP_PLUGINS, request, handlers); + } + + /** + * Gets the list of Plug-ins added to an App. This API retrieves the pre-live settings that have + * not yet been deployed to the live App. + * + * @param app the App ID + * @return a list of AppPlugin objects. + */ + public List getPluginsPreview(long app) { + return getPluginsPreview(app, null); + } + + /** + * Gets the list of Plug-ins added to an App. This API retrieves the pre-live settings that have + * not yet been deployed to the live App. + * + * @param app the App ID + * @param lang the localization language setting + * @return a list of AppPlugin objects. + */ + public List getPluginsPreview(long app, String lang) { + GetAppPluginsPreviewRequest req = new GetAppPluginsPreviewRequest(); + req.setApp(app); + req.setLang(lang); + return getPluginsPreview(req).getPlugins(); + } + + /** + * Gets the list of Plug-ins added to an App. This API retrieves the pre-live settings that have + * not yet been deployed to the live App. + * + * @param request the request parameters. See {@link GetAppPluginsPreviewRequest} + * @return the response data. See {@link GetAppPluginsPreviewResponseBody} + */ + public GetAppPluginsPreviewResponseBody getPluginsPreview(GetAppPluginsPreviewRequest request) { + return client.call(KintoneApi.GET_APP_PLUGINS_PREVIEW, request, handlers); + } + /** * Gets the process management settings of an App. * @@ -1357,6 +1403,30 @@ public GetViewsPreviewResponseBody getViewsPreview(GetViewsPreviewRequest reques return client.call(KintoneApi.GET_VIEWS_PREVIEW, request, handlers); } + /** + * Changes the Space to which an App belongs. + * + * @param app the App ID + * @param space the Space ID of where the App will be moved to. + */ + public void move(long app, Long space) { + MoveAppRequest req = new MoveAppRequest(); + req.setApp(app); + req.setSpace(space); + move(req); + } + + /** + * Changes the Space to which an App belongs. + * + * @param request the request parameters. See {@link MoveAppRequest} + * @return the response data. To remove an App from its current space, null can be specified. See + * {@link MoveAppResponseBody} + */ + public MoveAppResponseBody move(MoveAppRequest request) { + return client.call(KintoneApi.MOVE_APP_TO_SPACE, request, handlers); + } + /** * Cancel all changes made to the pre-live settings. The pre-live settings will be reverted back * to the current settings of the live app. @@ -1378,6 +1448,16 @@ public void revertApp(long app, Long revision) { deployApp(app, revision, true); } + /** + * Updates the notes for App administrators and their settings. + * + * @param request the request parameters. See {@link UpdateAdminNotesRequest} + * @return the response data. See {@link UpdateAdminNotesResponseBody} + */ + public UpdateAdminNotesResponseBody updateAdminNotes(UpdateAdminNotesRequest request) { + return client.call(KintoneApi.UPDATE_APP_ADMIN_NOTES, request, handlers); + } + /** * Updates the App permissions of an App. * diff --git a/src/main/java/com/kintone/client/KintoneApi.java b/src/main/java/com/kintone/client/KintoneApi.java index a27894c..656fd6f 100644 --- a/src/main/java/com/kintone/client/KintoneApi.java +++ b/src/main/java/com/kintone/client/KintoneApi.java @@ -3,17 +3,22 @@ import static com.kintone.client.KintoneHttpMethod.*; import com.kintone.client.api.KintoneResponseBody; +import com.kintone.client.api.app.AddAppPluginsResponseBody; import com.kintone.client.api.app.AddAppResponseBody; import com.kintone.client.api.app.AddFormFieldsResponseBody; import com.kintone.client.api.app.DeleteFormFieldsResponseBody; import com.kintone.client.api.app.DeployAppResponseBody; import com.kintone.client.api.app.EvaluateRecordAclResponseBody; +import com.kintone.client.api.app.GetAdminNotesPreviewResponseBody; +import com.kintone.client.api.app.GetAdminNotesResponseBody; import com.kintone.client.api.app.GetAppAclPreviewResponseBody; import com.kintone.client.api.app.GetAppAclResponseBody; import com.kintone.client.api.app.GetAppActionsPreviewResponseBody; import com.kintone.client.api.app.GetAppActionsResponseBody; import com.kintone.client.api.app.GetAppCustomizePreviewResponseBody; import com.kintone.client.api.app.GetAppCustomizeResponseBody; +import com.kintone.client.api.app.GetAppPluginsPreviewResponseBody; +import com.kintone.client.api.app.GetAppPluginsResponseBody; import com.kintone.client.api.app.GetAppResponseBody; import com.kintone.client.api.app.GetAppSettingsPreviewResponseBody; import com.kintone.client.api.app.GetAppSettingsResponseBody; @@ -39,6 +44,8 @@ import com.kintone.client.api.app.GetReportsResponseBody; import com.kintone.client.api.app.GetViewsPreviewResponseBody; import com.kintone.client.api.app.GetViewsResponseBody; +import com.kintone.client.api.app.MoveAppResponseBody; +import com.kintone.client.api.app.UpdateAdminNotesResponseBody; import com.kintone.client.api.app.UpdateAppAclResponseBody; import com.kintone.client.api.app.UpdateAppActionsResponseBody; import com.kintone.client.api.app.UpdateAppCustomizeResponseBody; @@ -56,6 +63,11 @@ import com.kintone.client.api.common.BulkRequestsResponseBody; import com.kintone.client.api.common.DownloadFileResponseBody; import com.kintone.client.api.common.UploadFileResponseBody; +import com.kintone.client.api.plugin.GetInstalledPluginsResponseBody; +import com.kintone.client.api.plugin.GetRequiredPluginsResponseBody; +import com.kintone.client.api.plugin.InstallPluginResponseBody; +import com.kintone.client.api.plugin.UninstallPluginResponseBody; +import com.kintone.client.api.plugin.UpdatePluginResponseBody; import com.kintone.client.api.record.AddRecordCommentResponseBody; import com.kintone.client.api.record.AddRecordResponseBody; import com.kintone.client.api.record.AddRecordsResponseBody; @@ -76,6 +88,7 @@ import com.kintone.client.api.space.AddGuestsResponseBody; import com.kintone.client.api.space.AddSpaceFromTemplateResponseBody; import com.kintone.client.api.space.AddThreadCommentResponseBody; +import com.kintone.client.api.space.AddThreadResponseBody; import com.kintone.client.api.space.DeleteGuestsResponseBody; import com.kintone.client.api.space.DeleteSpaceResponseBody; import com.kintone.client.api.space.GetSpaceMembersResponseBody; @@ -83,6 +96,7 @@ import com.kintone.client.api.space.UpdateSpaceBodyResponseBody; import com.kintone.client.api.space.UpdateSpaceGuestsResponseBody; import com.kintone.client.api.space.UpdateSpaceMembersResponseBody; +import com.kintone.client.api.space.UpdateSpaceResponseBody; import com.kintone.client.api.space.UpdateThreadResponseBody; import lombok.AccessLevel; import lombok.Getter; @@ -149,6 +163,11 @@ public enum KintoneApi { GET_APP_SETTINGS(GET, "app/settings", GetAppSettingsResponseBody.class), GET_APP_SETTINGS_PREVIEW(GET, "preview/app/settings", GetAppSettingsPreviewResponseBody.class), UPDATE_APP_SETTINGS(PUT, "preview/app/settings", UpdateAppSettingsResponseBody.class), + MOVE_APP_TO_SPACE(POST, "app/move", MoveAppResponseBody.class), + GET_APP_ADMIN_NOTES(GET, "app/adminNotes", GetAdminNotesResponseBody.class), + GET_APP_ADMIN_NOTES_PREVIEW( + GET, "preview/app/adminNotes", GetAdminNotesPreviewResponseBody.class), + UPDATE_APP_ADMIN_NOTES(PUT, "preview/app/adminNotes", UpdateAdminNotesResponseBody.class), GET_PROCESS_MANAGEMENT(GET, "app/status", GetProcessManagementResponseBody.class), GET_PROCESS_MANAGEMENT_PREVIEW( GET, "preview/app/status", GetProcessManagementPreviewResponseBody.class), @@ -159,9 +178,19 @@ public enum KintoneApi { GET_APP_CUSTOMIZE(GET, "app/customize", GetAppCustomizeResponseBody.class), GET_APP_CUSTOMIZE_PREVIEW(GET, "preview/app/customize", GetAppCustomizePreviewResponseBody.class), UPDATE_APP_CUSTOMIZE(PUT, "preview/app/customize", UpdateAppCustomizeResponseBody.class), + GET_APP_PLUGINS(GET, "app/plugins", GetAppPluginsResponseBody.class), + GET_APP_PLUGINS_PREVIEW(GET, "preview/app/plugins", GetAppPluginsPreviewResponseBody.class), + ADD_APP_PLUGINS(POST, "preview/app/plugins", AddAppPluginsResponseBody.class), GET_APP_ACL(GET, "app/acl", GetAppAclResponseBody.class), GET_APP_ACL_PREVIEW(GET, "preview/app/acl", GetAppAclPreviewResponseBody.class), UPDATE_APP_ACL(PUT, "preview/app/acl", UpdateAppAclResponseBody.class), + GET_PLUGINS(GET, "plugins", GetInstalledPluginsResponseBody.class), + INSTALL_PLUGIN(POST, "plugin", InstallPluginResponseBody.class), + UPDATE_PLUGIN(PUT, "plugin", UpdatePluginResponseBody.class), + UNINSTALL_PLUGIN(DELETE, "plugin", UninstallPluginResponseBody.class), + GET_APPS_PLUGIN_ADDED( + GET, "plugin/apps", com.kintone.client.api.plugin.GetAppsResponseBody.class), + GET_REQUIRED_PLUGINS(GET, "plugins/required", GetRequiredPluginsResponseBody.class), GET_RECORD_ACL(GET, "record/acl", GetRecordAclResponseBody.class), GET_RECORD_ACL_PREVIEW(GET, "preview/record/acl", GetRecordAclPreviewResponseBody.class), UPDATE_RECORD_ACL(PUT, "preview/record/acl", UpdateRecordAclResponseBody.class), @@ -172,9 +201,11 @@ public enum KintoneApi { GET_DEPLOY_STATUS(GET, "preview/app/deploy", GetDeployStatusResponseBody.class), DEPLOY_APP(POST, "preview/app/deploy", DeployAppResponseBody.class), GET_SPACE(GET, "space", GetSpaceResponseBody.class), + UPDATE_SPACE(PUT, "space", UpdateSpaceResponseBody.class), DELETE_SPACE(DELETE, "space", DeleteSpaceResponseBody.class), ADD_SPACE_FROM_TEMPLATE(POST, "template/space", AddSpaceFromTemplateResponseBody.class), UPDATE_SPACE_BODY(PUT, "space/body", UpdateSpaceBodyResponseBody.class), + ADD_THREAD(POST, "space/thread", AddThreadResponseBody.class), UPDATE_THREAD(PUT, "space/thread", UpdateThreadResponseBody.class), ADD_THREAD_COMMENT(POST, "space/thread/comment", AddThreadCommentResponseBody.class), GET_SPACE_MEMBERS(GET, "space/members", GetSpaceMembersResponseBody.class), diff --git a/src/main/java/com/kintone/client/KintoneClient.java b/src/main/java/com/kintone/client/KintoneClient.java index 9d20ec0..11e329b 100644 --- a/src/main/java/com/kintone/client/KintoneClient.java +++ b/src/main/java/com/kintone/client/KintoneClient.java @@ -42,6 +42,7 @@ public class KintoneClient implements AutoCloseable { private final SpaceClient spaceClient; private final FileClient fileClient; private final SchemaClient schemaClient; + private final PluginClient pluginClient; private final List handlers = new ArrayList<>(); @@ -54,6 +55,7 @@ public class KintoneClient implements AutoCloseable { spaceClient = new SpaceClient(client, handlers); fileClient = new FileClient(client, handlers); schemaClient = new SchemaClient(client, handlers); + pluginClient = new PluginClient(client, handlers); } /** @@ -101,6 +103,15 @@ public SchemaClient schema() { return schemaClient; } + /** + * Get the client for plugin APIs. + * + * @return the plugin client + */ + public PluginClient plugin() { + return pluginClient; + } + /** * Runs multiple API requests sequentially to multiple Apps. * diff --git a/src/main/java/com/kintone/client/PluginClient.java b/src/main/java/com/kintone/client/PluginClient.java new file mode 100644 index 0000000..98950ba --- /dev/null +++ b/src/main/java/com/kintone/client/PluginClient.java @@ -0,0 +1,196 @@ +package com.kintone.client; + +import com.kintone.client.api.plugin.*; +import com.kintone.client.api.plugin.GetAppsRequest; +import com.kintone.client.api.plugin.GetAppsResponseBody; +import com.kintone.client.api.plugin.InstallPluginRequest; +import com.kintone.client.api.plugin.InstallPluginResponseBody; +import com.kintone.client.api.plugin.UninstallPluginRequest; +import com.kintone.client.api.plugin.UninstallPluginResponseBody; +import com.kintone.client.api.plugin.UpdatePluginRequest; +import com.kintone.client.api.plugin.UpdatePluginResponseBody; +import com.kintone.client.model.plugin.App; +import com.kintone.client.model.plugin.Plugin; +import java.util.List; +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; + +/** A client that operates plugin APIs. */ +@RequiredArgsConstructor(access = AccessLevel.PACKAGE) +public class PluginClient { + + private final InternalClient client; + private final List handlers; + + /** + * Gets the list of plug-ins imported into Kintone. + * + * @return the response data. See {@link GetInstalledPluginsResponseBody} + */ + public GetInstalledPluginsResponseBody getInstalledPlugins() { + return getInstalledPlugins(null, null); + } + + /** + * Gets the list of plug-ins imported into Kintone. + * + * @param offset The number of plug-ins to skip from the list of installed plug-ins. + * @param limit The maximum number of plug-ins to retrieve. + * @return the response data. See {@link GetInstalledPluginsResponseBody} + */ + public GetInstalledPluginsResponseBody getInstalledPlugins(Long offset, Long limit) { + GetInstalledPluginsRequest request = new GetInstalledPluginsRequest(); + request.setOffset(offset); + request.setLimit(limit); + return getInstalledPlugins(request); + } + + /** + * Gets the list of plug-ins imported into Kintone. + * + * @param request the request parameters. See {@link GetInstalledPluginsRequest} + * @return the response data. See {@link GetInstalledPluginsResponseBody} + */ + public GetInstalledPluginsResponseBody getInstalledPlugins(GetInstalledPluginsRequest request) { + return client.call(KintoneApi.GET_PLUGINS, request, handlers); + } + + /** + * Installs a Plug-in into Kintone. + * + * @param fileKey the fileKey representing an uploaded file. + * @return the response data. See {@link InstallPluginResponseBody} + */ + public InstallPluginResponseBody installPlugin(String fileKey) { + InstallPluginRequest request = new InstallPluginRequest(); + request.setFileKey(fileKey); + return installPlugin(request); + } + + /** + * Installs a Plug-in into Kintone. + * + * @param request the request parameters. See {@link InstallPluginRequest} + * @return the response data. See {@link InstallPluginResponseBody} + */ + public InstallPluginResponseBody installPlugin(InstallPluginRequest request) { + return client.call(KintoneApi.INSTALL_PLUGIN, request, handlers); + } + + /** + * Uninstalls a Plug-in from the Kintone environment. + * + * @param id the Plug-in ID. + */ + public void uninstallPlugin(String id) { + UninstallPluginRequest request = new UninstallPluginRequest(); + request.setId(id); + uninstallPlugin(request); + } + + /** + * Uninstalls a Plug-in from the Kintone environment. + * + * @param request the request parameters. See {@link UninstallPluginRequest} + * @return the response data. See {@link UninstallPluginResponseBody} + */ + public UninstallPluginResponseBody uninstallPlugin(UninstallPluginRequest request) { + return client.call(KintoneApi.UNINSTALL_PLUGIN, request, handlers); + } + + /** + * Updates an installed Plug-in in the Kintone environment. + * + * @param id the Plug-in ID. + * @param fileKey the fileKey representing an uploaded file. + * @return the response data. See {@link UpdatePluginResponseBody} + */ + public UpdatePluginResponseBody updatePlugin(String id, String fileKey) { + UpdatePluginRequest request = new UpdatePluginRequest(); + request.setId(id); + request.setFileKey(fileKey); + return updatePlugin(request); + } + + /** + * Updates an installed Plug-in in the Kintone environment. + * + * @param request the request parameters. See {@link UpdatePluginRequest} + * @return the response data. See {@link UpdatePluginResponseBody} + */ + public UpdatePluginResponseBody updatePlugin(UpdatePluginRequest request) { + return client.call(KintoneApi.UPDATE_PLUGIN, request, handlers); + } + + /** + * Gets the list of Apps that have the specified Plug-in added. + * + * @param id The ID of the plug-in. + * @return A list of objects containing the App ID and name. + */ + public List getApps(String id) { + return getApps(id, null, null); + } + + /** + * Gets the list of Apps that have the specified Plug-in added. + * + * @param id The ID of the plug-in. + * @param offset The maximum number of plug-ins to retrieve. + * @param limit The number of plug-ins to skip from the list of plug-ins. + * @return A list of objects containing the App ID and name. + */ + public List getApps(String id, Long offset, Long limit) { + GetAppsRequest request = new GetAppsRequest(); + request.setId(id); + request.setLimit(limit); + request.setOffset(offset); + return getApps(request).getApps(); + } + + /** + * Gets the list of Apps that have the specified Plug-in added. + * + * @param request the request parameters. See {@link GetAppsRequest} + * @return the response data. See {@link GetAppsResponseBody} + */ + public GetAppsResponseBody getApps(GetAppsRequest request) { + return client.call(KintoneApi.GET_APPS_PLUGIN_ADDED, request, handlers); + } + + /** + * Gets the list of plug-ins that have been deleted from Kintone, but have already been added to + * Apps. + * + * @return A list of Plug-ins that needs to be installed. + */ + public List getRequiredPlugins() { + return getRequiredPlugins(null, null); + } + + /** + * Gets the list of plug-ins that have been deleted from Kintone, but have already been added to + * Apps. + * + * @param offset The number of plug-ins to skip from the list of required plug-ins. + * @param limit The maximum number of plug-ins to retrieve. + * @return A list of Plug-ins that needs to be installed. + */ + public List getRequiredPlugins(Long offset, Long limit) { + GetRequiredPluginsRequest request = new GetRequiredPluginsRequest(); + request.setOffset(offset); + request.setLimit(limit); + return getRequiredPlugins(request).getPlugins(); + } + + /** + * Gets the list of plug-ins that have been deleted from Kintone, but have already been added to + * Apps. + * + * @param request the request parameters. See {@link GetRequiredPluginsRequest} + * @return the response data. See {@link GetRequiredPluginsResponseBody} + */ + public GetRequiredPluginsResponseBody getRequiredPlugins(GetRequiredPluginsRequest request) { + return client.call(KintoneApi.GET_REQUIRED_PLUGINS, request, handlers); + } +} diff --git a/src/main/java/com/kintone/client/SpaceClient.java b/src/main/java/com/kintone/client/SpaceClient.java index 75edb14..71f19da 100644 --- a/src/main/java/com/kintone/client/SpaceClient.java +++ b/src/main/java/com/kintone/client/SpaceClient.java @@ -6,6 +6,8 @@ import com.kintone.client.api.space.AddSpaceFromTemplateResponseBody; import com.kintone.client.api.space.AddThreadCommentRequest; import com.kintone.client.api.space.AddThreadCommentResponseBody; +import com.kintone.client.api.space.AddThreadRequest; +import com.kintone.client.api.space.AddThreadResponseBody; import com.kintone.client.api.space.DeleteGuestsRequest; import com.kintone.client.api.space.DeleteGuestsResponseBody; import com.kintone.client.api.space.DeleteSpaceRequest; @@ -20,6 +22,8 @@ import com.kintone.client.api.space.UpdateSpaceGuestsResponseBody; import com.kintone.client.api.space.UpdateSpaceMembersRequest; import com.kintone.client.api.space.UpdateSpaceMembersResponseBody; +import com.kintone.client.api.space.UpdateSpaceRequest; +import com.kintone.client.api.space.UpdateSpaceResponseBody; import com.kintone.client.api.space.UpdateThreadRequest; import com.kintone.client.api.space.UpdateThreadResponseBody; import com.kintone.client.model.space.AddedSpaceMember; @@ -73,6 +77,30 @@ public AddSpaceFromTemplateResponseBody addSpaceFromTemplate( return client.call(KintoneApi.ADD_SPACE_FROM_TEMPLATE, request, handlers); } + /** + * Adds a Thread in a Space. + * + * @param spaceId the Space ID + * @param name the name of the new Thread + * @return the Thread ID of the created Thread + */ + public long addThread(long spaceId, String name) { + AddThreadRequest req = new AddThreadRequest(); + req.setSpace(spaceId); + req.setName(name); + return addThread(req).getId(); + } + + /** + * Adds a Thread in a Space. + * + * @param request the request parameters. See {@link AddThreadRequest} + * @return the response data. See {@link AddThreadResponseBody} + */ + public AddThreadResponseBody addThread(AddThreadRequest request) { + return client.call(KintoneApi.ADD_THREAD, request, handlers); + } + /** * Adds a comment to a Thread of a Space. * @@ -188,6 +216,16 @@ public GetSpaceMembersResponseBody getSpaceMembers(GetSpaceMembersRequest reques return client.call(KintoneApi.GET_SPACE_MEMBERS, request, handlers); } + /** + * Updates the settings of a Space. + * + * @param request the request parameters. See {@link UpdateSpaceRequest} + * @return the response data. See {@link UpdateSpaceResponseBody} + */ + public UpdateSpaceResponseBody updateSpace(UpdateSpaceRequest request) { + return client.call(KintoneApi.UPDATE_SPACE, request, handlers); + } + /** * Updates the body of a Space. * diff --git a/src/main/java/com/kintone/client/api/app/AddAppPluginsRequest.java b/src/main/java/com/kintone/client/api/app/AddAppPluginsRequest.java new file mode 100644 index 0000000..61b01a8 --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/AddAppPluginsRequest.java @@ -0,0 +1,23 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneRequest; +import java.util.List; +import lombok.Data; + +/** A request object for Add App Plug-ins API. */ +@Data +public class AddAppPluginsRequest implements KintoneRequest { + + /** The App ID (required). */ + private Long app; + + /** The Plug-in IDs that will be added to the App (required). */ + private List ids; + + /** + * The expected revision number of the App settings (optional). The request will fail if the + * revision number is not the latest revision. The revision will not be checked if this parameter + * is null, or -1 is specified. + */ + private Long revision; +} diff --git a/src/main/java/com/kintone/client/api/app/AddAppPluginsResponseBody.java b/src/main/java/com/kintone/client/api/app/AddAppPluginsResponseBody.java new file mode 100644 index 0000000..d611cb0 --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/AddAppPluginsResponseBody.java @@ -0,0 +1,12 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneResponseBody; +import lombok.Value; + +/** A response object for Add App Plug-ins API. */ +@Value +public class AddAppPluginsResponseBody implements KintoneResponseBody { + + /** The revision number of the App settings. */ + private final long revision; +} diff --git a/src/main/java/com/kintone/client/api/app/GetAdminNotesPreviewRequest.java b/src/main/java/com/kintone/client/api/app/GetAdminNotesPreviewRequest.java new file mode 100644 index 0000000..c4e1545 --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/GetAdminNotesPreviewRequest.java @@ -0,0 +1,12 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneRequest; +import lombok.Data; + +/** A request object for Get App Admin Notes Preview API. */ +@Data +public class GetAdminNotesPreviewRequest implements KintoneRequest { + + /** The App ID (required). */ + private Long app; +} diff --git a/src/main/java/com/kintone/client/api/app/GetAdminNotesPreviewResponseBody.java b/src/main/java/com/kintone/client/api/app/GetAdminNotesPreviewResponseBody.java new file mode 100644 index 0000000..1b83cae --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/GetAdminNotesPreviewResponseBody.java @@ -0,0 +1,18 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneResponseBody; +import lombok.Value; + +/** A response object for Get App Admin Notes Preview API. */ +@Value +public class GetAdminNotesPreviewResponseBody implements KintoneResponseBody { + + /** The content of the notes. If not set, an empty string is returned. */ + private final String content; + + /** The permission settings to include this note in app templates or duplicates. */ + private final boolean includeInTemplateAndDuplicates; + + /** The revision number of the App settings. */ + private final long revision; +} diff --git a/src/main/java/com/kintone/client/api/app/GetAdminNotesRequest.java b/src/main/java/com/kintone/client/api/app/GetAdminNotesRequest.java new file mode 100644 index 0000000..76d1610 --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/GetAdminNotesRequest.java @@ -0,0 +1,12 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneRequest; +import lombok.Data; + +/** A request object for Get App Admin Notes API. */ +@Data +public class GetAdminNotesRequest implements KintoneRequest { + + /** The App ID (required). */ + private Long app; +} diff --git a/src/main/java/com/kintone/client/api/app/GetAdminNotesResponseBody.java b/src/main/java/com/kintone/client/api/app/GetAdminNotesResponseBody.java new file mode 100644 index 0000000..5f94e3b --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/GetAdminNotesResponseBody.java @@ -0,0 +1,18 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneResponseBody; +import lombok.Value; + +/** A response object for Get App Admin Notes API. */ +@Value +public class GetAdminNotesResponseBody implements KintoneResponseBody { + + /** The content of the notes. If not set, an empty string is returned. */ + private final String content; + + /** The permission settings to include this note in app templates or duplicates. */ + private final boolean includeInTemplateAndDuplicates; + + /** The revision number of the App settings. */ + private final long revision; +} diff --git a/src/main/java/com/kintone/client/api/app/GetAppPluginsPreviewRequest.java b/src/main/java/com/kintone/client/api/app/GetAppPluginsPreviewRequest.java new file mode 100644 index 0000000..f04b881 --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/GetAppPluginsPreviewRequest.java @@ -0,0 +1,18 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneRequest; +import lombok.Data; + +/** A request object for Get App Plug-ins Preview API. */ +@Data +public class GetAppPluginsPreviewRequest implements KintoneRequest { + + /** The App ID (required). */ + private Long app; + + /** + * The localization language setting (optional). If set to null, the display language for the user + * executing the API is applied. + */ + private String lang; +} diff --git a/src/main/java/com/kintone/client/api/app/GetAppPluginsPreviewResponseBody.java b/src/main/java/com/kintone/client/api/app/GetAppPluginsPreviewResponseBody.java new file mode 100644 index 0000000..ef042cb --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/GetAppPluginsPreviewResponseBody.java @@ -0,0 +1,17 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneResponseBody; +import com.kintone.client.model.app.AppPlugin; +import java.util.List; +import lombok.Value; + +/** A response object for Get App Plug-ins Preview API. */ +@Value +public class GetAppPluginsPreviewResponseBody implements KintoneResponseBody { + + /** A list of Plug-ins added to the App. * */ + private final List plugins; + + /** The revision number of the app settings. */ + private final long revision; +} diff --git a/src/main/java/com/kintone/client/api/app/GetAppPluginsRequest.java b/src/main/java/com/kintone/client/api/app/GetAppPluginsRequest.java new file mode 100644 index 0000000..89a7850 --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/GetAppPluginsRequest.java @@ -0,0 +1,18 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneRequest; +import lombok.Data; + +/** A request object for Get App Plug-ins API. */ +@Data +public class GetAppPluginsRequest implements KintoneRequest { + + /** The App ID (required). */ + private Long app; + + /** + * The localization language setting (optional). If set to null, the display language for the user + * executing the API is applied. + */ + private String lang; +} diff --git a/src/main/java/com/kintone/client/api/app/GetAppPluginsResponseBody.java b/src/main/java/com/kintone/client/api/app/GetAppPluginsResponseBody.java new file mode 100644 index 0000000..6767a19 --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/GetAppPluginsResponseBody.java @@ -0,0 +1,17 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneResponseBody; +import com.kintone.client.model.app.AppPlugin; +import java.util.List; +import lombok.Value; + +/** A response object for Get App Plug-ins API. */ +@Value +public class GetAppPluginsResponseBody implements KintoneResponseBody { + + /** A list of Plug-ins added to the App. * */ + private final List plugins; + + /** The revision number of the app settings. */ + private final long revision; +} diff --git a/src/main/java/com/kintone/client/api/app/MoveAppRequest.java b/src/main/java/com/kintone/client/api/app/MoveAppRequest.java new file mode 100644 index 0000000..d02ce2d --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/MoveAppRequest.java @@ -0,0 +1,18 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneRequest; +import lombok.Data; + +/** A request object for Move App to Space API. */ +@Data +public class MoveAppRequest implements KintoneRequest { + + /** The App ID (required). */ + private Long app; + + /** + * The Space ID of where the App will be moved to (required). To remove an App from its current + * space, null can be specified. + */ + private Long space; +} diff --git a/src/main/java/com/kintone/client/api/app/MoveAppResponseBody.java b/src/main/java/com/kintone/client/api/app/MoveAppResponseBody.java new file mode 100644 index 0000000..9a5295e --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/MoveAppResponseBody.java @@ -0,0 +1,8 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneResponseBody; +import lombok.Value; + +/** A response object for Move App to Space API. */ +@Value +public class MoveAppResponseBody implements KintoneResponseBody {} diff --git a/src/main/java/com/kintone/client/api/app/UpdateAdminNotesRequest.java b/src/main/java/com/kintone/client/api/app/UpdateAdminNotesRequest.java new file mode 100644 index 0000000..6be560e --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/UpdateAdminNotesRequest.java @@ -0,0 +1,30 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneRequest; +import lombok.Data; + +/** A request object for Update App Admin Notes API. */ +@Data +public class UpdateAdminNotesRequest implements KintoneRequest { + + /** The App ID (required). */ + private Long app; + + /** + * The content of the notes (optional). The content will not be updated if this parameter is null. + */ + private String content; + + /** + * The permission settings to include this note in app templates or duplicates (optional). The + * content will not be updated if this parameter is null. + */ + private Boolean includeInTemplateAndDuplicates; + + /** + * The expected revision number of the App settings (optional). The request will fail if the + * revision number is not the latest revision. The revision will not be checked if this parameter + * is null, or -1 is specified. + */ + private Long revision; +} diff --git a/src/main/java/com/kintone/client/api/app/UpdateAdminNotesResponseBody.java b/src/main/java/com/kintone/client/api/app/UpdateAdminNotesResponseBody.java new file mode 100644 index 0000000..3d230ad --- /dev/null +++ b/src/main/java/com/kintone/client/api/app/UpdateAdminNotesResponseBody.java @@ -0,0 +1,12 @@ +package com.kintone.client.api.app; + +import com.kintone.client.api.KintoneResponseBody; +import lombok.Value; + +/** A response object for Update App Admin Notes API. */ +@Value +public class UpdateAdminNotesResponseBody implements KintoneResponseBody { + + /** The revision number of the App settings. */ + private final long revision; +} diff --git a/src/main/java/com/kintone/client/api/plugin/GetAppsRequest.java b/src/main/java/com/kintone/client/api/plugin/GetAppsRequest.java new file mode 100644 index 0000000..e1071af --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/GetAppsRequest.java @@ -0,0 +1,17 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneRequest; +import lombok.Data; + +/** A request object for Get Apps API. */ +@Data +public class GetAppsRequest implements KintoneRequest { + /** The ID of the plug-in. */ + private String id; + + /** The maximum number of plug-ins to retrieve. */ + private Long limit; + + /** The number of plug-ins to skip from the list of plug-ins. */ + private Long offset; +} diff --git a/src/main/java/com/kintone/client/api/plugin/GetAppsResponseBody.java b/src/main/java/com/kintone/client/api/plugin/GetAppsResponseBody.java new file mode 100644 index 0000000..30a19d6 --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/GetAppsResponseBody.java @@ -0,0 +1,17 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneResponseBody; +import com.kintone.client.model.plugin.App; +import java.util.List; +import lombok.Value; + +/** A response object for Get Apps API. */ +@Value +public class GetAppsResponseBody implements KintoneResponseBody { + + /** + * A list of objects containing the App ID and name. Objects are listed in ascending order of + * their App IDs. + */ + private final List apps; +} diff --git a/src/main/java/com/kintone/client/api/plugin/GetInstalledPluginsRequest.java b/src/main/java/com/kintone/client/api/plugin/GetInstalledPluginsRequest.java new file mode 100644 index 0000000..470eb9d --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/GetInstalledPluginsRequest.java @@ -0,0 +1,15 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneRequest; +import lombok.Data; + +/** A request object for Get Installed Plugins API. */ +@Data +public class GetInstalledPluginsRequest implements KintoneRequest { + + /** The maximum number of plug-ins to retrieve. */ + private Long limit; + + /** The number of plug-ins to skip from the list of installed plug-ins. */ + private Long offset; +} diff --git a/src/main/java/com/kintone/client/api/plugin/GetInstalledPluginsResponseBody.java b/src/main/java/com/kintone/client/api/plugin/GetInstalledPluginsResponseBody.java new file mode 100644 index 0000000..1eccbf6 --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/GetInstalledPluginsResponseBody.java @@ -0,0 +1,14 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneResponseBody; +import com.kintone.client.model.plugin.Plugin; +import java.util.List; +import lombok.Value; + +/** A response object for Get Installed Plugins API. */ +@Value +public class GetInstalledPluginsResponseBody implements KintoneResponseBody { + + /** A list of Plug-ins added to the App. */ + private final List plugins; +} diff --git a/src/main/java/com/kintone/client/api/plugin/GetRequiredPluginsRequest.java b/src/main/java/com/kintone/client/api/plugin/GetRequiredPluginsRequest.java new file mode 100644 index 0000000..802308d --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/GetRequiredPluginsRequest.java @@ -0,0 +1,14 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneRequest; +import lombok.Data; + +/** A request object for Get Required Plug-ins API. */ +@Data +public class GetRequiredPluginsRequest implements KintoneRequest { + /** The maximum number of plug-ins to retrieve. */ + private Long limit; + + /** The number of plug-ins to skip from the list of plug-ins. */ + private Long offset; +} diff --git a/src/main/java/com/kintone/client/api/plugin/GetRequiredPluginsResponseBody.java b/src/main/java/com/kintone/client/api/plugin/GetRequiredPluginsResponseBody.java new file mode 100644 index 0000000..a01f972 --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/GetRequiredPluginsResponseBody.java @@ -0,0 +1,14 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneResponseBody; +import com.kintone.client.model.plugin.Plugin; +import java.util.List; +import lombok.Value; + +/** A response object for Get Required Plug-ins API. */ +@Value +public class GetRequiredPluginsResponseBody implements KintoneResponseBody { + + /** A list of Plug-ins that needs to be installed. */ + private final List plugins; +} diff --git a/src/main/java/com/kintone/client/api/plugin/InstallPluginRequest.java b/src/main/java/com/kintone/client/api/plugin/InstallPluginRequest.java new file mode 100644 index 0000000..c640a3c --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/InstallPluginRequest.java @@ -0,0 +1,17 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneRequest; +import java.nio.file.Path; +import lombok.Data; + +/** A request object for Install Plug-in API. */ +@Data +public class InstallPluginRequest implements KintoneRequest { + + /** + * The fileKey representing an uploaded file (required). Use {@link + * com.kintone.client.FileClient#uploadFile(Path, String)} to upload the file and retrieve the + * fileKey. + */ + private String fileKey; +} diff --git a/src/main/java/com/kintone/client/api/plugin/InstallPluginResponseBody.java b/src/main/java/com/kintone/client/api/plugin/InstallPluginResponseBody.java new file mode 100644 index 0000000..8c6b93a --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/InstallPluginResponseBody.java @@ -0,0 +1,15 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneResponseBody; +import lombok.Value; + +/** A response object for Install Plug-in API. */ +@Value +public class InstallPluginResponseBody implements KintoneResponseBody { + + /** The installed Plug-in ID. */ + private final String id; + + /** The version number of the Plug-in. */ + private final String version; +} diff --git a/src/main/java/com/kintone/client/api/plugin/UninstallPluginRequest.java b/src/main/java/com/kintone/client/api/plugin/UninstallPluginRequest.java new file mode 100644 index 0000000..f1a223b --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/UninstallPluginRequest.java @@ -0,0 +1,12 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneRequest; +import lombok.Data; + +/** A request object for Uninstall Plug-in API. */ +@Data +public class UninstallPluginRequest implements KintoneRequest { + + /** The ID of the Plug-in (required). */ + private String id; +} diff --git a/src/main/java/com/kintone/client/api/plugin/UninstallPluginResponseBody.java b/src/main/java/com/kintone/client/api/plugin/UninstallPluginResponseBody.java new file mode 100644 index 0000000..876cb53 --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/UninstallPluginResponseBody.java @@ -0,0 +1,8 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneResponseBody; +import lombok.Value; + +/** A response object for Uninstall Plug-in API. */ +@Value +public class UninstallPluginResponseBody implements KintoneResponseBody {} diff --git a/src/main/java/com/kintone/client/api/plugin/UpdatePluginRequest.java b/src/main/java/com/kintone/client/api/plugin/UpdatePluginRequest.java new file mode 100644 index 0000000..cea064a --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/UpdatePluginRequest.java @@ -0,0 +1,20 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneRequest; +import java.nio.file.Path; +import lombok.Data; + +/** A request object for Update Plug-in API. */ +@Data +public class UpdatePluginRequest implements KintoneRequest { + + /** The ID of the Plug-in to be updated (required). */ + private String id; + + /** + * The fileKey representing an uploaded file (required). Use {@link + * com.kintone.client.FileClient#uploadFile(Path, String)} to upload the file and retrieve the + * fileKey. + */ + private String fileKey; +} diff --git a/src/main/java/com/kintone/client/api/plugin/UpdatePluginResponseBody.java b/src/main/java/com/kintone/client/api/plugin/UpdatePluginResponseBody.java new file mode 100644 index 0000000..6ceaae4 --- /dev/null +++ b/src/main/java/com/kintone/client/api/plugin/UpdatePluginResponseBody.java @@ -0,0 +1,15 @@ +package com.kintone.client.api.plugin; + +import com.kintone.client.api.KintoneResponseBody; +import lombok.Value; + +/** A response object for Update Plug-in API. */ +@Value +public class UpdatePluginResponseBody implements KintoneResponseBody { + + /** The Plug-in ID of the updated Plug-in. */ + private final String id; + + /** The version number of the Plug-in. */ + private final String version; +} diff --git a/src/main/java/com/kintone/client/api/space/AddThreadRequest.java b/src/main/java/com/kintone/client/api/space/AddThreadRequest.java new file mode 100644 index 0000000..063d3df --- /dev/null +++ b/src/main/java/com/kintone/client/api/space/AddThreadRequest.java @@ -0,0 +1,15 @@ +package com.kintone.client.api.space; + +import com.kintone.client.api.KintoneRequest; +import lombok.Data; + +/** A request object for Add Thread API. */ +@Data +public class AddThreadRequest implements KintoneRequest { + + /** The Space ID (required). */ + private Long space; + + /** The name of the new Thread (required). */ + private String name; +} diff --git a/src/main/java/com/kintone/client/api/space/AddThreadResponseBody.java b/src/main/java/com/kintone/client/api/space/AddThreadResponseBody.java new file mode 100644 index 0000000..605a7a7 --- /dev/null +++ b/src/main/java/com/kintone/client/api/space/AddThreadResponseBody.java @@ -0,0 +1,12 @@ +package com.kintone.client.api.space; + +import com.kintone.client.api.KintoneResponseBody; +import lombok.Value; + +/** A response object for Add Thread API. */ +@Value +public class AddThreadResponseBody implements KintoneResponseBody { + + /** The Thread ID of the created Thread. */ + private final long id; +} diff --git a/src/main/java/com/kintone/client/api/space/UpdateSpaceRequest.java b/src/main/java/com/kintone/client/api/space/UpdateSpaceRequest.java new file mode 100644 index 0000000..0caf4c9 --- /dev/null +++ b/src/main/java/com/kintone/client/api/space/UpdateSpaceRequest.java @@ -0,0 +1,51 @@ +package com.kintone.client.api.space; + +import com.kintone.client.api.KintoneRequest; +import com.kintone.client.model.space.SpacePermissions; +import lombok.Data; + +/** A request object for Update Space API. */ +@Data +public class UpdateSpaceRequest implements KintoneRequest { + + /** The Space ID (required). */ + private Long id; + + /** The name of the Space (optional). */ + private String name; + + /** The "Private" settings of the Space (optional). */ + private Boolean isPrivate; + + /** + * The "Enable multiple threads." setting (optional). If this parameter is ignored or false + * is specified, this parameter will not be updated. + */ + private Boolean useMultiThread; + + /** + * The "Block users from joining or leaving the space and following or unfollowing the threads." + * setting (optional). + */ + private Boolean fixedMember; + + /** Whether the "Announcement" widget in the Space Portal page is shown (optional). */ + private Boolean showAnnouncement; + + /** Whether the "Apps" widget in the Space Portal page is shown (optional). */ + private Boolean showAppList; + + /** Whether the "People" widget in the Space Portal page is shown (optional). */ + private Boolean showMemberList; + + /** Whether the "Threads" widget in the Space Portal page is shown (optional). */ + private Boolean showThreadList; + + /** + * Whether the "Related Apps & Spaces" widget in the Space Portal page is shown (optional). + */ + private Boolean showRelatedLinkList; + + /** An object contains information of permissions of the Space (optional). */ + private SpacePermissions permissions; +} diff --git a/src/main/java/com/kintone/client/api/space/UpdateSpaceResponseBody.java b/src/main/java/com/kintone/client/api/space/UpdateSpaceResponseBody.java new file mode 100644 index 0000000..e64be26 --- /dev/null +++ b/src/main/java/com/kintone/client/api/space/UpdateSpaceResponseBody.java @@ -0,0 +1,6 @@ +package com.kintone.client.api.space; + +import com.kintone.client.api.KintoneResponseBody; + +/** A response object for Update Space API. */ +public class UpdateSpaceResponseBody implements KintoneResponseBody {} diff --git a/src/main/java/com/kintone/client/model/app/AppPlugin.java b/src/main/java/com/kintone/client/model/app/AppPlugin.java new file mode 100644 index 0000000..3bc750c --- /dev/null +++ b/src/main/java/com/kintone/client/model/app/AppPlugin.java @@ -0,0 +1,17 @@ +package com.kintone.client.model.app; + +import lombok.Value; + +/** An object containing the information of a Plug-in added to an App. */ +@Value +public class AppPlugin { + + /** The Plug-in ID. */ + private String id; + + /** The name of the Plug-in. */ + private String name; + + /** The status of the Plug-in. true for active Plug-in, and false for inactive Plug-in. */ + private boolean enabled; +} diff --git a/src/main/java/com/kintone/client/model/plugin/App.java b/src/main/java/com/kintone/client/model/plugin/App.java new file mode 100644 index 0000000..850b061 --- /dev/null +++ b/src/main/java/com/kintone/client/model/plugin/App.java @@ -0,0 +1,14 @@ +package com.kintone.client.model.plugin; + +import lombok.Value; + +/** General information of an App retrieved by Get Apps API. */ +@Value +public class App { + + /** The App ID. */ + private final long id; + + /** The name of the App. */ + private final String name; +} diff --git a/src/main/java/com/kintone/client/model/plugin/Plugin.java b/src/main/java/com/kintone/client/model/plugin/Plugin.java new file mode 100644 index 0000000..830210e --- /dev/null +++ b/src/main/java/com/kintone/client/model/plugin/Plugin.java @@ -0,0 +1,20 @@ +package com.kintone.client.model.plugin; + +import lombok.Value; + +/** General information of a Plugin retrieved by Get Plugins API. */ +@Value +public class Plugin { + + /** The Plugin ID. */ + private final String id; + + /** The name of the Plugin. */ + private final String name; + + /** States whether or not the plug-in is a Marketplace plug-in. */ + private final boolean isMarketPlugin; + + /** The version number of the plug-in. */ + private final String version; +} diff --git a/src/main/java/com/kintone/client/model/plugin/package-info.java b/src/main/java/com/kintone/client/model/plugin/package-info.java new file mode 100644 index 0000000..8cd846f --- /dev/null +++ b/src/main/java/com/kintone/client/model/plugin/package-info.java @@ -0,0 +1,2 @@ +/** Classes for values related to Plug-in operations. */ +package com.kintone.client.model.plugin; diff --git a/src/test/java/com/kintone/client/AppClientTest.java b/src/test/java/com/kintone/client/AppClientTest.java index 00b6484..a6bcc4d 100644 --- a/src/test/java/com/kintone/client/AppClientTest.java +++ b/src/test/java/com/kintone/client/AppClientTest.java @@ -3,106 +3,7 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.common.collect.Lists; -import com.kintone.client.api.app.AddAppRequest; -import com.kintone.client.api.app.AddAppResponseBody; -import com.kintone.client.api.app.AddFormFieldsRequest; -import com.kintone.client.api.app.AddFormFieldsResponseBody; -import com.kintone.client.api.app.DeleteFormFieldsRequest; -import com.kintone.client.api.app.DeleteFormFieldsResponseBody; -import com.kintone.client.api.app.DeployAppRequest; -import com.kintone.client.api.app.DeployAppResponseBody; -import com.kintone.client.api.app.EvaluateRecordAclRequest; -import com.kintone.client.api.app.EvaluateRecordAclResponseBody; -import com.kintone.client.api.app.GetAppAclPreviewRequest; -import com.kintone.client.api.app.GetAppAclPreviewResponseBody; -import com.kintone.client.api.app.GetAppAclRequest; -import com.kintone.client.api.app.GetAppAclResponseBody; -import com.kintone.client.api.app.GetAppActionsPreviewRequest; -import com.kintone.client.api.app.GetAppActionsPreviewResponseBody; -import com.kintone.client.api.app.GetAppActionsRequest; -import com.kintone.client.api.app.GetAppActionsResponseBody; -import com.kintone.client.api.app.GetAppCustomizePreviewRequest; -import com.kintone.client.api.app.GetAppCustomizePreviewResponseBody; -import com.kintone.client.api.app.GetAppCustomizeRequest; -import com.kintone.client.api.app.GetAppCustomizeResponseBody; -import com.kintone.client.api.app.GetAppRequest; -import com.kintone.client.api.app.GetAppResponseBody; -import com.kintone.client.api.app.GetAppSettingsPreviewRequest; -import com.kintone.client.api.app.GetAppSettingsPreviewResponseBody; -import com.kintone.client.api.app.GetAppSettingsRequest; -import com.kintone.client.api.app.GetAppSettingsResponseBody; -import com.kintone.client.api.app.GetAppsRequest; -import com.kintone.client.api.app.GetAppsResponseBody; -import com.kintone.client.api.app.GetDeployStatusRequest; -import com.kintone.client.api.app.GetDeployStatusResponseBody; -import com.kintone.client.api.app.GetFieldAclPreviewRequest; -import com.kintone.client.api.app.GetFieldAclPreviewResponseBody; -import com.kintone.client.api.app.GetFieldAclRequest; -import com.kintone.client.api.app.GetFieldAclResponseBody; -import com.kintone.client.api.app.GetFormFieldsPreviewRequest; -import com.kintone.client.api.app.GetFormFieldsPreviewResponseBody; -import com.kintone.client.api.app.GetFormFieldsRequest; -import com.kintone.client.api.app.GetFormFieldsResponseBody; -import com.kintone.client.api.app.GetFormLayoutPreviewRequest; -import com.kintone.client.api.app.GetFormLayoutPreviewResponseBody; -import com.kintone.client.api.app.GetFormLayoutRequest; -import com.kintone.client.api.app.GetFormLayoutResponseBody; -import com.kintone.client.api.app.GetGeneralNotificationsPreviewRequest; -import com.kintone.client.api.app.GetGeneralNotificationsPreviewResponseBody; -import com.kintone.client.api.app.GetGeneralNotificationsRequest; -import com.kintone.client.api.app.GetGeneralNotificationsResponseBody; -import com.kintone.client.api.app.GetPerRecordNotificationsPreviewRequest; -import com.kintone.client.api.app.GetPerRecordNotificationsPreviewResponseBody; -import com.kintone.client.api.app.GetPerRecordNotificationsRequest; -import com.kintone.client.api.app.GetPerRecordNotificationsResponseBody; -import com.kintone.client.api.app.GetProcessManagementPreviewRequest; -import com.kintone.client.api.app.GetProcessManagementPreviewResponseBody; -import com.kintone.client.api.app.GetProcessManagementRequest; -import com.kintone.client.api.app.GetProcessManagementResponseBody; -import com.kintone.client.api.app.GetRecordAclPreviewRequest; -import com.kintone.client.api.app.GetRecordAclPreviewResponseBody; -import com.kintone.client.api.app.GetRecordAclRequest; -import com.kintone.client.api.app.GetRecordAclResponseBody; -import com.kintone.client.api.app.GetReminderNotificationsPreviewRequest; -import com.kintone.client.api.app.GetReminderNotificationsPreviewResponseBody; -import com.kintone.client.api.app.GetReminderNotificationsRequest; -import com.kintone.client.api.app.GetReminderNotificationsResponseBody; -import com.kintone.client.api.app.GetReportsPreviewRequest; -import com.kintone.client.api.app.GetReportsPreviewResponseBody; -import com.kintone.client.api.app.GetReportsRequest; -import com.kintone.client.api.app.GetReportsResponseBody; -import com.kintone.client.api.app.GetViewsPreviewRequest; -import com.kintone.client.api.app.GetViewsPreviewResponseBody; -import com.kintone.client.api.app.GetViewsRequest; -import com.kintone.client.api.app.GetViewsResponseBody; -import com.kintone.client.api.app.UpdateAppAclRequest; -import com.kintone.client.api.app.UpdateAppAclResponseBody; -import com.kintone.client.api.app.UpdateAppActionsRequest; -import com.kintone.client.api.app.UpdateAppActionsResponseBody; -import com.kintone.client.api.app.UpdateAppCustomizeRequest; -import com.kintone.client.api.app.UpdateAppCustomizeResponseBody; -import com.kintone.client.api.app.UpdateAppSettingsRequest; -import com.kintone.client.api.app.UpdateAppSettingsResponseBody; -import com.kintone.client.api.app.UpdateFieldAclRequest; -import com.kintone.client.api.app.UpdateFieldAclResponseBody; -import com.kintone.client.api.app.UpdateFormFieldsRequest; -import com.kintone.client.api.app.UpdateFormFieldsResponseBody; -import com.kintone.client.api.app.UpdateFormLayoutRequest; -import com.kintone.client.api.app.UpdateFormLayoutResponseBody; -import com.kintone.client.api.app.UpdateGeneralNotificationsRequest; -import com.kintone.client.api.app.UpdateGeneralNotificationsResponseBody; -import com.kintone.client.api.app.UpdatePerRecordNotificationsRequest; -import com.kintone.client.api.app.UpdatePerRecordNotificationsResponseBody; -import com.kintone.client.api.app.UpdateProcessManagementRequest; -import com.kintone.client.api.app.UpdateProcessManagementResponseBody; -import com.kintone.client.api.app.UpdateRecordAclRequest; -import com.kintone.client.api.app.UpdateRecordAclResponseBody; -import com.kintone.client.api.app.UpdateReminderNotificationsRequest; -import com.kintone.client.api.app.UpdateReminderNotificationsResponseBody; -import com.kintone.client.api.app.UpdateReportsRequest; -import com.kintone.client.api.app.UpdateReportsResponseBody; -import com.kintone.client.api.app.UpdateViewsRequest; -import com.kintone.client.api.app.UpdateViewsResponseBody; +import com.kintone.client.api.app.*; import com.kintone.client.model.Entity; import com.kintone.client.model.EntityType; import com.kintone.client.model.User; @@ -110,6 +11,7 @@ import com.kintone.client.model.app.App; import com.kintone.client.model.app.AppAction; import com.kintone.client.model.app.AppDeployStatus; +import com.kintone.client.model.app.AppPlugin; import com.kintone.client.model.app.AppRightEntity; import com.kintone.client.model.app.CustomizeScope; import com.kintone.client.model.app.DeployApp; @@ -344,6 +246,32 @@ public void addFormFields_AddFormFieldsRequest() { assertThat(mockClient.getLastBody()).isEqualTo(req); } + @Test + public void addPlugins_long_List() { + mockClient.setResponseBody(new AddAppPluginsResponseBody(2)); + + assertThat(sut.addPlugins(1, Collections.singletonList("plugin1"))).isEqualTo(2); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.ADD_APP_PLUGINS); + assertThat(mockClient.getLastBody()) + .usingRecursiveComparison() + .isEqualTo( + new AddAppPluginsRequest() + .setApp(1L) + .setIds(Collections.singletonList("plugin1")) + .setRevision(null)); + } + + @Test + public void addPlugins_AddAppPluginsRequest() { + AddAppPluginsRequest req = new AddAppPluginsRequest(); + AddAppPluginsResponseBody resp = new AddAppPluginsResponseBody(1); + mockClient.setResponseBody(resp); + + assertThat(sut.addPlugins(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.ADD_APP_PLUGINS); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + @Test public void deleteFormFields_long_List() { mockClient.setResponseBody(new DeleteFormFieldsResponseBody(2)); @@ -462,6 +390,48 @@ public void evaluateRecordAcl_EvaluateRecordAclRequest() { assertThat(mockClient.getLastBody()).isEqualTo(req); } + @Test + public void getAdminNotes_long() { + GetAdminNotesResponseBody resp = new GetAdminNotesResponseBody("test", true, 1); + mockClient.setResponseBody(resp); + + assertThat(sut.getAdminNotes(1)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APP_ADMIN_NOTES); + assertThat(mockClient.getLastBody()).isEqualTo(new GetAdminNotesRequest().setApp(1L)); + } + + @Test + public void getAdminNotes_GetAdminNotesRequest() { + GetAdminNotesRequest req = new GetAdminNotesRequest(); + GetAdminNotesResponseBody resp = new GetAdminNotesResponseBody("test", true, 1); + mockClient.setResponseBody(resp); + + assertThat(sut.getAdminNotes(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APP_ADMIN_NOTES); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + + @Test + public void getAdminNotesPreview_long() { + GetAdminNotesPreviewResponseBody resp = new GetAdminNotesPreviewResponseBody("test", true, 1); + mockClient.setResponseBody(resp); + + assertThat(sut.getAdminNotesPreview(1)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APP_ADMIN_NOTES_PREVIEW); + assertThat(mockClient.getLastBody()).isEqualTo(new GetAdminNotesPreviewRequest().setApp(1L)); + } + + @Test + public void getAdminNotesPreview_GetAdminNotesPreviewRequest() { + GetAdminNotesPreviewRequest req = new GetAdminNotesPreviewRequest(); + GetAdminNotesPreviewResponseBody resp = new GetAdminNotesPreviewResponseBody("test", true, 1); + mockClient.setResponseBody(resp); + + assertThat(sut.getAdminNotesPreview(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APP_ADMIN_NOTES_PREVIEW); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + @Test public void getApp_long() { ZonedDateTime time = ZonedDateTime.of(2020, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC); @@ -1131,6 +1101,94 @@ public void getPerRecordNotificationsPreview_GetPerRecordNotificationsPreviewReq assertThat(mockClient.getLastBody()).isEqualTo(req); } + @Test + public void getPlugins_long() { + AppPlugin appPlugin = new AppPlugin("pluginId", "pluginName", true); + + GetAppPluginsResponseBody resp = + new GetAppPluginsResponseBody(Collections.singletonList(appPlugin), 1); + mockClient.setResponseBody(resp); + + assertThat(sut.getPlugins(10L)).containsExactly(appPlugin); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APP_PLUGINS); + assertThat(mockClient.getLastBody()) + .isEqualTo(new GetAppPluginsRequest().setApp(10L).setLang(null)); + } + + @Test + public void getPlugins_long_String() { + AppPlugin appPlugin = new AppPlugin("pluginId", "pluginName", true); + + GetAppPluginsResponseBody resp = + new GetAppPluginsResponseBody(Collections.singletonList(appPlugin), 1); + mockClient.setResponseBody(resp); + + assertThat(sut.getPlugins(10L, "en")).containsExactly(appPlugin); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APP_PLUGINS); + assertThat(mockClient.getLastBody()) + .isEqualTo(new GetAppPluginsRequest().setApp(10L).setLang("en")); + } + + @Test + public void getPlugins_GetPluginsRequest() { + GetAppPluginsRequest req = new GetAppPluginsRequest(); + req.setApp(10L); + req.setLang("en"); + + AppPlugin appPlugin = new AppPlugin("pluginId", "pluginName", true); + GetAppPluginsResponseBody resp = + new GetAppPluginsResponseBody(Collections.singletonList(appPlugin), 1); + mockClient.setResponseBody(resp); + + assertThat(sut.getPlugins(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APP_PLUGINS); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + + @Test + public void getPluginsPreview_long() { + AppPlugin appPlugin = new AppPlugin("pluginId", "pluginName", true); + + GetAppPluginsPreviewResponseBody resp = + new GetAppPluginsPreviewResponseBody(Collections.singletonList(appPlugin), 1); + mockClient.setResponseBody(resp); + + assertThat(sut.getPluginsPreview(10L)).containsExactly(appPlugin); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APP_PLUGINS_PREVIEW); + assertThat(mockClient.getLastBody()) + .isEqualTo(new GetAppPluginsPreviewRequest().setApp(10L).setLang(null)); + } + + @Test + public void getPluginsPreview_long_String() { + AppPlugin appPlugin = new AppPlugin("pluginId", "pluginName", true); + + GetAppPluginsPreviewResponseBody resp = + new GetAppPluginsPreviewResponseBody(Collections.singletonList(appPlugin), 1); + mockClient.setResponseBody(resp); + + assertThat(sut.getPluginsPreview(10L, "en")).containsExactly(appPlugin); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APP_PLUGINS_PREVIEW); + assertThat(mockClient.getLastBody()) + .isEqualTo(new GetAppPluginsPreviewRequest().setApp(10L).setLang("en")); + } + + @Test + public void getPlugins_GetPluginsPreviewRequest() { + GetAppPluginsPreviewRequest req = new GetAppPluginsPreviewRequest(); + req.setApp(10L); + req.setLang("en"); + + AppPlugin appPlugin = new AppPlugin("pluginId", "pluginName", true); + GetAppPluginsPreviewResponseBody resp = + new GetAppPluginsPreviewResponseBody(Collections.singletonList(appPlugin), 1); + mockClient.setResponseBody(resp); + + assertThat(sut.getPluginsPreview(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APP_PLUGINS_PREVIEW); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + @Test public void getProcessManagement_long() { GetProcessManagementResponseBody resp = @@ -1480,6 +1538,39 @@ public void getViewsPreview_GetViewsPreviewRequest() { assertThat(mockClient.getLastBody()).isEqualTo(req); } + @Test + public void moveToSpace_long_long() { + mockClient.setResponseBody(new MoveAppResponseBody()); + + sut.move(1, 2L); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.MOVE_APP_TO_SPACE); + assertThat(mockClient.getLastBody()) + .usingRecursiveComparison() + .isEqualTo(new MoveAppRequest().setApp(1L).setSpace(2L)); + } + + @Test + public void moveToSpace_long_null() { + mockClient.setResponseBody(new MoveAppResponseBody()); + + sut.move(1, null); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.MOVE_APP_TO_SPACE); + assertThat(mockClient.getLastBody()) + .usingRecursiveComparison() + .isEqualTo(new MoveAppRequest().setApp(1L).setSpace(null)); + } + + @Test + public void moveToSpace_MoveToSpaceRequest() { + MoveAppRequest req = new MoveAppRequest(); + MoveAppResponseBody resp = new MoveAppResponseBody(); + mockClient.setResponseBody(resp); + + assertThat(sut.move(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.MOVE_APP_TO_SPACE); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + @Test public void revertApp_long() { mockClient.setResponseBody(new DeployAppResponseBody()); @@ -1508,6 +1599,17 @@ public void revertApp_long_Long() { .setRevert(true)); } + @Test + public void updateAdminNotes_UpdateAdminNotesRequest() { + UpdateAdminNotesRequest req = new UpdateAdminNotesRequest(); + UpdateAdminNotesResponseBody resp = new UpdateAdminNotesResponseBody(1); + mockClient.setResponseBody(resp); + + assertThat(sut.updateAdminNotes(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.UPDATE_APP_ADMIN_NOTES); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + @Test public void updateAppAcl_long_List() { mockClient.setResponseBody(new UpdateAppAclResponseBody(2)); diff --git a/src/test/java/com/kintone/client/PluginClientTest.java b/src/test/java/com/kintone/client/PluginClientTest.java new file mode 100644 index 0000000..9458e06 --- /dev/null +++ b/src/test/java/com/kintone/client/PluginClientTest.java @@ -0,0 +1,199 @@ +package com.kintone.client; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.kintone.client.api.plugin.*; +import com.kintone.client.model.plugin.App; +import com.kintone.client.model.plugin.Plugin; +import java.util.Collections; +import java.util.List; +import org.junit.jupiter.api.Test; + +public class PluginClientTest { + + private InternalClientMock mockClient = new InternalClientMock(); + private PluginClient sut = new PluginClient(mockClient, Collections.emptyList()); + + @Test + public void getInstalledPlugins() { + List plugins = Collections.emptyList(); + GetInstalledPluginsResponseBody resp = new GetInstalledPluginsResponseBody(plugins); + mockClient.setResponseBody(resp); + + assertThat(sut.getInstalledPlugins()).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_PLUGINS); + assertThat(mockClient.getLastBody()).isEqualTo(new GetInstalledPluginsRequest()); + } + + @Test + public void getInstalledPlugins_Long() { + List plugins = Collections.emptyList(); + GetInstalledPluginsResponseBody resp = new GetInstalledPluginsResponseBody(plugins); + mockClient.setResponseBody(resp); + + assertThat(sut.getInstalledPlugins(0L, 100L)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_PLUGINS); + assertThat(mockClient.getLastBody()) + .isEqualTo(new GetInstalledPluginsRequest().setOffset(0L).setLimit(100L)); + } + + @Test + public void getInstalledPlugins_Request() { + GetInstalledPluginsRequest req = new GetInstalledPluginsRequest(); + req.setOffset(5L); + req.setLimit(50L); + List plugins = Collections.emptyList(); + GetInstalledPluginsResponseBody resp = new GetInstalledPluginsResponseBody(plugins); + mockClient.setResponseBody(resp); + + assertThat(sut.getInstalledPlugins(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_PLUGINS); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + + @Test + public void installPlugin_String() { + InstallPluginResponseBody resp = new InstallPluginResponseBody("1", "2"); + mockClient.setResponseBody(resp); + + assertThat(sut.installPlugin("fileKey")).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.INSTALL_PLUGIN); + assertThat(mockClient.getLastBody()) + .isEqualTo(new InstallPluginRequest().setFileKey("fileKey")); + } + + @Test + public void installPlugin_Request() { + InstallPluginRequest req = new InstallPluginRequest(); + req.setFileKey("fileKey"); + InstallPluginResponseBody resp = new InstallPluginResponseBody("1", "2"); + mockClient.setResponseBody(resp); + + assertThat(sut.installPlugin(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.INSTALL_PLUGIN); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + + @Test + public void updatePlugin_String_String() { + UpdatePluginResponseBody resp = new UpdatePluginResponseBody("1", "2"); + mockClient.setResponseBody(resp); + + assertThat(sut.updatePlugin("id", "fileKey")).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.UPDATE_PLUGIN); + assertThat(mockClient.getLastBody()) + .isEqualTo(new UpdatePluginRequest().setId("id").setFileKey("fileKey")); + } + + @Test + public void updatePlugin_Request() { + UpdatePluginRequest req = new UpdatePluginRequest(); + req.setId("id"); + req.setFileKey("fileKey"); + UpdatePluginResponseBody resp = new UpdatePluginResponseBody("1", "2"); + mockClient.setResponseBody(resp); + + assertThat(sut.updatePlugin(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.UPDATE_PLUGIN); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + + @Test + public void uninstallPlugin_String() { + mockClient.setResponseBody(new UninstallPluginResponseBody()); + + sut.uninstallPlugin("id"); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.UNINSTALL_PLUGIN); + assertThat(mockClient.getLastBody()).isEqualTo(new UninstallPluginRequest().setId("id")); + } + + @Test + public void uninstallPlugin_Request() { + UninstallPluginRequest req = new UninstallPluginRequest(); + req.setId("id"); + UninstallPluginResponseBody resp = new UninstallPluginResponseBody(); + mockClient.setResponseBody(resp); + + assertThat(sut.uninstallPlugin(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.UNINSTALL_PLUGIN); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + + @Test + public void getApps() { + List apps = Collections.emptyList(); + GetAppsResponseBody resp = new GetAppsResponseBody(apps); + mockClient.setResponseBody(resp); + + assertThat(sut.getApps("123")).isEqualTo(apps); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APPS_PLUGIN_ADDED); + assertThat(mockClient.getLastBody()).isEqualTo(new GetAppsRequest().setId("123")); + } + + @Test + public void getApps_Long() { + List apps = Collections.emptyList(); + GetAppsResponseBody resp = new GetAppsResponseBody(apps); + mockClient.setResponseBody(resp); + + assertThat(sut.getApps("123", 0L, 100L)).isEqualTo(apps); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APPS_PLUGIN_ADDED); + assertThat(mockClient.getLastBody()) + .isEqualTo(new GetAppsRequest().setId("123").setOffset(0L).setLimit(100L)); + } + + @Test + public void getApps_Request() { + GetAppsRequest req = new GetAppsRequest(); + req.setId("123"); + req.setOffset(5L); + req.setLimit(50L); + List apps = Collections.emptyList(); + GetAppsResponseBody resp = new GetAppsResponseBody(apps); + mockClient.setResponseBody(resp); + + assertThat(sut.getApps(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_APPS_PLUGIN_ADDED); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + + @Test + public void getRequiredPlugins() { + GetRequiredPluginsRequest req = new GetRequiredPluginsRequest(); + List plugins = Collections.emptyList(); + GetRequiredPluginsResponseBody resp = new GetRequiredPluginsResponseBody(plugins); + mockClient.setResponseBody(resp); + + assertThat(sut.getRequiredPlugins()).isEqualTo(plugins); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_REQUIRED_PLUGINS); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + + @Test + public void getRequiredPlugins_Long() { + GetRequiredPluginsRequest req = new GetRequiredPluginsRequest(); + req.setOffset(0L); + req.setLimit(100L); + List plugins = Collections.emptyList(); + GetRequiredPluginsResponseBody resp = new GetRequiredPluginsResponseBody(plugins); + mockClient.setResponseBody(resp); + + assertThat(sut.getRequiredPlugins(0L, 100L)).isEqualTo(plugins); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_REQUIRED_PLUGINS); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + + @Test + public void getRequiredPlugins_Request() { + GetRequiredPluginsRequest req = new GetRequiredPluginsRequest(); + req.setOffset(5L); + req.setLimit(50L); + List plugins = Collections.emptyList(); + GetRequiredPluginsResponseBody resp = new GetRequiredPluginsResponseBody(plugins); + mockClient.setResponseBody(resp); + + assertThat(sut.getRequiredPlugins(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.GET_REQUIRED_PLUGINS); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } +} diff --git a/src/test/java/com/kintone/client/SpaceClientTest.java b/src/test/java/com/kintone/client/SpaceClientTest.java index 77df125..d153e5a 100644 --- a/src/test/java/com/kintone/client/SpaceClientTest.java +++ b/src/test/java/com/kintone/client/SpaceClientTest.java @@ -8,6 +8,8 @@ import com.kintone.client.api.space.AddSpaceFromTemplateResponseBody; import com.kintone.client.api.space.AddThreadCommentRequest; import com.kintone.client.api.space.AddThreadCommentResponseBody; +import com.kintone.client.api.space.AddThreadRequest; +import com.kintone.client.api.space.AddThreadResponseBody; import com.kintone.client.api.space.DeleteGuestsRequest; import com.kintone.client.api.space.DeleteGuestsResponseBody; import com.kintone.client.api.space.DeleteSpaceRequest; @@ -22,6 +24,8 @@ import com.kintone.client.api.space.UpdateSpaceGuestsResponseBody; import com.kintone.client.api.space.UpdateSpaceMembersRequest; import com.kintone.client.api.space.UpdateSpaceMembersResponseBody; +import com.kintone.client.api.space.UpdateSpaceRequest; +import com.kintone.client.api.space.UpdateSpaceResponseBody; import com.kintone.client.api.space.UpdateThreadRequest; import com.kintone.client.api.space.UpdateThreadResponseBody; import com.kintone.client.model.Entity; @@ -77,6 +81,27 @@ public void addSpaceFromTemplate_AddSpaceFromTemplateRequest() { assertThat(mockClient.getLastBody()).isEqualTo(req); } + @Test + public void addThread_long_String() { + mockClient.setResponseBody(new AddThreadResponseBody(1)); + + assertThat(sut.addThread(1, "name")).isEqualTo(1); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.ADD_THREAD); + assertThat(mockClient.getLastBody()) + .isEqualTo(new AddThreadRequest().setSpace(1L).setName("name")); + } + + @Test + public void addThread_AddThreadRequest() { + AddThreadRequest req = new AddThreadRequest(); + AddThreadResponseBody resp = new AddThreadResponseBody(1); + mockClient.setResponseBody(resp); + + assertThat(sut.addThread(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.ADD_THREAD); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + @Test public void addThreadComment_long_long_ThreadComment() { mockClient.setResponseBody(new AddThreadCommentResponseBody(3)); @@ -235,6 +260,17 @@ public void getSpaceMembers_GetSpaceMembersRequest() { assertThat(mockClient.getLastBody()).isEqualTo(req); } + @Test + public void updateSpace_UpdateSpaceRequest() { + UpdateSpaceRequest req = new UpdateSpaceRequest(); + UpdateSpaceResponseBody resp = new UpdateSpaceResponseBody(); + mockClient.setResponseBody(resp); + + assertThat(sut.updateSpace(req)).isEqualTo(resp); + assertThat(mockClient.getLastApi()).isEqualTo(KintoneApi.UPDATE_SPACE); + assertThat(mockClient.getLastBody()).isEqualTo(req); + } + @Test public void updateSpaceBody_long_String() { mockClient.setResponseBody(new UpdateSpaceBodyResponseBody());