-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Messages API Q3 2024 updates (#542)
* Bump versions * Factor out Text & TTL * Add RCS text * MessagePayload in base class * Factor out custom messages * Additional WhatsApp Referral properties * Fix viber_service deserialisation * MMS content test * Add remaining RCS outbound tests * Add WhatsApp Reaction * Add WhatsApp Button * Move Button up to accomodate RCS * Add vCard name * Add update message endpoint * Require context for Reaction * Update tests
- Loading branch information
Showing
67 changed files
with
2,005 additions
and
406 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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2024 Vonage | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.vonage.client; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonValue; | ||
|
||
/** | ||
* Enum representing the different regions that the Vonage API can be accessed from. | ||
* | ||
* @since 8.11.0 | ||
*/ | ||
public enum ApiRegion { | ||
/** | ||
* The region for the Vonage API in Europe. | ||
*/ | ||
API_EU, | ||
|
||
/** | ||
* The region for the Vonage API in the US. | ||
*/ | ||
API_US, | ||
|
||
/** | ||
* The region for the Vonage API in Asia Pacific. | ||
*/ | ||
API_AP; | ||
|
||
@JsonValue | ||
@Override | ||
public String toString() { | ||
return name().toLowerCase().replace("_", "-"); | ||
} | ||
|
||
/** | ||
* Converts a string representation of a region to the corresponding enum value. | ||
* | ||
* @param region The region as a string. | ||
* @return The region enum, or {@code null} if the input is {@code null}. | ||
*/ | ||
@JsonCreator | ||
public static ApiRegion fromString(String region) { | ||
if (region == null) return null; | ||
return valueOf(region.toUpperCase().replace("-", "_")); | ||
} | ||
} |
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
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,63 @@ | ||
/* | ||
* Copyright 2024 Vonage | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.vonage.client.messages; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.vonage.client.JsonableBaseObject; | ||
import java.util.Map; | ||
|
||
/** | ||
* Used for inbound Button messages. | ||
* | ||
* @since 8.11.0 | ||
*/ | ||
public final class Button extends JsonableBaseObject { | ||
private Object payload; | ||
private String text, subtype; | ||
|
||
Button() {} | ||
|
||
/** | ||
* Payload for the button. Contents can be varied depending on the type of button. | ||
* For WhatsApp messages, this will be a Map. For RCS, this will be a String. | ||
* | ||
* @return The button payload, or {@code null} if absent. | ||
*/ | ||
@JsonProperty("payload") | ||
public Object getPayload() { | ||
return payload; | ||
} | ||
|
||
/** | ||
* Additional context for the button. | ||
* | ||
* @return The button text, or {@code null} if absent. | ||
*/ | ||
@JsonProperty("text") | ||
public String getText() { | ||
return text; | ||
} | ||
|
||
/** | ||
* Subtype of button being received. This only applies to WhatsApp messages. | ||
* | ||
* @return The button subtype, or {@code null} if absent / not applicable. | ||
*/ | ||
@JsonProperty("subtype") | ||
public String getSubtype() { | ||
return subtype; | ||
} | ||
} |
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
Oops, something went wrong.