forked from baloise/rocket-chat-notifier
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new-rocket-api): first basic implementation (see #JENKINS-40595)
- Loading branch information
Showing
14 changed files
with
789 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/main/java/jenkins/plugins/rocketchatnotifier/model/Response.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package jenkins.plugins.rocketchatnotifier.model; | ||
|
||
|
||
public class Response { | ||
private boolean success; | ||
private Message[] messages; | ||
private Message message; | ||
private User[] users; | ||
private User user; | ||
private Room[] channels; | ||
private Room channel; | ||
|
||
public void setSuccess(boolean result) { | ||
this.success = result; | ||
} | ||
|
||
public boolean isSuccessful() { | ||
return this.success; | ||
} | ||
|
||
public void setMessages(final Message[] messages) { | ||
this.messages = messages.clone(); | ||
} | ||
|
||
public Message[] getMessages() { | ||
return this.messages.clone(); | ||
} | ||
|
||
public boolean isMessages() { | ||
return this.messages != null; | ||
} | ||
|
||
public void setMessage(final Message message) { | ||
this.message = message; | ||
} | ||
|
||
public Message getMessage() { | ||
return this.message; | ||
} | ||
|
||
public boolean isMessage() { | ||
return this.message != null; | ||
} | ||
|
||
public void setUsers(final User[] users) { | ||
this.users = users.clone(); | ||
} | ||
|
||
public User[] getUsers() { | ||
return this.users.clone(); | ||
} | ||
|
||
public Room[] getChannels() { | ||
return this.channels.clone(); | ||
} | ||
|
||
public boolean isUsers() { | ||
return this.users != null; | ||
} | ||
|
||
public void setUser(final User user) { | ||
this.user = user; | ||
} | ||
|
||
public User getUser() { | ||
return this.user; | ||
} | ||
|
||
public boolean isUser() { | ||
return this.user != null; | ||
} | ||
} |
139 changes: 139 additions & 0 deletions
139
src/main/java/jenkins/plugins/rocketchatnotifier/model/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
package jenkins.plugins.rocketchatnotifier.model; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* Represents a Rocket.Chat user. | ||
* | ||
* @author Bradley Hilton (graywolf336) | ||
* @version 0.0.1 | ||
* @since 0.1.0 | ||
*/ | ||
public class User extends Identified { | ||
private String username, name; | ||
private Date createdAt, lastLogin; | ||
private boolean active; | ||
private int utcOffset; | ||
|
||
/** | ||
* Sets the username of this user. | ||
* | ||
* @param username of this user | ||
*/ | ||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
/** | ||
* Gets the username of this user. | ||
* | ||
* @return user of this user | ||
*/ | ||
public String getUsername() { | ||
return this.username; | ||
} | ||
|
||
/** | ||
* Sets the display name of this user. | ||
* | ||
* @param name of this user | ||
*/ | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
/** | ||
* Gets the display name of this user. | ||
* | ||
* @return the name of this user | ||
*/ | ||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
/** | ||
* Sets the created date of this user. | ||
* | ||
* @param date this user was created | ||
*/ | ||
public void setCreatedAt(Date date) { | ||
this.createdAt = new Date(date.getTime()); | ||
} | ||
|
||
/** | ||
* Gets the date this user was created | ||
* | ||
* @return creation date of this user | ||
*/ | ||
public Date getCreatedAt() { | ||
return new Date(this.createdAt.getTime()); | ||
} | ||
|
||
/** | ||
* Sets the last login date of this user. | ||
* | ||
* @param date this user last logged in | ||
*/ | ||
public void setLastLogin(Date date) { | ||
this.lastLogin = new Date(date.getTime()); | ||
} | ||
|
||
/** | ||
* Gets the date this user last logged in | ||
* | ||
* @return last logged in date | ||
*/ | ||
public Date getLastLogin() { | ||
return new Date(this.lastLogin.getTime()); | ||
} | ||
|
||
/** | ||
* Sets whether this user is active or not | ||
* | ||
* @param active whether this user is active or not | ||
*/ | ||
public void setActive(boolean active) { | ||
this.active = active; | ||
} | ||
|
||
/** | ||
* Gets whether this user is active or not, non-active users can not log in. | ||
* | ||
* @return whether this user is logged in or not | ||
*/ | ||
public boolean getActive() { | ||
return this.active; | ||
} | ||
|
||
/** | ||
* Checks whether this user is active or not, non-active users can not log in. | ||
* | ||
* @return whether this user is logged in or not | ||
*/ | ||
public boolean isActive() { | ||
return this.active; | ||
} | ||
|
||
/** | ||
* Sets the UTC Offset of this user. | ||
* | ||
* @param offset of this user | ||
*/ | ||
public void setUtcOffset(int offset) { | ||
this.utcOffset = offset; | ||
} | ||
|
||
/** | ||
* Gets the UTC Offset of this user | ||
* | ||
* @return utc offset for this user | ||
*/ | ||
public int getUtcOffset() { | ||
return this.utcOffset; | ||
} | ||
} | ||
|
||
/* | ||
* "type": "user",//TODO: Convert to ENUM "status": "offline",//TODO: Convert to ENUM "roles": [ | ||
* "user" ], "statusConnection": "offline",//TODO: Convert to ENUM | ||
*/ |
13 changes: 13 additions & 0 deletions
13
src/main/java/jenkins/plugins/rocketchatnotifier/rocket/HttpMethods.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package jenkins.plugins.rocketchatnotifier.rocket; | ||
|
||
|
||
/** | ||
* Represents the http methods. | ||
* | ||
* @author Bradley Hilton (graywolf336) | ||
* @version 1.0.0 | ||
* @since 0.1.0 | ||
*/ | ||
public enum HttpMethods { | ||
GET, POST, PUT, DELETE, PATCH | ||
} |
Oops, something went wrong.