pushbullet

package module
v0.0.0-...-e690842 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2016 License: MIT Imports: 15 Imported by: 0

README

gopushbullet

GoDoc Build Status Coverage Status

A complete go package for interacting with the fantastic Pushbullet service.

Status

Many major features complete, see notes below. Additional tests need to be written and a couple less common features. Also need some example code for the test file.

Features

Users
  • Get User
  • Set User preferences
Pushes
  • Send Pushes
  • Note
  • Link
  • Address
  • Checklist
  • File
    • File Uploads
  • Delete a push
  • Get push history
  • Dismiss push
  • Update a push (update list items)
Devices
  • Get Devices
Contacts
  • Get Contacts
  • Create Contacts
  • Update Contact
  • Delete Contact
Channels
  • Subscribe
  • Unsubscribe
  • Get channel info

Todo

  • Web Sockets
  • OAuth account access

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authorization

type Authorization struct {
	FileType  string `json:"file_type"`
	FileName  string `json:"file_name"`
	FileURL   string `json:"file_url"`
	UploadURL string `json:"upload_url"`
	Data      struct {
		Awsaccesskeyid string `json:"awsaccesskeyid"`
		Acl            string `json:"acl"`
		Key            string `json:"key"`
		Signature      string `json:"signature"`
		Policy         string `json:"policy"`
		ContentType    string `json:"content-type"`
	} `json:"data"`
}

Authorization describes a file upload authorization.

type Channel

type Channel struct {
	ID          string `json:"iden"`
	Tag         string `json:"tag"`
	Name        string `json:"name"`
	Description string `json:"description"`
	ImageURL    string `json:"image_url"`
}

Channel describes a channel on a subscription.

type Client

