goadafruit

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2021 License: MIT Imports: 15 Imported by: 2

README

goAdafruit

Go SDK for Adafruit IO

Go Reference

A go client library for talking to your io.adafruit.com account. This SDK is for V2 of the io.adafruit.com API. It works basically as the V1 version, just expanded to take advantage of all the features of V2

Requires go version 1.6 or better. Running tests requires the github.com/stretchr/testify library, which can be installed with:

$ go get github.com/stretchr/testify

Usage

import aio "github.com/jakefau/goAdafruit"

Authentication for Adafruit IO is managed by providing your Adafruit IO token in the head of all web requests via the X-AIO-Key header. This is handled for you by the client library, which expects you API Token when it is initialized.

To connect to the API you need a user name and a secret key

func connect() aio.Client {
    // basic stuff
    username := "JakeFau"
    baseURL := "https://io.adafruit.com/"
    // Hide your key
    key := os.Getenv("ADAFRUIT_IO_KEY")
    // get a client
    client := aio.NewClient(key, username)
    client.BaseURL, _ = url.Parse(baseURL)
    return *client
}

The entire http API is provided by this SDK, to get a sense of what the API can do please see https://io.adafruit.com/api/docs/

Feeds

Feeds are what contain the individual datapoints. Before you can get the data points in JSON or in Charting format you have to set the current feed in the client.

