Class WhatsappBusinessCloudApi

java.lang.Object
com.whatsapp.api.impl.WhatsappBusinessCloudApi

public class WhatsappBusinessCloudApi extends Object
Implementation of WhatsApp Business Platform Cloud API with synchronous/blocking method calls.
See Also:
  • Constructor Details

    • WhatsappBusinessCloudApi

      public WhatsappBusinessCloudApi(String token)
      Instantiates a new Whatsapp business cloud api.
      Parameters:
      token - the token
    • WhatsappBusinessCloudApi

      public WhatsappBusinessCloudApi(String token, ApiVersion apiVersion)
      Instantiates a new Whatsapp business cloud api, specifying API version
      Parameters:
      token - the token
      apiVersion - api version
  • Method Details

    • sendMessage

      public MessageResponse 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.
      Parameters:
      phoneNumberId - Represents a specific phone number.
      message - The Message 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 earlier

      The 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.jpg
      fileType - the file type. See FileType
      file - byte[] - file content
      Returns:
      UploadResponse
      See Also:
    • retrieveMediaUrl

      public Media retrieveMediaUrl(String mediaId)
      Retrieve Media object. A successful response includes an object with a media url. The URL is only valid for 5 minutes. To use this URL, see downloadMediaFile(String)
      Parameters:
      mediaId - the media id
      Returns:
      the media
      See Also:
    • downloadMediaFile

      public MediaFile downloadMediaFile(String url)
      Download media file from whatsapp server
      Parameters:
      url - the url
      Returns:
      the media file MediaFile
      See Also:
    • deleteMedia

      public Response deleteMedia(String mediaId)
      Delete media from whatsapp server
      Parameters:
      mediaId - the media id
      Returns:
      the response
      See Also:
    • markMessageAsRead

      public Response markMessageAsRead(String phoneNumberId, ReadMessage message)
      Mark a message as Read
      Parameters:
      phoneNumberId - Represents a specific phone number.
      message - The ReadMessage object.
      Returns:
      the response
      See Also:
    • twoStepVerification

      public Response twoStepVerification(String phoneNumberId, TwoStepCode twoStepCode)
      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 - The TwoStepCode object.
      Returns:
      the response
      See Also: