-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for updating Conversations webhooks
* Added update conversation webhook call includes unit tests Refactoring ConversationWebhookTest to use mocking instead of Spying service Refactored DTOs * Added an example for updating conversation webhook * Fixed comments on PR and upgraded to Java 11 Added status to ConversationWebhook Reverted Conversation web hook request for backwards compatibility Extracted creation of objects used in tests to TestUtil Added support for default values in example of testing update of conversation web hook * Updated travis ci to support Oracle JDK 11 * Updated major version * Renaming of DTO and testing against 11th of oracle and open jdks * Updated README.md * Updated travis ci job to remove matrix that was causing an extra build job to run
- Loading branch information
1 parent
defc2c0
commit 7f9f332
Showing
15 changed files
with
396 additions
and
151 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
<groupId>com.messagebird</groupId> | ||
<artifactId>messagebird-api</artifactId> | ||
<version>2.1.2</version> <!-- | ||
<version>3.0.0</version> <!-- | ||
are you going to bump a major number? | ||
then you are pleased to replace com.messagebird.Base64 with some library, for example net.iharder.base64 | ||
--> | ||
|
@@ -43,7 +43,7 @@ | |
<developerConnection>scm:git:[email protected]:messagebird/java-rest-api.git</developerConnection> | ||
<url>[email protected]:messagebird/java-rest-api.git</url> | ||
<tag>HEAD</tag> | ||
</scm> | ||
</scm> | ||
|
||
<profiles> | ||
<profile> | ||
|
@@ -67,7 +67,7 @@ | |
<profile> | ||
<id>disable-doclint</id> | ||
<activation> | ||
<jdk>[1.8,)</jdk> | ||
<jdk>[11,)</jdk> | ||
</activation> | ||
<properties> | ||
<doclint>none</doclint> | ||
|
@@ -140,7 +140,7 @@ | |
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>3.0.0</version> | ||
<version>3.1.0</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
|
@@ -177,8 +177,8 @@ | |
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.7.0</version> | ||
<configuration> | ||
<source>1.7</source> | ||
<target>1.7</target> | ||
<source>11</source> | ||
<target>11</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
|
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
41 changes: 41 additions & 0 deletions
41
api/src/main/java/com/messagebird/objects/conversations/ConversationWebhookBaseRequest.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,41 @@ | ||
package com.messagebird.objects.conversations; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Contains common fields for webhook requests. | ||
*/ | ||
public abstract class ConversationWebhookBaseRequest { | ||
protected String url; | ||
protected List<ConversationWebhookEvent> events; | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
public List<ConversationWebhookEvent> getEvents() { | ||
return events; | ||
} | ||
|
||
public void setEvents(List<ConversationWebhookEvent> events) { | ||
this.events = events; | ||
} | ||
|
||
protected abstract String getRequestName(); | ||
|
||
protected abstract String getStringRepresentationOfExtraParameters(); | ||
|
||
@Override | ||
public String toString() { | ||
return getRequestName() + "{" + | ||
getStringRepresentationOfExtraParameters() + '\'' + | ||
", url='" + url + '\'' + | ||
", events=" + events.stream().map(ConversationWebhookEvent::toString).collect(Collectors.joining(",")) + | ||
'}'; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...src/main/java/com/messagebird/objects/conversations/ConversationWebhookCreateRequest.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,31 @@ | ||
package com.messagebird.objects.conversations; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Request object used to create webhooks. | ||
*/ | ||
public class ConversationWebhookCreateRequest extends ConversationWebhookBaseRequest{ | ||
|
||
private String channelId; | ||
|
||
public ConversationWebhookCreateRequest( | ||
final String channelId, | ||
final String url, | ||
final List<ConversationWebhookEvent> events | ||
) { | ||
this.channelId = channelId; | ||
this.url = url; | ||
this.events = events; | ||
} | ||
|
||
@Override | ||
protected String getRequestName() { | ||
return "ConversationWebhookCreateRequest"; | ||
} | ||
|
||
@Override | ||
protected String getStringRepresentationOfExtraParameters() { | ||
return "channelId='" + channelId; | ||
} | ||
} |
60 changes: 0 additions & 60 deletions
60
api/src/main/java/com/messagebird/objects/conversations/ConversationWebhookRequest.java
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
api/src/main/java/com/messagebird/objects/conversations/ConversationWebhookStatus.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,43 @@ | ||
package com.messagebird.objects.conversations; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
/** | ||
* Indicates whether a conversation webhook is <strong>enabled</strong> or <strong>disabled</strong>. | ||
*/ | ||
public enum ConversationWebhookStatus { | ||
ENABLED("enabled"), | ||
DISABLED("disabled"); | ||
|
||
private final String status; | ||
|
||
ConversationWebhookStatus(final String status) { | ||
this.status = status; | ||
} | ||
|
||
@JsonCreator | ||
public static ConversationWebhookStatus forValue(final String value) { | ||
for (ConversationWebhookStatus conversationWebhookStatus : ConversationWebhookStatus.values()) { | ||
if (conversationWebhookStatus.getStatus().equals(value)) { | ||
return conversationWebhookStatus; | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@JsonValue | ||
public String toJson() { | ||
return getStatus(); | ||
} | ||
|
||
public String getStatus() { | ||
return status; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getStatus(); | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...src/main/java/com/messagebird/objects/conversations/ConversationWebhookUpdateRequest.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,38 @@ | ||
package com.messagebird.objects.conversations; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Request object used to update webhook. | ||
*/ | ||
public class ConversationWebhookUpdateRequest extends ConversationWebhookBaseRequest { | ||
private ConversationWebhookStatus status; | ||
|
||
public ConversationWebhookUpdateRequest( | ||
final ConversationWebhookStatus status, | ||
final String url, | ||
final List<ConversationWebhookEvent> events | ||
) { | ||
this.status = status; | ||
this.url = url; | ||
this.events = events; | ||
} | ||
|
||
public ConversationWebhookStatus getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(ConversationWebhookStatus status) { | ||
this.status = status; | ||
} | ||
|
||
@Override | ||
protected String getRequestName() { | ||
return "ConversationWebhookUpdateRequest"; | ||
} | ||
|
||
@Override | ||
protected String getStringRepresentationOfExtraParameters() { | ||
return "status='" + status; | ||
} | ||
} |
Oops, something went wrong.