Skip to content

Commit

Permalink
♻️ refactor: refactor codebase #2
Browse files Browse the repository at this point in the history
  • Loading branch information
pnguyen215 committed Jun 15, 2024
1 parent 26f107b commit cd4e53b
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 114 deletions.
57 changes: 57 additions & 0 deletions plugin/src/main/groovy/org/bot4j/base/request/BaseConnections.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.bot4j.base.request;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BaseConnections implements Serializable {
public BaseConnections() {
super();
}

private boolean debugging = false; // enable to trace log as debug mode
private boolean skip = false; // skipping the action for sending message
private boolean retry = false; // enable retry REST HTTP API when sending message got failure
private int maxRetries = 2; // retry no. times when sending message, default is 2 times

public boolean isDebugging() {
return debugging;
}

public void setDebugging(boolean debugging) {
this.debugging = debugging;
}

public boolean isSkip() {
return skip;
}

public void setSkip(boolean skip) {
this.skip = skip;
}

public boolean isRetry() {
return retry;
}

public void setRetry(boolean retry) {
this.retry = retry;
}

public int getMaxRetries() {
return maxRetries;
}

public void setMaxRetries(int maxRetries) {
this.maxRetries = maxRetries;
}

@Override
public String toString() {
return String.format("connections { debugging: %s, skip: %s, retry: %s, max_retries: %d }",
this.debugging, this.skip, this.retry, this.maxRetries);
}
}
26 changes: 26 additions & 0 deletions plugin/src/main/groovy/org/bot4j/base/request/BaseOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.bot4j.base.request;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.unify4j.common.UniqueId4j;

import java.io.Serializable;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BaseOptions implements Serializable {
public BaseOptions() {
super();
this.setRequestId(String.valueOf(UniqueId4j.getUniqueId19()));
}

private String requestId;

public String getRequestId() {
return requestId;
}

public void setRequestId(String requestId) {
this.requestId = requestId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,17 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import org.bot4j.base.request.BaseConnections;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SlackConnections implements Serializable {
public class SlackConnections extends BaseConnections {
public SlackConnections() {
super();
}

private boolean debugging = false; // enable to trace log as debug mode
private boolean skip = false; // skipping the action for sending message
private boolean retry = false; // enable retry REST HTTP Telegram API when sending message got failure
private int maxRetries = 2; // retry no. times when sending message, default is 2 times

public boolean isDebugging() {
return debugging;
}

public void setDebugging(boolean debugging) {
this.debugging = debugging;
}

public boolean isSkip() {
return skip;
}

public void setSkip(boolean skip) {
this.skip = skip;
}

public boolean isRetry() {
return retry;
}

public void setRetry(boolean retry) {
this.retry = retry;
}

public int getMaxRetries() {
return maxRetries;
}

public void setMaxRetries(int maxRetries) {
this.maxRetries = maxRetries;
}

@Override
public String toString() {
return String.format("Slack connections { debugging: %s, skip: %s, retry: %s, max_retries: %d }",
this.debugging, this.skip, this.retry, this.maxRetries);
return String.format("%s %s", "Slack", super.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,12 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.unify4j.common.UniqueId4j;

import java.io.Serializable;
import org.bot4j.base.request.BaseOptions;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class SlackOptions implements Serializable {
public class SlackOptions extends BaseOptions {
public SlackOptions() {
super();
this.setRequestId(String.valueOf(UniqueId4j.getUniqueId19()));
}

private String requestId;

public String getRequestId() {
return requestId;
}

public void setRequestId(String requestId) {
this.requestId = requestId;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,17 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import org.bot4j.base.request.BaseConnections;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TelegramConnections implements Serializable {
public class TelegramConnections extends BaseConnections {
public TelegramConnections() {
super();
}

private boolean debugging = false; // enable to trace log as debug mode
private boolean skip = false; // skipping the action for sending message
private boolean retry = false; // enable retry REST HTTP Telegram API when sending message got failure
private int maxRetries = 2; // retry no. times when sending message, default is 2 times

public boolean isDebugging() {
return debugging;
}

public void setDebugging(boolean debugging) {
this.debugging = debugging;
}

public boolean isSkip() {
return skip;
}

public void setSkip(boolean skip) {
this.skip = skip;
}

public boolean isRetry() {
return retry;
}

public void setRetry(boolean retry) {
this.retry = retry;
}

public int getMaxRetries() {
return maxRetries;
}

public void setMaxRetries(int maxRetries) {
this.maxRetries = maxRetries;
}

@Override
public String toString() {
return String.format("Telegram connections { debugging: %s, skip: %s, retry: %s, max_retries: %d }",
this.debugging, this.skip, this.retry, this.maxRetries);
return String.format("%s %s", "Telegram", super.toString());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,12 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.unify4j.common.UniqueId4j;

import java.io.Serializable;
import org.bot4j.base.request.BaseOptions;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TelegramOptions implements Serializable {
public class TelegramOptions extends BaseOptions {
public TelegramOptions() {
super();
this.setRequestId(String.valueOf(UniqueId4j.getUniqueId19()));
}

private String requestId;

public String getRequestId() {
return requestId;
}

public void setRequestId(String requestId) {
this.requestId = requestId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.bot4j.viber.model.builder;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.bot4j.viber.model.request.ViberConnections;

import java.io.Serializable;

@JsonIgnoreProperties(ignoreUnknown = true)
public class ViberConnectionBuilder implements Serializable {
public ViberConnectionBuilder() {
super();
}

private boolean debugging = false; // enable to trace log as debug mode
private boolean skip = false; // skipping the action for sending message
private boolean retry = false; // enable retry REST HTTP API when sending message got failure
private int maxRetries = 2; // retry no. times when sending message, default is 2 times

public ViberConnectionBuilder debugging(boolean value) {
this.debugging = value;
return this;
}

public ViberConnectionBuilder skip(boolean value) {
this.skip = value;
return this;
}

public ViberConnectionBuilder retry(boolean value) {
this.retry = value;
return this;
}

public ViberConnectionBuilder maxRetries(int value) {
this.maxRetries = value;
return this;
}

public ViberConnections build() {
ViberConnections e = new ViberConnections();
e.setDebugging(debugging);
e.setSkip(skip);
e.setRetry(retry);
e.setMaxRetries(maxRetries);
return e;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.bot4j.viber.model.builder;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.bot4j.viber.model.request.ViberOptions;
import org.unify4j.common.UniqueId4j;

import java.io.Serializable;

@JsonIgnoreProperties(ignoreUnknown = true)
public class ViberOptionBuilder implements Serializable {
public ViberOptionBuilder() {
super();
this.requestId = String.valueOf(UniqueId4j.getUniqueId19());
}

private String requestId;

public ViberOptionBuilder requestId(String value) {
this.requestId = value;
return this;
}

public ViberOptions build() {
ViberOptions e = new ViberOptions();
e.setRequestId(this.requestId);
return e;
}
}
Loading

0 comments on commit cd4e53b

Please sign in to comment.