Skip to content

Commit

Permalink
feat: Implement coding standard adherence
Browse files Browse the repository at this point in the history
  • Loading branch information
mayorJAY committed May 28, 2024
1 parent 3e42109 commit b1b4d5c
Show file tree
Hide file tree
Showing 153 changed files with 832 additions and 628 deletions.
12 changes: 6 additions & 6 deletions src/main/java/co/novu/api/blueprints/BlueprintsHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@

import java.io.IOException;

public class BlueprintsHandler {
public final class BlueprintsHandler {

private final RestHandler restHandler;

private final BlueprintsApi blueprintsApi;

public BlueprintsHandler(RestHandler restHandler) {
this.restHandler = restHandler;
this.blueprintsApi = restHandler.buildRetrofit().create(BlueprintsApi.class);
public BlueprintsHandler(final RestHandler handler) {
this.restHandler = handler;
this.blueprintsApi = handler.buildRetrofit().create(BlueprintsApi.class);
}

public BlueprintsByCategoryResponse getBlueprintsByCategory() throws IOException, NovuNetworkException {
Response<BlueprintsByCategoryResponse> response = blueprintsApi.getBlueprintsByCategory().execute();
return restHandler.extractResponse(response);
}

public Blueprint getBlueprint(String templateId) throws IOException, NovuNetworkException {
public Blueprint getBlueprint(final String templateId) throws IOException, NovuNetworkException {
Response<Blueprint> response = blueprintsApi.getBlueprint(templateId).execute();
return restHandler.extractResponse(response);
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/blueprints/pojos/Blueprint.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ public class Blueprint {
@SerializedName("__v")
private Long version;
private NotificationGroup notificationGroup;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/blueprints/pojos/Content.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public class Content {
private String type;
private String content;
private Styles styles;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/blueprints/pojos/Filters.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public class Filters {
private List<String> children;
@SerializedName("_id")
private String id;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/blueprints/pojos/General.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
public class General {
private String name;
private List<Blueprint> blueprints;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/blueprints/pojos/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
@Data
public class Metadata {
private Timed timed;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/blueprints/pojos/Popular.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
public class Popular {
private String name;
private List<Blueprint> blueprints;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/blueprints/pojos/Styles.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
@Data
public class Styles {
private String textAlign;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/blueprints/pojos/Template.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public class Template {
private String updatedAt;
@SerializedName("__v")
private Long version;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/blueprints/pojos/Timed.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
public class Timed {
private List<String> weekDays;
private List<String> monthDays;
}
}
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 @@ -8,4 +8,4 @@ public class Variables {
private String type;
private Boolean required;
private String id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
@Data
public class BlueprintsByCategoryResponse {
private BlueprintsResponseData data;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package co.novu.api.blueprints.responses;

import co.novu.api.blueprints.pojos.General;
import co.novu.api.blueprints.pojos.Popular;
import lombok.Data;
Expand All @@ -9,4 +10,4 @@
public class BlueprintsResponseData {
private List<General> general;
private Popular popular;
}
}
28 changes: 14 additions & 14 deletions src/main/java/co/novu/api/changes/ChangeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,25 @@
import java.util.Map;

@RequiredArgsConstructor
public class ChangeHandler {
public final class ChangeHandler {

private final RestHandler restHandler;

private final ChangeApi changeApi;

private static final String ENDPOINT = "changes";

public ChangeHandler(RestHandler restHandler) {
this.restHandler = restHandler;
this.changeApi = restHandler.buildRetrofit().create(ChangeApi.class);
public ChangeHandler(final RestHandler handler) {
this.restHandler = handler;
this.changeApi = handler.buildRetrofit().create(ChangeApi.class);
}


public GetChangesResponse getChanges(GetChangesRequest request) throws IOException, NovuNetworkException {
public GetChangesResponse getChanges(final GetChangesRequest 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());
if (request.getPage() != null) {
params.put("page", request.getPage());
}
if (request.getLimit() != null) {
params.put("limit", request.getLimit());
}
params.put("promoted", request.getPromoted());
Response<GetChangesResponse> response = changeApi.getChanges(params).execute();
return restHandler.extractResponse(response);
Expand All @@ -43,15 +44,14 @@ public ChangeCountResponse getChangesCount() throws IOException, NovuNetworkExce
return restHandler.extractResponse(response);
}

public ApplyChangesResponse applyChanges(ApplyChangesRequest request) throws IOException, NovuNetworkException {
public ApplyChangesResponse applyChanges(final ApplyChangesRequest request)
throws IOException, NovuNetworkException {
Response<ApplyChangesResponse> response = changeApi.applyChanges(request).execute();
return restHandler.extractResponse(response);
}

public ApplyChangesResponse applyChange(String changeId) throws IOException, NovuNetworkException {
public ApplyChangesResponse applyChange(final String changeId) throws IOException, NovuNetworkException {
Response<ApplyChangesResponse> response = changeApi.applyChange(changeId).execute();
return restHandler.extractResponse(response);
}


}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/common/Filters.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public class Filters {
private String type;
private String value;
private List<Children> children;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/common/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ public class Metadata {
private String backoffUnit;
private Long backoffAmount;
private Boolean updateMode;
}
}
4 changes: 2 additions & 2 deletions src/main/java/co/novu/api/common/NotificationGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

@Data
public class NotificationGroup {
@SerializedName("_id")
@SerializedName("_id")
private String id;
private String name;
@SerializedName("_organizationId")
Expand All @@ -19,4 +19,4 @@ public class NotificationGroup {
private String updatedAt;
@SerializedName("__v")
private String version;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/common/PreferenceSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public class PreferenceSettings {
private Boolean inApp;
private Boolean chat;
private Boolean push;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/common/ReplyCallback.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
@Data
public class ReplyCallback {
private Boolean active;
}
}
4 changes: 1 addition & 3 deletions src/main/java/co/novu/api/common/Step.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import com.google.gson.annotations.SerializedName;
import lombok.Data;

import java.util.List;

@Data
public class Step {
@SerializedName("_id")
Expand All @@ -21,4 +19,4 @@ public class Step {
private String parentId;
private Object filters;
private Object metadata;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/common/SubscriberRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ public class SubscriberRequest implements IRequest {
private String avatar;
private String locale;
private Object data;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/common/Template.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ public class Template {
private String name;
private Boolean critical;
private List<Trigger> triggers;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/common/Trigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public class Trigger {
private List<Variables> variables;
private List<Variables> subscriberVariables;
private List<Variables> reservedVariables;
}
}
39 changes: 20 additions & 19 deletions src/main/java/co/novu/api/environments/EnvironmentApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@

public interface EnvironmentApi {

String ENDPOINT = "environments";

@GET(ENDPOINT + "/me")
Call<SingleEnvironmentResponse> getCurrentEnvironment();

@POST(ENDPOINT)
Call<SingleEnvironmentResponse> createEnvironment(@Body CreateEnvironmentRequest request);

@GET(ENDPOINT)
Call<BulkEnvironmentResponse> getEnvironments();

@PUT(ENDPOINT + "/{environmentId}")
Call<SingleEnvironmentResponse> updateEnvironmentById(@Path("environmentId") String environmentId, @Body UpdateEnvironmentRequest request);

@GET(ENDPOINT + "/api-keys")
Call<ApiKeyResponse> getApiKeys();

@POST(ENDPOINT + "/api-keys/regenerate")
Call<ApiKeyResponse> regenerateApiKeys();
String ENDPOINT = "environments";

@GET(ENDPOINT + "/me")
Call<SingleEnvironmentResponse> getCurrentEnvironment();

@POST(ENDPOINT)
Call<SingleEnvironmentResponse> createEnvironment(@Body CreateEnvironmentRequest request);

@GET(ENDPOINT)
Call<BulkEnvironmentResponse> getEnvironments();

@PUT(ENDPOINT + "/{environmentId}")
Call<SingleEnvironmentResponse> updateEnvironmentById(@Path("environmentId") String environmentId,
@Body UpdateEnvironmentRequest request);

@GET(ENDPOINT + "/api-keys")
Call<ApiKeyResponse> getApiKeys();

@POST(ENDPOINT + "/api-keys/regenerate")
Call<ApiKeyResponse> regenerateApiKeys();
}
32 changes: 18 additions & 14 deletions src/main/java/co/novu/api/environments/EnvironmentHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,48 @@
import co.novu.common.rest.RestHandler;
import retrofit2.Response;

public class EnvironmentHandler {
public final class EnvironmentHandler {

private final RestHandler restHandler;

private final EnvironmentApi environmentApi;
public EnvironmentHandler(RestHandler restHandler) {
this.restHandler = restHandler;
this.environmentApi = restHandler.buildRetrofit().create(EnvironmentApi.class);

public EnvironmentHandler(final RestHandler handler) {
this.restHandler = handler;
this.environmentApi = handler.buildRetrofit().create(EnvironmentApi.class);
}

public SingleEnvironmentResponse getCurrentEnvironment() throws IOException, NovuNetworkException {
Response<SingleEnvironmentResponse> response = environmentApi.getCurrentEnvironment().execute();
Response<SingleEnvironmentResponse> response = environmentApi.getCurrentEnvironment().execute();
return restHandler.extractResponse(response);
}

public SingleEnvironmentResponse createEnvironment(CreateEnvironmentRequest request) throws IOException, NovuNetworkException {
Response<SingleEnvironmentResponse> response = environmentApi.createEnvironment(request).execute();
public SingleEnvironmentResponse createEnvironment(final CreateEnvironmentRequest request)
throws IOException, NovuNetworkException {
Response<SingleEnvironmentResponse> response = environmentApi.createEnvironment(request).execute();
return restHandler.extractResponse(response);
}

public BulkEnvironmentResponse getEnvironments() throws IOException, NovuNetworkException {
Response<BulkEnvironmentResponse> response = environmentApi.getEnvironments().execute();
Response<BulkEnvironmentResponse> response = environmentApi.getEnvironments().execute();
return restHandler.extractResponse(response);
}

public SingleEnvironmentResponse updateEnvironmentById(String environmentId, UpdateEnvironmentRequest request) throws IOException, NovuNetworkException {
Response<SingleEnvironmentResponse> response = environmentApi.updateEnvironmentById(environmentId, request).execute();
public SingleEnvironmentResponse updateEnvironmentById(final String environmentId,
final UpdateEnvironmentRequest request)
throws IOException, NovuNetworkException {
Response<SingleEnvironmentResponse> response =
environmentApi.updateEnvironmentById(environmentId, request).execute();
return restHandler.extractResponse(response);
}

public ApiKeyResponse getApiKeys() throws IOException, NovuNetworkException {
Response<ApiKeyResponse> response = environmentApi.getApiKeys().execute();
Response<ApiKeyResponse> response = environmentApi.getApiKeys().execute();
return restHandler.extractResponse(response);
}

public ApiKeyResponse regenerateApiKeys() throws IOException, NovuNetworkException {
Response<ApiKeyResponse> response = environmentApi.regenerateApiKeys().execute();
Response<ApiKeyResponse> response = environmentApi.regenerateApiKeys().execute();
return restHandler.extractResponse(response);
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/environments/pojos/ApiKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ public class ApiKey {
private String key;
@SerializedName("_userId")
private String userId;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/environments/pojos/Dns.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
@Data
public class Dns {
private String inboundParseDomain;
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/novu/api/environments/pojos/Widget.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
@Data
public class Widget {
private Boolean notificationCenterEncryption;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
public class CreateEnvironmentRequest implements IRequest {
private String name;
private String parentId;
}
}
Loading

0 comments on commit b1b4d5c

Please sign in to comment.