Skip to content

Commit

Permalink
Ignore unknown properties on webhooks
Browse files Browse the repository at this point in the history
Prevent webhook deserialization failing when Meta adds a field.
Fixes Bindambc#127
  • Loading branch information
sgdesmet committed Jan 2, 2024
1 parent 9153eb9 commit dcd64ea
Show file tree
Hide file tree
Showing 40 changed files with 80 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Address.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Address.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Address(

@JsonProperty("zip") String zip,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Audio.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand All @@ -9,6 +10,7 @@
* @param mimeType The mime type of the media. The caption that describes the media.
* @param id The ID of the medi
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Audio(

@JsonProperty("mime_type") String mimeType,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/BanInfo.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Ban info.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record BanInfo(@JsonProperty("waba_ban_state") String wabaBanState,

@JsonProperty("waba_ban_date") String wabaBanDate
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Button.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand All @@ -8,6 +9,7 @@
* @param payload The developer-defined payload for the button when a business account sends interactive messages.
* @param text The button text
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Button(

@JsonProperty("payload") String payload,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand All @@ -8,6 +9,7 @@
* @param id The unique identifier of the button.
* @param title The title of the button.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record ButtonReply(

@JsonProperty("id")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Change.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.whatsapp.api.domain.webhook.type.FieldType;

Expand All @@ -9,6 +10,7 @@
* @param field A value object. Contains details of the changes related to the specified field.
* @param value Contains the type of notification you are getting on that Webhook. Currently, the only option for this API is “messages”.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Change(
/*
Contains the type of notification you are getting on that Webhook. Currently, the only option for this API is “messages”.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Contact.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;
Expand All @@ -10,6 +11,7 @@
* @param profile The {@link Profile} object.
* @param waId The WhatsApp ID of the customer. You can send messages using this wa_id.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Contact(

@JsonProperty("profile") Profile profile,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Context.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand All @@ -11,6 +12,7 @@
* @param forwarded Added to Webhooks if message was forwarded. Set to true if the received message has been forwarded.
* @param frequentlyForwarded Added to Webhooks if message has been frequently forwarded.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Context(

@JsonProperty("from") String from,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand All @@ -9,6 +10,7 @@
* @param origin Describes where the conversation originated from. See {@link Origin} object for more information.
* @param id The ID of the conversation the given status notification belongs to.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Conversation(

@JsonProperty("expiration_timestamp") String expirationTimestamp,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Disable info.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record DisableInfo(@JsonProperty("disable_date") String disableDate) {
}
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Document.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand All @@ -11,6 +12,7 @@
* @param id ID for the document
* @param caption Caption for the document, if provided
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Document(

@JsonProperty("filename") String filename,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Email.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Email.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Email(

@JsonProperty("type")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Entry.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;
Expand All @@ -11,6 +12,7 @@
* @param id The ID of Whatsapp Business Accounts this Webhook belongs to.
* @param time Time for the entry. (WhatsApp Business Management API)
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Entry(

/*
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Error.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Error.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Error(

@JsonProperty("code")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/ErrorData.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Error data.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record ErrorData(

@JsonProperty("details")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Image.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand All @@ -10,6 +11,7 @@
* @param caption Added to Webhooks if it has been previously specified. The caption that describes the media.
* @param id The ID of the medi
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Image(

@JsonProperty("sha256") String sha256,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand All @@ -9,6 +10,7 @@
* @param type Contains the type of interactive object. Supported options are:<ul> <li>button_reply: for responses of Reply Buttons.</li> <li>list_reply: for responses to List Messages and other interactive objects.</li></ul>
* @param buttonReply Used on Webhooks related to Reply Buttons. Contains a {@link ButtonReply} reply object.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Interactive(

@JsonProperty("list_reply") ListReply listReply,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/ListReply.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand All @@ -9,6 +10,7 @@
* @param id The unique identifier (ID) of the selected row.
* @param title The title of the selected row.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record ListReply(

@JsonProperty("description")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Location.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Location.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Location(

@JsonProperty("address") String address,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Message.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.whatsapp.api.domain.messages.type.MessageType;

Expand Down Expand Up @@ -29,6 +30,7 @@
* @param audio A media object with the audio information. Added to Webhook if type is audio (including voice messages). See {@link Audio}
* @param document A media object with the document information. Added to Webhook if type is document. See {@link Document}
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Message(

@JsonProperty("reaction") Reaction reaction,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Metadata.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
Expand All @@ -8,6 +9,7 @@
* @param phoneNumberId The ID of the phone number receiving the Webhooks. You can use this phone_number_id to send messages back to customers.
* @param displayPhoneNumber The phone number of the business account that is receiving the Webhooks.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Metadata(
/*
The ID of the phone number receiving the Webhooks. You can use this phone_number_id to send messages back to customers.
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Name.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Name.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Name(

@JsonProperty("prefix") String prefix,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Order.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;

/**
* The type Order.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Order(

@JsonProperty("catalog_id") String catalogId,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Org.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Org.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Org(

@JsonProperty("company") String company,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Origin.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Origin.
*
* @param type Indicates where a conversation has started. This can also be referred to as a conversation entry point. Currently, the available options are: <ul><li>business_initiated: indicates that the conversation started by a business sending the first message to a user. This applies any time it has been more than 24 hours since the last user message.</li> <li>user_initiated: indicates that the conversation started by a business replying to a user message. This applies only when the business reply is within 24 hours of the last user message.</li> <li>referral_conversion: indicates that the conversation originated from a free entry point. These conversations are always user-initiated.</li> </ul>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Origin(

@JsonProperty("type") String type
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Phone.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Phone.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Phone(

@JsonProperty("phone") String phone,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Pricing.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Pricing.
*
* @param pricingModel Type of pricing model being used. Current supported values are:<ul> <li>"CBP" (conversation-based pricing): See Conversation-Based Pricing for rates based on recipient country.</li> <li>"NBP" (notification-based pricing): Notifications are also known as Template Messages (click here for details on pricing).</li> </ul> This pricing model will be deprecated in a future release early 2022.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Pricing(

@JsonProperty("pricing_model") String pricingModel,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/whatsapp/api/domain/webhook/Product.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package com.whatsapp.api.domain.webhook;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* The type Product.
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record Product(

@JsonProperty("quantity") String quantity,
Expand Down
Loading

0 comments on commit dcd64ea

Please sign in to comment.