wopan

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 18 Imported by: 1

README

wopan-sdk-go

Wopan SDK for the Go programming language

Installation

go get github.com/Xhofe/wopan-sdk-go

Usage

package main

import (
	"fmt"
	"github.com/Xhofe/wopan-sdk-go"
)

func main() {
	w := wopan.DefaultWithRefreshToken("91d4b946-xxxx-4909-bac1-d9914e45f2de")
	res, err := w.AppQueryUser()
	if err != nil {
		fmt.Printf("AppQueryUser() error = %v", err)
	} else {
		fmt.Printf("AppQueryUser() = %+v", res)
	}
}

Documentation

Index

Constants

View Source
const (
	DefaultClientID     = "1001000021"
	DefaultClientSecret = "XFmi9GS2hzk98jGX"
	DefaultAppID        = "10000001"
	DefaultBaseURL      = "https://panservice.mail.wo.cn"
	DefaultZoneURL      = "https://gxupload.pan.wo.cn:8443"
	DefaultUA           = "" /* 129-byte string literal not displayed */
	DefaultPartSize     = int64(8 * 1024 * 1024)
)
View Source
const (
	ChannelAPIUser = "api-user"
	ChannelWoHome  = "wohome"
	ChannelWoCloud = "wocloud"
)
View Source
const (
	SpaceTypePersonal = "0"
	SpaceTypeFamily   = "1"
)
View Source
const (
	KeyPcWebLogin        = "PcWebLogin"
	KeyPcLoginVerifyCode = "PcLoginVerifyCode"
	KeyAppQueryUser      = "AppQueryUser"
	KeyAppRefreshToken   = "AppRefreshToken"
	KeyAppLogout         = "AppLogout"
)

api-user methods

View Source
const (
	KeyFCloudProductOrdListQry = "FCloudProductOrdListQry"
	KeyQueryCloudUsageInfo     = "QueryCloudUsageInfo"
	KeyFCloudProductPackage    = "FCloudProductPackage"
	KeyClassifyRule            = "ClassifyRule"
	KeyGetZoneInfo             = "GetZoneInfo"
	KeyQuerySysConfig          = "QuerySysConfig"
	KeyFamilyUserCurrentEncode = "FamilyUserCurrentEncode"
	KeyQueryAllFiles           = "QueryAllFiles"
	KeyGetSearchDirectory      = "GetSearchDirectory"
	KeyGetDownloadUrlV2        = "GetDownloadUrlV2"
	KeyGetDownloadUrl          = "GetDownloadUrl"
	KeyCreateDirectory         = "CreateDirectory"
	KeyRenameFileOrDirectory   = "RenameFileOrDirectory"
	KeyMoveFile                = "MoveFile"
	KeyCopyFile                = "CopyFile"
	KeyDeleteFile              = "DeleteFile"
	KeyEmptyRecycleData        = "EmptyRecycleData"
	KeyUpload2C                = "upload2C"
)

wohome methods

View Source
const (
	SortNameAsc = iota + 1
	SortNameDesc
	SortSizeAsc
	SortSizeDesc
	SortTimeAsc
	SortTimeDesc
)

Variables

View Source
var (
	JsonClientIDSecret = Json{
		"clientId": DefaultClientID,
		"secret":   true,
	}
	JsonSecret = Json{
		"secret": true,
	}
)
View Source
var (
	ErrInvalidAccessToken = errors.New("invalid access token")
)

Functions

func AesDecrypt

func AesDecrypt(data []byte, key []byte, iv []byte) ([]byte, error)

AesDecrypt 解密

func AesEncrypt

func AesEncrypt(data []byte, key []byte, iv []byte) ([]byte, error)

AesEncrypt 加密

Types

type AppQueryUserData

type AppQueryUserData struct {
	UserId        string `json:"userId"`
	HeadUrl       string `json:"headUrl"`
	UserName      string `json:"userName"`
	Sex           string `json:"sex"`
	Birthday      string `json:"birthday"`
	IsModify      string `json:"isModify"`
	IsHeadModify  string `json:"isHeadModify"`
	IsSetPassword string `json:"isSetPassword"`
	RegisterTime  string `json:"registerTime"`
}

type AppRefreshTokenData

type AppRefreshTokenData struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
	Scope        string `json:"scope"`
}

AppRefreshTokenData no encrypt

type ClassifyRuleData

