pushbullet

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2015 License: MIT Imports: 11 Imported by: 20

README

pushbullet-go

License GoDoc Wercker

A library to call Pushbullet HTTP API for Golang.

Installation

Just execute the following command:

$ go get -u github.com/mitsuse/pushbullet-go/...

Example

This is an example to send a simple note via Pushbullet.

package main

import (
	"fmt"
	"os"

	"github.com/mitsuse/pushbullet-go"
	"github.com/mitsuse/pushbullet-go/requests"
)

func main() {
	// Set the access token.
	token := ""

	// Create a client for Pushbullet.
	pb := pushbullet.New(token)

	// Create a push. The following codes create a note, which is one of push types.
	n := requests.NewNote()
	n.Title = "Hello, world!"
	n.Body = "Send via Pushbullet."

	// Send the note via Pushbullet.
	if _, err := pb.PostPushesNote(n); err != nil {
		fmt.Frintf(os.Stderr, "error: %s\n", err)
		return
	}
}

License

The MIT License (MIT)

Copyright (c) 2015 Tomoya Kose.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Overview

Package "pushbullet" provides interfaces for Pushbullet HTTP API.

Pushbullet is a web service, which makes your devices work better together by allowing you to move things between them easily.

The official url: https://www.pushbullet.com/

Currently, this package supports only "pushes" except file.

See the API documentation for the details: https://docs.pushbullet.com/#http

Index

Constants

View Source
const (
	ENDPOINT_DEVICES   = _BASE_URL + "/v2/devices"
	ENDPOINT_PUSHES    = _BASE_URL + "/v2/pushes"
	ENDPOINT_UPLOADREQ = _BASE_URL + "/v2/upload-request"
	ENDPOINT_USERS_ME  = _BASE_URL + "/v2/users/me"
)

Variables

This section is empty.

Functions

func Upload

func Upload(client *http.Client, upload *responses.Upload, reader io.Reader) error

Upload a file to S3 specified with the response of PostUploadRequest.

Types

type Pushbullet

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

func New

func New(token string) *Pushbullet

Create a client to call Pushbullet HTTP API. This requires the access token. The token is found in account settings.

Account settings: https://www.pushbullet.com/account

func NewClient

func NewClient(token string, c *http.Client) *Pushbullet

Create a client to call Pushbullet HTTP API. This requires the access token and an aribitary *http.Client. The token is found in account settings.

Account settings: https://www.pushbullet.com/account

func (*Pushbullet) Client

func (pb *Pushbullet) Client() *http.Client

func (*Pushbullet) GetDevices

func (pb *Pushbullet) GetDevices() ([]*responses.Device, error)

Get the devices thath can be pushed to.

func (*Pushbullet) GetUsersMe

func (pb *Pushbullet) GetUsersMe() (*responses.User, error)

Get the current user.

func (*Pushbullet) PostPushesAddress

func (pb *Pushbullet) PostPushesAddress(a *requests.Address) (*responses.Address, error)

Push an address, which consists of the place "name" and "address (searchquery)" for map.

func (*Pushbullet) PostPushesChecklist

func (pb *Pushbullet) PostPushesChecklist(c *requests.Checklist) (*responses.Checklist, error)

Push a checklist, which consists of "title" and the list of items.

func (*Pushbullet) PostPushesFile

func (pb *Pushbullet) PostPushesFile(f *requests.File) (*responses.File, error)

Push a file, which consists of "title", "message" and the information of uploaded file.

func (pb *Pushbullet) PostPushesLink(l *requests.Link) (*responses.Link, error)

Push a link, which consists of "title", "message" and "url" strings.

func (*Pushbullet) PostPushesNote

func (pb *Pushbullet) PostPushesNote(n *requests.Note) (*responses.Note, error)

Push a note, which consists of "title" and "message" strings.

func (*Pushbullet) PostUploadRequest

func (pb *Pushbullet) PostUploadRequest(name, mime string) (*responses.Upload, error)

Post the information of file and get the information of upload destination.

Directories

Path Synopsis
Package "request" provides structs to represent the request for Pushbullet HTTP API.
Package "request" provides structs to represent the request for Pushbullet HTTP API.
Package "responses" provides structs to represent the response of Pushbullet HTTP API.
Package "responses" provides structs to represent the response of Pushbullet HTTP API.

Jump to

Keyboard shortcuts

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