wemeetcore

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPHeaderContentType = "Content-Type"
	HTTPHeaderUserAgent   = "User-Agent"

	XTCHeaderNonce      = "X-TC-Nonce"      // 随机正整数。
	XTCHeaderKey        = "X-TC-Key"        // 应用安全凭证密钥对中的 SecretId。
	XTCHeaderAction     = "X-TC-Action"     // 操作的接口名称。
	XTCHeaderRegion     = "X-TC-Region"     // 地域参数,用来标识希望操作哪个地域的数据。
	XTCHeaderTimestamp  = "X-TC-Timestamp"  // 当前 UNIX 时间戳,可记录发起 API 请求的时间。例如1529223702,单位为秒。
	XTCHeaderVersion    = "X-TC-Version"    // 应用 App 的版本号,建议设置,以便灰度和查找问题。
	XTCHeaderSignature  = "X-TC-Signature"  // 签名方法产生的签名。
	XTCHeaderRegistered = "X-TC-Registered" // 启用账户通讯录,传入值必须为1,创建的会议可出现在用户的会议列表中。
	HeaderAppId         = "AppId"           // 腾讯会议分配给企业的企业 ID。
	HeaderSdkId         = "SdkId"           // 用户子账号或开发的应用 ID。
	HeaderAccessToken   = "AccessToken"     // OAuth2.0 鉴权成功后返回的 token 信息。
	HeaderOpenId        = "OpenId"          // OAuth2.0 鉴权成功后的用户信息。
)

SDK 使用的原生+自定义请求头

View Source
const (
	DefaultContentType = "application/json; charset=utf-8"
)
View Source
const DefaultProtocol = "https"

DefaultProtocol 默认协议

View Source
const OpenAPIDomain = "api.meeting.qq.com"

OpenAPIDomain 域名

View Source
const Version = "v1.0.1"

Version SDK 版本

Variables

View Source
var DefaultAuthenticator xhttp.Authentication = &VersionAuthenticator{}

DefaultAuthenticator 默认鉴权器,用于增加 SDK 版本标识头

View Source
var DefaultSerializer xhttp.Serializable = JsonSerializer

DefaultSerializer 默认序列化器

View Source
var JsonSerializer = &JSONSerializer{}

JsonSerializer 全局 JSON 序列化器

Functions

func PathValue

func PathValue(v interface{}) string

PathValue is helper routine that returns a string to given path value.

func PtrBool

func PtrBool(v bool) *bool

PtrBool is a helper routine that returns a pointer to given boolean value.

func PtrFloat32

func PtrFloat32(v float32) *float32

PtrFloat32 is a helper routine that returns a pointer to given float value.

func PtrFloat64

func PtrFloat64(v float64) *float64

PtrFloat64 is a helper routine that returns a pointer to given float value.

func PtrInt

func PtrInt(v int) *int

PtrInt is a helper routine that returns a pointer to given integer value.

func PtrInt32

func PtrInt32(v int32) *int32

PtrInt32 is a helper routine that returns a pointer to given integer value.

func PtrInt64

func PtrInt64(v int64) *int64

PtrInt64 is a helper routine that returns a pointer to given integer value.

func PtrString

func PtrString(v string) *string

PtrString is a helper routine that returns a pointer to given string value.

func PtrTime

func PtrTime(v time.Time) *time.Time

PtrTime is helper routine that returns a pointer to given Time value.

func QueryValue

func QueryValue(v interface{}) string

QueryValue is helper routine that returns a string to given query value.

Types

type ClientError

type ClientError struct {
	Err error
}

ClientError 客户端异常

func (ClientError) Error

func (ce ClientError) Error() string

type Config

type Config struct {
	Clt xhttp.Client // wemeet 封装的 http client

	Version string // 应用 App 的版本号,建议设置,以便灰度和查找问题。通过设置该字段,API 会把该版本信息传递给会议后台,以控制一些和 App 版本有关的特性。

	// 腾讯会议分配给企业的企业 ID。
	//
	// 企业管理员可以登录 腾讯会议官网,单击右上角用户中心,在左侧菜单栏中的企业管理 > 账户管理 > 账户信息中进行查看。
	//
	// 开发者可以单击右上角用户中心,在左侧菜单栏中的企业管理 > 高级  > REST API 应用信息中查看。
	AppId string

	// 用户子账号或开发的应用 ID。
	//
	// 企业管理员可以登录 腾讯会议官网,单击右上角用户中心,在左侧菜单栏中的企业管理 > 高级 > REST API 中进行查看(如存在 SdkId 则必须填写,早期申请 API 且未分配 SdkId 的客户可不填写)。
	SdkId     string
	SecretID  string // 应用生成的 Secret ID。JWT 鉴权用。
	SecretKey string // 应用生成的 Secret Key。JWT 鉴权用。
}

