Package com.whatsapp.api.impl
Class WhatsappBusinessCloudApi
java.lang.Object
com.whatsapp.api.impl.WhatsappBusinessCloudApi
Implementation of WhatsApp Business Platform Cloud API with synchronous/blocking
method calls.
- See Also:
-
Constructor Summary
ConstructorDescriptionWhatsappBusinessCloudApi
(String token) Instantiates a new Whatsapp business cloud api.WhatsappBusinessCloudApi
(String token, ApiVersion apiVersion) Instantiates a new Whatsapp business cloud api, specifying API version -
Method Summary
Modifier and TypeMethodDescriptiondeleteMedia
(String mediaId) Delete media from whatsapp serverdownloadMediaFile
(String url) Download media file from whatsapp servermarkMessageAsRead
(String phoneNumberId, ReadMessage message) Mark a message as ReadretrieveMediaUrl
(String mediaId) RetrieveMedia
object.sendMessage
(String phoneNumberId, Message message) Use this endpoint to send text, media, contacts, location, and interactive messages, as well as message templates to your customers.twoStepVerification
(String phoneNumberId, TwoStepCode twoStepCode) Business Solution Providers (BSPs) must authenticate themselves with an access token with the whatsapp_business_management permission.uploadMedia
(String phoneNumberId, String fileName, FileType fileType, byte[] file) You can use the endpoint to upload media: All media files sent through this endpoint are encrypted and persist for 30 days, unless they are deleted earlier
-
Constructor Details
-
WhatsappBusinessCloudApi
Instantiates a new Whatsapp business cloud api.- Parameters:
token
- the token
-
WhatsappBusinessCloudApi
Instantiates a new Whatsapp business cloud api, specifying API version- Parameters:
token
- the tokenapiVersion
- api version
-
-
Method Details
-
sendMessage
Use this endpoint to send text, media, contacts, location, and interactive messages, as well as message templates to your customers.- Parameters:
phoneNumberId
- Represents a specific phone number.message
- TheMessage
object.- Returns:
MessageResponse
- See Also:
-
uploadMedia
public UploadResponse uploadMedia(String phoneNumberId, String fileName, FileType fileType, byte[] file) You can use the endpoint to upload media: All media files sent through this endpoint are encrypted and persist for 30 days, unless they are deleted earlierThe maximum supported file size for media messages on Cloud API is 100MB. In the event the customer sends a file that is greater than 100MB, you will receive a webhook with error code 131052 and title: "Media file size too big. Max file size we currently support: 100MB. Please communicate with your customer to send a media file that is smaller than 100MB"_. We advise that you send customers a warning message that their media file exceeds the maximum file size when this webhook event is triggered.
- Parameters:
phoneNumberId
- Business phone number ID. If included, the operation will only be processed if the ID matches the ID of the business phone number that the media was uploaded on.fileName
- file name. Ex: photo1.jpgfileType
- the file type. SeeFileType
file
- byte[] - file content- Returns:
UploadResponse
- See Also:
-
retrieveMediaUrl
RetrieveMedia
object. A successful response includes an object with a media url. The URL is only valid for 5 minutes. To use this URL, seedownloadMediaFile(String)
- Parameters:
mediaId
- the media id- Returns:
- the media
- See Also:
-
downloadMediaFile
Download media file from whatsapp server- Parameters:
url
- the url- Returns:
- the media file
MediaFile
- See Also:
-
deleteMedia
Delete media from whatsapp server- Parameters:
mediaId
- the media id- Returns:
- the response
- See Also:
-
markMessageAsRead
Mark a message as Read- Parameters:
phoneNumberId
- Represents a specific phone number.message
- TheReadMessage
object.- Returns:
- the response
- See Also:
-
twoStepVerification
Business Solution Providers (BSPs) must authenticate themselves with an access token with the whatsapp_business_management permission.- Parameters:
phoneNumberId
- Represents a specific phone number.twoStepCode
- TheTwoStepCode
object.- Returns:
- the response
- See Also:
-