import "../base.api"
import "./label_relationship.api"

type (
    // The response data of contact list | Contact列表数据
    ContactListResp {
        BaseDataInfo

        // Contact list data | Contact列表数据
        Data ContactListInfo `json:"data"`
    }

    // Contact list data | Contact列表数据
    ContactListInfo {
        BaseListInfo

        // The API list data | Contact列表数据
        Data  []ContactInfo  `json:"data"`
    }

    // Get contact list request params | Contact列表请求参数
    ContactListReq {
        PageInfo

        // Label ID list | 标签ID列表
        LabelIDs []uint64 `json:"labelIDs,optional"`

        // 属主微信id
        WxWxid  *string `json:"wxWxid,optional"`

        // 微信id 公众号微信ID 
        Wxid  *string `json:"wxid,optional"`

        // 微信账号 
        Account  *string `json:"account,optional"`

        // 昵称
        Nickname  *string `json:"nickname,optional"`

        // 联系人类型:1好友,2群组,3公众号,4企业微信联系人
        Type  *int `json:"type,optional"`
    }

    // Contact information response | Contact信息返回体
    ContactInfoResp {
        BaseDataInfo

        // Contact information | Contact数据
        Data ContactInfo `json:"data"`
    }

    AddNewFriendReq {
        OwnerWxid string `json:"ownerWxid"`
        Wxid string `json:"wxid"`
        Gid string `json:"gid"`
        Desc string `json:"desc"`
        AddType string `json:"addType"`
    }

    changeBlockListReq {
        OwnerWxid string `json:"ownerWxid"`
        Wxid string `json:"wxid"`
        Type  *int `json:"type,optional"`
        Ai *bool `json:"ai,optional"`
    }
)

@server(
    jwt: Auth
    group: contact
    middleware: Authority
)

service Wechat {
    // Create contact information | 创建Contact
    @handler createContact
    post /contact/create (ContactInfo) returns (BaseMsgResp)

    // Update contact information | 更新Contact
    @handler updateContact
    post /contact/update (ContactInfo) returns (BaseMsgResp)

    // Delete contact information | 删除Contact信息
    @handler deleteContact
    post /contact/delete (IDsReq) returns (BaseMsgResp)

    // Get contact list | 获取Contact列表
    @handler getContactList
    post /contact/list (ContactListReq) returns (ContactListResp)

    // Get contact by ID | 通过ID获取Contact
    @handler getContactById
    post /contact (IDReq) returns (ContactInfoResp)

    @handler addNewFriend
    post /contact/addNewFriend (AddNewFriendReq) returns (BaseMsgResp)

    @handler changeBlockList
    post /contact/changeBlockList (changeBlockListReq) returns (BaseMsgResp)
}