Class Message

  • All Implemented Interfaces:
    API

    public class Message
    extends Object
    implements API
    Author:
    svenkubiak
    • Constructor Detail

      • Message

        public Message()
    • Method Detail

      • withToken

        public Message withToken​(String token)
        Your application's API token (required)
        Parameters:
        token - The pushover API token
        Returns:
        Message instance
      • withUser

        public Message withUser​(String user)
        The user/group key (not e-mail address) of your user (or you), viewable when logged into the @see pushover dashboard (required)
        Parameters:
        user - The username
        Returns:
        Message instance
      • withRetry

        public Message withRetry​(int retry)
        Specifies how often (in seconds) the Pushover servers will send the same notification to the user. Only required if priority is set to emergency. (optional)
        Parameters:
        retry - Number of seconds
        Returns:
        Message instance
      • withExpire

        public Message withExpire​(int expire)
        Specifies how many seconds your notification will continue to be retried for (every retry seconds). Only required if priority is set to emergency. (optional)
        Parameters:
        expire - Number of seconds
        Returns:
        Message instance
      • withMessage

        public Message withMessage​(String message)
        Your message (required)
        Parameters:
        message - The message to sent
        Returns:
        Message instance
      • withDevice

        public Message withDevice​(String device)
        Your user's device name to send the message directly to that device, rather than all of the user's devices (optional)
        Parameters:
        device - The device name
        Returns:
        Message instance
      • withTitle

        public Message withTitle​(String title)
        Your message's title, otherwise your app's name is used (optional)
        Parameters:
        title - The title
        Returns:
        Message instance
      • withUrl

        public Message withUrl​(String url)
        A supplementary URL to show with your message (optional)
        Parameters:
        url - The url
        Returns:
        Message instance
      • enableMonospace

        public Message enableMonospace()
        Enables HTML in the pushover message Either HTML or monospace can be enabled (optional)
        Returns:
        Message instance
      • enableHtml

        public Message enableHtml()
        Enables HTML in the pushover message Either HTML or monospace can be enabled (optional)
        Returns:
        Message instance
      • withUrlTitle

        public Message withUrlTitle​(String urlTitle)
        A title for your supplementary URL, otherwise just the URL is shown (optional)
        Parameters:
        urlTitle - The url title
        Returns:
        Message instance
      • withTimestamp

        public Message withTimestamp​(int timestamp)
        A Unix timestamp of your message's date and time to display to the user, rather than the time your message is received by our API (optional)
        Parameters:
        timestamp - The Unix timestamp
        Returns:
        Message instance
      • withPriority

        public Message withPriority​(Priority priority)
        Priority of the message based on the @see documentation (optional)
        Parameters:
        priority - The priority enum
        Returns:
        Message instance
      • withSound

        public Message withSound​(Sound sound)
        The name of one of the sounds supported by device clients to override the user's default sound choice (optional)
        Parameters:
        sound - THe sound enum
        Returns:
        Message instance
      • withCallback

        public Message withCallback​(String callback)
        Callback parameter may be supplied with a publicly-accessible URL that the pushover servers will send a request to when the user has acknowledged your notification. Only used if priority is set to emergency. (optional)
        Parameters:
        callback - The callback URL
        Returns:
        Message instance
      • withTTL

        public Message withTTL​(int ttl)
        Adds a ttl to the Pushover message
        Parameters:
        ttl - Seconds until this message should be automatically removed from the device. Needs to be positive
        Returns:
        Message instance
      • withProxy

        public Message withProxy​(String proxyHost,
                                 int proxyPort)
        Uses a given proxy for the HTTP requests to Pushover
        Parameters:
        proxyHost - The host that should be used for the Proxy
        proxyPort - The port that should be used for the Proxy
        Returns:
        Message instance
      • validate

        public boolean validate()
                         throws JPushoverException
        Sends a validation request to pushover ensuring that the token and user is correct, that there is at least one active device on the account. Requires token parameter Requires user parameter Optional device parameter to check specific device
        Returns:
        true if token and user are valid and at least on device is on the account, false otherwise
        Throws:
        JPushoverException