public class Pushbullet
extends java.lang.Object
We implemented here the main Pushbullet features that can be useful for your project. The utilization is really simple. You can for example easily send some requests to your robots from any of your Pushbullet devices, receive a response from your robot, or even setup a notification system to be notified when some specific event occurs.
All you need to use this Pushbullet wrapper is a Pushbullet account,
and an access token for this account.
This access token can easily be retrieved from your Pushbullet settings.
Constructor and Description |
---|
Pushbullet(java.lang.String accessToken,
java.lang.String deviceName,
Router router)
Constructor for a new Pushbullet instance with a specific access token, a device name
corresponding to the name that your robot will take in your Pushbullet list of devices,
and the Raspoid router to use with this Pushbullet instance.
|
Modifier and Type | Method and Description |
---|---|
java.util.List<Device> |
getListOfDevices()
Retrieve the list of Pushbullet devices linked to the specified access token account.
|
java.util.List<Push> |
getListOfPushes(double modifiedAfter,
int limit)
Retrieve the list of pushes received after a specific timestamp,
with a specific limit in the number of retrieved pushes.
|
java.util.List<Push> |
getListOfPushes(int limit)
Retrieve the list of pushes without any limit in time, with a specific limit
in the number of retrieved pushes.
|
int |
postFile(java.lang.String url,
java.lang.String filePath)
Upload a file on the Pushbullet servers.
|
java.lang.String |
sendGetRequest(java.lang.String url)
Executes an Http Get request and returns the String representation
of the response from the server.
|
Push |
sendNewFile(java.lang.String filePath,
java.lang.String fileName,
java.lang.String fileType,
java.lang.String targetDeviceIden)
Sends a new file to the Pushbullet servers and sends this file through a push.
|
Push |
sendNewPush(java.lang.String body)
Sends a new push with a specific body to the Pushbullet server.
|
Push |
sendNewPush(java.lang.String title,
java.lang.String body)
Sends a new push with a specific title and a specific body to the Pushbullet server.
|
Push |
sendNewPush(java.lang.String title,
java.lang.String body,
java.lang.String targetDeviceIden)
Sends a new push with a specific title and a specific body to the Pushbullet server.
|
java.lang.String |
sendPostRequest(java.lang.String url)
Executes an Http Post request and returns the String representation
of the response from the server.
|
java.lang.String |
sendPostRequest(java.lang.String url,
java.util.List<org.apache.http.NameValuePair> urlParameters)
Executes an Http Post request with specific url parameters
and returns the String representation of the response from the server.
|
public Pushbullet(java.lang.String accessToken, java.lang.String deviceName, Router router)
The access token can easily be retrieved from your Pushbullet account settings.
Note that if a device with the specified name already exists, this device will be retrieved. If no devices with this name exists, a new one will be created.
As for other types of servers, the router is used to deal with requests received on this Pushbullet instance.
accessToken
- the access token used to access Pushbullet services.deviceName
- the name corresponding to your robot's Pushbullet device.router
- the router to use to deal with requests received on the deviceName.public java.lang.String sendGetRequest(java.lang.String url)
url
- the url of the Get request to execute.public java.lang.String sendPostRequest(java.lang.String url)
url
- the url of the Post request to execute.public java.lang.String sendPostRequest(java.lang.String url, java.util.List<org.apache.http.NameValuePair> urlParameters)
url
- the url of the Post request to execute.urlParameters
- the url parameters to add to the request.public int postFile(java.lang.String url, java.lang.String filePath)
url
- authorized url to post the file.filePath
- the local path of the file to post.public java.util.List<Push> getListOfPushes(double modifiedAfter, int limit)
modifiedAfter
- the timestamp from which to retrieve pushes.limit
- the maximum number of pushes to retrieve on the Pushbullet servers. -1 if no limit.public java.util.List<Push> getListOfPushes(int limit)
limit
- the maximum number of pushes to retrieve on the Pushbullet servers. -1 if no limit.public java.util.List<Device> getListOfDevices()
public Push sendNewPush(java.lang.String body)
body
- the body of the push sent to Pushbullet server.public Push sendNewPush(java.lang.String title, java.lang.String body)
title
- the title of the push sent to the Pusbullet server.body
- the body of the push sent to the Pushbullet server.public Push sendNewPush(java.lang.String title, java.lang.String body, java.lang.String targetDeviceIden)
title
- the title of the push sent to the Pusbullet server.body
- the body of the push sent to the Pushbullet server.targetDeviceIden
- the user's device targeted by the push. null for broadcast.public Push sendNewFile(java.lang.String filePath, java.lang.String fileName, java.lang.String fileType, java.lang.String targetDeviceIden)
filePath
- the path of the file to send.fileName
- the name of the file to send.fileType
- the type of the file to send.targetDeviceIden
- the user's device targeted by the push. null for broadcast.