import * as util from 'util' ; import { HttpKit } from '@tnwx/kits' ; import { AccessToken , OpenCpAccessTokenApi , AccessTokenType } from '@tnwx/accesstoken' ; author Javen
 *  copyright description export class OpenQrCode { private static getRegisterCodeUrl = 'https://qyapi.weixin.qq.com/cgi-bin/service/get_register_code?provider_access_token=%s' ; param templateId param corpName param adminName param adminMobile param state param followUser public static async getRegisterCode ( templateId , corpName ? , adminName ? , adminMobile ? , state ? , followUser ? ) { let accessToken = await OpenCpAccessTokenApi . getAccessToken ( AccessTokenType . PROVIDER_TOKEN ) ; let url = util . format ( this . getRegisterCodeUrl , accessToken . getAccessToken ) ; return HttpKit . getHttpDelegate . httpPost ( url , JSON . stringify ( { template_id : templateId , corp_name : corpName , admin_name : adminName , admin_mobile : adminMobile , state : state , follow_user : followUser } ) ) ; } private static getRegisterCodeInfoUrl = 'https://qyapi.weixin.qq.com/cgi-bin/service/get_register_info?provider_access_token=%s' ; param registerCode public static async getRegisterCodeInfo ( registerCode ) { let accessToken = await OpenCpAccessTokenApi . getAccessToken ( AccessTokenType . PROVIDER_TOKEN ) ; let url = util . format ( this . getRegisterCodeInfoUrl , accessToken . getAccessToken ) ; return HttpKit . getHttpDelegate . httpPost ( url , JSON . stringify ( { register_code : registerCode } ) ) ; } private static setScopeUrl = 'https://qyapi.weixin.qq.com/cgi-bin/agent/set_scope?access_token=%s' ; param accessToken param agentId param allowUser param allowParty param allowTag public static async setScope ( accessToken , agentId , allowUser ? , allowParty ? , allowTag ? ) { let url = util . format ( this . setScopeUrl , accessToken ) ; return HttpKit . getHttpDelegate . httpPost ( url , JSON . stringify ( { agentid : agentId , allow_user : allowUser , allow_party : allowParty , allow_tag : allowTag } ) ) ; } private static contactSyncSuccessUrl = 'https://qyapi.weixin.qq.com/cgi-bin/sync/contact_sync_success=%s' ; param accessToken public static async contactSyncSuccess ( accessToken ) { let url = util . format ( this . contactSyncSuccessUrl , accessToken ) ; return HttpKit . getHttpDelegate . httpGet ( url ) ; } }