func GetDataForFeed() {
    client := connect()
    feed, _, err := client.Feed.Get("weather.humidity")
    if err != nil {
        log.Fatal(err)
    }
    client.SetFeed(feed)
    // choose the key from one of your feeds
    data, _, err := client.Data.All(nil)

Please let me know what you think and be sure to let me know if there are any bugs you find or enhancements you would like to see. Feel free to fork the project and add to it, I will monitor pull requests.

Documentation

Index

Constants

View Source
const (
	BaseURL = "https://io.adafruit.com/"
)
View Source
const (
	Version = "2.0.0"
)

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range.

adapted from https://github.com/google/go-github

Types

type AIOError

type AIOError struct {
	Message string `json:"error"`
}

type Activities

type Activities struct {
	Username  string    `json:"username"`
	Owner     Owner     `json:"owner"`
	ID        int       `json:"id"`
	Action    string    `json:"action"`
	Model     string    `json:"model"`
	Data      string    `json:"data"`
	UserID    int       `json:"user_id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

type ActivitiesService

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

func (*ActivitiesService) ActivitiesByType

func (s *ActivitiesService) ActivitiesByType(atype *string) ([]*Activities, *Response, error)

func (*ActivitiesService) All

func (s *ActivitiesService) All() ([]*Activities, *Response, error)

type Block

type Block struct {
	ID         int          `json:"id"`
	Name       string       `json:"name"`
	VisualType string       `json:"visual_type"`
	Column     interface{}  `json:"column"`
	Row        interface{}  `json:"row"`
	SizeX      interface{}  `json:"size_x"`
	SizeY      interface{}  `json:"size_y"`
	SourceKey  interface{}  `json:"source_key"`
	Source     interface{}  `json:"source"`
	Properties Properties   `json:"properties"`
	CreatedAt  time.Time    `json:"created_at"`
	UpdatedAt  time.Time    `json:"updated_at"`
	BlockFeeds []BlockFeeds `json:"block_feeds"`
}

type BlockFeeds

type BlockFeeds struct {
	ID int `json:"id"`
}

type BlockService

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

func (*BlockService) AllBlocks

func (s *BlockService) AllBlocks(dashboardID string) ([]*Block, *Response, error)

func (*BlockService) CreateBlock

func (s *BlockService) CreateBlock(dashboardID string, b *Block) (*Block, *Response, error)

func (*BlockService) DeleteBlock

func (s *BlockService) DeleteBlock(dashboardID string, blockID string) (*Response, error)

func (*BlockService) GetBlock

func (s *BlockService) GetBlock(dashboardID string, blockID string) (*Block, *Response, error)

func (*BlockService) ReplaceBlock

func (s *BlockService) ReplaceBlock(dashboardID string, blockID string, b Block) (*Block, *Response, error)

type Client

type Client struct {
	BaseURL *url.URL

	APIKey   string
	Username string

	Feed       *FeedService
	Group      *GroupService
	Data       *DataService
	User       *UserService
	Webhook    *WebhookService
	Trigger    *TriggerService
	Activities *ActivitiesService
	Blocks     *BlockService
	Dashboard  *DashboardService
	Permission *PermissionService
	Tokens     *TokenService
	Utils      *UtilService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(key string, username string) *Client

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred. If v implements the io.Writer interface, the raw response body will be written to v, without attempting to first decode it.

adapted from https://github.com/google/go-github

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

adapted from https://github.com/google/go-github

func (*Client) SetFeed

func (c *Client) SetFeed(feed *Feed)

SetFeed takes a Feed record as a parameter and uses that feed for all subsequent Data related API calls.

A Feed must be set before making calls to the Data service.

type Dashboard

type Dashboard struct {
	Username       string      `json:"username"`
	Owner          Owner       `json:"owner"`
	ID             int         `json:"id"`
	Name           string      `json:"name"`
	Key            string      `json:"key"`
	Description    string      `json:"description"`
	Visibility     string      `json:"visibility"`
	CreatedAt      time.Time   `json:"created_at"`
	UpdatedAt      time.Time   `json:"updated_at"`
	ShowHeader     bool        `json:"show_header"`
	ColorMode      string      `json:"color_mode"`
	BlockBorders   bool        `json:"block_borders"`
	HeaderImageURL interface{} `json:"header_image_url"`
}

type DashboardService

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

func (*DashboardService) AllDashboards

func (s *DashboardService) AllDashboards() ([]*Dashboard, *Response, error)

func (*DashboardService) ChangeDashboard

func (s *DashboardService) ChangeDashboard(id string, d Dashboard) (*Dashboard, *Response, error)

func (*DashboardService) CreateDashboard

func (s *DashboardService) CreateDashboard(d *Dashboard) (*Dashboard, *Response, error)

func (*DashboardService) DeleteDashboad

func (s *DashboardService) DeleteDashboad(id string) (*Response, error)

func (*DashboardService) GetDashboard

func (s *DashboardService) GetDashboard(id string) (*Dashboard, *Response, error)

type Data

type Data struct {
	ID        string `json:"id,omitempty"`
	Value     string `json:"value,omitempty"`
	FeedID    int    `json:"feed_id,omitempty"`
	FeedKey   string `json:"feed_key,omitempty"`
	CreatedAt string `json:"created_at,omitempty"`
	Location  struct {
	} `json:"location,omitempty"`
	Lat          string `json:"lat,omitempty"`
	Lon          string `json:"lon,omitempty"`
	Ele          string `json:"ele,omitempty"`
	CreatedEpoch int    `json:"created_epoch,omitempty"`
	Expiration   string `json:"expiration,omitempty"`
}

Data are the values contained by a Feed.

type DataFilter

type DataFilter struct {
	StartTime string `url:"start_time,omitempty"`
	EndTime   string `url:"end_time,omitempty"`
}

type DataPoint

type DataPoint struct {
	X string `json:"X"`
	Y string `json:"Y"`
}

type DataService

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

func (*DataService) All

func (s *DataService) All(opt *DataFilter) ([]*Data, *Response, error)

All returns all Data for the currently selected Feed. See Client.SetFeed() for details on selecting a Feed.

func (*DataService) Create

func (s *DataService) Create(dp *Data) (*Data, *Response, error)

Create adds a new Data value to an existing Feed.

func (*DataService) CreateBatch

func (s *DataService) CreateBatch(dp *[]Data) (*[]Data, *Response, error)

Create adds new Data values to an existing Feed.

func (*DataService) CreateGroupData

func (s *DataService) CreateGroupData(groupKey string, gd GroupData) (*[]GroupDataResults, *Response, error)

func (*DataService) Delete

func (s *DataService) Delete(id string) (*Response, error)

Delete the Data identified by the given ID.

func (*DataService) First

func (s *DataService) First() (*Data, *Response, error)

Last returns the first Data in the stream.

func (*DataService) Get

func (s *DataService) Get(id string) (*Data, *Response, error)

Get returns a single Data element, identified by the given ID parameter.

func (*DataService) GetChartData

func (s *DataService) GetChartData(opt *DataFilter) ([]*DataPoint, *Response, error)

returns the feed data ready for charting

func (*DataService) Last

func (s *DataService) Last() (*Data, *Response, error)

Last returns the last Data in the stream.

func (*DataService) Next

func (s *DataService) Next() (*Data, *Response, error)

Next returns the next Data in the stream.

func (*DataService) Prev

func (s *DataService) Prev() (*Data, *Response, error)

Prev returns the previous Data in the stream.

func (*DataService) Search

func (s *DataService) Search(filter *DataFilter) ([]*Data, *Response, error)

Search has the same response format as All, but it accepts optional params with which your data can be queried.

func (*DataService) Update

func (s *DataService) Update(id interface{}, data *Data) (*Data, *Response, error)

Update takes an ID and a Data record, updates the record idendified by ID, and returns a new, updated Data instance.

type DateStruct

type DateStruct struct {
	Year  int `json:"year"`
	Mon   int `json:"mon"`
	Mday  int `json:"mday"`
	Hour  int `json:"hour"`
	Min   int `json:"min"`
	Sec   int `json:"sec"`
	Wday  int `json:"wday"`
	Yday  int `json:"yday"`
	Isdst int `json:"isdst"`
}

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that carried the error message
	Message  string
	AIOError *AIOError
}

ErrorResponse reports one or more errors caused by an API request.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type Feed

type Feed struct {
	Username             string              `json:"username,omitempty"`
	Owner                Owner               `json:"owner,omitempty"`
	ID                   int                 `json:"id,omitempty"`
	Name                 string              `json:"name,omitempty"`
	Description          string              `json:"description,omitempty"`
	License              interface{}         `json:"license,omitempty"`
	History              bool                `json:"history,omitempty"`
	Enabled              bool                `json:"enabled,omitempty"`
	Visibility           string              `json:"visibility,omitempty"`
	UnitType             interface{}         `json:"unit_type,omitempty"`
	UnitSymbol           interface{}         `json:"unit_symbol,omitempty"`
	LastValue            string              `json:"last_value,omitempty"`
	CreatedAt            interface{}         `json:"created_at,omitempty"`
	UpdatedAt            interface{}         `json:"updated_at,omitempty"`
	StatusNotify         bool                `json:"status_notify,omitempty"`
	StatusTimeout        int                 `json:"status_timeout,omitempty"`
	Status               string              `json:"status,omitempty"`
	Key                  string              `json:"key,omitempty"`
	Writable             bool                `json:"writable,omitempty"`
	Group                Group               `json:"group,omitempty"`
	Groups               []Groups            `json:"groups,omitempty"`
	FeedWebhookReceivers []interface{}       `json:"feed_webhook_receivers,omitempty"`
	FeedStatusChanges    []FeedStatusChanges `json:"feed_status_changes,omitempty"`
}

type FeedCreation

type FeedCreation struct {
	Name          string      `json:"name,omitempty"`
	Key           string      `json:"key,omitempty"`
	Description   string      `json:"description,omitempty"`
	UnitType      interface{} `json:"unit_type,omitempty"`
	UnitSymbol    interface{} `json:"unit_symbol,omitempty"`
	History       bool        `json:"history,omitempty"`
	Visibility    string      `json:"visibility,omitempty"`
	License       interface{} `json:"license,omitempty"`
	StatusNotify  bool        `json:"status_notify,omitempty"`
	StatusTimeout int         `json:"status_timeout,omitempty"`
	Enabled       bool        `json:"enabled,omitempty"`
}

type FeedService

type FeedService struct {
	// CurrentFeed is the Feed used for all Data access.
	CurrentFeed *Feed
	// contains filtered or unexported fields
}

func (*FeedService) All

func (s *FeedService) All() ([]*Feed, *Response, error)

All lists all available feeds.

func (*FeedService) Create

func (s *FeedService) Create(feed *FeedCreation) (*FeedCreation, *Response, error)

Create takes a Feed record, creates it, and returns the updated record or an error.

func (*FeedService) CreateInGroup

func (s *FeedService) CreateInGroup(feed *FeedCreation, groupName string) (*FeedCreation, *Response, error)

Create takes a Feed record, creates it, and returns the updated record or an error.

func (*FeedService) Delete

func (s *FeedService) Delete(id interface{}) (*Response, error)

Delete the Feed identified by the given ID.

func (*FeedService) Get

func (s *FeedService) Get(id interface{}) (*Feed, *Response, error)

Get returns the Feed record identified by the given parameter. Parameter can be the Feed's Name, Key, or ID.

func (*FeedService) GetDetails

func (s *FeedService) GetDetails(id interface{}) (*Feed, *Response, error)

Get returns the Feed record identified by the given parameter. Parameter can be the Feed's Name, Key, or ID.

func (*FeedService) Path

func (s *FeedService) Path(suffix string) (string, error)

Path generates a Feed-specific path with the given suffix.

func (*FeedService) Update

func (s *FeedService) Update(id interface{}, feed *Feed) (*Feed, *Response, error)

Update takes an ID and a Feed record, updates it, and returns an updated record instance or an error.

Only the Feed Name and Description can be modified.

type FeedStatusChanges

type FeedStatusChanges struct {
	CreatedAt   time.Time   `json:"created_at,omitempty"`
	FromStatus  string      `json:"from_status,omitempty"`
	ToStatus    string      `json:"to_status,omitempty"`
	EmailSent   interface{} `json:"email_sent,omitempty"`
	EmailSentTo interface{} `json:"email_sent_to,omitempty"`
}

type Group

type Group struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Feeds       []Feed `json:"feeds"`
	CreatedAt   string `json:"created_at"`
	UpdatedAt   string `json:"updated_at"`
}

type GroupData

type GroupData struct {
	Feeds []struct {
		Key   string `json:"key"`
		Value string `json:"value"`
	} `json:"feeds"`
}

type GroupDataResults

type GroupDataResults struct {
	ID           string `json:"id"`
	Value        string `json:"value"`
	FeedID       int    `json:"feed_id"`
	FeedKey      string `json:"feed_key"`
	CreatedAt    string `json:"created_at"`
	CreatedEpoch int    `json:"created_epoch"`
	Expiration   string `json:"expiration"`
}

type GroupService

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

func (GroupService) AddFeedToGroup

func (s GroupService) AddFeedToGroup(groupID string, feedID string) (*Response, error)

Add a feed to a group

func (*GroupService) All

func (s *GroupService) All() ([]*Group, *Response, error)

All returns all Groups for the current account.

func (*GroupService) Create

func (s *GroupService) Create(g *Group) (*Group, *Response, error)

Create makes a new Group and either returns a new Group instance or an error.

func (*GroupService) CreateFeedInGroup

func (s *GroupService) CreateFeedInGroup(id interface{}, f *Feed) (*Feed, *Response, error)

Create a feed in a group

func (*GroupService) Delete

func (s *GroupService) Delete(id interface{}) (*Response, error)

Delete the Group identified by the given ID.

func (*GroupService) Get

func (s *GroupService) Get(id interface{}) (*Group, *Response, error)

Get returns the Group record identified by the given ID

func (GroupService) ListGroupFeeds

func (s GroupService) ListGroupFeeds(id interface{}) ([]*Feed, *Response, error)

List all group feeds

func (GroupService) RemoveFeedFromGroup

func (s GroupService) RemoveFeedFromGroup(groupID string, feedID string) (*Response, error)

Remove a feed from a group

func (*GroupService) Update

func (s *GroupService) Update(id interface{}, group *Group) (*Group, *Response, error)

Update takes an ID and a Group record, updates it, and returns a new Group instance or an error.

type Groups

type Groups struct {
	ID     int    `json:"id,omitempty"`
	Key    string `json:"key,omitempty"`
	Name   string `json:"name,omitempty"`
	UserID int    `json:"user_id,omitempty"`
}

type Owner

type Owner struct {
	ID       int    `json:"id"`
	Username string `json:"username"`
}

type Permission

type Permission struct {
	ID         int    `json:"id"`
	UserID     int    `json:"user_id"`
	Scope      string `json:"scope"`
	ScopeValue string `json:"scope_value"`
	Model      string `json:"model"`
	ObjectID   int    `json:"object_id"`
	CreatedAt  string `json:"created_at"`
	UpdatedAt  string `json:"updated_at"`
}

type PermissionService

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

func (*PermissionService) AllPermissions

func (s *PermissionService) AllPermissions() ([]*Permission, *Response, error)

func (*PermissionService) CreatePermission

func (s *PermissionService) CreatePermission(p *Permission, ptype string, typeid string) (*Permission, *Response, error)

func (*PermissionService) DeletePermission

func (s *PermissionService) DeletePermission(ptype string, typeid string, pid string) (*Response, error)

func (*PermissionService) GetPermission

func (s *PermissionService) GetPermission(ptype string, typeid string, pid string) (*Permission, *Response, error)

func (*PermissionService) ReplacePermission

func (s *PermissionService) ReplacePermission(p Permission, ptype string, typeid string, pid string) (*Permission, *Response, error)

type Properties

type Properties struct {
	XAxisLabel    string `json:"xAxisLabel"`
	YAxisLabel    string `json:"yAxisLabel"`
	YAxisMin      string `json:"yAxisMin"`
	YAxisMax      string `json:"yAxisMax"`
	DecimalPlaces string `json:"decimalPlaces"`
	RawDataOnly   bool   `json:"rawDataOnly"`
	SteppedLine   bool   `json:"steppedLine"`
	FeedKeyLegend bool   `json:"feedKeyLegend"`
	GridLines     bool   `json:"gridLines"`
	HistoryHours  string `json:"historyHours"`
}

type Response

type Response struct {
	*http.Response
}

Response wraps http.Response and adds fields unique to Adafruit's API.

func (*Response) Debug

func (r *Response) Debug()

type Token

type Token struct {
	Token string `json:"token"`
}

type TokenResponse

type TokenResponse struct {
	ID         interface{} `json:"id"`
	Key        string      `json:"key"`
	Master     bool        `json:"master"`
	Createable bool        `json:"createable"`
	Readable   bool        `json:"readable"`
	Updateable bool        `json:"updateable"`
	Deleteable bool        `json:"deleteable"`
	Expiration interface{} `json:"expiration"`
	UserID     int         `json:"user_id"`
	FeedID     interface{} `json:"feed_id"`
	CreatedAt  time.Time   `json:"created_at"`
	UpdatedAt  time.Time   `json:"updated_at"`
	QrCode     string      `json:"qr_code"`
	Status     string      `json:"status"`
}

type TokenService

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

func (*TokenService) CreateToken

func (s *TokenService) CreateToken(t Token) (*TokenResponse, *Response, error)

func (*TokenService) DeleteToken

func (s *TokenService) DeleteToken(id string) (*Response, error)

func (*TokenService) GetAllTokens

func (s *TokenService) GetAllTokens() ([]*TokenResponse, *Response, error)

func (*TokenService) GetToken

func (s *TokenService) GetToken(id string) (*TokenResponse, *Response, error)

type Trigger

type Trigger struct {
	Name string `json:"name"`
}

type TriggerService

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

func (*TriggerService) All

func (s *TriggerService) All() ([]*Trigger, *Response, error)

func (*TriggerService) Create

func (s *TriggerService) Create(t *Trigger) (*Trigger, *Response, error)

func (TriggerService) DeleteTrigger

func (s TriggerService) DeleteTrigger(id *string, t *Trigger) (*Response, error)

func (*TriggerService) GetTrigger

func (s *TriggerService) GetTrigger(id *string) (*Trigger, *Response, error)

func (TriggerService) ReplaceTrigger

func (s TriggerService) ReplaceTrigger(id *string, t *Trigger) (*Trigger, *Response, error)

type User

type User struct {
	User struct {
		ID                 int         `json:"id"`
		Name               string      `json:"name"`
		Color              string      `json:"color"`
		Username           string      `json:"username"`
		Role               string      `json:"role"`
		DefaultGroupID     int         `json:"default_group_id"`
		DefaultDashboardID interface{} `json:"default_dashboard_id"`
		TimeZone           string      `json:"time_zone"`
		CreatedAt          time.Time   `json:"created_at"`
		UpdatedAt          time.Time   `json:"updated_at"`
		Subscription       struct {
			Status string `json:"status"`
			Limits struct {
				Feeds      int `json:"feeds"`
				Dashboards int `json:"dashboards"`
				Groups     int `json:"groups"`
				DataTTL    int `json:"data_ttl"`
				DataRate   int `json:"data_rate"`
			} `json:"limits"`
			Plan struct {
				Name       string  `json:"name"`
				Price      float64 `json:"price"`
				Interval   string  `json:"interval"`
				StripeID   string  `json:"stripe_id"`
				BaseLimits struct {
					Feeds      int `json:"feeds"`
					Dashboards int `json:"dashboards"`
					Groups     int `json:"groups"`
					DataTTL    int `json:"data_ttl"`
					DataRate   int `json:"data_rate"`
				} `json:"base_limits"`
				Free bool `json:"free"`
				Paid bool `json:"paid"`
			} `json:"plan"`
		} `json:"subscription"`
		BetaFlags interface{} `json:"beta_flags"`
	} `json:"user"`
	Profile struct {
		Name              string        `json:"name"`
		Username          string        `json:"username"`
		TimeZone          string        `json:"time_zone"`
		CreatedAt         time.Time     `json:"created_at"`
		ConnectedAccounts []interface{} `json:"connected_accounts"`
		Subscription      struct {
			ID   interface{} `json:"id"`
			Plan struct {
				Name       string  `json:"name"`
				Price      float64 `json:"price"`
				Interval   string  `json:"interval"`
				StripeID   string  `json:"stripe_id"`
				BaseLimits struct {
					Feeds      int `json:"feeds"`
					Dashboards int `json:"dashboards"`
					Groups     int `json:"groups"`
					DataTTL    int `json:"data_ttl"`
					DataRate   int `json:"data_rate"`
				} `json:"base_limits"`
				Free bool `json:"free"`
				Paid bool `json:"paid"`
			} `json:"plan"`
			CreatedAt interface{} `json:"created_at"`
			Status    string      `json:"status"`
			Limits    struct {
				Feeds      int `json:"feeds"`
				Dashboards int `json:"dashboards"`
				Groups     int `json:"groups"`
				DataTTL    int `json:"data_ttl"`
				DataRate   int `json:"data_rate"`
			} `json:"limits"`
			Price    float64       `json:"price"`
			Upgrades []interface{} `json:"upgrades"`
		} `json:"subscription"`
		HasBillingHistory bool        `json:"has_billing_history"`
		HasPaymentSource  bool        `json:"has_payment_source"`
		AccountBalance    int         `json:"account_balance"`
		BetaDiscount      interface{} `json:"beta_discount"`
		ActionItems       struct {
			PendingShares []interface{} `json:"pending_shares"`
		} `json:"action_items"`
		PromotionDiscounts []interface{} `json:"promotion_discounts"`
		Coupons            []interface{} `json:"coupons"`
	} `json:"profile"`
	Sidebar struct {
		FeedCount      int `json:"feed_count"`
		GroupCount     int `json:"group_count"`
		DashboardCount int `json:"dashboard_count"`
		ActiveDataRate int `json:"active_data_rate"`
	} `json:"sidebar"`
	Navigation struct {
		Feeds struct {
			Records []struct {
				ID        int       `json:"id"`
				Name      string    `json:"name"`
				Key       string    `json:"key"`
				UpdatedAt time.Time `json:"updated_at"`
				LastValue string    `json:"last_value"`
			} `json:"records"`
			Count int `json:"count"`
		} `json:"feeds"`
		Dashboards struct {
			Records []struct {
				ID        int       `json:"id"`
				Name      string    `json:"name"`
				UpdatedAt time.Time `json:"updated_at"`
				Key       string    `json:"key"`
			} `json:"records"`
			Count int `json:"count"`
		} `json:"dashboards"`
		Devices struct {
			Records []interface{} `json:"records"`
		} `json:"devices"`
		Triggers struct {
			Records []interface{} `json:"records"`
		} `json:"triggers"`
	} `json:"navigation"`
	Throttle struct {
		DataRateLimit              int         `json:"data_rate_limit"`
		ActiveDataRate             int         `json:"active_data_rate"`
		AuthenticationRate         int         `json:"authentication_rate"`
		SubscribeAuthorizationRate int         `json:"subscribe_authorization_rate"`
		PublishAuthorizationRate   int         `json:"publish_authorization_rate"`
		HourlyBanRate              int         `json:"hourly_ban_rate"`
		MqttBanErrorMessage        interface{} `json:"mqtt_ban_error_message"`
	} `json:"throttle"`
	SystemMessages []interface{} `json:"system_messages"`
}

type UserDetails

type UserDetails struct {
	DataRateLimit              int         `json:"data_rate_limit"`
	ActiveDataRate             int         `json:"active_data_rate"`
	AuthenticationRate         int         `json:"authentication_rate"`
	SubscribeAuthorizationRate int         `json:"subscribe_authorization_rate"`
	PublishAuthorizationRate   int         `json:"publish_authorization_rate"`
	HourlyBanRate              int         `json:"hourly_ban_rate"`
	MqttBanErrorMessage        interface{} `json:"mqtt_ban_error_message"`
}

type UserService

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

func (*UserService) GetDetailedUserInformation

func (u *UserService) GetDetailedUserInformation() (*UserDetails, *Response, error)

func (*UserService) GetUserInformation

func (s *UserService) GetUserInformation() (*User, *Response, error)

type UtilService

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

func (*UtilService) ISOTime

func (s *UtilService) ISOTime() (*string, *Response, error)

func (*UtilService) UnixMilliSeconds

func (s *UtilService) UnixMilliSeconds() (*float64, *Response, error)

func (*UtilService) UnixSeconds

func (s *UtilService) UnixSeconds() (*int64, *Response, error)

type WebhookData

type WebhookData struct {
	ID        string `json:"id"`
	Value     string `json:"value"`
	FeedID    int    `json:"feed_id"`
	FeedKey   string `json:"feed_key"`
	CreatedAt string `json:"created_at"`
	Location  struct {
	} `json:"location"`
	Lat          float64 `json:"lat"`
	Lon          float64 `json:"lon"`
	Ele          float64 `json:"ele"`
	CreatedEpoch int     `json:"created_epoch"`
	Expiration   string  `json:"expiration"`
}

type WebhookService

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

func (*WebhookService) SendArbitraryDataViaWebhook

func (s *WebhookService) SendArbitraryDataViaWebhook(token string, d *WebhookData) (*WebhookData, *Response, error)

func (*WebhookService) SendDataViaWebhook

func (s *WebhookService) SendDataViaWebhook(token string, d *WebhookData) (*WebhookData, *Response, error)

func (*WebhookService) SendNotificationViaWebhook

func (s *WebhookService) SendNotificationViaWebhook(token string, d *WebhookData) (*WebhookData, *Response, error)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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