type ClassifyRuleData struct {
	FileTypes map[string]struct {
		SubType string `json:"subType"`
		Ability string `json:"ability"`
		Type    string `json:"type"`
	} `json:"fileTypes"`
	FileIcons struct {
		App struct {
			Zip   string `json:"zip"`
			Image string `json:"image"`
			Other string `json:"other"`
			Xmind string `json:"xmind"`
			Gif   string `json:"gif"`
			Csv   string `json:"csv"`
			Video string `json:"video"`
			Excel string `json:"excel"`
			Pdf   string `json:"pdf"`
			Ppt   string `json:"ppt"`
			Doc   string `json:"doc"`
			Audio string `json:"audio"`
			Text  string `json:"text"`
			Word  string `json:"word"`
		} `json:"app"`
		H5 struct {
		} `json:"h5"`
	} `json:"fileIcons"`
}

type CreateDirectoryData

type CreateDirectoryData struct {
	Id string `json:"id"`
}

type Crypto

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

func NewCrypto

func NewCrypto() *Crypto

func (*Crypto) Decrypt

func (c *Crypto) Decrypt(content string, channel string) (string, error)

func (*Crypto) Encrypt

func (c *Crypto) Encrypt(content string, channel string) (string, error)

func (*Crypto) EncryptBytes

func (c *Crypto) EncryptBytes(bs []byte, channel string) (string, error)

func (*Crypto) SetAccessToken

func (c *Crypto) SetAccessToken(token string) error

func (*Crypto) UserDecrypt

func (c *Crypto) UserDecrypt(content string) (string, error)

func (*Crypto) UserEncrypt

func (c *Crypto) UserEncrypt(content string) (string, error)

func (*Crypto) WoHomeDecrypt

func (c *Crypto) WoHomeDecrypt(content string) (string, error)

func (*Crypto) WoHomeEncrypt

func (c *Crypto) WoHomeEncrypt(content string) (string, error)

type FCloudProductOrdListQryCtxData

type FCloudProductOrdListQryCtxData struct {
	FcloudProductOrds []struct {
		ActiviteCode        string `json:"activiteCode"`
		AppStorePackageDesc string `json:"appStorePackageDesc"`
		AppStorePackageFee  string `json:"appStorePackageFee"`
		AppStoreProductId   string `json:"appStoreProductId"`
		ApplyTime           string `json:"applyTime"`
		ApplyTimeFormate    string `json:"applyTimeFormate"`
		CbssOrderId         string `json:"cbssOrderId"`
		City                string `json:"city"`
		ClientId            string `json:"clientId"`
		Days                string `json:"days"`
		DescUrl             string `json:"descUrl"`
		EffectState         string `json:"effectState"`
		EffectiveDays       int    `json:"effectiveDays"`
		ExpireTime          string `json:"expireTime"`
		ExpireTimeFormate   string `json:"expireTimeFormate"`
		Fee                 string `json:"fee"`
		IsAppStorePay       string `json:"isAppStorePay"`
		IsAutoSub           string `json:"isAutoSub"`
		IsExpire            string `json:"isExpire"`
		IsNewPackage        string `json:"isNewPackage"`
		IsOnline            string `json:"isOnline"`
		IsPlus              string `json:"isPlus"`
		IsShowExpireTips    string `json:"isShowExpireTips"`
		OrderId             string `json:"orderId"`
		OrderState          string `json:"orderState"`
		OrderStatus         string `json:"orderStatus"`
		PackageDesc         string `json:"packageDesc"`
		PackageProductCode  string `json:"packageProductCode"`
		PackageProductId    string `json:"packageProductId"`
		PayMethod           string `json:"payMethod"`
		PayTransactionId    string `json:"payTransactionId"`
		PayType             string `json:"payType"`
		Province            string `json:"province"`
		RemainDays          string `json:"remainDays"`
		SignStatus          string `json:"signStatus"`
		Source              string `json:"source"`
		SubTime             string `json:"subTime"`
		SubTimeFormate      string `json:"subTimeFormate"`
		SubType             string `json:"subType"`
		UserId              string `json:"userId"`
		VipDesc             string `json:"vipDesc"`
		VipDescNew          string `json:"vipDescNew"`
		VipExpireTimeLabel  string `json:"vipExpireTimeLabel"`
		VipLevel            string `json:"vipLevel"`
	} `json:"fcloudProductOrds"`
	MaxVipLevel string `json:"maxVipLevel"`
	IsShowInlet string `json:"isShowInlet"`
}

