pushbullet.go
func (c *Client) Devices() ([]*Device, error) {
	req := c.buildRequest("/devices", nil)
	resp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		var errjson errorResponse
		dec := json.NewDecoder(resp.Body)
		err = dec.Decode(&errjson)
		if err == nil {
			return nil, &errjson.ErrResponse
		}

		return nil, errors.New(resp.Status)
	}

	var devResp deviceResponse
	dec := json.NewDecoder(resp.Body)
	err = dec.Decode(&devResp)
	if err != nil {
		return nil, err
	}

	for i := range devResp.Devices {
		devResp.Devices[i].Client = c
	}
	devices := append(devResp.Devices, devResp.SharedDevices...)
	return devices, nil
}
func (c *Client) Devices() ([]*Device, error) {
	req := c.buildRequest("/devices", nil)
	resp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		var errjson errorResponse
		dec := json.NewDecoder(resp.Body)
		err = dec.Decode(&errjson)
		if err == nil {
			return nil, &errjson.ErrResponse
		}

		return nil, errors.New(resp.Status)
	}

	var devResp deviceResponse
	dec := json.NewDecoder(resp.Body)
	err = dec.Decode(&devResp)
	if err != nil {
		return nil, err
	}

	for i := range devResp.Devices {
		devResp.Devices[i].Client = c
	}
	devices := append(devResp.Devices, devResp.SharedDevices...)
	return devices, nil
}
func ( c * Client ) Devices ( ) ( [ ] * Device , error ) { req := c . buildRequest ( " " , nil ) resp , err := c . Client . Do ( req ) if err != nil { return nil , err } defer resp . Body . Close ( ) if resp . StatusCode != http . StatusOK { var errjson errorResponse dec := json . NewDecoder ( resp . Body ) err = dec . Decode ( & errjson ) if err == nil { return nil , & errjson . ErrResponse } return nil , errors . New ( resp . Status ) } var devResp deviceResponse dec := json . NewDecoder ( resp . Body ) err = dec . Decode ( & devResp ) if err != nil { return nil , err } for i := range devResp . Devices { devResp . Devices [ i ] . Client = c } devices := append ( devResp . Devices , devResp . SharedDevices ... ) return devices , nil }
// Devices fetches a list of devices from PushBullet.
Devices fetches a list of devices from PushBullet .