Documentation
¶
Index ¶
- Constants
- func GetCompleteEndpointUrl(a *APIUrl) string
- func GetEndpoint(i interface{}) string
- func ParseToken(i interface{}) (string, error)
- type APIUrl
- type AccessToken
- type AccessTokenList
- type AccessTokenService
- type ApiError
- type CoreInfo
- type DeleteAccessTokenResponse
- type Device
- func (d *Device) GetDeviceVariable(dVar *DeviceVariable, i interface{}) (*GetDeviceVariableResponse, error)
- func (d *Device) InvokeFunction(dFunc *DeviceFunction, i interface{}) (*InvokeFunctionResponse, error)
- func (d *Device) NewDeviceFunction(name string, args []string)
- func (d *Device) NewDeviceVariable(name string)
- type DeviceFunction
- type DeviceVariable
- type ErrorResponse
- type GetDeviceVariableResponse
- type InvokeFunctionResponse
- type OAuthRequest
- type OAuthResponse
Constants ¶
const ( APIVersion = "/v1" BaseUrl = "https://api.spark.io" MaxVariableLen = 12 )
const ( UserName = "YOUR_EMAIL@ADDRE.SS" Password = "YOUR_PASSWORD" BasicAuthId = "spark" BasicAuthPassword = "spark" )
Variables ¶
This section is empty.
Functions ¶
func GetCompleteEndpointUrl ¶
func GetEndpoint ¶
func GetEndpoint(i interface{}) string
func ParseToken ¶
Types ¶
type AccessToken ¶
type AccessToken struct { Token string `json:"token"` ExpiresAt string `json:"expires_at"` Client string `json:"client"` }
func NewAccessToken ¶
func NewAccessToken() *AccessToken
type AccessTokenList ¶
type AccessTokenList struct {
Tokens []*AccessToken
}
func NewAccessTokenList ¶
func NewAccessTokenList() *AccessTokenList
type AccessTokenService ¶
type AccessTokenService struct { OaRequest *OAuthRequest AToken *AccessToken ATokenList *AccessTokenList }
AccessTokenService is an entrypoint for any AccessToken related operation.
func NewAccessTokenService ¶
func NewAccessTokenService(username, password string) *AccessTokenService
func (*AccessTokenService) DeleteAccessToken ¶
func (s *AccessTokenService) DeleteAccessToken(a *AccessToken) ( *DeleteAccessTokenResponse, error)
func (*AccessTokenService) GetAccessToken ¶
func (s *AccessTokenService) GetAccessToken() (*OAuthResponse, error)
Get returns an AccessToken in the form of a OAuthResponse object.
func (*AccessTokenService) ListAllAccessTokens ¶
func (s *AccessTokenService) ListAllAccessTokens() error
type CoreInfo ¶
type CoreInfo struct { LastApp string `json:"last_app, omitempty"` LastHeard string `json:"last_heard, omitempty"` Connected bool `json:"connected, omitempty"` DeviceID string `json:"deviceID, omitempty"` }
CoreInfo is a representation of the json struct coreInfo.
type DeleteAccessTokenResponse ¶
type DeleteAccessTokenResponse struct {
Status bool `json:"ok"`
}
type Device ¶
type Device struct { ID string Functions map[string]*DeviceFunction Variables map[string]*DeviceVariable }
Device is a representation of a Spark Core.
func (*Device) GetDeviceVariable ¶
func (d *Device) GetDeviceVariable(dVar *DeviceVariable, i interface{}) ( *GetDeviceVariableResponse, error)
GetDeviceVariable is the method to GET the value of a particular Device Variable.
func (*Device) InvokeFunction ¶
func (d *Device) InvokeFunction(dFunc *DeviceFunction, i interface{}) (*InvokeFunctionResponse, error)
InvokeFunction is used to Invoke a DeviceFunction instance.
func (*Device) NewDeviceFunction ¶
NewDeviceFunction is a constuctor for DeviceFunction that also links the function to a Device object.
func (*Device) NewDeviceVariable ¶
NewDeviceVariable is a constructor for DeviceVariable and links it to a Device object.
type DeviceFunction ¶
DeviceFunction is a representation of a function.
type DeviceVariable ¶
type DeviceVariable struct {
Name string
}
DeviceVariable is a representation of a Variable that can be associated with a device.
type ErrorResponse ¶
type ErrorResponse struct { Code int32 `json:"code, omitempty"` Err string `json:"error, omitempty"` ErrorDescription string `json:"error_description, omitempty"` Info string `json:"info, omitempty"` }
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
type GetDeviceVariableResponse ¶
type GetDeviceVariableResponse struct { Cmd string `json:"cmd, omitempty"` Name string `json:"name, omitempty"` // Result can be a string, int, float or bool. Not the best // way to do this here, but I'm sorry about this. Ugly I will agree. Result interface{} `json:"result, omitempty"` CoreInfo CoreInfo `json:"coreInfo, omitempty"` }
GetDeviceVariableResponse is a representation of the response received on doing a GET on a Device Variable.
type InvokeFunctionResponse ¶
type InvokeFunctionResponse struct { DeviceID string `json:"id"` Name string `json:name` Connected bool `json:connected` ReturnValue int32 `json:connected` }
InvokeFunctionResponse is the representation of a response when a particular function is invoked via the REST API.
type OAuthRequest ¶
type OAuthRequest struct { GrantType string `json:"grant_type, omitempty"` UserName string `json:"username, omitoempty"` Password string `json:"password, omitempty"` }
OAuthRequest is a struct for the body of a request to get an access token.
func NewOAuthRequest ¶
func NewOAuthRequest(username, password string) *OAuthRequest