type FamilyUserCurrentEncodeData

type FamilyUserCurrentEncodeData struct {
	Count           string `json:"count"`
	DefaultHomeId   int    `json:"defaultHomeId"`
	DefaultHomeName string `json:"defaultHomeName"`
	GroupHeadUrl    string `json:"groupHeadUrl"`
	GroupName       string `json:"groupName"`
	Id              int    `json:"id"`
	MemberRole      string `json:"memberRole"`
	OwnerId         string `json:"owner  Id"`
	UnreadFlag      string `json:"unreadFlag"`
}

type File

type File struct {
	FamilyId     int    `json:"familyId"`
	Fid          string `json:"fid"`
	Creator      string `json:"creator"`
	Size         int64  `json:"size"`
	CreateTime   string `json:"createTime"`
	Name         string `json:"name"`
	ShootingTime string `json:"shootingTime"`
	Id           string `json:"id"`
	Type         int    `json:"type"`
	ThumbUrl     string `json:"thumbUrl"`
	FileType     string `json:"fileType"`
}

type GetDownloadUrlData

type GetDownloadUrlData struct {
	Fid         string `json:"fid"`
	DownloadUrl string `json:"downloadUrl"`
}

type GetDownloadUrlV2Data

type GetDownloadUrlV2Data struct {
	Type int `json:"type"`
	List []struct {
		Fid         string `json:"fid"`
		DownloadUrl string `json:"downloadUrl"`
	} `json:"list"`
}

type GetZoneInfoData

type GetZoneInfoData struct {
	Url string `json:"url"`
}
type Header struct {
	Key     string `json:"key"`
	ResTime int64  `json:"resTime"`
	ReqSeq  int    `json:"reqSeq"`
	Channel string `json:"channel"`
	Sign    string `json:"sign"`
	Version string `json:"version"`
}

type Json

type Json map[string]interface{}

type Option

type Option func(w *WoClient)

func WithAccessToken

func WithAccessToken(token string) Option

func WithClient

func WithClient(hc *http.Client) Option

func WithDebug

func WithDebug() Option

func WithJsonMarshalFunc

func WithJsonMarshalFunc(f func(v interface{}) ([]byte, error)) Option

func WithJsonUnmarshalFunc

func WithJsonUnmarshalFunc(f func(data []byte, v interface{}) error) Option

func WithProxy

func WithProxy(proxy string) Option

func WithRefreshToken

func WithRefreshToken(token string) Option

func WithRestyClient

func WithRestyClient(rc *resty.Client) Option

func WithTrace

func WithTrace() Option

func WithUA

func WithUA(ua string) Option

type PcLoginVerifyCodeData

type PcLoginVerifyCodeData struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int    `json:"expires_in"`
}

PcLoginVerifyCodeData no encrypt

type PcWebLoginData

type PcWebLoginData struct {
	NeedSmsCode string `json:"needSmsCode"`
}

PcWebLoginData no encrypt

type QueryAllFilesData

type QueryAllFilesData struct {
	Files []File `json:"files"`
}

type QueryCloudUsageInfoData

type QueryCloudUsageInfoData struct {
	Code      string `json:"code"`
	UsageInfo struct {
		TotalSize     string `json:"totalSize"`
		UsedSize      int64  `json:"usedSize"`
		ImageSize     int64  `json:"imageSize"`
		VideoSize     int64  `json:"videoSize"`
		AudioSize     int64  `json:"audioSize"`
		TextSize      int64  `json:"textSize"`
		OtherSize     int64  `json:"otherSize"`
		ByteUsedSize  int64  `json:"byteUsedSize"`
		ByteTotalSize string `json:"byteTotalSize"`
	} `json:"usageInfo"`
	VipLevel   string `json:"vipLevel"`
	ExpireTime string `json:"expireTime"`
	ApplyTime  string `json:"applyTime"`
	PayType    string `json:"payType"`
	Source     string `json:"source"`
	OrderState string `json:"orderState"`
	Status     string `json:"status"`
}

type Req

type Req[T any] struct {
	Header `json:"header"`
	Body   T `json:"body"`
}

type Resp

