Return Methods
There are multiple return methods that help you determine the status of your request.
Common Methods
These methods are supported across all methods
These methods are available in the base response class and commonly used across all response types.
-
isSuccess()
: Checks if the operation was successful. This method should be implemented by subclasses to define what constitutes success for their specific response type. -
getFullResponse()
: Returns the complete, raw JSON response from the API. Useful for debugging or accessing other data not directly exposed by this class's properties. -
getErrorMessage()
: Retrieves a descriptive error message if the operation failed. It parses theerror
field from the full response to return a human-readable message, or a generic message if no error is found. -
getErrorCode()
: Gets the numeric error code from a failed operation. Returns thecode
field from the error object in the API response, or0
if the operation was successful. -
getErrorType()
: Gets the type of error from a failed operation. Returns thetype
field from the error object in the API response, or an empty string if the operation was successful.
Messages Methods
These methods are specific to other response types such as messaging, templates, etc.
-
getMessageId()
: Returns the unique ID of the sent message. -
getContactId()
: Returns the WhatsApp ID of the recipient contact.
Media Methods
These methods are specific to media-related operations such as uploading, getting, or deleting media.
-
getMediaId()
: Returns the WhatsApp ID of the uploaded or retrieved media. -
getMediaUrl()
: Returns the full URL of the media. -
getMediaMimeType()
: Returns the MIME type of the media. -
getMediaSha256()
: Returns the SHA-256 hash of the media. -
getMediaFileSize()
: Returns the file size of the media. -
isDeleted()
: Checks if the media was deleted successfully. This method is deprecated and should be replaced withisSuccess()
. It returns the result of callingisSuccess()
. -
isUploaded()
: Deprecated. CallsisSuccess()
and returns the result.
Business Account Methods
These methods are specific to other response types such as messaging, business accounts, and user management.
-
getAbout()
: Returns theabout
field value or an empty string. -
getAddress()
: Returns theaddress
field value or an empty string. -
getDescription()
: Returns thedescription
field value or an empty string. -
getEmail()
: Returns theemail
field value or an empty string. -
getProfilePictureUrl()
: Returns theprofilePictureUrl
field value or an empty string. -
getVertical()
: Returns thevertical
field value or an empty string. -
getWebsites()
: Returns thewebsites
field value or an empty string.
Users Block/Unblock Methods
-
isSomeSuccess()
: Checks if some users were blocked (partial success). Returnstrue
if there are failed users, indicating partial success. -
getUsersList()
: Returns the list of blocked users. -
getCursorBefore()
: Returns the cursor for pagination to get the previous page of results. -
getCursorAfter()
: Returns the cursor for pagination to get the next page of results.
Resumable Methods
-
getId()
: Returns the id of created resumable upload session. -
getH()
: Returns theh
id of uploaded image. -
getFileOffset()
: Returns the file size in bytes of created resumable upload session.