Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug in Workflow Override API and Modify fields Signature #115

Merged
merged 4 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ public class Main {
- `getWorkflowOverrideById(overrideId)`
- `updateWorkflowOverride(workflowId, tenantId)`
- `updateWorkflowOverrideById(overrideId)`
- `deleteWorkflow(overrideId)`
- `deleteWorkflowOverride(overrideId)`

### Notification

Expand Down
1 change: 1 addition & 0 deletions src/main/java/co/novu/api/blueprints/pojos/Blueprint.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/co/novu/api/blueprints/pojos/Filters.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package co.novu.api.blueprints.pojos;

import com.google.gson.annotations.SerializedName;
import lombok.Data;

import java.util.List;

@Data
public class Filters {
private List<String> children;
private String _id;
@SerializedName("_id")
private String id;
}
1 change: 1 addition & 0 deletions src/main/java/co/novu/api/blueprints/pojos/General.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package co.novu.api.blueprints.pojos;

import lombok.Data;

import java.util.List;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/co/novu/api/blueprints/pojos/Popular.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package co.novu.api.blueprints.pojos;

import lombok.Data;

import java.util.List;
Expand Down
23 changes: 16 additions & 7 deletions src/main/java/co/novu/api/blueprints/pojos/Template.java
Original file line number Diff line number Diff line change
@@ -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> 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> variables;
private String createdAt;
private String updatedAt;
private Long __v;
@SerializedName("__v")
private Long version;
}
1 change: 1 addition & 0 deletions src/main/java/co/novu/api/blueprints/pojos/Timed.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package co.novu.api.blueprints.pojos;

import lombok.Data;

import java.util.List;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/blueprints/pojos/Variables.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ public class Variables {
private String name;
private String type;
private Boolean required;
private String Id;
private String id;
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/common/NotificationGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ public class NotificationGroup {
private String createdAt;
private String updatedAt;
@SerializedName("__v")
private String v;
private String version;
}
4 changes: 3 additions & 1 deletion src/main/java/co/novu/api/common/PreferenceSettings.java
Original file line number Diff line number Diff line change
@@ -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;
}
10 changes: 7 additions & 3 deletions src/main/java/co/novu/api/common/Step.java
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApiKey> apiKeys;
private Widget widget;
private String createdAt;
private String updatedAt;
private String _parentId;
@SerializedName("_parentId")
private String parentId;
}
Original file line number Diff line number Diff line change
@@ -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;
}
16 changes: 11 additions & 5 deletions src/main/java/co/novu/api/layouts/responses/LayoutResponse.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -20,5 +25,6 @@ public class LayoutResponse {
private Boolean isDeleted;
private String createdAt;
private String updatedAt;
private String _parentId;
@SerializedName("_parentId")
private String parentId;
}
7 changes: 5 additions & 2 deletions src/main/java/co/novu/api/notifications/pojos/Job.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/co/novu/api/tenants/pojos/Tenant.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
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;
import retrofit2.Call;
import retrofit2.http.Body;
Expand All @@ -27,7 +24,7 @@ public interface WorkflowOverrideApi {
Call<WorkflowOverrideResponse> createWorkflowOverride(@Body CreateWorkflowOverrideRequest request);

@GET(ENDPOINT)
Call<GetWorkflowOverridesResponse> getWorkflowOverrides(@QueryMap Map<String, Object> params);
Call<BulkWorkflowOverridesResponse> getWorkflowOverrides(@QueryMap Map<String, Object> params);

@GET(ENDPOINT + "/workflows/{workflowId}/tenants/{tenantId}")
Call<WorkflowOverrideResponse> getWorkflowOverride(@Path("workflowId") String workflowId, @Path("tenantId") String tenantId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
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;
import co.novu.common.rest.NovuNetworkException;
import co.novu.common.rest.RestHandler;
Expand All @@ -32,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<String, Object> params = new HashMap<>();
if (request.getPage() != null) params.put("page", request.getPage());
if (request.getLimit() != null) params.put("limit", request.getLimit());
Response<GetWorkflowOverridesResponse> response = workflowOverrideApi.getWorkflowOverrides(params).execute();
Response<BulkWorkflowOverridesResponse> response = workflowOverrideApi.getWorkflowOverrides(params).execute();
return restHandler.extractResponse(response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
@Data
public class UpdateWorkflowOverrideRequest {
private Boolean active;
private PreferenceSettings data;
private PreferenceSettings preferenceSettings;
}

This file was deleted.

10 changes: 4 additions & 6 deletions src/main/java/co/novu/common/base/Novu.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down
Loading
Loading