-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from facebookincubator/hunter/better_send_resp…
…onse_handling more flexible handling of responses from the cloud api
- Loading branch information
Showing
3 changed files
with
117 additions
and
49 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
51 changes: 51 additions & 0 deletions
51
src/main/java/com/meta/cp4m/message/webhook/whatsapp/SendResponse.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,51 @@ | ||
/* | ||
* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.meta.cp4m.message.webhook.whatsapp; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
public record SendResponse( | ||
String messagingProduct, | ||
List<SendResponseContact> contacts, | ||
List<SendResponseMessages> messages) { | ||
@JsonCreator | ||
public SendResponse( | ||
@JsonProperty("messaging_product") String messagingProduct, | ||
@JsonProperty("contacts") List<SendResponseContact> contacts, | ||
@JsonProperty("messages") List<SendResponseMessages> messages) { | ||
this.messagingProduct = messagingProduct; | ||
this.contacts = contacts == null ? Collections.emptyList() : contacts; | ||
this.messages = messages == null ? Collections.emptyList() : messages; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "SendResponse[" | ||
+ "messagingProduct=" | ||
+ messagingProduct | ||
+ ", " | ||
+ "contacts=" | ||
+ contacts | ||
+ ", " | ||
+ "messages=" | ||
+ messages | ||
+ ']'; | ||
} | ||
|
||
public record SendResponseContact( | ||
@JsonProperty("input") String phoneNumber, @JsonProperty("wa_id") String phoneNumberId) {} | ||
|
||
public record SendResponseMessages( | ||
@JsonProperty("id") String messageId, | ||
@Nullable @JsonProperty("message_status") String messageStatus) {} | ||
} |
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