Documentation ¶
Overview ¶
Package pushbullet provides simple access to the v2 API of http://pushbullet.com.
Example client:
pb := pushbullet.New("YOUR_API_KEY") devices, err := pb.Devices() ... err = pb.PushNote(devices[0].Iden, "Hello!", "Hi from go-pushbullet!")
The API is document at https://docs.pushbullet.com/http/ . At the moment, it only supports querying devices and sending notifications.
Index ¶
- Variables
- type Channel
- type Client
- func (c *Client) Device(nickname string) (*Device, error)
- func (c *Client) Devices() ([]*Device, error)
- func (c *Client) Me() (*User, error)
- func (c *Client) Push(endPoint string, data interface{}) error
- func (c *Client) PushLink(iden, title, u, body string) error
- func (c *Client) PushLinkToChannel(tag, title, u, body string) error
- func (c *Client) PushNote(iden string, title, body string) error
- func (c *Client) PushNoteToChannel(tag string, title, body string) error
- func (c *Client) PushSMS(userIden, deviceIden, phoneNumber, message string) error
- func (c *Client) Subscription(tag string) (*Subscription, error)
- func (c *Client) Subscriptions() ([]*Subscription, error)
- type Device
- type Endpoint
- type Ephemeral
- type EphemeralPush
- type ErrResponse
- type Link
- type Note
- type Subscription
- type User
Constants ¶
This section is empty.
Variables ¶
var EndpointURL = "https://api.pushbullet.com/v2"
EndpointURL sets the default URL for the Pushbullet API
var ErrDeviceNotFound = errors.New("Device not found")
ErrDeviceNotFound is raised when device nickname is not found on pusbullet server
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { Iden string `json:"iden"` Tag string `json:"tag"` Name string `json:"name"` Description string `json:"description"` ImageUrl string `json:"image_url"` WebsiteUrl string `json:"website_url"` }
Channel object contains specific information about the pushbullet Channel
type Client ¶
A Client connects to PushBullet with an API Key.
func NewWithClient ¶
NewWithClient creates a new client with your personal API key and the given http Client
func (*Client) Push ¶
Push pushes the data to a specific device registered with PushBullet. The 'data' parameter is marshaled to JSON and sent as the request body. Most users should call one of PusNote, PushLink, PushAddress, or PushList.
func (*Client) PushLink ¶
PushLink pushes a link with a title and url to a specific PushBullet device.
func (*Client) PushLinkToChannel ¶
PushLinkToChannel pushes a link with a title and url to a specific PushBullet device.
func (*Client) PushNote ¶
PushNote pushes a note with title and body to a specific PushBullet device.
func (*Client) PushNoteToChannel ¶
PushNoteToChannel pushes a note with title and body to a specific PushBullet channel.
func (*Client) Subscription ¶
func (c *Client) Subscription(tag string) (*Subscription, error)
Subscription fetches an subscription with a given channel tag from PushBullet.
func (*Client) Subscriptions ¶
func (c *Client) Subscriptions() ([]*Subscription, error)
type Device ¶
type Device struct { Iden string `json:"iden"` Active bool `json:"active"` Created float32 `json:"created"` Modified float32 `json:"modified"` Icon string `json:"icon"` Nickname string `json:"nickname"` GeneratedNickname bool `json:"generated_nickname"` Manufacturer string `json:"manufacturer"` Model string `json:"model"` AppVersion int `json:"app_version"` Fingerprint string `json:"fingerprint"` KeyFingerprint string `json:"key_fingerprint"` PushToken string `json:"push_token"` HasSms bool `json:"has_sms"` Client *Client `json:"-"` }
A Device is a PushBullet device
type Endpoint ¶
type Endpoint struct {
URL string
}
Endpoint allows manipulation of pushbullet API endpoint for testing
type Ephemeral ¶
type Ephemeral struct { Type string `json:"type"` Push EphemeralPush `json:"push"` }
Ephemeral constructs the Ephemeral object for pushing which requires the EphemeralPush object
type EphemeralPush ¶
type EphemeralPush struct { Type string `json:"type"` PackageName string `json:"package_name"` SourceUserIden string `json:"source_user_iden"` TargetDeviceIden string `json:"target_device_iden"` ConversationIden string `json:"conversation_iden"` Message string `json:"message"` }
EphemeralPush exposes the required fields of the Pushbullet ephemeral object
type ErrResponse ¶
type ErrResponse struct { Type string `json:"type"` Message string `json:"message"` Cat string `json:"cat"` }
ErrResponse is an error returned by the PushBullet API
func (*ErrResponse) Error ¶
func (e *ErrResponse) Error() string
type Link ¶
type Link struct { Iden string `json:"device_iden,omitempty"` Tag string `json:"channel_tag,omitempty"` Type string `json:"type"` Title string `json:"title"` URL string `json:"url"` Body string `json:"body,omitempty"` }
Link exposes the required and optional fields of the Pushbullet push type=link
type Note ¶
type Note struct { Iden string `json:"device_iden,omitempty"` Tag string `json:"channel_tag,omitempty"` Type string `json:"type"` Title string `json:"title"` Body string `json:"body"` }
Note exposes the required and optional fields of the Pushbullet push type=note
type Subscription ¶
type Subscription struct { Iden string `json:"iden"` Active bool `json:"active"` Created float32 `json:"created"` Modified float32 `json:"modified"` Muted string `json:"muted"` Channel *Channel `json:"channel"` Client *Client `json:"-"` }
Subscription object allows interaction with pushbullet channels
func (*Subscription) PushLink ¶
func (s *Subscription) PushLink(title, u, body string) error
PushNote sends a link to the specific Channel with the given title, url and body
func (*Subscription) PushNote ¶
func (s *Subscription) PushNote(title, body string) error
PushNote sends a note to the specific Channel with the given title and body
type User ¶
type User struct { Iden string `json:"iden"` Email string `json:"email"` EmailNormalized string `json:"email_normalized"` Created float64 `json:"created"` Modified float64 `json:"modified"` Name string `json:"name"` ImageUrl string `json:"image_url"` Preferences interface{} `json:"preferences"` }
User represents the User object for pushbullet