package hook

import "fmt"

// 网络获取群成员wxid
func (h *Hook) BatchGetChatRoomMemberWxid(gid string) (result GetBatchGetChatRoomMemberWxidReap, err error) {
	resp, err := h.Client.R().SetBody(&GetBatchGetChatRoomMemberWxidReq{
		Gid: gid,
	}).SetSuccessResult(&result).Post("http://" + h.ServerIp + ":" + h.WxPort + "/BatchGetChatRoomMemberWxid")
	if err != nil {
		return
	}
	if !resp.IsSuccessState() {
		err = fmt.Errorf("BatchGetChatRoomMemberWxid failed with status code %d", resp.StatusCode)
		return
	}
	return
}

// 批量获取群成员邀请信息
func (h *Hook) GetChatrooMmemberDetail(gid string) (result GetChatrooMmemberDetailReap, err error) {
	resp, err := h.Client.R().SetBody(&GetChatrooMmemberDetailReq{
		Gid: gid,
	}).SetSuccessResult(&result).Post("http://" + h.ServerIp + ":" + h.WxPort + "/GetChatrooMmemberDetail")
	if err != nil {
		return
	}
	if !resp.IsSuccessState() {
		err = fmt.Errorf("GetChatrooMmemberDetail failed with status code %d", resp.StatusCode)
		return
	}
	return
}

// 网络获取群成员详细信息
func (h *Hook) GetChatroomMemberDetailInfo(gid string, wxid string) (result GetChatroomMemberDetailInfoReap, err error) {
	resp, err := h.Client.R().SetBody(&GetChatroomMemberDetailInfoReq{
		Gid:  gid,
		Wxid: wxid,
	}).SetSuccessResult(&result).Post("http://" + h.ServerIp + ":" + h.WxPort + "/GetChatroomMemberDetailInfo")
	if err != nil {
		return
	}
	if !resp.IsSuccessState() {
		err = fmt.Errorf("GetChatroomMemberDetailInfo failed with status code %d", resp.StatusCode)
		return
	}
	return
}
