// 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"
)

// EventV1AppStatusChange 了解事件订阅的使用场景和配置流程, 请点击查看 [事件订阅概述](https://open.feishu.cn/document/ukTMukTMukTM/uUTNz4SN1MjL1UzM)
//
// 当企业管理员在管理员后台启用、停用应用, 或应用被平台停用时, 开放平台推送 app_status_change 事件到请求网址。
// - 订阅条件: 只有应用商店应用才能订阅此事件。自建应用无此事件。
// - 特殊说明: 管理员手动安装应用时, 也会触发启用事件。
//
// doc: https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/application-v6/event/app-enabled-or-disabled
// new doc: https://open.feishu.cn/document/server-docs/application-v6/event/app-enabled-or-disabled
func (r *EventCallbackService) HandlerEventV1AppStatusChange(f EventV1AppStatusChangeHandler) {
	r.cli.eventHandler.eventV1AppStatusChangeHandler = f
}

// EventV1AppStatusChangeHandler event EventV1AppStatusChange handler
type EventV1AppStatusChangeHandler func(ctx context.Context, cli *Lark, schema string, header *EventHeaderV1, event *EventV1AppStatusChange) (string, error)

// EventV1AppStatusChange ...
type EventV1AppStatusChange struct {
	AppID     string                               `json:"app_id,omitempty"`     // 应用ID. 如: cli_xxx
	TenantKey string                               `json:"tenant_key,omitempty"` // 企业唯一标识. 如: xxx
	Type      string                               `json:"type,omitempty"`       // 事件类型. 如: app_status_change
	Status    string                               `json:"status,omitempty"`     // 应用状态 start_by_tenant: 租户启用; stop_by_tenant: 租户停用; stop_by_platform: 平台停用. 如: start_by_tenant
	Operator  *EventV1AppStatusChangeEventOperator `json:"operator,omitempty"`   // 仅status=start_by_tenant时有此字段
}

// EventV1AppStatusChangeEventOperator ...
type EventV1AppStatusChangeEventOperator struct {
	OpenID  string `json:"open_id,omitempty"`  // 如: xxx
	UserID  string `json:"user_id,omitempty"`  // 仅自建应用才会返回. 如: yyy
	UnionID string `json:"union_id,omitempty"` // 用户在ISV下的唯一标识. 如: zzz
}
