From e160358326cf57d7f706fc0603f3c4faf7eb4526 Mon Sep 17 00:00:00 2001 From: MayorJay Date: Sun, 11 Feb 2024 01:07:08 +0000 Subject: [PATCH 1/4] feat: Fix bug in Workflow Override API --- .../java/co/novu/api/common/PreferenceSettings.java | 4 +++- .../api/workflowoverrides/WorkflowOverrideApi.java | 3 --- .../workflowoverrides/WorkflowOverrideHandler.java | 2 -- .../request/UpdateWorkflowOverrideRequest.java | 2 +- .../WorkflowOverrideHandlerTest.java | 4 ++-- .../co/novu/api/workflows/WorkflowHandlerTest.java | 12 ++++++------ 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/main/java/co/novu/api/common/PreferenceSettings.java b/src/main/java/co/novu/api/common/PreferenceSettings.java index b9255a7..5696d6a 100644 --- a/src/main/java/co/novu/api/common/PreferenceSettings.java +++ b/src/main/java/co/novu/api/common/PreferenceSettings.java @@ -1,12 +1,14 @@ package co.novu.api.common; +import com.google.gson.annotations.SerializedName; import lombok.Data; @Data public class PreferenceSettings { private Boolean email; private Boolean sms; - private Boolean in_app; + @SerializedName("in_app") + private Boolean inApp; private Boolean chat; private Boolean push; } \ No newline at end of file diff --git a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java index 2c64438..46571b5 100644 --- a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java +++ b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java @@ -1,10 +1,7 @@ package co.novu.api.workflowoverrides; -import co.novu.api.workflowoverrides.pojos.WorkflowOverride; - import co.novu.api.workflowoverrides.request.CreateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.UpdateWorkflowOverrideRequest; -import co.novu.api.workflowoverrides.response.BulkWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.DeleteWorkflowOverrideResponse; import co.novu.api.workflowoverrides.response.GetWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.WorkflowOverrideResponse; diff --git a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java index 56c51be..8ac123c 100644 --- a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java +++ b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java @@ -1,10 +1,8 @@ package co.novu.api.workflowoverrides; -import co.novu.api.workflowoverrides.pojos.WorkflowOverride; import co.novu.api.workflowoverrides.request.CreateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.GetWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.UpdateWorkflowOverrideRequest; -import co.novu.api.workflowoverrides.response.BulkWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.DeleteWorkflowOverrideResponse; import co.novu.api.workflowoverrides.response.GetWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.WorkflowOverrideResponse; diff --git a/src/main/java/co/novu/api/workflowoverrides/request/UpdateWorkflowOverrideRequest.java b/src/main/java/co/novu/api/workflowoverrides/request/UpdateWorkflowOverrideRequest.java index e5ddde1..6956417 100644 --- a/src/main/java/co/novu/api/workflowoverrides/request/UpdateWorkflowOverrideRequest.java +++ b/src/main/java/co/novu/api/workflowoverrides/request/UpdateWorkflowOverrideRequest.java @@ -7,5 +7,5 @@ @Data public class UpdateWorkflowOverrideRequest { private Boolean active; - private PreferenceSettings data; + private PreferenceSettings preferenceSettings; } diff --git a/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java b/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java index 54db60f..fd0352a 100644 --- a/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java +++ b/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java @@ -136,7 +136,7 @@ private PreferenceSettings getPreferenceSettings() { preferenceSettings.setSms(true); preferenceSettings.setPush(true); preferenceSettings.setEmail(true); - preferenceSettings.setIn_app(true); + preferenceSettings.setInApp(true); return preferenceSettings; } @@ -180,7 +180,7 @@ private GetWorkflowOverridesResponse getWorkflowOverridesResponse() { private UpdateWorkflowOverrideRequest getUpdateWorkflowOverrideRequest() { UpdateWorkflowOverrideRequest updateWorkflowOverrideRequest = new UpdateWorkflowOverrideRequest(); updateWorkflowOverrideRequest.setActive(true); - updateWorkflowOverrideRequest.setData(getPreferenceSettings()); + updateWorkflowOverrideRequest.setPreferenceSettings(getPreferenceSettings()); return updateWorkflowOverrideRequest; } diff --git a/src/test/java/co/novu/api/workflows/WorkflowHandlerTest.java b/src/test/java/co/novu/api/workflows/WorkflowHandlerTest.java index 7c5d0be..e66e7f3 100644 --- a/src/test/java/co/novu/api/workflows/WorkflowHandlerTest.java +++ b/src/test/java/co/novu/api/workflows/WorkflowHandlerTest.java @@ -67,7 +67,7 @@ public void test_createWorkflow() throws IOException, NovuNetworkException, Inte PreferenceSettings preferenceSettings = new PreferenceSettings(); preferenceSettings.setEmail(true); preferenceSettings.setSms(true); - preferenceSettings.setIn_app(true); + preferenceSettings.setInApp(true); preferenceSettings.setPush(true); preferenceSettings.setChat(true); workflowRequest.setPreferenceSettings(preferenceSettings); @@ -94,7 +94,7 @@ public void test_createWorkflow() throws IOException, NovuNetworkException, Inte PreferenceSettings preferenceSettings1 = new PreferenceSettings(); preferenceSettings1.setEmail(true); preferenceSettings1.setSms(true); - preferenceSettings1.setIn_app(true); + preferenceSettings1.setInApp(true); preferenceSettings1.setPush(true); preferenceSettings1.setChat(true); data.setPreferenceSettings(preferenceSettings1); @@ -140,7 +140,7 @@ public void test_updateWorkflow() throws IOException, NovuNetworkException, Inte PreferenceSettings preferenceSettings = new PreferenceSettings(); preferenceSettings.setEmail(true); preferenceSettings.setSms(true); - preferenceSettings.setIn_app(true); + preferenceSettings.setInApp(true); preferenceSettings.setPush(true); preferenceSettings.setChat(true); workflowRequest.setPreferenceSettings(preferenceSettings); @@ -165,7 +165,7 @@ public void test_updateWorkflow() throws IOException, NovuNetworkException, Inte PreferenceSettings preferenceSettings1 = new PreferenceSettings(); preferenceSettings1.setEmail(true); preferenceSettings1.setSms(true); - preferenceSettings1.setIn_app(true); + preferenceSettings1.setInApp(true); preferenceSettings1.setPush(true); preferenceSettings1.setChat(true); data.setPreferenceSettings(preferenceSettings1); @@ -229,7 +229,7 @@ public void test_getWorkflow() throws IOException, NovuNetworkException, Interru PreferenceSettings preferenceSettings1 = new PreferenceSettings(); preferenceSettings1.setEmail(true); preferenceSettings1.setSms(true); - preferenceSettings1.setIn_app(true); + preferenceSettings1.setInApp(true); preferenceSettings1.setPush(true); preferenceSettings1.setChat(true); data.setPreferenceSettings(preferenceSettings1); @@ -277,7 +277,7 @@ public void test_updateWorkflowStatus() throws IOException, NovuNetworkException PreferenceSettings preferenceSettings1 = new PreferenceSettings(); preferenceSettings1.setEmail(true); preferenceSettings1.setSms(true); - preferenceSettings1.setIn_app(true); + preferenceSettings1.setInApp(true); preferenceSettings1.setPush(true); preferenceSettings1.setChat(true); data.setPreferenceSettings(preferenceSettings1); From f1204f0084e6e543d78cf9fb1c25ee73f554a924 Mon Sep 17 00:00:00 2001 From: MayorJay Date: Sun, 11 Feb 2024 01:23:26 +0000 Subject: [PATCH 2/4] feat: Modify fields signature --- .../novu/api/blueprints/pojos/Blueprint.java | 1 + .../co/novu/api/blueprints/pojos/Filters.java | 5 +++- .../co/novu/api/blueprints/pojos/General.java | 1 + .../co/novu/api/blueprints/pojos/Popular.java | 1 + .../novu/api/blueprints/pojos/Template.java | 23 +++++++++++++------ .../co/novu/api/blueprints/pojos/Timed.java | 1 + .../novu/api/blueprints/pojos/Variables.java | 2 +- .../co/novu/api/common/NotificationGroup.java | 2 +- src/main/java/co/novu/api/common/Step.java | 10 +++++--- .../responses/EnvironmentResponse.java | 10 +++++--- .../responses/CreateLayoutResponseData.java | 5 ++-- .../api/layouts/responses/LayoutResponse.java | 16 +++++++++---- .../co/novu/api/notifications/pojos/Job.java | 7 ++++-- .../co/novu/api/tenants/pojos/Tenant.java | 7 ++++-- .../environments/EnvironmentHandlerTest.java | 18 +++++++-------- .../novu/api/layouts/LayoutHandlerTest.java | 2 +- 16 files changed, 74 insertions(+), 37 deletions(-) diff --git a/src/main/java/co/novu/api/blueprints/pojos/Blueprint.java b/src/main/java/co/novu/api/blueprints/pojos/Blueprint.java index 010b795..f46c430 100644 --- a/src/main/java/co/novu/api/blueprints/pojos/Blueprint.java +++ b/src/main/java/co/novu/api/blueprints/pojos/Blueprint.java @@ -1,4 +1,5 @@ package co.novu.api.blueprints.pojos; + import co.novu.api.common.PreferenceSettings; import co.novu.api.common.Step; import co.novu.api.common.Trigger; diff --git a/src/main/java/co/novu/api/blueprints/pojos/Filters.java b/src/main/java/co/novu/api/blueprints/pojos/Filters.java index 755c38f..3379a52 100644 --- a/src/main/java/co/novu/api/blueprints/pojos/Filters.java +++ b/src/main/java/co/novu/api/blueprints/pojos/Filters.java @@ -1,4 +1,6 @@ package co.novu.api.blueprints.pojos; + +import com.google.gson.annotations.SerializedName; import lombok.Data; import java.util.List; @@ -6,5 +8,6 @@ @Data public class Filters { private List children; - private String _id; + @SerializedName("_id") + private String id; } \ No newline at end of file diff --git a/src/main/java/co/novu/api/blueprints/pojos/General.java b/src/main/java/co/novu/api/blueprints/pojos/General.java index e3cc24a..71a7e17 100644 --- a/src/main/java/co/novu/api/blueprints/pojos/General.java +++ b/src/main/java/co/novu/api/blueprints/pojos/General.java @@ -1,4 +1,5 @@ package co.novu.api.blueprints.pojos; + import lombok.Data; import java.util.List; diff --git a/src/main/java/co/novu/api/blueprints/pojos/Popular.java b/src/main/java/co/novu/api/blueprints/pojos/Popular.java index a42cdef..c5648d6 100644 --- a/src/main/java/co/novu/api/blueprints/pojos/Popular.java +++ b/src/main/java/co/novu/api/blueprints/pojos/Popular.java @@ -1,4 +1,5 @@ package co.novu.api.blueprints.pojos; + import lombok.Data; import java.util.List; diff --git a/src/main/java/co/novu/api/blueprints/pojos/Template.java b/src/main/java/co/novu/api/blueprints/pojos/Template.java index 59d015d..e03e7dd 100644 --- a/src/main/java/co/novu/api/blueprints/pojos/Template.java +++ b/src/main/java/co/novu/api/blueprints/pojos/Template.java @@ -1,23 +1,32 @@ package co.novu.api.blueprints.pojos; + +import com.google.gson.annotations.SerializedName; import lombok.Data; import java.util.List; @Data public class Template { - private String _id; + @SerializedName("_id") + private String id; private String type; private Boolean active; private String subject; private List content; private String contentType; - private String _environmentId; - private String _organizationId; - private String _creatorId; - private String _parentId; - private String _layoutId; + @SerializedName("_environmentId") + private String environmentId; + @SerializedName("_organizationId") + private String organizationId; + @SerializedName("_creatorId") + private String creatorId; + @SerializedName("_parentId") + private String parentId; + @SerializedName("_layoutId") + private String layoutId; private List variables; private String createdAt; private String updatedAt; - private Long __v; + @SerializedName("__v") + private Long version; } \ No newline at end of file diff --git a/src/main/java/co/novu/api/blueprints/pojos/Timed.java b/src/main/java/co/novu/api/blueprints/pojos/Timed.java index af95933..ee4a3c0 100644 --- a/src/main/java/co/novu/api/blueprints/pojos/Timed.java +++ b/src/main/java/co/novu/api/blueprints/pojos/Timed.java @@ -1,4 +1,5 @@ package co.novu.api.blueprints.pojos; + import lombok.Data; import java.util.List; diff --git a/src/main/java/co/novu/api/blueprints/pojos/Variables.java b/src/main/java/co/novu/api/blueprints/pojos/Variables.java index a467e53..48b087c 100644 --- a/src/main/java/co/novu/api/blueprints/pojos/Variables.java +++ b/src/main/java/co/novu/api/blueprints/pojos/Variables.java @@ -7,5 +7,5 @@ public class Variables { private String name; private String type; private Boolean required; - private String Id; + private String id; } \ No newline at end of file diff --git a/src/main/java/co/novu/api/common/NotificationGroup.java b/src/main/java/co/novu/api/common/NotificationGroup.java index f36ffab..64e8e00 100644 --- a/src/main/java/co/novu/api/common/NotificationGroup.java +++ b/src/main/java/co/novu/api/common/NotificationGroup.java @@ -18,5 +18,5 @@ public class NotificationGroup { private String createdAt; private String updatedAt; @SerializedName("__v") - private String v; + private String version; } \ No newline at end of file diff --git a/src/main/java/co/novu/api/common/Step.java b/src/main/java/co/novu/api/common/Step.java index 0fcca72..56a8914 100644 --- a/src/main/java/co/novu/api/common/Step.java +++ b/src/main/java/co/novu/api/common/Step.java @@ -1,20 +1,24 @@ package co.novu.api.common; +import com.google.gson.annotations.SerializedName; import lombok.Data; import java.util.List; @Data public class Step { - private String _id; - private String _templateId; + @SerializedName("_id") + private String id; + @SerializedName("_templateId") + private String templateId; private Boolean active; private Boolean shouldStopOnFail; private Object template; private Object replyCallback; private String uuid; private String name; - private String _parentId; + @SerializedName("_parentId") + private String parentId; private Object filters; private Object metadata; } \ No newline at end of file diff --git a/src/main/java/co/novu/api/environments/responses/EnvironmentResponse.java b/src/main/java/co/novu/api/environments/responses/EnvironmentResponse.java index f9ea2bb..6a196b1 100644 --- a/src/main/java/co/novu/api/environments/responses/EnvironmentResponse.java +++ b/src/main/java/co/novu/api/environments/responses/EnvironmentResponse.java @@ -2,19 +2,23 @@ import co.novu.api.environments.pojos.ApiKey; import co.novu.api.environments.pojos.Widget; +import com.google.gson.annotations.SerializedName; import lombok.Data; import java.util.List; @Data public class EnvironmentResponse { - private String _id; + @SerializedName("_id") + private String id; private String name; private String identifier; - private String _organizationId; + @SerializedName("_organizationId") + private String organizationId; private List apiKeys; private Widget widget; private String createdAt; private String updatedAt; - private String _parentId; + @SerializedName("_parentId") + private String parentId; } \ No newline at end of file diff --git a/src/main/java/co/novu/api/layouts/responses/CreateLayoutResponseData.java b/src/main/java/co/novu/api/layouts/responses/CreateLayoutResponseData.java index f2a4644..1fe5a97 100644 --- a/src/main/java/co/novu/api/layouts/responses/CreateLayoutResponseData.java +++ b/src/main/java/co/novu/api/layouts/responses/CreateLayoutResponseData.java @@ -1,9 +1,10 @@ package co.novu.api.layouts.responses; - +import com.google.gson.annotations.SerializedName; import lombok.Data; @Data public class CreateLayoutResponseData { - private String _id; + @SerializedName("_id") + private String id; } diff --git a/src/main/java/co/novu/api/layouts/responses/LayoutResponse.java b/src/main/java/co/novu/api/layouts/responses/LayoutResponse.java index 7271768..f1b2491 100644 --- a/src/main/java/co/novu/api/layouts/responses/LayoutResponse.java +++ b/src/main/java/co/novu/api/layouts/responses/LayoutResponse.java @@ -1,15 +1,20 @@ package co.novu.api.layouts.responses; +import com.google.gson.annotations.SerializedName; import lombok.Data; import java.util.List; @Data public class LayoutResponse { - private String _id; - private String _organizationId; - private String _environmentId; - private String _creatorId; + @SerializedName("_id") + private String id; + @SerializedName("_organizationId") + private String organizationId; + @SerializedName("_environmentId") + private String environmentId; + @SerializedName("_creatorId") + private String creatorId; private String name; private String description; private String channel; @@ -20,5 +25,6 @@ public class LayoutResponse { private Boolean isDeleted; private String createdAt; private String updatedAt; - private String _parentId; + @SerializedName("_parentId") + private String parentId; } diff --git a/src/main/java/co/novu/api/notifications/pojos/Job.java b/src/main/java/co/novu/api/notifications/pojos/Job.java index 7b4690a..e504d91 100644 --- a/src/main/java/co/novu/api/notifications/pojos/Job.java +++ b/src/main/java/co/novu/api/notifications/pojos/Job.java @@ -1,17 +1,20 @@ package co.novu.api.notifications.pojos; import co.novu.api.common.Step; +import com.google.gson.annotations.SerializedName; import lombok.Data; import java.util.List; @Data public class Job { - private String _id; + @SerializedName("_id") + private String id; private Object digest; private String status; private Object payload; - private String _notificationId; + @SerializedName("_notificationId") + private String notificationId; private String type; private String createdAt; private String updatedAt; diff --git a/src/main/java/co/novu/api/tenants/pojos/Tenant.java b/src/main/java/co/novu/api/tenants/pojos/Tenant.java index 653b5a2..d068bdc 100644 --- a/src/main/java/co/novu/api/tenants/pojos/Tenant.java +++ b/src/main/java/co/novu/api/tenants/pojos/Tenant.java @@ -1,11 +1,14 @@ package co.novu.api.tenants.pojos; +import com.google.gson.annotations.SerializedName; import lombok.Data; @Data public class Tenant { - private String _environmentId; - private String _id; + @SerializedName("_environmentId") + private String environmentId; + @SerializedName("_id") + private String id; private String createdAt; private Object data; private String identifier; diff --git a/src/test/java/co/novu/api/environments/EnvironmentHandlerTest.java b/src/test/java/co/novu/api/environments/EnvironmentHandlerTest.java index 524a679..05fe385 100644 --- a/src/test/java/co/novu/api/environments/EnvironmentHandlerTest.java +++ b/src/test/java/co/novu/api/environments/EnvironmentHandlerTest.java @@ -40,17 +40,17 @@ public void test_getCurrentEnvironment() throws IOException, NovuNetworkExceptio SingleEnvironmentResponse singleEnvironmentResponse = new SingleEnvironmentResponse(); EnvironmentResponse data = new EnvironmentResponse(); - data.set_id("id"); + data.setId("id"); data.setName("name"); data.setIdentifier("identifier"); - data.set_organizationId("organizationId"); + data.setOrganizationId("organizationId"); data.setApiKeys(Collections.singletonList(new ApiKey())); Widget widget = new Widget(); widget.setNotificationCenterEncryption(false); data.setWidget(widget); data.setCreatedAt("createdAt"); data.setUpdatedAt("updatedAt"); - data.set_parentId("parentId"); + data.setParentId("parentId"); singleEnvironmentResponse.setData(data); Gson gson = new Gson(); @@ -72,17 +72,17 @@ public void test_createEnvironment() throws IOException, NovuNetworkException, I SingleEnvironmentResponse singleEnvironmentResponse = new SingleEnvironmentResponse(); EnvironmentResponse data = new EnvironmentResponse(); - data.set_id("id"); + data.setId("id"); data.setName("name"); data.setIdentifier("identifier"); - data.set_organizationId("organizationId"); + data.setOrganizationId("organizationId"); data.setApiKeys(Collections.singletonList(new ApiKey())); Widget widget = new Widget(); widget.setNotificationCenterEncryption(false); data.setWidget(widget); data.setCreatedAt("createdAt"); data.setUpdatedAt("updatedAt"); - data.set_parentId("parentId"); + data.setParentId("parentId"); singleEnvironmentResponse.setData(data); Gson gson = new Gson(); @@ -124,17 +124,17 @@ public void test_updateEnvironmentById() throws IOException, NovuNetworkExceptio SingleEnvironmentResponse singleEnvironmentResponse = new SingleEnvironmentResponse(); EnvironmentResponse data = new EnvironmentResponse(); - data.set_id("id"); + data.setId("id"); data.setName("name"); data.setIdentifier("identifier"); - data.set_organizationId("organizationId"); + data.setOrganizationId("organizationId"); data.setApiKeys(Collections.singletonList(new ApiKey())); Widget widget = new Widget(); widget.setNotificationCenterEncryption(false); data.setWidget(widget); data.setCreatedAt("createdAt"); data.setUpdatedAt("updatedAt"); - data.set_parentId("parentId"); + data.setParentId("parentId"); singleEnvironmentResponse.setData(data); Gson gson = new Gson(); diff --git a/src/test/java/co/novu/api/layouts/LayoutHandlerTest.java b/src/test/java/co/novu/api/layouts/LayoutHandlerTest.java index fa27e14..fd45222 100644 --- a/src/test/java/co/novu/api/layouts/LayoutHandlerTest.java +++ b/src/test/java/co/novu/api/layouts/LayoutHandlerTest.java @@ -48,7 +48,7 @@ public void test_createLayout() throws IOException, NovuNetworkException, Interr CreateLayoutResponse createLayoutResponse = new CreateLayoutResponse(); CreateLayoutResponseData createLayoutResponseData = new CreateLayoutResponseData(); - createLayoutResponseData.set_id("id"); + createLayoutResponseData.setId("id"); createLayoutResponse.setData(createLayoutResponseData); Gson gson = new Gson(); From 157b904888bf8b50c4d6d6e1c6755d6152546ae5 Mon Sep 17 00:00:00 2001 From: MayorJay Date: Sun, 11 Feb 2024 15:14:07 +0000 Subject: [PATCH 3/4] feat: Modify WorkflowOverrides Response --- .../api/workflowoverrides/WorkflowOverrideApi.java | 4 ++-- .../workflowoverrides/WorkflowOverrideHandler.java | 6 +++--- .../response/GetWorkflowOverridesResponse.java | 8 -------- src/main/java/co/novu/common/base/Novu.java | 10 ++++------ .../workflowoverride/WorkflowOverrideHandlerTest.java | 11 ++++------- 5 files changed, 13 insertions(+), 26 deletions(-) delete mode 100644 src/main/java/co/novu/api/workflowoverrides/response/GetWorkflowOverridesResponse.java diff --git a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java index 46571b5..01d915c 100644 --- a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java +++ b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideApi.java @@ -2,8 +2,8 @@ import co.novu.api.workflowoverrides.request.CreateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.UpdateWorkflowOverrideRequest; +import co.novu.api.workflowoverrides.response.BulkWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.DeleteWorkflowOverrideResponse; -import co.novu.api.workflowoverrides.response.GetWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.WorkflowOverrideResponse; import retrofit2.Call; import retrofit2.http.Body; @@ -24,7 +24,7 @@ public interface WorkflowOverrideApi { Call createWorkflowOverride(@Body CreateWorkflowOverrideRequest request); @GET(ENDPOINT) - Call getWorkflowOverrides(@QueryMap Map params); + Call getWorkflowOverrides(@QueryMap Map params); @GET(ENDPOINT + "/workflows/{workflowId}/tenants/{tenantId}") Call getWorkflowOverride(@Path("workflowId") String workflowId, @Path("tenantId") String tenantId); diff --git a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java index 8ac123c..95df046 100644 --- a/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java +++ b/src/main/java/co/novu/api/workflowoverrides/WorkflowOverrideHandler.java @@ -3,8 +3,8 @@ import co.novu.api.workflowoverrides.request.CreateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.GetWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.UpdateWorkflowOverrideRequest; +import co.novu.api.workflowoverrides.response.BulkWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.DeleteWorkflowOverrideResponse; -import co.novu.api.workflowoverrides.response.GetWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.WorkflowOverrideResponse; import co.novu.common.rest.NovuNetworkException; import co.novu.common.rest.RestHandler; @@ -30,11 +30,11 @@ public WorkflowOverrideResponse createWorkflowOverride(CreateWorkflowOverrideReq return restHandler.extractResponse(response); } - public GetWorkflowOverridesResponse getWorkflowOverrides(GetWorkflowOverrideRequest request) throws IOException, NovuNetworkException { + public BulkWorkflowOverridesResponse getWorkflowOverrides(GetWorkflowOverrideRequest request) throws IOException, NovuNetworkException { Map params = new HashMap<>(); if (request.getPage() != null) params.put("page", request.getPage()); if (request.getLimit() != null) params.put("limit", request.getLimit()); - Response response = workflowOverrideApi.getWorkflowOverrides(params).execute(); + Response response = workflowOverrideApi.getWorkflowOverrides(params).execute(); return restHandler.extractResponse(response); } diff --git a/src/main/java/co/novu/api/workflowoverrides/response/GetWorkflowOverridesResponse.java b/src/main/java/co/novu/api/workflowoverrides/response/GetWorkflowOverridesResponse.java deleted file mode 100644 index 8dd4d05..0000000 --- a/src/main/java/co/novu/api/workflowoverrides/response/GetWorkflowOverridesResponse.java +++ /dev/null @@ -1,8 +0,0 @@ -package co.novu.api.workflowoverrides.response; - -import lombok.Data; - -@Data -public class GetWorkflowOverridesResponse { - private BulkWorkflowOverridesResponse data; -} diff --git a/src/main/java/co/novu/common/base/Novu.java b/src/main/java/co/novu/common/base/Novu.java index af13ec9..11d89fa 100644 --- a/src/main/java/co/novu/common/base/Novu.java +++ b/src/main/java/co/novu/common/base/Novu.java @@ -108,13 +108,11 @@ import co.novu.api.workflowgroups.responses.GetWorkflowGroupsResponse; import co.novu.api.workflowgroups.responses.WorkflowGroupResponse; import co.novu.api.workflowoverrides.WorkflowOverrideHandler; -import co.novu.api.workflowoverrides.pojos.WorkflowOverride; import co.novu.api.workflowoverrides.request.CreateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.GetWorkflowOverrideRequest; import co.novu.api.workflowoverrides.request.UpdateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.response.BulkWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.DeleteWorkflowOverrideResponse; -import co.novu.api.workflowoverrides.response.GetWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.WorkflowOverrideResponse; import co.novu.api.workflows.WorkflowHandler; import co.novu.api.workflows.requests.UpdateWorkflowRequest; @@ -996,11 +994,11 @@ public WorkflowOverrideResponse createWorkflowOverride(CreateWorkflowOverrideReq } } - public GetWorkflowOverridesResponse getWorkflowOverrides(GetWorkflowOverrideRequest request) throws IOException, NovuNetworkException { + public BulkWorkflowOverridesResponse getWorkflowOverrides(GetWorkflowOverrideRequest request) throws IOException, NovuNetworkException { try { return workflowOverrideHandler.getWorkflowOverrides(request); } catch (Exception e) { - log.error("Error fetching Workflow-Override", e); + log.error("Error fetching bulk Workflow-Override", e); throw e; } } @@ -1018,7 +1016,7 @@ public WorkflowOverrideResponse getWorkflowOverrideById(String overrideId) throw try { return workflowOverrideHandler.getWorkflowOverrideById(overrideId); } catch (Exception e) { - log.error("Error fetching Workflow-Override", e); + log.error("Error fetching Workflow-Override by id", e); throw e; } } @@ -1027,7 +1025,7 @@ public WorkflowOverrideResponse updateWorkflowOverrideById(String overrideId, Up try { return workflowOverrideHandler.updateWorkflowOverrideById(overrideId, request); } catch (Exception e) { - log.error("Error updating Workflow-Override", e); + log.error("Error updating Workflow-Override by id", e); throw e; } } diff --git a/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java b/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java index fd0352a..ca881f9 100644 --- a/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java +++ b/src/test/java/co/novu/api/workflowoverride/WorkflowOverrideHandlerTest.java @@ -8,7 +8,6 @@ import co.novu.api.workflowoverrides.request.UpdateWorkflowOverrideRequest; import co.novu.api.workflowoverrides.response.BulkWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.DeleteWorkflowOverrideResponse; -import co.novu.api.workflowoverrides.response.GetWorkflowOverridesResponse; import co.novu.api.workflowoverrides.response.WorkflowOverrideResponse; import co.novu.common.base.NovuConfig; import co.novu.common.rest.NovuNetworkException; @@ -52,13 +51,13 @@ public void test_createWorkflowOverrideHandler() throws IOException, NovuNetwork } public void test_getWorkflowOverrides() throws IOException, NovuNetworkException, InterruptedException { - GetWorkflowOverridesResponse workflowOverridesResponse = getWorkflowOverridesResponse(); + BulkWorkflowOverridesResponse workflowOverridesResponse = getWorkflowOverridesResponse(); Gson gson = new Gson(); mockWebServer.enqueue(new MockResponse().setResponseCode(200).setBody(gson.toJson(workflowOverridesResponse))); GetWorkflowOverrideRequest getWorkflowOverrideRequest = new GetWorkflowOverrideRequest(); getWorkflowOverrideRequest.setPage(1); getWorkflowOverrideRequest.setLimit(10); - GetWorkflowOverridesResponse response = workflowOverrideHandler.getWorkflowOverrides(getWorkflowOverrideRequest); + BulkWorkflowOverridesResponse response = workflowOverrideHandler.getWorkflowOverrides(getWorkflowOverrideRequest); assertNotNull(response); RecordedRequest request = mockWebServer.takeRequest(); assertEquals("/workflow-overrides?limit=10&page=1", request.getPath()); @@ -166,15 +165,13 @@ private CreateWorkflowOverrideRequest getCreateWorkflowOverrideRequest() { return createWorkflowOverrideRequest; } - private GetWorkflowOverridesResponse getWorkflowOverridesResponse() { + private BulkWorkflowOverridesResponse getWorkflowOverridesResponse() { BulkWorkflowOverridesResponse bulkWorkflowOverridesResponse = new BulkWorkflowOverridesResponse(); bulkWorkflowOverridesResponse.setData(List.of(getWorkflowOverride(), getWorkflowOverride())); bulkWorkflowOverridesResponse.setHasMore(true); bulkWorkflowOverridesResponse.setPageSize(10L); bulkWorkflowOverridesResponse.setPage(1L); - GetWorkflowOverridesResponse getWorkflowOverridesResponse = new GetWorkflowOverridesResponse(); - getWorkflowOverridesResponse.setData(bulkWorkflowOverridesResponse); - return getWorkflowOverridesResponse; + return bulkWorkflowOverridesResponse; } private UpdateWorkflowOverrideRequest getUpdateWorkflowOverrideRequest() { From ddfba1967a696cc3031b313f5b85887d01eb0f10 Mon Sep 17 00:00:00 2001 From: MayorJay Date: Sun, 11 Feb 2024 23:47:35 +0000 Subject: [PATCH 4/4] feat: Update ReadMe --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 53ce4f2..ef3b1ee 100644 --- a/README.md +++ b/README.md @@ -437,7 +437,7 @@ public class Main { - `getWorkflowOverrideById(overrideId)` - `updateWorkflowOverride(workflowId, tenantId)` - `updateWorkflowOverrideById(overrideId)` -- `deleteWorkflow(overrideId)` +- `deleteWorkflowOverride(overrideId)` ### Notification