type Resp struct {
	Status string `json:"STATUS"`
	Msg    string `json:"MSG"`
	LogID  string `json:"LOGID"`
	Rsp    struct {
		RspCode string          `json:"RSP_CODE"`
		RspDesc string          `json:"RSP_DESC"`
		Data    json.RawMessage `json:"DATA"`
	} `json:"RSP"`
}

type RestyOption

type RestyOption func(request *resty.Request)

type Upload2CFile

type Upload2CFile struct {
	Name        string
	Size        int64
	Content     io.Reader
	ContentType string
}

type Upload2COption

type Upload2COption struct {
	OnProgress func(current, total int64)
	Ctx        context.Context
}

type Upload2CResp

type Upload2CResp struct {
	Code string `json:"code"`
	Data struct {
		Fid string `json:"fid"`
	} `json:"data"`
	Msg string `json:"msg"`
}

type WoClient

type WoClient struct {
	Phone            string
	ZoneURL          string
	ClassifyRuleData *ClassifyRuleData
	// contains filtered or unexported fields
}

func Default

func Default() *WoClient

func DefaultWithAccessToken

func DefaultWithAccessToken(accessToken string) *WoClient

func DefaultWithRefreshToken

func DefaultWithRefreshToken(refreshToken string) *WoClient

func New

func New(opts ...Option) *WoClient

func (*WoClient) AppLogout

func (w *WoClient) AppLogout(opts ...RestyOption) error

func (*WoClient) AppQueryUser

func (w *WoClient) AppQueryUser(opts ...RestyOption) (*AppQueryUserData, error)

func (*WoClient) AppRefreshToken

func (w *WoClient) AppRefreshToken(opts ...RestyOption) (*AppRefreshTokenData, error)

func (*WoClient) ClassifyRule

func (w *WoClient) ClassifyRule(opts ...RestyOption) (*ClassifyRuleData, error)

func (*WoClient) CopyFile

func (w *WoClient) CopyFile(dirList, fileList []string, targetDirId string, sourceType, targetType string, fromFamilyId, targetFamilyId string, opts ...RestyOption) error

func (*WoClient) CreateDirectory

func (w *WoClient) CreateDirectory(spaceType, parentDirectoryId string, directoryName, familyId string, opts ...RestyOption) (*CreateDirectoryData, error)

func (*WoClient) DeleteFile

func (w *WoClient) DeleteFile(spaceType string, dirList, fileList []string, opts ...RestyOption) error

func (*WoClient) EmptyRecycleData

func (w *WoClient) EmptyRecycleData(opts ...RestyOption) error

func (*WoClient) EnableTrace

func (w *WoClient) EnableTrace() *WoClient

func (*WoClient) EncryptParam

func (w *WoClient) EncryptParam(channel string, param Json) (string, error)

func (*WoClient) FCloudProductOrdListQry

func (w *WoClient) FCloudProductOrdListQry(opts ...RestyOption) (*FCloudProductOrdListQryCtxData, error)

func (*WoClient) FamilyUserCurrentEncode

func (w *WoClient) FamilyUserCurrentEncode(opts ...RestyOption) (*FamilyUserCurrentEncodeData, error)

func (*WoClient) GetDownloadUrl

func (w *WoClient) GetDownloadUrl(spaceType string, fidList []string, opts ...RestyOption) ([]GetDownloadUrlData, error)

func (*WoClient) GetDownloadUrlV2

func (w *WoClient) GetDownloadUrlV2(fidList []string, opts ...RestyOption) (*GetDownloadUrlV2Data, error)

func (*WoClient) GetFileType

func (w *WoClient) GetFileType(filename string) string

func (*WoClient) GetToken

func (w *WoClient) GetToken() (string, string)

func (*WoClient) GetZoneInfo

func (w *WoClient) GetZoneInfo(opts ...RestyOption) (*GetZoneInfoData, error)

func (*WoClient) InitClassifyRule

func (w *WoClient) InitClassifyRule() error

func (*WoClient) InitData

func (w *WoClient) InitData() error

func (*WoClient) InitPhone

func (w *WoClient) InitPhone() error

func (*WoClient) InitZoneURL

func (w *WoClient) InitZoneURL() error

func (*WoClient) MoveFile

func (w *WoClient) MoveFile(dirList, fileList []string, targetDirId string, sourceType, targetType string, fromFamilyId, targetFamilyId string, opts ...RestyOption) error

func (*WoClient) NewBody

