Documentation ¶
Index ¶
- Variables
- type APIErrorCause
- type ActionPayload
- type AppInformation
- type Application
- type AuthenticateActionPayload
- type AuthenticationResponse
- type Authenticator
- type Client
- type Configuration
- type ConfigurationOptionFunc
- type Device
- type DeviceOutletPowerStateAction
- type DevicePowerStateParameters
- type DevicesResponse
- type Envelope
- type Ewelink
- func (e Ewelink) Authenticate(context context.Context, configuration *Configuration, ...) (*Session, error)
- func (e Ewelink) AuthenticateWithEmail(context context.Context, configuration *Configuration, email string, ...) (*Session, error)
- func (e Ewelink) AuthenticateWithPhoneNumber(context context.Context, configuration *Configuration, phoneNumber string, ...) (*Session, error)
- func (e Ewelink) GetDevice(ctx context.Context, session *Session, deviceID string) (*Device, error)
- func (e Ewelink) GetDevices(ctx context.Context, session *Session) (*DevicesResponse, error)
- func (e Ewelink) SetDeviceOutletPowerState(context context.Context, session *Session, device *Device, stateOn bool, ...) (Response, error)
- func (e Ewelink) SetDevicePowerState(context context.Context, session *Session, device *Device, stateOn bool) (Response, error)
- type HTTPRequest
- type IOSDevice
- type MobileDevice
- type Option
- type Response
- type Session
- type SessionOptionFunc
- type SetDeviceOutletPowerStateResponse
- type SetDevicePowerStateResponse
- type User
- type WebsocketClient
- type WebsocketRequest
Constants ¶
This section is empty.
Variables ¶
var APIErrorCauses = struct { WrongRegion APIErrorCause AuthenticationError APIErrorCause InvalidRequest APIErrorCause InternalError APIErrorCause UnknownError APIErrorCause }{ WrongRegion: "Wrong region", AuthenticationError: "Authentication required", InvalidRequest: "Invalid request", InternalError: "Internal server error", }
APIErrorCauses holds information about all known api error causes.
Functions ¶
This section is empty.
Types ¶
type APIErrorCause ¶
type APIErrorCause string
APIErrorCause corresponds to a typical api error cause.
type ActionPayload ¶
type ActionPayload struct { Action string `json:"action"` UserAgent string `json:"userAgent"` Parameters parameters `json:"params"` APIKey string `json:"apikey"` DeviceID string `json:"deviceid"` Sequence int64 `json:"sequence"` }
ActionPayload struct.
type Application ¶
Application contains the application specific fields.
func (Application) String ¶
func (a Application) String() string
type AuthenticateActionPayload ¶
type AuthenticateActionPayload struct { Action string `json:"action"` APIKey string `json:"apikey"` AppID string `json:"appid"` UserAgent string `json:"userAgent"` Version string `json:"version"` Nonce string `json:"nonce"` ApkVersion string `json:"apkVersion"` Os string `json:"os"` At string `json:"at"` Ts string `json:"ts"` Model string `json:"model"` RomVersion string `json:"romVersion"` Sequence int64 `json:"sequence"` }
AuthenticateActionPayload struct.
type AuthenticationResponse ¶
type AuthenticationResponse struct { At string `json:"at"` Rt string `json:"rt"` User User `json:"user"` // contains filtered or unexported fields }
AuthenticationResponse struct.
func (*AuthenticationResponse) Decode ¶
func (a *AuthenticationResponse) Decode(payload io.ReadCloser) (Response, error)
func (AuthenticationResponse) String ¶
func (a AuthenticationResponse) String() string
type Authenticator ¶
type Authenticator interface {
Authenticate(context context.Context, client Client, session *Session) error
}
Authenticator is the interface implemented by types that authenticate a user.
func NewEmailAuthenticator ¶
func NewEmailAuthenticator(email string, password string) Authenticator
NewEmailAuthenticator returns a new instance of 'NewEmailAuthenticator.
func NewPhoneNumberAuthenticator ¶
func NewPhoneNumberAuthenticator(phoneNumber string, password string) Authenticator
NewPhoneNumberAuthenticator returns a new instance of 'NewPhoneNumberAuthenticator.
type Client ¶
type Client interface {
// contains filtered or unexported methods
}
Client is the interface implemented by types that can invoke the Ewelink API.
type Configuration ¶
type Configuration struct { // The user account region Region string APIURL string WebsocketURL *url.URL AppID string AppSecret string }
Configuration contains the configuration specific fields.
func NewConfiguration ¶
func NewConfiguration(region string, optionFunc ...ConfigurationOptionFunc) *Configuration
NewConfiguration creates a new Configuration.
func (Configuration) String ¶
func (c Configuration) String() string
type ConfigurationOptionFunc ¶
type ConfigurationOptionFunc func(c *Configuration)
ConfigurationOptionFunc option definition.
func WithAppID ¶
func WithAppID(appID string) ConfigurationOptionFunc
WithAppID option func to provide custom AppID.
func WithAppSecret ¶
func WithAppSecret(appSecret string) ConfigurationOptionFunc
WithAppSecret option func to provide custom AppSecret.
type Device ¶
type Device struct { Settings struct { OpsNotify int `json:"opsNotify"` OpsHistory int `json:"opsHistory"` AlarmNotify int `json:"alarmNotify"` } `json:"settings"` Group string `json:"group"` Online bool `json:"online"` Groups []interface{} `json:"groups"` DevGroups []interface{} `json:"devGroups"` ID string `json:"_id"` Name string `json:"name"` Type string `json:"type"` DeviceID string `json:"deviceid"` Apikey string `json:"apikey"` Extra struct { Extra struct { Description string `json:"description"` BrandID string `json:"brandId"` Apmac string `json:"apmac"` Mac string `json:"mac"` UI string `json:"ui"` ModelInfo string `json:"modelInfo"` Model string `json:"model"` Manufacturer string `json:"manufacturer"` Uiid int `json:"uiid"` StaMac string `json:"staMac"` } `json:"extra"` ID string `json:"_id"` } `json:"extra"` CreatedAt time.Time `json:"createdAt"` V int `json:"__v"` OnlineTime time.Time `json:"onlineTime"` IP string `json:"ip"` Location string `json:"location"` Params struct { Rssi int `json:"rssi"` StaMac string `json:"staMac"` Timers []struct { Enabled int `json:"enabled"` Type string `json:"type"` At string `json:"at"` MID string `json:"mId"` CoolkitTimerType string `json:"coolkit_timer_type"` Do struct { Switch string `json:"switch"` } `json:"do"` } `json:"timers"` Startup string `json:"startup"` FwVersion string `json:"fwVersion"` Switch string `json:"switch"` Switches []struct { Switch string `json:"switch"` Outlet int `json:"outlet"` } `json:"switches"` ControlType int `json:"controlType"` PartnerApikey string `json:"partnerApikey"` BindInfos struct { Gaction []string `json:"gaction"` } `json:"bindInfos"` } `json:"params"` OfflineTime time.Time `json:"offlineTime"` DeviceStatus string `json:"deviceStatus"` Devicekey string `json:"devicekey"` DeviceURL string `json:"deviceUrl"` BrandName string `json:"brandName"` ShowBrand bool `json:"showBrand"` BrandLogoURL string `json:"brandLogoUrl"` ProductModel string `json:"productModel"` DevConfig struct{} `json:"devConfig"` Uiid int `json:"uiid"` Tags struct { DisableTimers []struct { Do struct { Switch string `json:"switch"` } `json:"do"` CoolkitTimerType string `json:"coolkit_timer_type"` MID string `json:"mId"` At string `json:"at"` Type string `json:"type"` Enabled int `json:"enabled"` } `json:"disable_timers"` } `json:"tags,omitempty"` }
Device struct. nolint:maligned
type DeviceOutletPowerStateAction ¶
type DeviceOutletPowerStateAction struct { PowerOn []bool `json:"switches"` // contains filtered or unexported fields }
DeviceOutletPowerStateAction device with multiple outlets.
func (DeviceOutletPowerStateAction) MarshalJSON ¶
func (d DeviceOutletPowerStateAction) MarshalJSON() ([]byte, error)
MarshalJSON returns a JSON encoded 'DeviceOutletPowerStateAction'.
type DevicePowerStateParameters ¶
type DevicePowerStateParameters struct { PowerOn bool `json:"switch"` // contains filtered or unexported fields }
DevicePowerStateParameters for devices with only one outlet.
func (DevicePowerStateParameters) MarshalJSON ¶
func (d DevicePowerStateParameters) MarshalJSON() ([]byte, error)
MarshalJSON returns a JSON encoded 'DevicePowerStateParameters'.
type DevicesResponse ¶
type DevicesResponse struct { Devicelist []Device `json:"devicelist"` // contains filtered or unexported fields }
DevicesResponse struct.
func (*DevicesResponse) Decode ¶
func (d *DevicesResponse) Decode(payload io.ReadCloser) (Response, error)
func (DevicesResponse) String ¶
func (d DevicesResponse) String() string
type Ewelink ¶
type Ewelink struct {
// contains filtered or unexported fields
}
Ewelink contains the validator and Configuration context.
func (Ewelink) Authenticate ¶
func (e Ewelink) Authenticate(context context.Context, configuration *Configuration, authenticator Authenticator, options ...SessionOptionFunc) (*Session, error)
Authenticate - Authenticates a new user session using an authenticator.
func (Ewelink) AuthenticateWithEmail ¶
func (e Ewelink) AuthenticateWithEmail(context context.Context, configuration *Configuration, email string, password string, options ...SessionOptionFunc) (*Session, error)
AuthenticateWithEmail - Authenticates a new user session using email as identifier.
func (Ewelink) AuthenticateWithPhoneNumber ¶
func (e Ewelink) AuthenticateWithPhoneNumber(context context.Context, configuration *Configuration, phoneNumber string, password string, options ...SessionOptionFunc) (*Session, error)
AuthenticateWithPhoneNumber - Authenticates a new user session using phoneNumber as identifier.
func (Ewelink) GetDevices ¶
GetDevices - Returns information about the devices.
type HTTPRequest ¶
type HTTPRequest interface { Method() string URI() string Query() *url.Values Payload() payload Headers() *http.Header Response() Response IsToBeSigned() bool Session() *Session }
HTTPRequest interface.
type IOSDevice ¶
type IOSDevice struct {
// contains filtered or unexported fields
}
IOSDevice holds the contextual information for a IOS device.
func (IOSDevice) RomVersion ¶
RomVersion returns the Rom version.
type MobileDevice ¶
MobileDevice is the interface implemented by types that can deliver information about a mobile device.
type Response ¶
type Response interface { Decode(payload io.ReadCloser) (Response, error) Envelope() Envelope }
Response interface.
type Session ¶
type Session struct { MobileDevice MobileDevice Application *Application AuthenticationToken string User *User Configuration *Configuration }
Session holds the session metadata.
type SessionOptionFunc ¶
type SessionOptionFunc func(session *Session)
SessionOptionFunc option definition.
type SetDeviceOutletPowerStateResponse ¶
type SetDeviceOutletPowerStateResponse struct {
// contains filtered or unexported fields
}
SetDeviceOutletPowerStateResponse struct.
func (*SetDeviceOutletPowerStateResponse) Decode ¶
func (r *SetDeviceOutletPowerStateResponse) Decode(payload io.ReadCloser) (Response, error)
func (SetDeviceOutletPowerStateResponse) Envelope ¶
func (w SetDeviceOutletPowerStateResponse) Envelope() Envelope
func (SetDeviceOutletPowerStateResponse) String ¶
func (r SetDeviceOutletPowerStateResponse) String() string
type SetDevicePowerStateResponse ¶
type SetDevicePowerStateResponse struct {
// contains filtered or unexported fields
}
SetDevicePowerStateResponse struct.
func (*SetDevicePowerStateResponse) Decode ¶
func (r *SetDevicePowerStateResponse) Decode(payload io.ReadCloser) (Response, error)
func (SetDevicePowerStateResponse) Envelope ¶
func (w SetDevicePowerStateResponse) Envelope() Envelope
func (SetDevicePowerStateResponse) String ¶
func (r SetDevicePowerStateResponse) String() string
type User ¶
type User struct { ID string `json:"_id"` Email string `json:"email"` Password string `json:"password"` AppID string `json:"appid"` CreatedAt string `json:"createdat"` APIKey string `json:"apikey"` Online bool `json:"online"` OnlineTime string `json:"onlinetime"` IP string `json:"ip"` Location string `json:"location"` Language string `json:"lang"` OfflineTime string `json:"offlinetime"` BindInformation interface{} `json:"bindInfos"` AppInformation interface{} `json:"appInfos"` UserStatus string `json:"userstatus"` UnknownField01 int `json:"__v"` }
User struct.
type WebsocketClient ¶
type WebsocketClient interface {
// contains filtered or unexported methods
}
WebsocketClient is the interface implemented by types that can invoke the Ewelink Websocket Api.
type WebsocketRequest ¶
WebsocketRequest interface.