diff --git a/src/main/java/com/github/sheigutn/pushbullet/Pushbullet.java b/src/main/java/com/github/sheigutn/pushbullet/Pushbullet.java index db19ce6..c137f0c 100644 --- a/src/main/java/com/github/sheigutn/pushbullet/Pushbullet.java +++ b/src/main/java/com/github/sheigutn/pushbullet/Pushbullet.java @@ -149,7 +149,11 @@ public class Pushbullet implements Pushable { .registerSubtype(ClipEphemeral.class, "clip") .registerSubtype(DismissalEphemeral.class, "dismissal") .registerSubtype(NotificationEphemeral.class, "mirror") - .registerSubtype(SmsReplyEphemeral.class, "message_extension_reply")) + .registerSubtype(SmsReplyEphemeral.class, "message_extension_reply") + .registerSubtype(SmsChangedEphemeral.class, "sms_changed")) + .registerTypeAdapterFactory( + RuntimeTypeAdapterFactory.of(SmsNotification.class) + ) .registerTypeAdapterFactory(new EphemeralEncryptionHandler(this)) .create(); diff --git a/src/main/java/com/github/sheigutn/pushbullet/ephemeral/Ephemeral.java b/src/main/java/com/github/sheigutn/pushbullet/ephemeral/Ephemeral.java index 83f9c82..9fb9129 100644 --- a/src/main/java/com/github/sheigutn/pushbullet/ephemeral/Ephemeral.java +++ b/src/main/java/com/github/sheigutn/pushbullet/ephemeral/Ephemeral.java @@ -30,6 +30,9 @@ public enum EphemeralType { @SerializedName("messaging_extension_reply") SMS_REPLY, + @SerializedName("sms_changed") + SMS_CHANGED, + /** * Used for universal copy paste */ diff --git a/src/main/java/com/github/sheigutn/pushbullet/ephemeral/SmsChangedEphemeral.java b/src/main/java/com/github/sheigutn/pushbullet/ephemeral/SmsChangedEphemeral.java new file mode 100644 index 0000000..22bcd7e --- /dev/null +++ b/src/main/java/com/github/sheigutn/pushbullet/ephemeral/SmsChangedEphemeral.java @@ -0,0 +1,31 @@ +package com.github.sheigutn.pushbullet.ephemeral; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.ToString; +import lombok.experimental.Accessors; + +@Accessors(chain = true) +@Data +@ToString(callSuper = true) +public +class SmsChangedEphemeral extends Ephemeral +{ + + public + SmsChangedEphemeral() + { + setType(EphemeralType.SMS_CHANGED); + } + + /** + * The identity of the originating device + */ + @SerializedName("source_device_iden") + private String sourceDeviceIdentity; + + /** + * An array of SMS messages. + */ + private SmsNotification[] notifications; +} diff --git a/src/main/java/com/github/sheigutn/pushbullet/ephemeral/SmsNotification.java b/src/main/java/com/github/sheigutn/pushbullet/ephemeral/SmsNotification.java new file mode 100644 index 0000000..c36cd3e --- /dev/null +++ b/src/main/java/com/github/sheigutn/pushbullet/ephemeral/SmsNotification.java @@ -0,0 +1,41 @@ +package com.github.sheigutn.pushbullet.ephemeral; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * Note, the originating phone number is not always available through the pushbullet API. + */ +@Accessors(chain = true) +@Data +public +class SmsNotification +{ + @SerializedName("thread_id") + private String threadId; + + /** + * The person/company name that sent this text message (if the sender has an entry in the device's + * contacts database), otherwise this is usually the originating phone number (of varying degrees + * of normalization). + * + * e.g. "Hubby" + */ + private String title; + + /** + * The actual SMS/text message. + * + * e.g. "Hello" + */ + private String body; + + /** + * The unix-time (in seconds from 1970) that this message was received by the remote device. + * + * e.g. 1545606829 + */ + private Long timestamp; + +}