Config 通用配置

type JSONSerializer

type JSONSerializer struct {
}

func (*JSONSerializer) ContentType

func (d *JSONSerializer) ContentType() string

func (*JSONSerializer) Deserialize

func (d *JSONSerializer) Deserialize(data []byte, v interface{}) error

func (*JSONSerializer) Name

func (d *JSONSerializer) Name() string

func (*JSONSerializer) Serialize

func (d *JSONSerializer) Serialize(v interface{}) ([]byte, error)

type JWTAuthenticator

type JWTAuthenticator struct {
	Nonce uint64 // 此参数参与签名计算。随机正整数。SDK 默认自动随机生成。

	// 此参数参与签名计算。当前 UNIX 时间戳,可记录发起 API 请求的时间。SDK 默认当前时间戳。
	//
	// 例如1529223702,单位为秒。注意:如果与服务器时间相差超过5分钟,会引起签名过期错误。
	Timestamp string
	Action    string // 操作的接口名称。注意:某些接口不需要传递该参数,接口文档中会对此特别说明,此时即使传递该参数也不会生效。
	Region    string // 地域参数,用来标识希望操作哪个地域的数据。注意:某些接口不需要传递该参数,接口文档中会对此特别说明,此时即使传递该参数也不会生效。
	Signature string // 放置由官网的签名方法产生的签名。SDK 默认自动生成,也可替换为自己生成符合标准的签名。

	// 启用账户通讯录,传入值必须为1,创建的会议可出现在用户的会议列表中。
	//
	// 启用账户通讯录说明:
	//
	// 1. 通过 SSO 接入腾讯会议账号体系。
	//
	// 2. 通过调用接口创建企业用户。
	//
	// 3. 通过企业管理后台添加或批量导入企业用户。
	Registered string
	// contains filtered or unexported fields
}

JWTAuthenticator jwt 鉴权器 提供标准的 jwt 鉴权头的设置和签名生成逻辑。

func (JWTAuthenticator) AuthHeader

func (jwt JWTAuthenticator) AuthHeader(req *http.Request) error

type OAuth2Authenticator

type OAuth2Authenticator struct {
	Nonce uint64 // 此参数参与签名计算。随机正整数。SDK 默认自动随机生成。

	// 此参数参与签名计算。当前 UNIX 时间戳,可记录发起 API 请求的时间。SDK 默认当前时间戳。
	//
	// 例如1529223702,单位为秒。注意:如果与服务器时间相差超过5分钟,会引起签名过期错误。
	Timestamp string
	Action    string // 操作的接口名称。注意:某些接口不需要传递该参数,接口文档中会对此特别说明,此时即使传递该参数也不会生效。
	Region    string // 地域参数,用来标识希望操作哪个地域的数据。注意:某些接口不需要传递该参数,接口文档中会对此特别说明,此时即使传递该参数也不会生效。

	AccessToken string // OAuth2.0 鉴权成功后返回的 token 信息。
	OpenId      string // OAuth2.0 鉴权成功后的用户信息。
	// contains filtered or unexported fields
}

OAuth2Authenticator oauth2 鉴权器

func (OAuth2Authenticator) AuthHeader

func (oauth2 OAuth2Authenticator) AuthHeader(httpReq *http.Request) error

type RequestOptionFunc

type RequestOptionFunc func(config Config) xhttp.RequestOptionFunc

RequestOptionFunc 对外请求配置

func WithJWTAuth

func WithJWTAuth(jwt *JWTAuthenticator) RequestOptionFunc

WithJWTAuth 配置 JWT 鉴权

func WithOAuth2Auth

func WithOAuth2Auth(oauth2 *OAuth2Authenticator) RequestOptionFunc

WithOAuth2Auth 配置 OAuth2 鉴权

func WithRequestHeader

func WithRequestHeader(header http.Header) RequestOptionFunc

WithRequestHeader 配置自定义请求头

type ServiceError

type ServiceError struct {
	*xhttp.ApiResponse

	// ErrorInfo 业务错误
	ErrorInfo *struct {
		ErrorCode    int64  `json:"error_code"`
		NewErrorCode int64  `json:"new_error_code"`
		Message      string `json:"message"`
	} `json:"error_info"`
}

ServiceError 接口服务异常

func (ServiceError) Error

func (se ServiceError) Error() string

type VersionAuthenticator

type VersionAuthenticator struct{}

VersionAuthenticator SDK 版本鉴权器

func (VersionAuthenticator) AuthHeader

func (v VersionAuthenticator) AuthHeader(httpReq *http.Request) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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