request

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ok                 = "OK"
	NotFound           = "NOT_FOUND"
	Unauthorized       = "UNAUTHORIZED"
	PermissionDenied   = "PERMISSION_DENIED"
	IllegalArgument    = "ILLEGAL_ARGUMENT"
	Failed             = "FAILED"
	Occupy             = "OCCUPY"
	InvalidAccessToken = "INVALID_ACCESS_TOKEN"
)

Variables

View Source
var ProviderSet = wire.NewSet(NewRequest)

Functions

func AuthUrl

func AuthUrl(host string) string

func BindAppUrl

func BindAppUrl(host, productKey, sn, appId string) string

func DownloadFirmwareUrl

func DownloadFirmwareUrl(host, productKey, firmsoftId string) string

func RefreshTokenUrl

func RefreshTokenUrl(host string) string

func ReportCmdResultUrl

func ReportCmdResultUrl(host, productKey, sn string) string

func ReportEventUrl

func ReportEventUrl(host, productKey, sn string) string

func ReportGwTopologyUrl

func ReportGwTopologyUrl(host string) string

func ReportStatusUrl

func ReportStatusUrl(host, productKey, sn string) string

func ReportUpgradeProgressUrl

func ReportUpgradeProgressUrl(host, productKey, sn string) string

func SubscribeUrl

func SubscribeUrl(host string) string

Types

type AuthResult

type AuthResult struct {
	ResponseBody
	Body authResultBody `json:"body"`
}

type GwTopology

type GwTopology struct {
	GwProductKey string                 `json:"gwProductKey"`
	GwSn         string                 `json:"gwSn"`
	States       map[string]interface{} `json:"states"`
	SubDevices   []SubDevice            `json:"subDevices"`
}

type Request

type Request interface {
	Auth(ctx context.Context, dalId string) *AuthResult
	RefreshToken(ctx context.Context, dalId string, refreshToken string) *AuthResult
	BindApp(ctx context.Context, dalId, productKey, appId, sn string) (err error)
	SetCallbackUrl(ctx context.Context, dalId, serverUrl string) (err error)
	ReportCmdResultWithoutParams(ctx context.Context, dalId, productKey, sn, messageId, result string, time time.Time, remark string) (err error)
	ReportCmdResult(ctx context.Context, dalId, productKey, sn, messageId, result string, time time.Time, remark string, states map[string]interface{}) (err error)
	ReportStatus(ctx context.Context, dalId, productKey, sn string, states map[string]interface{}, time time.Time) (err error)
	ReportEvent(ctx context.Context, dalId, productKey, sn, reportId, eventCode string, params map[string]interface{}, time time.Time) (err error)
	ReportUpgradeProgress(ctx context.Context, dalId, productKey, sn, upgradeId, status string, progress int, remark string, time time.Time) (err error)
	ReportGwTopology(ctx context.Context, dalId string, gwTopology *GwTopology) (err error)
	ReportSerialNet(ctx context.Context, dalId, productKey, sn, reportId, data string, time time.Time, params map[string]interface{}) (err error)
}

func NewRequest

func NewRequest(cfg config.Config, log *zap.Logger, dalInfoService service.DalInfoService, reportService service.ReportService) Request

type ResponseBody

type ResponseBody struct {
	Code    string      `json:"code"`
	ErrCode interface{} `json:"errCode"`
	Message string      `json:"message"`
	Body    interface{} `json:"body"`
}

func BuildResponseFailed

func BuildResponseFailed() *ResponseBody

func BuildResponseIllegalArgument

func BuildResponseIllegalArgument() *ResponseBody

func BuildResponseNotFound

func BuildResponseNotFound() *ResponseBody

func BuildResponseOk

func BuildResponseOk() *ResponseBody

func (*ResponseBody) GetErrCode added in v0.5.2

func (resp *ResponseBody) GetErrCode() int32

func (*ResponseBody) SetBody

func (resp *ResponseBody) SetBody(body interface{}) *ResponseBody

func (*ResponseBody) SetMessage

func (resp *ResponseBody) SetMessage(message string) *ResponseBody

type SubDevice

type SubDevice struct {
	SubProductKey   string                 `json:"subProductKey"`
	SubDeviceSn     string                 `json:"subDeviceSn"`
	SubDeviceName   string                 `json:"subDeviceName"`
	SubDeviceRemark string                 `json:"subDeviceRemark"`
	States          map[string]interface{} `json:"states"`
}

Jump to

Keyboard shortcuts

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