func (w *WoClient) NewBody(channel string, param, other Json) (Json, error)

func (*WoClient) NewRequest

func (w *WoClient) NewRequest() *resty.Request

func (*WoClient) OnRefreshToken

func (w *WoClient) OnRefreshToken(f func(accessToken, refreshToken string))

func (*WoClient) PcLoginVerifyCode

func (w *WoClient) PcLoginVerifyCode(phone, password, messageCode string, opts ...RestyOption) (*PcLoginVerifyCodeData, error)

func (*WoClient) PcWebLogin

func (w *WoClient) PcWebLogin(phone, password string, opts ...RestyOption) (*PcWebLoginData, error)

func (*WoClient) QueryAllFiles

func (w *WoClient) QueryAllFiles(spaceType, parentDirectoryId string, pageNum, pageSize int, sortRule int, familyId string, opts ...RestyOption) (*QueryAllFilesData, error)

func (*WoClient) QueryAllFilesFamily

func (w *WoClient) QueryAllFilesFamily(parentDirectoryId string, pageNum, pageSize int, sortRule int, familyId string, opts ...RestyOption) (*QueryAllFilesData, error)

func (*WoClient) QueryAllFilesPersonal

func (w *WoClient) QueryAllFilesPersonal(parentDirectoryId string, pageNum, pageSize int, sortRule int, opts ...RestyOption) (*QueryAllFilesData, error)

func (*WoClient) QueryCloudUsageInfo

func (w *WoClient) QueryCloudUsageInfo(opts ...RestyOption) (*QueryCloudUsageInfoData, error)

func (*WoClient) RefreshToken

func (w *WoClient) RefreshToken() error

func (*WoClient) RenameFileOrDirectory

func (w *WoClient) RenameFileOrDirectory(spaceType string, _type int, id string, name string, familyId string, opts ...RestyOption) error

RenameFileOrDirectory _type: 1: file, 0: directory

func (*WoClient) RenameFileOrDirectoryFamily

func (w *WoClient) RenameFileOrDirectoryFamily(_type int, id string, name string, familyId string, opts ...RestyOption) error

func (*WoClient) RenameFileOrDirectoryPersonal

func (w *WoClient) RenameFileOrDirectoryPersonal(_type int, id string, name string, opts ...RestyOption) error

func (*WoClient) Request

func (w *WoClient) Request(channel string, key string, param, other Json, resp interface{}, opts ...RestyOption) ([]byte, error)

func (*WoClient) RequestApiUser

func (w *WoClient) RequestApiUser(key string, param, other Json, resp interface{}, opts ...RestyOption) ([]byte, error)

func (*WoClient) RequestWoHome

func (w *WoClient) RequestWoHome(key string, param, other Json, resp interface{}, opts ...RestyOption) ([]byte, error)

func (*WoClient) SetAccessToken

func (w *WoClient) SetAccessToken(token string)

func (*WoClient) SetDebug

func (w *WoClient) SetDebug(d bool) *WoClient

func (*WoClient) SetHttpClient

func (w *WoClient) SetHttpClient(httpClient *http.Client) *WoClient

func (*WoClient) SetJsonMarshalFunc

func (w *WoClient) SetJsonMarshalFunc(f func(v interface{}) ([]byte, error))

func (*WoClient) SetJsonUnmarshalFunc

func (w *WoClient) SetJsonUnmarshalFunc(f func(data []byte, v interface{}) error)

func (*WoClient) SetProxy

func (w *WoClient) SetProxy(proxy string) *WoClient

func (*WoClient) SetRefreshToken

func (w *WoClient) SetRefreshToken(token string)

func (*WoClient) SetUA

func (w *WoClient) SetUA(ua string)

func (*WoClient) SetUserAgent

func (w *WoClient) SetUserAgent(userAgent string) *WoClient

func (*WoClient) Upload2C

func (w *WoClient) Upload2C(spaceType string, file Upload2CFile, targetDirId string, familyId string, opt Upload2COption) (string, error)

func (*WoClient) Upload2CFamily

func (w *WoClient) Upload2CFamily(file Upload2CFile, targetDirId string, familyId string, opt Upload2COption) (string, error)

func (*WoClient) Upload2CPersonal

func (w *WoClient) Upload2CPersonal(file Upload2CFile, targetDirId string, opt Upload2COption) (string, error)

Jump to

Keyboard shortcuts

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