Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #1182 - Product template added to messaging webhook object
- Loading branch information
Showing
7 changed files
with
243 additions
and
2 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
57 changes: 57 additions & 0 deletions
57
src/main/lombok/com/restfb/types/webhook/messaging/ProductItem.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,57 @@ | ||
/* | ||
* Copyright (c) 2010-2021 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.webhook.messaging; | ||
|
||
import com.restfb.Facebook; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@ToString | ||
public class ProductItem { | ||
|
||
@Getter | ||
@Setter | ||
private String id; | ||
|
||
@Getter | ||
@Setter | ||
@Facebook("retailer_id") | ||
private String retailerId; | ||
|
||
@Getter | ||
@Setter | ||
@Facebook("image_url") | ||
private String imageUrl; | ||
|
||
@Getter | ||
@Setter | ||
private String title; | ||
|
||
@Getter | ||
@Setter | ||
private String subtitle; | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/lombok/com/restfb/types/webhook/messaging/ProductTemplateItem.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,40 @@ | ||
/* | ||
* Copyright (c) 2010-2021 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.webhook.messaging; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import com.restfb.Facebook; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
|
||
@ToString | ||
public class ProductTemplateItem { | ||
|
||
@Getter | ||
@Setter | ||
private List<ProductItem> elements = new ArrayList<>(); | ||
} |
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
42 changes: 42 additions & 0 deletions
42
src/test/resources/json/webhooks/messaging-message-product-template-2.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,42 @@ | ||
{ | ||
"object": "page", | ||
"entry": [ | ||
{ | ||
"id": "page id", | ||
"time": 1636729432317, | ||
"messaging": [ | ||
{ | ||
"sender": { | ||
"id": "send id" | ||
}, | ||
"recipient": { | ||
"id": "page id" | ||
}, | ||
"timestamp": 1636729431949, | ||
"message": { | ||
"mid": "m_id", | ||
"text": "text sent along with the product", | ||
"attachments": [ | ||
{ | ||
"type": "template", | ||
"payload": { | ||
"product": { | ||
"elements": [ | ||
{ | ||
"id": "12345678910", | ||
"retailer_id": "123456", | ||
"image_url": "https://scontent.xx.fbcdn.net/v/andSoOn.png", | ||
"title": "product name", | ||
"subtitle": "product price as a string" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
41 changes: 41 additions & 0 deletions
41
src/test/resources/json/webhooks/messaging-message-product-template.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,41 @@ | ||
{ | ||
"object": "page", | ||
"entry": [ | ||
{ | ||
"id": "682498302938465", | ||
"time": 1518479195594, | ||
"messaging": [ | ||
{ | ||
"sender": { | ||
"id": "<PSID>" | ||
}, | ||
"recipient": { | ||
"id": "<PAGE_ID>" | ||
}, | ||
"timestamp": 1518479195308, | ||
"message": { | ||
"mid": "mid.$cAAJdkrCd2ORnva8ErFhjGm0X_Q_c", | ||
"attachments": [ | ||
{ | ||
"type": "template", | ||
"payload": { | ||
"product": { | ||
"elements": [ | ||
{ | ||
"id": "<PRODUCT_ID>", | ||
"retailer_id": "<EXTERNAL_ID>", | ||
"image_url": "https://fb.cdn.com/sdsd", | ||
"title": "Some product title", | ||
"subtitle": "$40" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |