Ejemplo n.º 1
0
 public void CreateMemberTest(string userId)
 {
     Extattr extattr = new Extattr()
     {
         attrs = new List<Attr>()
                 {
                     new Attr(){ name = "员工角色",value = "123"}
                 }
     };
     var accessToken = AccessTokenContainer.GetToken(_corpId);
     var result = MailListApi.CreateMember(accessToken, userId, "ceshi", new[] { 2 }, null, "18913536683", null, null, null, 0, extattr);
     Assert.IsNotNull(result);
     Assert.IsTrue(result.errcode == ReturnCode.请求成功);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新成员(mobile/weixinid/email三者不能同时为空)
        /// </summary>
        /// <param name="accessToken">调用接口凭证</param>
        /// <param name="userId">员工UserID。必须企业内唯一</param>
        /// <param name="name">成员名称。长度为1~64个字符</param>
        /// <param name="department">成员所属部门id列表。注意,每个部门的直属员工上限为1000个</param>
        /// <param name="position">职位信息。长度为0~64个字符</param>
        /// <param name="mobile">手机号码。必须企业内唯一</param>
        ///// <param name="tel">办公电话。长度为0~64个字符</param>
        /// <param name="email">邮箱。长度为0~64个字符。必须企业内唯一</param>
        /// <param name="weixinId">微信号。必须企业内唯一</param>
        /// <param name="enable">启用/禁用成员。1表示启用成员,0表示禁用成员</param>
        ///// <param name="gender">性别。gender=0表示男,=1表示女。默认gender=0</param>
        /// <param name="extattr">扩展属性。扩展属性需要在WEB管理端创建后才生效,否则忽略未知属性的赋值</param>
        /// <param name="timeOut">代理请求超时时间(毫秒)</param>
        /// accessToken和userId为必须的参数,其余参数不是必须的,可以传入null
        /// <returns></returns>
        public static WxJsonResult UpdateMember(string accessToken, string userId, string name = null, int[] department = null, string position = null,
                                                string mobile = null, string email = null, string weixinId = null, int enable = 1, /*string tel = null,
                                                                                                                                    * int gender = 0,*/Extattr extattr = null, int timeOut = Config.TIME_OUT)
        {
            var url = "https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token={0}";

            var data = new
            {
                userid     = userId,
                name       = name,
                department = department,
                position   = position,
                mobile     = mobile,

                //最新的接口中去除了以下两个字段
                //gender = gender,
                //tel = tel,

                email    = email,
                weixinid = weixinId,
                enable   = enable,
                extattr  = extattr
            };

            return(CommonJsonSend.Send <WxJsonResult>(accessToken, url, data, CommonJsonSendType.POST, timeOut));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新成员(mobile/weixinid/email三者不能同时为空)
        /// </summary>
        /// <param name="accessToken">调用接口凭证</param>
        /// <param name="userId">员工UserID。必须企业内唯一</param>
        /// <param name="name">成员名称。长度为1~64个字符</param>
        /// <param name="department">成员所属部门id列表。注意,每个部门的直属员工上限为1000个</param>
        /// <param name="position">职位信息。长度为0~64个字符</param>
        /// <param name="mobile">手机号码。必须企业内唯一</param>
        ///// <param name="tel">办公电话。长度为0~64个字符</param>
        /// <param name="email">邮箱。长度为0~64个字符。必须企业内唯一</param>
        /// <param name="weixinId">微信号。必须企业内唯一</param>
        /// <param name="enable">启用/禁用成员。1表示启用成员,0表示禁用成员</param>
        ///// <param name="gender">性别。gender=0表示男,=1表示女。默认gender=0</param>
        /// <param name="extattr">扩展属性。扩展属性需要在WEB管理端创建后才生效,否则忽略未知属性的赋值</param>
        /// <param name="timeOut">代理请求超时时间(毫秒)</param>
        /// accessToken和userId为必须的参数,其余参数不是必须的,可以传入null
        /// <returns></returns>
        public static QyJsonResult UpdateMember(string accessToken, string userId, string name = null, int[] department = null, string position = null,
            string mobile = null, string email = null, string weixinId = null, int enable = 1, /*string tel = null,
            int gender = 0,*/ Extattr extattr = null, int timeOut = Config.TIME_OUT)
        {
            var url = "https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token={0}";

            var data = new
            {
                userid = userId,
                name = name,
                department = department,
                position = position,
                mobile = mobile,

                //最新的接口中去除了以下两个字段
                //gender = gender,
                //tel = tel,

                email = email,
                weixinid = weixinId,
                enable = enable,
                extattr = extattr
            };

            return CommonJsonSend.Send<QyJsonResult>(accessToken, url, data, CommonJsonSendType.POST, timeOut);
        }