type Client struct {
	APIKey     string
	BaseURL    string
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client a Pushbullet API client

func ClientWithKey

func ClientWithKey(key string, deviceID string) *Client

ClientWithKey returns a pushbullet.Client pointer with API key.

func (*Client) AuthorizeUpload

func (c *Client) AuthorizeUpload(fileName, fileType string) (Authorization, error)

AuthorizeUpload requests an authorization to upload a file

func (*Client) ChannelInfo

func (c *Client) ChannelInfo(channelTag string) (channel Channel, err error)

ChannelInfo gets detained info for the requested channel

func (*Client) CreateContact

func (c *Client) CreateContact(name, email string) error

CreateContact creates a new contact with the specified name and email

func (*Client) DeleteContact

func (c *Client) DeleteContact(contactID string) error

DeleteContact creates a new contact with the specified name and email

func (*Client) DeletePush

func (c *Client) DeletePush(pushID string) error

DeletePush deletes a push message

func (*Client) DismissPush

func (c *Client) DismissPush(ID string) error

DismissPush allows for dismissal of a push message

func (*Client) GetContacts

func (c *Client) GetContacts() (ContactList, error)

GetContacts obtains a list of your contacts

func (*Client) GetDevices

func (c *Client) GetDevices() (DeviceList, error)

GetDevices obtains a list of registered devices from Pushbullet

func (*Client) GetPushHistory

func (c *Client) GetPushHistory(modifiedAfter time.Time) ([]PushMessage, error)

GetPushHistory gets pushes modified after the provided timestamp

func (*Client) GetUser

func (c *Client) GetUser() (u User, err error)

GetUser gets the current authenticate users details.

func (*Client) ListSubscriptions

func (c *Client) ListSubscriptions() (subscriptions SubscriptionList, err error)

ListSubscriptions returns a list of channels to which the user is subscribed

func (*Client) ListenForPushes

func (c *Client) ListenForPushes(since time.Time, callback func(PushMessage)) error

ListenForPushes Fires callback for each message since a time

func (*Client) SendAddress

func (c *Client) SendAddress(title, name, address string) error

SendAddress simply sends an address type push to all of the users devices

func (*Client) SendAddressToTarget

func (c *Client) SendAddressToTarget(targetType, target, title, name, address string) error

SendAddressToTarget sends an address type push to a specific device.

func (*Client) SendChecklist

func (c *Client) SendChecklist(title string, items []string) error

SendChecklist simply sends a checklist type push to all of the users devices

func (*Client) SendChecklistToTarget

func (c *Client) SendChecklistToTarget(targetType, target, title string, items []string) error

SendChecklistToTarget sends a checklist type push to a specific device.

func (*Client) SendFile

func (c *Client) SendFile(title string, items []string) error

SendFile simply sends a file type push to all of the users devices

func (*Client) SendFileToTarget

func (c *Client) SendFileToTarget(targetType, target, fileName, fileType, fileURL, body string, items []string) error

SendFileToTarget sends a file type push to a specific device.

func (c *Client) SendLink(title, body, url string) error

SendLink simply sends a link type push to all of the users devices

func (*Client) SendLinkToTarget

func (c *Client) SendLinkToTarget(targetType, target, title, body, url string) error

SendLinkToTarget sends a link type push to a specific device.

func (*Client) SendNote

func (c *Client) SendNote(title string, body string, deviceID string) error

SendNote simply sends a note type push to all of the users devices

func (*Client) SendNoteToTarget

func (c *Client) SendNoteToTarget(targetType string, target string, title string, body string, deviceID string) error

SendNoteToTarget sends a note type push to a specific device.

func (*Client) SubscribeChannel

func (c *Client) SubscribeChannel(channel string) error

SubscribeChannel subscribes use to a specified channel

func (*Client) UnsubscribeChannel

func (c *Client) UnsubscribeChannel(channelID string) error

UnsubscribeChannel unsubscribes from the specified channel

func (*Client) UpdateContact

func (c *Client) UpdateContact(contactID, name string) error

UpdateContact creates a new contact with the specified name and email

func (*Client) UpdateList

func (c *Client) UpdateList(pushID string, list ItemsList) error

UpdateList allows for updating a list type push

func (*Client) UpdatePreferences

func (c *Client) UpdatePreferences(preferences Preferences) error

UpdatePreferences overwrites user preferences with specified ones

type Contact

type Contact struct {
	ID              string  `json:"iden"`
	Name            string  `json:"name"`
	Created         float32 `json:"created"`
	Modified        float32 `json:"modified"`
	Email           string  `json:"email"`
	EmailNormalized string  `json:"email_normalized"`
	Active          bool    `json:"active"`
}

Contact describes a contact entry.

type ContactList

type ContactList struct {
	Contacts []Contact `json:"contacts"`
}

ContactList describes an array of contacts

type Device

type Device struct {
	ID           string  `json:"iden"`
	PushToken    string  `json:"push_token"`
	AppVersion   int     `json:"app_version"`
	Fingerprint  string  `json:"fingerprint"`
	Active       bool    `json:"active"`
	Nickname     string  `json:"nickname"`
	Manufacturer string  `json:"manufacturer"`
	Type         string  `json:"type"`
	Created      float32 `json:"created"`
	Modified     float32 `json:"modified"`
	Model        string  `json:"model"`
	Pushable     bool    `json:"pushable"`
}

Device describes a registered device (phone, stream).

type DeviceList

type DeviceList struct {
	Devices []Device `json:"devices"`
}

DeviceList describes an array of devices

type Error

type Error struct {
	ErrorBody errorBody `json:"error"`
}

Error (any non-200 error code) contain information on the kind of error that happened.

func (*Error) String

func (e *Error) String() string

type Item

type Item struct {
	Text    string `json:"text"`
	Checked bool   `json:"checked"`
}

Item describes a checklist item

type ItemsList

type ItemsList struct {
	// contains filtered or unexported fields
}

ItemsList describes a list of checklist items

type Preferences

type Preferences struct {
	Onboarding struct {
		App       bool `json:"app"`
		Friends   bool `json:"friends"`
		Extension bool `json:"extension"`
	} `json:"onboarding"`
	Social bool   `json:"social"`
	Cat    string `json:"cat"`
}

Preferences describes a set of user preferences.

type PushList

type PushList struct {
	Pushes []PushMessage `json:"pushes"`
}

PushList describes a list of push messages

type PushMessage

type PushMessage struct {
	ID string `json:"iden"`

	// Target specific properties
	DeviceID   string `json:"device_iden"`
	Email      string `json:"email"`
	ChannelTag string `json:"channel_tag"`
	ClientID   string `json:"client_iden"`

	// Type indicates the type of push message being sent
	Type    string   `json:"type"`    // note, link, address, checklist, or file
	Title   string   `json:"title"`   // Title is used within note, link, and checklist types
	Body    string   `json:"body"`    // Body is used with link, note, or file types
	URL     string   `json:"url"`     // URL is used for link types
	Name    string   `json:"name"`    // Name of place used with address type
	Address string   `json:"address"` // Address is used with address type
	Items   []string `json:"items"`   // Items are used with checklist types
	// The following are used with file types
	FileName       string `json:"file_name"`
	FileType       string `json:"file_type"` // MIME type of the file
	FileURL        string `json:"file_url"`
	SourceDeviceID string `json:"source_device_iden"`

	// Properties for response messages
	Created                 float32 `json:"created"`
	Modified                float32 `json:"modified"`
	Active                  bool    `json:"active"`
	Dismissed               bool    `json:"dismissed"`
	SenderID                string  `json:"sender_iden"`
	SenderEmail             string  `json:"sender_email"`
	SenderEmailNormalized   string  `json:"sender_email_normalized"`
	ReceiverID              string  `json:"receiver_iden"`
	ReceiverEmail           string  `json:"receiver_email"`
	ReceiverEmailNormalized string  `json:"receiver_email_normalized"`
	TargetDeviceID          string  `json:"target_device_iden"`

	// Properties of the event stream
	Subtype string `json:"subtype"` // push, device
}

PushMessage describes a message to be sent via Pushbullet. Only one of the first 4 properties may be specified with a message being sent.

type Subscription

type Subscription struct {
	ID       string  `json:"iden"`
	Created  float32 `json:"created"`
	Modified float32 `json:"modified"`
	Active   bool    `json:"active"`
	Channel  Channel `json:"channel"`
}

Subscription describes a channel subscription.

type SubscriptionList

type SubscriptionList struct {
	Subscriptions []Subscription `json:"subscriptions"`
}

SubscriptionList describes a list of subscribed channels

type User

type User struct {
	ID              string      `json:"iden"`
	Email           string      `json:"email"`
	EmailNormalized string      `json:"email_normalized"`
	Created         float32     `json:"created"`
	Modified        float32     `json:"modified"`
	Name            string      `json:"name"`
	ImageURL        string      `json:"image_url"`
	Preferences     Preferences `json:"preferences"`
}

User describes the authenticated user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL