/// <summary> /// 获取企业号的永久授权码 /// 该API用于使用临时授权码换取授权方的永久授权码,并换取授权信息、企业access_token。 /// </summary> /// <param name="helper"></param> /// <param name="suite_id"></param> /// <param name="auth_code"></param> /// <param name="suiteAccessToken"></param> /// <returns></returns> public static GetPermanentCodeResult GetPermanentCode(this IQyHelper helper, string suite_id, string auth_code, string suiteAccessToken) { var request = new GetPermanentCodeRequest { suite_id = suite_id, auth_code = auth_code }; return(helper.GetPermanentCode(request, suiteAccessToken)); }
/// <summary> /// 获取应用套件令牌 /// </summary> /// <param name="helper"></param> /// <param name="suite_id"></param> /// <param name="suite_secret"></param> /// <param name="suite_ticket"></param> /// <returns></returns> public static GetSuiteTokenResult GetSuiteToken(this IQyHelper helper, string suite_id, string suite_secret, string suite_ticket) { GetSuiteTokenRequest request = new GetSuiteTokenRequest(); request.suite_id = suite_id; request.suite_secret = suite_secret; request.suite_ticket = suite_ticket; return(helper.GetSuiteToken(request)); }
/// <summary> /// 创建会话 /// </summary> /// <param name="chatid"> /// 回话ID,字符串类型,最长32个字符。只允许字符0-9及字母a-zA-Z,如果值内容为64bit无符号整型:要求值范围在[1, 2^63)之间,[2^63, 2^64)为系统分配会话id区间 /// </param> /// <param name="access_token"></param> /// <param name="name">会话标题</param> /// <param name="owner">管理员userid,必须是该会话userlist的成员之一</param> /// <param name="userlist">会话成员列表,成员用userid来标识。会话成员必须在3人或以上,1000人以下</param> /// <returns></returns> public static APIJsonResult CreateChat(this IQyHelper helper, string access_token, string chatid, string name, string owner, string[] userlist) { string url = string.Format("{0}chat/create?access_token={1}", baseUrl, access_token); var request = new CreateChatRequest(); request.chatid = chatid; request.name = name; request.owner = owner; request.userlist = userlist; return(helper.CreateChat(access_token, request)); }
/// <summary> /// 获取企业号应用 /// 该API用于获取授权方的企业号某个应用的基本信息,包括头像、昵称、帐号类型、认证类型、可见范围等信息 /// </summary> /// <param name="helper"></param> /// <param name="suite_id">套件ID</param> /// <param name="auth_corpid">授权方企业ID</param> /// <param name="permanent_code">永久授权码</param> /// <param name="agentid">授权方应用ID</param> /// <param name="suiteAccessToken"></param> /// <returns></returns> public static GetAgentResult GetAgent(this IQyHelper helper, string suite_id, string auth_corpid, string permanent_code, string agentid, string suiteAccessToken) { var request = new GetAgentRequest(); request.suite_id = suite_id; request.auth_corpid = auth_corpid; request.permanent_code = permanent_code; request.agentid = agentid; return(helper.GetAgent(request, suiteAccessToken)); }
/// <summary> /// /// </summary> /// <param name="access_token"></param> /// <param name="chatid_or_userid">type 为single时是userid,否则为chatid</param> /// <param name="op_user"></param> /// <param name="type"></param> /// <returns></returns> public static APIJsonResult ClearNotifyChat(this IQyHelper helper, string access_token, string chatid_or_userid, string op_user, ChatType type) { string url = string.Format("{0}chat/clearnotify?access_token={1}", baseUrl, access_token); return(HttpHelper.HttpPost.GetJsonResult <dynamic, GetChatResult>(url, new { op_user = op_user, chat = new { type = type.ToString(), id = chatid_or_userid } })); }
/// <summary> /// 获取会话 /// </summary> /// <param name="access_token"></param> /// <param name="chatid"></param> /// <returns></returns> public static GetChatResult GetChat(this IQyHelper helper, string access_token, string chatid) { string url = string.Format("{0}chat/get?access_token={1}&chatid={2}", baseUrl, access_token, chatid); return(HttpHelper.HttpGet.GetJsonResult <GetChatResult>(url)); }
/// <summary> /// 修改会话信息 /// </summary> /// <param name="access_token"></param> /// <param name="request"></param> /// <returns></returns> public static APIJsonResult UpdateChat(this IQyHelper helper, string access_token, UpdateChatRequest request) { string url = string.Format("{0}chat/update?access_token={1}", baseUrl, access_token); return(HttpHelper.HttpPost.GetJsonResult <UpdateChatRequest, GetChatResult>(url, request)); }
/// <summary> /// 设置成员新消息免打扰 /// </summary> /// <param name="access_token"></param> /// <param name="user_mute_list"></param> /// <returns></returns> public static SetMuteChatResult SetMuteChat(this IQyHelper helper, string access_token, SetMuteChatInfo[] user_mute_list) { string url = string.Format("{0}chat/setmute?access_token={1}", baseUrl, access_token); return(HttpHelper.HttpPost.GetJsonResult <dynamic, SetMuteChatResult>(url, new { user_mute_list = user_mute_list })); }
/// <summary> /// 获取套件访问Token(suite_access_token) /// </summary> /// <param name="helper"></param> /// <param name="suite_access_token"></param> /// <param name="tmp_auth_code"></param> /// <returns></returns> public static GetSuiteTokenResult DtGetSuiteToken(this IQyHelper helper, string suite_key, string suite_secret, string suite_ticket) { string url = string.Format("https://oapi.dingtalk.com/service/get_suite_token"); return(HttpHelper.Send <dynamic, GetSuiteTokenResult>(url, new { suite_key = suite_key, suite_secret = suite_secret, suite_ticket = suite_ticket })); }
/// <summary> /// 获取企业的永久授权码 /// </summary> /// <param name="helper"></param> /// <param name="suite_access_token"></param> /// <param name="tmp_auth_code"></param> /// <returns></returns> public static DtGetPermanentCodeResult DtGetPermanentCode(this IQyHelper helper, string suite_access_token, string tmp_auth_code) { string url = string.Format("https://oapi.dingtalk.com/service/get_permanent_code?suite_access_token={0}", suite_access_token); return(HttpHelper.Send <dynamic, DtGetPermanentCodeResult>(url, new { tmp_auth_code = tmp_auth_code })); }
/// <summary> /// 获取企业号的永久授权码 /// 该API用于使用临时授权码换取授权方的永久授权码,并换取授权信息、企业access_token。 /// </summary> /// <param name="helper"></param> /// <param name="request"></param> /// <returns></returns> public static GetPermanentCodeResult GetPermanentCode(this IQyHelper helper, GetPermanentCodeRequest request, string suiteAccessToken) { string url = string.Format("{0}service/get_permanent_code?suite_access_token={1}", baseUrl, suiteAccessToken); return(HttpHelper.HttpPost.GetJsonResult <GetPermanentCodeRequest, GetPermanentCodeResult>(request, url)); }
/// <summary> /// 获取企业授权的access_token /// </summary> /// <param name="helper"></param> /// <param name="suite_access_token"></param> /// <param name="auth_corpid"></param> /// <param name="permanent_code"></param> /// <returns></returns> public static DtGetCorpTokenResult DtGetCorpToken(this IQyHelper helper, string suite_access_token, string auth_corpid, string permanent_code) { string url = string.Format("https://oapi.dingtalk.com/service/get_corp_token?suite_access_token={0}", suite_access_token); return(HttpHelper.Send <dynamic, DtGetCorpTokenResult>(url, new { auth_corpid = auth_corpid, permanent_code = permanent_code })); }
/// <summary> /// 获取应用套件令牌 /// 该API用于获取应用套件令牌(suite_access_token)。 /// 注1:由于应用提供商可能托管了大量的企业号,其安全问题造成的影响会更加严重,故API中除了合法来源IP校验之外,还额外增加了1项安全策略: /// 获取suite_access_token时,还额外需要suite_ticket参数(请永远使用最新接收到的suite_ticket)。suite_ticket由企业号后台定时推送给应用套件,并定时更新。 /// 注2:通过本接口获取的accesstoken不会自动续期,每次获取都会自动更新。 /// </summary> /// <param name="helper"></param> /// <param name="request"></param> /// <returns></returns> public static GetSuiteTokenResult GetSuiteToken(this IQyHelper helper, GetSuiteTokenRequest request) { string url = string.Format("{0}service/get_suite_token", baseUrl); return(HttpHelper.HttpPost.GetJsonResult <GetSuiteTokenRequest, GetSuiteTokenResult>(request, url)); }
/// <summary> /// 退出会话 /// </summary> /// <param name="access_token"></param> /// <param name="chatid">会话id </param> /// <param name="op_user">操作人userid </param> /// <returns></returns> public static APIJsonResult QuitChat(this IQyHelper helper, string access_token, string chatid, string op_user) { string url = string.Format("{0}chat/quit?access_token={1}", baseUrl, access_token); return(HttpHelper.HttpPost.GetJsonResult <dynamic, GetChatResult>(url, new { chatid = chatid, op_user = op_user })); }
/// <summary> /// 该API用于设置企业应用的选项设置信息,如:地理位置上报等。第三方服务商不能调用该接口设置授权的主页型应用。 /// </summary> /// <param name="helper"></param> /// <param name="access_token"></param> /// <param name="request"></param> /// <returns></returns> public static QyResult SetAgentByAccessToken(this IQyHelper helper, string access_token, SetAgentQyRequest request) { string url = string.Format("{0}agent/set?access_token={1}", baseurl, access_token); return(HttpHelper.Send <SetAgentQyRequest, QyResult>(url, request)); }
/// <summary> /// 获取企业号的授权信息 /// 该API用于通过永久授权码换取企业号的授权信息。 永久code的获取,是通过临时授权码使用get_permanent_code 接口获取到的permanent_code。 /// </summary> /// <param name="helper"></param> /// <param name="request"></param> /// <returns></returns> public static GetAuthInfoResult GetAuthInfo(this IQyHelper helper, GetAuthInfoRequest request, string suiteAccessToken) { string url = string.Format("{0}service/get_auth_info?suite_access_token={1}", baseUrl, suiteAccessToken); return(HttpHelper.HttpPost.GetJsonResult <GetAuthInfoRequest, GetAuthInfoResult>(request, url)); }
/// <summary> /// 获取预授权码 /// 该API用于获取预授权码。预授权码用于企业号授权时的应用提供商安全验证。 /// </summary> /// <param name="request"></param> /// <param name="suite_access_token"></param> /// <returns></returns> public static GetPreAuthCodeResult GetPreAuthCode(this IQyHelper helper, GetPreAuthCodeReqeust request, string suite_access_token) { string url = string.Format("{0}service/get_pre_auth_code?suite_access_token={1}", baseUrl, suite_access_token); return(HttpHelper.HttpPost.GetJsonResult <GetPreAuthCodeReqeust, GetPreAuthCodeResult>(url, request)); }
/// <summary> /// 获取企业号access_token /// 应用提供商在取得企业号的永久授权码并完成对企业号应用的设置之后,便可以开始通过调用企业接口(详见企业接口文档)来运营这些应用。 /// </summary> /// <param name="request"></param> /// <param name="suite_access_token"></param> /// <returns></returns> public static GetCorpTokenResult GetCorpToken(this IQyHelper helper, GetCorpTokenRequest request, string suite_access_token) { string url = string.Format("{0}service/get_corp_token?suite_access_token={1}", baseUrl, suite_access_token); return(HttpHelper.HttpPost.GetJsonResult <GetCorpTokenRequest, GetCorpTokenResult>(url, request)); }
/// <summary> /// /// </summary> /// <param name="helper"></param> /// <param name="suite_access_token"></param> /// <param name="suite_key"></param> /// <param name="auth_corpid"></param> /// <param name="permanent_code"></param> /// <returns></returns> public static QyResult DtActivateSuite(this IQyHelper helper, string suite_access_token, string suite_key, string auth_corpid, string permanent_code) { string url = string.Format("https://oapi.dingtalk.com/service/activate_suite?suite_access_token={0}", suite_access_token); return(HttpHelper.Send <dynamic, QyResult>(url, new { suite_key = suite_key, auth_corpid = auth_corpid, permanent_code = permanent_code })); }
/// <summary> /// 获取企业的应用信息 /// </summary> /// <param name="helper"></param> /// <param name="suite_access_token"></param> /// <param name="suite_key"></param> /// <param name="auth_corpid"></param> /// <param name="permanent_code"></param> /// <param name="agentid"></param> /// <returns></returns> public static DtGetAgentResult DtGetAgent(this IQyHelper helper, string suite_access_token, string suite_key, string auth_corpid, string permanent_code, int agentid) { string url = string.Format("https://oapi.dingtalk.com/service/get_agent?suite_access_token={0}", suite_access_token); return(HttpHelper.Send <dynamic, DtGetAgentResult>(url, new { suite_key = suite_key, auth_corpid = auth_corpid, permanent_code = permanent_code, agentid = agentid })); }
/// <summary> /// 设置企业号应用 /// 该API用于设置授权方的企业应用的选项设置信息,如:地理位置上报等。注意,获取各项选项设置信息,需要有授权方的授权。 /// </summary> /// <param name="helper"></param> /// <param name="request"></param> /// <returns></returns> public static SetAgentResult SetAgent(this IQyHelper helper, SetAgentRequest request, string suiteAccessToken) { string url = string.Format("{0}service/set_agent?suite_access_token={1}", baseUrl, suiteAccessToken); return(HttpHelper.HttpPost.GetJsonResult <SetAgentRequest, SetAgentResult>(request, url)); }
/// <summary> /// 获取企业号某个应用的基本信息,包括头像、昵称、帐号类型、认证类型、可见范围等信息 /// </summary> /// <param name="helper"></param> /// <param name="access_token"></param> /// <param name="agentid"></param> /// <returns></returns> public static GetAgentQyResult GetAgentByAccessToken(this IQyHelper helper, string access_token, int agentid) { string url = string.Format("{0}agent/get?access_token={1}&agentid={2}", baseurl, access_token, agentid); return(HttpHelper.Get <GetAgentQyResult>(url)); }