From 3df462cb8efa8266e46e1ff06f2ccadf511a8547 Mon Sep 17 00:00:00 2001 From: Norbert Bartels Date: Tue, 4 Feb 2020 23:27:12 +0100 Subject: [PATCH] Issue #1055 - One-time notification api added --- .../send/OneTimeNotifMessageRecipient.java | 38 +++++++++++++++++ .../send/OneTimeNotifReqTemplatePayload.java | 42 +++++++++++++++++++ .../types/webhook/messaging/OptinItem.java | 19 +++++++++ 3 files changed, 99 insertions(+) create mode 100644 src/main/lombok/com/restfb/types/send/OneTimeNotifMessageRecipient.java create mode 100644 src/main/lombok/com/restfb/types/send/OneTimeNotifReqTemplatePayload.java diff --git a/src/main/lombok/com/restfb/types/send/OneTimeNotifMessageRecipient.java b/src/main/lombok/com/restfb/types/send/OneTimeNotifMessageRecipient.java new file mode 100644 index 000000000..cd53d273b --- /dev/null +++ b/src/main/lombok/com/restfb/types/send/OneTimeNotifMessageRecipient.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2020 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.send; + +import com.restfb.Facebook; +import com.restfb.types.AbstractFacebookType; + +import lombok.Getter; + +public class OneTimeNotifMessageRecipient extends AbstractFacebookType implements MessageRecipient { + + @Getter + @Facebook("one_time_notif_token") + private String oneTimeNotifToken; + + public OneTimeNotifMessageRecipient(String oneTimeNotifToken) { + this.oneTimeNotifToken = oneTimeNotifToken; + } +} diff --git a/src/main/lombok/com/restfb/types/send/OneTimeNotifReqTemplatePayload.java b/src/main/lombok/com/restfb/types/send/OneTimeNotifReqTemplatePayload.java new file mode 100644 index 000000000..1ce3e3b9b --- /dev/null +++ b/src/main/lombok/com/restfb/types/send/OneTimeNotifReqTemplatePayload.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2010-2020 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.send; + +import com.restfb.Facebook; +import lombok.Getter; + +public class OneTimeNotifReqTemplatePayload extends TemplatePayload { + + @Getter + @Facebook + private String title; + + @Getter + @Facebook + private String payload; + + public OneTimeNotifReqTemplatePayload(String title, String payload) { + this.title = title; + this.payload = payload; + setTemplateType("one_time_notif_req"); + } +} diff --git a/src/main/lombok/com/restfb/types/webhook/messaging/OptinItem.java b/src/main/lombok/com/restfb/types/webhook/messaging/OptinItem.java index 528e510e5..a13320ce6 100644 --- a/src/main/lombok/com/restfb/types/webhook/messaging/OptinItem.java +++ b/src/main/lombok/com/restfb/types/webhook/messaging/OptinItem.java @@ -42,6 +42,21 @@ public class OptinItem implements InnerMessagingItem { @Facebook("user_ref") private String userRef; + @Getter + @Setter + @Facebook + private String type; + + @Getter + @Setter + @Facebook + private String payload; + + @Getter + @Setter + @Facebook("one_time_notif_token") + private String oneTimeNotifToken; + @Getter private UserRefMessageRecipient userRefMessageRecipient; @@ -51,4 +66,8 @@ private void provideRecipient() { userRefMessageRecipient = new UserRefMessageRecipient(userRef); } } + + public boolean isOneTimeNotif() { + return oneTimeNotifToken != null; + } }