From d08bb33043082357c8907f7856f2b2b4d3ea7abb Mon Sep 17 00:00:00 2001 From: neeleshmalpani Date: Sat, 19 Aug 2023 22:53:08 +0530 Subject: [PATCH] Added Notifications APIs|| Refactored Class and Role names --- .../client/notifications/NotificationsApi.java | 14 ++++++-------- ...NotificationRequestToOrganizationMembers.java | 4 ---- .../NotificationRequestToProjectMember.java | 4 ---- ...dNotificationToAuthenticatedUserRequest.java} | 2 +- ...ationToOrganizationMembersByRoleRequest.java} | 2 +- ...onToOrganizationMembersByUserIdsRequest.java} | 2 +- ...NotificationToOrganizationMembersRequest.java | 4 ++++ ...otificationToProjectMemberByRoleRequest.java} | 2 +- ...ficationToProjectMemberByUserIdsRequest.java} | 2 +- .../SendNotificationToProjectMemberRequest.java | 4 ++++ .../notifications/NotificationsApiTest.java | 16 ++++++---------- ...cationRequestToOrganizationMembersByRole.json | 2 +- ...otificationRequestToProjectMembersByRole.json | 2 +- 13 files changed, 27 insertions(+), 33 deletions(-) delete mode 100644 src/main/java/com/crowdin/client/notifications/model/NotificationRequestToOrganizationMembers.java delete mode 100644 src/main/java/com/crowdin/client/notifications/model/NotificationRequestToProjectMember.java rename src/main/java/com/crowdin/client/notifications/model/{NotificationRequestToAuthenticatedUsers.java => SendNotificationToAuthenticatedUserRequest.java} (64%) rename src/main/java/com/crowdin/client/notifications/model/{NotificationRequestToOrganizationMembersByRole.java => SendNotificationToOrganizationMembersByRoleRequest.java} (52%) rename src/main/java/com/crowdin/client/notifications/model/{NotificationRequestToOrganizationMembersByUserIds.java => SendNotificationToOrganizationMembersByUserIdsRequest.java} (57%) create mode 100644 src/main/java/com/crowdin/client/notifications/model/SendNotificationToOrganizationMembersRequest.java rename src/main/java/com/crowdin/client/notifications/model/{NotificationRequestToProjectMemberByRole.java => SendNotificationToProjectMemberByRoleRequest.java} (55%) rename src/main/java/com/crowdin/client/notifications/model/{NotificationRequestToProjectMemberByUserIds.java => SendNotificationToProjectMemberByUserIdsRequest.java} (59%) create mode 100644 src/main/java/com/crowdin/client/notifications/model/SendNotificationToProjectMemberRequest.java diff --git a/src/main/java/com/crowdin/client/notifications/NotificationsApi.java b/src/main/java/com/crowdin/client/notifications/NotificationsApi.java index e23b72584..812ed60da 100644 --- a/src/main/java/com/crowdin/client/notifications/NotificationsApi.java +++ b/src/main/java/com/crowdin/client/notifications/NotificationsApi.java @@ -6,9 +6,9 @@ import com.crowdin.client.core.http.exceptions.HttpException; import com.crowdin.client.core.model.ClientConfig; import com.crowdin.client.core.model.Credentials; -import com.crowdin.client.notifications.model.NotificationRequestToAuthenticatedUsers; -import com.crowdin.client.notifications.model.NotificationRequestToOrganizationMembers; -import com.crowdin.client.notifications.model.NotificationRequestToProjectMember; +import com.crowdin.client.notifications.model.SendNotificationToAuthenticatedUserRequest; +import com.crowdin.client.notifications.model.SendNotificationToOrganizationMembersRequest; +import com.crowdin.client.notifications.model.SendNotificationToProjectMemberRequest; public class NotificationsApi extends CrowdinApi { public NotificationsApi(Credentials credentials) { @@ -23,10 +23,9 @@ public NotificationsApi(Credentials credentials, ClientConfig clientConfig) { * @param request request object * @see */ - public void sendNotificationToAuthenticatedUser(NotificationRequestToAuthenticatedUsers request) throws HttpException, HttpBadRequestException { + public void sendNotificationToAuthenticatedUser(SendNotificationToAuthenticatedUserRequest request) throws HttpException, HttpBadRequestException { String builtUrl = String.format("%s/notify", this.url); this.httpClient.post(builtUrl, request, new HttpRequestConfig(), Void.class); } @@ -39,7 +38,7 @@ public void sendNotificationToAuthenticatedUser(NotificationRequestToAuthenticat *
  • Enterprise API Documentation
  • * */ - public void sendNotificationToProjectMembers(Long projectId, NotificationRequestToProjectMember request) throws HttpException, HttpBadRequestException { + public void sendNotificationToProjectMembers(Long projectId, SendNotificationToProjectMemberRequest request) throws HttpException, HttpBadRequestException { String builtUrl = String.format("%s/projects/%d/notify", this.url, projectId); this.httpClient.post(builtUrl, request, new HttpRequestConfig(), Void.class); } @@ -47,11 +46,10 @@ public void sendNotificationToProjectMembers(Long projectId, NotificationRequest /** * @param request request object * @see */ - public void sendNotificationToOrganizationMembers(NotificationRequestToOrganizationMembers request) throws HttpException, HttpBadRequestException { + public void sendNotificationToOrganizationMembers(SendNotificationToOrganizationMembersRequest request) throws HttpException, HttpBadRequestException { String builtUrl = String.format("%s/notify", this.url); this.httpClient.post(builtUrl, request, new HttpRequestConfig(), Void.class); } diff --git a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToOrganizationMembers.java b/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToOrganizationMembers.java deleted file mode 100644 index fcc8948f8..000000000 --- a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToOrganizationMembers.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.crowdin.client.notifications.model; - -public abstract class NotificationRequestToOrganizationMembers { -} diff --git a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToProjectMember.java b/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToProjectMember.java deleted file mode 100644 index a0e85068d..000000000 --- a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToProjectMember.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.crowdin.client.notifications.model; - -public abstract class NotificationRequestToProjectMember { -} diff --git a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToAuthenticatedUsers.java b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToAuthenticatedUserRequest.java similarity index 64% rename from src/main/java/com/crowdin/client/notifications/model/NotificationRequestToAuthenticatedUsers.java rename to src/main/java/com/crowdin/client/notifications/model/SendNotificationToAuthenticatedUserRequest.java index b1adbc6ec..3d84ea07f 100644 --- a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToAuthenticatedUsers.java +++ b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToAuthenticatedUserRequest.java @@ -3,6 +3,6 @@ import lombok.Data; @Data -public class NotificationRequestToAuthenticatedUsers { +public class SendNotificationToAuthenticatedUserRequest { private String message; } diff --git a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToOrganizationMembersByRole.java b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToOrganizationMembersByRoleRequest.java similarity index 52% rename from src/main/java/com/crowdin/client/notifications/model/NotificationRequestToOrganizationMembersByRole.java rename to src/main/java/com/crowdin/client/notifications/model/SendNotificationToOrganizationMembersByRoleRequest.java index 1b1a32d6c..042ee3ba1 100644 --- a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToOrganizationMembersByRole.java +++ b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToOrganizationMembersByRoleRequest.java @@ -3,7 +3,7 @@ import lombok.Data; @Data -public class NotificationRequestToOrganizationMembersByRole extends NotificationRequestToOrganizationMembers{ +public class SendNotificationToOrganizationMembersByRoleRequest extends SendNotificationToOrganizationMembersRequest { private String role; private String message; } diff --git a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToOrganizationMembersByUserIds.java b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToOrganizationMembersByUserIdsRequest.java similarity index 57% rename from src/main/java/com/crowdin/client/notifications/model/NotificationRequestToOrganizationMembersByUserIds.java rename to src/main/java/com/crowdin/client/notifications/model/SendNotificationToOrganizationMembersByUserIdsRequest.java index ccc255c24..83c20e575 100644 --- a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToOrganizationMembersByUserIds.java +++ b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToOrganizationMembersByUserIdsRequest.java @@ -5,7 +5,7 @@ import java.util.List; @Data -public class NotificationRequestToOrganizationMembersByUserIds extends NotificationRequestToOrganizationMembers{ +public class SendNotificationToOrganizationMembersByUserIdsRequest extends SendNotificationToOrganizationMembersRequest { private List userIds; private String message; } diff --git a/src/main/java/com/crowdin/client/notifications/model/SendNotificationToOrganizationMembersRequest.java b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToOrganizationMembersRequest.java new file mode 100644 index 000000000..9c0eae696 --- /dev/null +++ b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToOrganizationMembersRequest.java @@ -0,0 +1,4 @@ +package com.crowdin.client.notifications.model; + +public abstract class SendNotificationToOrganizationMembersRequest { +} diff --git a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToProjectMemberByRole.java b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToProjectMemberByRoleRequest.java similarity index 55% rename from src/main/java/com/crowdin/client/notifications/model/NotificationRequestToProjectMemberByRole.java rename to src/main/java/com/crowdin/client/notifications/model/SendNotificationToProjectMemberByRoleRequest.java index 5e50707f0..33bb36c0d 100644 --- a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToProjectMemberByRole.java +++ b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToProjectMemberByRoleRequest.java @@ -3,7 +3,7 @@ import lombok.Data; @Data -public class NotificationRequestToProjectMemberByRole extends NotificationRequestToProjectMember { +public class SendNotificationToProjectMemberByRoleRequest extends SendNotificationToProjectMemberRequest { private String role; private String message; } diff --git a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToProjectMemberByUserIds.java b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToProjectMemberByUserIdsRequest.java similarity index 59% rename from src/main/java/com/crowdin/client/notifications/model/NotificationRequestToProjectMemberByUserIds.java rename to src/main/java/com/crowdin/client/notifications/model/SendNotificationToProjectMemberByUserIdsRequest.java index 48017b638..4aed96125 100644 --- a/src/main/java/com/crowdin/client/notifications/model/NotificationRequestToProjectMemberByUserIds.java +++ b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToProjectMemberByUserIdsRequest.java @@ -5,7 +5,7 @@ import java.util.List; @Data -public class NotificationRequestToProjectMemberByUserIds extends NotificationRequestToProjectMember { +public class SendNotificationToProjectMemberByUserIdsRequest extends SendNotificationToProjectMemberRequest { private List userIds; private String message; } diff --git a/src/main/java/com/crowdin/client/notifications/model/SendNotificationToProjectMemberRequest.java b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToProjectMemberRequest.java new file mode 100644 index 000000000..0bf8958f9 --- /dev/null +++ b/src/main/java/com/crowdin/client/notifications/model/SendNotificationToProjectMemberRequest.java @@ -0,0 +1,4 @@ +package com.crowdin.client.notifications.model; + +public abstract class SendNotificationToProjectMemberRequest { +} diff --git a/src/test/java/com/crowdin/client/notifications/NotificationsApiTest.java b/src/test/java/com/crowdin/client/notifications/NotificationsApiTest.java index ee39e9dcb..b29e3fa98 100644 --- a/src/test/java/com/crowdin/client/notifications/NotificationsApiTest.java +++ b/src/test/java/com/crowdin/client/notifications/NotificationsApiTest.java @@ -2,13 +2,9 @@ import com.crowdin.client.framework.RequestMock; import com.crowdin.client.framework.TestClient; -import com.crowdin.client.notifications.model.NotificationRequestToAuthenticatedUsers; -import com.crowdin.client.notifications.model.NotificationRequestToOrganizationMembers; -import com.crowdin.client.notifications.model.NotificationRequestToOrganizationMembersByRole; -import com.crowdin.client.notifications.model.NotificationRequestToOrganizationMembersByUserIds; -import com.crowdin.client.notifications.model.NotificationRequestToProjectMember; -import com.crowdin.client.notifications.model.NotificationRequestToProjectMemberByRole; -import com.crowdin.client.notifications.model.NotificationRequestToProjectMemberByUserIds; +import com.crowdin.client.notifications.model.SendNotificationToAuthenticatedUserRequest; +import com.crowdin.client.notifications.model.SendNotificationToProjectMemberRequest; +import com.crowdin.client.notifications.model.SendNotificationToProjectMemberByRoleRequest; import org.apache.http.client.methods.HttpPost; import org.junit.jupiter.api.Test; @@ -29,7 +25,7 @@ public List getMocks() { @Test public void sendNotificationToAuthenticatedUserTest(){ - NotificationRequestToAuthenticatedUsers request = new NotificationRequestToAuthenticatedUsers(){{ + SendNotificationToAuthenticatedUserRequest request = new SendNotificationToAuthenticatedUserRequest(){{ setMessage("Hiii..."); }}; this.getNotificationsApi().sendNotificationToAuthenticatedUser(request); @@ -38,8 +34,8 @@ public void sendNotificationToAuthenticatedUserTest(){ @Test public void sendNotificationToProjectMembersByRole(){ - NotificationRequestToProjectMember request = new NotificationRequestToProjectMemberByRole(){{ - setRole("Admin"); + SendNotificationToProjectMemberRequest request = new SendNotificationToProjectMemberByRoleRequest(){{ + setRole("owner"); setMessage("Hiii..."); }}; this.getNotificationsApi().sendNotificationToProjectMembers(projectId,request); diff --git a/src/test/resources/api/notifications/notificationRequestToOrganizationMembersByRole.json b/src/test/resources/api/notifications/notificationRequestToOrganizationMembersByRole.json index 200b486ab..2387beedf 100644 --- a/src/test/resources/api/notifications/notificationRequestToOrganizationMembersByRole.json +++ b/src/test/resources/api/notifications/notificationRequestToOrganizationMembersByRole.json @@ -1,4 +1,4 @@ { - "role": "Admin", + "role": "owner", "message": "New notification message to Admin" } \ No newline at end of file diff --git a/src/test/resources/api/notifications/notificationRequestToProjectMembersByRole.json b/src/test/resources/api/notifications/notificationRequestToProjectMembersByRole.json index 039b7f699..684072def 100644 --- a/src/test/resources/api/notifications/notificationRequestToProjectMembersByRole.json +++ b/src/test/resources/api/notifications/notificationRequestToProjectMembersByRole.json @@ -1,4 +1,4 @@ { - "role": "Admin", + "role": "owner", "message": "Hiii..." } \ No newline at end of file