Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #1234 - Interactive object added to incoming WABP webhook message
- Loading branch information
Showing
5 changed files
with
253 additions
and
1 deletion.
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
88 changes: 88 additions & 0 deletions
88
src/main/lombok/com/restfb/types/whatsapp/platform/message/Interactive.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,88 @@ | ||
/* | ||
* Copyright (c) 2010-2022 Mark Allen, Norbert Bartels. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package com.restfb.types.whatsapp.platform.message; | ||
|
||
import com.restfb.Facebook; | ||
import com.restfb.types.AbstractFacebookType; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
public class Interactive extends AbstractFacebookType { | ||
|
||
@Getter | ||
@Setter | ||
@Facebook("list_reply") | ||
private Reply listReply; | ||
|
||
@Getter | ||
@Setter | ||
@Facebook("button_reply") | ||
private Reply buttonReply; | ||
|
||
@Getter | ||
@Setter | ||
private Type type; | ||
|
||
public Reply getReply() { | ||
if (buttonReply != null) { | ||
return buttonReply; | ||
} | ||
|
||
if (listReply != null) { | ||
return listReply; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public boolean isButtonReply() { | ||
return buttonReply != null; | ||
} | ||
|
||
public boolean isListReply() { | ||
return listReply != null; | ||
} | ||
|
||
public static class Reply extends AbstractFacebookType { | ||
|
||
@Getter | ||
@Setter | ||
private String id; | ||
|
||
@Getter | ||
@Setter | ||
private String title; | ||
|
||
@Getter | ||
@Setter | ||
private String description; | ||
} | ||
|
||
public enum Type { | ||
list_reply, button_reply | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
src/test/resources/json/whatsapp/webhook-incoming-message-interactive-btn.json
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 @@ | ||
{ | ||
"object": "whatsapp_business_account", | ||
"entry": [ | ||
{ | ||
"id": "101809759215303", | ||
"changes": [ | ||
{ | ||
"value": { | ||
"messaging_product": "whatsapp", | ||
"metadata": { | ||
"display_phone_number": "1234567891", | ||
"phone_number_id": "10634295353625" | ||
}, | ||
"contacts": [ | ||
{ | ||
"profile": { | ||
"name": "TestUser" | ||
}, | ||
"wa_id": "491234567890" | ||
} | ||
], | ||
"messages": [ | ||
{ | ||
"from": "491234567890", | ||
"id": "wamid.HBgNNDkxNTIwOTgzMzM5OBUCABIYHGDEHJVFHJEVCFHJEVBCMTkyODk1OEIyAA==", | ||
"timestamp": "1653253313", | ||
"interactive": { | ||
"button_reply": { | ||
"id": "unique-button-identifier-here", | ||
"title": "button-text" | ||
}, | ||
"type": "button_reply" | ||
}, | ||
"type": "interactive" | ||
} | ||
] | ||
}, | ||
"field": "messages" | ||
} | ||
] | ||
} | ||
] | ||
} |
44 changes: 44 additions & 0 deletions
44
src/test/resources/json/whatsapp/webhook-incoming-message-interactive-list.json
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,44 @@ | ||
{ | ||
"object": "whatsapp_business_account", | ||
"entry": [ | ||
{ | ||
"id": "101809759215303", | ||
"changes": [ | ||
{ | ||
"value": { | ||
"messaging_product": "whatsapp", | ||
"metadata": { | ||
"display_phone_number": "1234567891", | ||
"phone_number_id": "10634295353625" | ||
}, | ||
"contacts": [ | ||
{ | ||
"profile": { | ||
"name": "TestUser" | ||
}, | ||
"wa_id": "491234567890" | ||
} | ||
], | ||
"messages": [ | ||
{ | ||
"from": "491234567890", | ||
"id": "wamid.HBgNNDkxNTIwOTgzMzM5OBUCABIYHGDEHJVFHJEVCFHJEVBCMTkyODk1OEIyAA==", | ||
"timestamp": "1653253313", | ||
"interactive": { | ||
"list_reply": { | ||
"id": "list_reply_id", | ||
"title": "list_reply_title", | ||
"description": "list_reply_description" | ||
}, | ||
"type": "list_reply" | ||
}, | ||
"type": "interactive" | ||
} | ||
] | ||
}, | ||
"field": "messages" | ||
} | ||
] | ||
} | ||
] | ||
} |