package dingdingapi

import "git.rosy.net.cn/baseapi/utils"

type UserID struct {
	UserID   string `json:"userid"`
	IsSys    bool   `json:"is_sys"`
	DeviceID string `json:"deviceId"`
}

func (a *API) GetUserID(code string) (userID *UserID, err error) {
	result, err := a.AccessAPI("user/getuserinfo", utils.Params2Map("code", code), nil)
	if err != nil {
		return nil, err
	}
	return &UserID{
		UserID:   utils.Interface2String(result["userid"]),
		IsSys:    result["is_sys"].(bool),
		DeviceID: utils.Interface2String(result["deviceId"]),
	}, nil
}

func (a *API) GetUserDetail(userID string) (userDetail map[string]interface{}, err error) {
	result, err := a.AccessAPI("user/get", utils.Params2Map("userid", userID), nil)
	if err != nil {
		return nil, err
	}
	return result, nil
}
