Class WhatsAppClient
- java.lang.Object
-
- org.pahappa.systems.whatsapphelper.WhatsAppClient
-
public class WhatsAppClient extends java.lang.ObjectClass that handles the processing of the notification object. This class is responsible for performing Webhook verification, as well parsing the notification object.- Author:
- katusiimeconrad
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringchallengeUsed to verify the webhook.private java.lang.StringmodeStores the mode of the request e.g.private java.lang.StringverificationTokenA token set by the application to use for authentication with the whatsapp endpoint.private java.lang.Stringverify_tokenThe secret key used to verify the webhook.
-
Constructor Summary
Constructors Constructor Description WhatsAppClient(java.lang.String verificationToken)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringdoAuth(java.util.Map<java.lang.String,java.lang.String> params)Performs the authentication of the webhook.MessageEntitygetNotification(NotificationObject notificationObject)Handles the receiving of the notifications from the whatsapp webhook.java.lang.StringgetVerificationToken()voidsetVerificationToken(java.lang.String verificationToken)
-
-
-
Field Detail
-
mode
private java.lang.String mode
Stores the mode of the request e.g. "subscribe" or "unsubscribe".
-
verify_token
private java.lang.String verify_token
The secret key used to verify the webhook. To be set in the webhook configuration in WhatsApp.
-
challenge
private java.lang.String challenge
Used to verify the webhook.
-
verificationToken
private java.lang.String verificationToken
A token set by the application to use for authentication with the whatsapp endpoint. Set by me in this application
-
-
Method Detail
-
doAuth
public java.lang.String doAuth(java.util.Map<java.lang.String,java.lang.String> params) throws java.lang.ExceptionPerforms the authentication of the webhook. By extracting the token from the request and comparing it to the token set in the webhook configuration.- Returns:
- challenge
- Throws:
java.lang.Exception
-
getNotification
public MessageEntity getNotification(NotificationObject notificationObject) throws java.lang.Exception
Handles the receiving of the notifications from the whatsapp webhook.Receives the body of the request and extracts Message, From, To, Type and Id. Can be modified to extract more information from the request.
Returns the Notification object to the Caller.
Guide : ...
- Parameters:
notificationObject- - the body of the request- Returns:
- Throws:
java.lang.Exception
-
getVerificationToken
public java.lang.String getVerificationToken()
-
setVerificationToken
public void setVerificationToken(java.lang.String verificationToken)
-
-