// Code generated by lark_sdk_gen. DO NOT EDIT.
/**
 * Copyright 2022 chyroc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package lark

import (
	"context"
)

// GetApplicationFavourite 获取用户自定义常用的应用。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v5/application/favourite
// new doc: https://open.feishu.cn/document/server-docs/workplace-v1/app_recommend_rule/favourite
func (r *ApplicationService) GetApplicationFavourite(ctx context.Context, request *GetApplicationFavouriteReq, options ...MethodOptionFunc) (*GetApplicationFavouriteResp, *Response, error) {
	if r.cli.mock.mockApplicationGetApplicationFavourite != nil {
		r.cli.Log(ctx, LogLevelDebug, "[lark] Application#GetApplicationFavourite mock enable")
		return r.cli.mock.mockApplicationGetApplicationFavourite(ctx, request, options...)
	}

	req := &RawRequestReq{
		Scope:               "Application",
		API:                 "GetApplicationFavourite",
		Method:              "GET",
		URL:                 r.cli.openBaseURL + "/open-apis/application/v5/applications/favourite",
		Body:                request,
		MethodOption:        newMethodOption(options),
		NeedUserAccessToken: true,
	}
	resp := new(getApplicationFavouriteResp)

	response, err := r.cli.RawRequest(ctx, req, resp)
	return resp.Data, response, err
}

// MockApplicationGetApplicationFavourite mock ApplicationGetApplicationFavourite method
func (r *Mock) MockApplicationGetApplicationFavourite(f func(ctx context.Context, request *GetApplicationFavouriteReq, options ...MethodOptionFunc) (*GetApplicationFavouriteResp, *Response, error)) {
	r.mockApplicationGetApplicationFavourite = f
}

// UnMockApplicationGetApplicationFavourite un-mock ApplicationGetApplicationFavourite method
func (r *Mock) UnMockApplicationGetApplicationFavourite() {
	r.mockApplicationGetApplicationFavourite = nil
}

// GetApplicationFavouriteReq ...
type GetApplicationFavouriteReq struct {
	Language  *string `query:"language" json:"-"`   // 应用信息的语言版本, 示例值: "zh_cn", 可选值有: zh_cn: 中文, en_us: 英文, ja_jp: 日文
	PageToken *string `query:"page_token" json:"-"` // 分页标记, 第一次请求不填, 表示从头开始遍历；分页查询结果还有更多项时会同时返回新的 page_token, 下次遍历可采用该 page_token 获取查询结果, 示例值: "new-e11ee058b4a8ed2881da11ac7e37c4fc"
	PageSize  *int64  `query:"page_size" json:"-"`  // 分页大小, 示例值: 10, 默认值: `10`
}

// GetApplicationFavouriteResp ...
type GetApplicationFavouriteResp struct {
	PageToken  string                            `json:"page_token,omitempty"`  // 分页标记, 当 has_more 为 true 时, 会同时返回新的 page_token, 否则不返回 page_token
	TotalCount int64                             `json:"total_count,omitempty"` // 总的数量
	HasMore    bool                              `json:"has_more,omitempty"`    // 是否还有更多项
	AppList    []*GetApplicationFavouriteRespApp `json:"app_list,omitempty"`    // 应用数据列表
}

// GetApplicationFavouriteRespApp ...
type GetApplicationFavouriteRespApp struct {
	AppID       string                                      `json:"app_id,omitempty"`       // 应用id
	AppName     string                                      `json:"app_name,omitempty"`     // 应用名
	Description string                                      `json:"description,omitempty"`  // 应用描述
	AppType     string                                      `json:"app_type,omitempty"`     // 应用类型, 可选值有: app: 普通应用, shortcut: 快捷入口
	AvatarURL   string                                      `json:"avatar_url,omitempty"`   // 应用图标
	OpenMethods []*GetApplicationFavouriteRespAppOpenMethod `json:"open_methods,omitempty"` // 可以打开应用的方式, 包含移动端小程序applink、移动端网页applink、PC端小程序applink、移动端小程序applink、PC端网页applink、机器人applink
}

// GetApplicationFavouriteRespAppOpenMethod ...
type GetApplicationFavouriteRespAppOpenMethod struct {
	Type    string `json:"type,omitempty"`    // applink类型, 可选值有: mobile_gadget: 移动端小程序, mobile_web: 移动端Web, pc_gadget: pc端小程序, pc_web: pc端web, bot: 机器人
	Applink string `json:"applink,omitempty"` // applink链接
}

// getApplicationFavouriteResp ...
type getApplicationFavouriteResp struct {
	Code  int64                        `json:"code,omitempty"` // 错误码, 非 0 表示失败
	Msg   string                       `json:"msg,omitempty"`  // 错误描述
	Data  *GetApplicationFavouriteResp `json:"data,omitempty"`
	Error *ErrorDetail                 `json:"error,omitempty"`
}
