<commit_before>require 'wechat/api_base'
require 'wechat/http_client'
require 'wechat/token/corp_access_token'
require 'wechat/ticket/corp_jsapi_ticket'
require 'cgi'

module Wechat
  class CorpApi < ApiBase
    attr_reader :agentid

    API_BASE = 'https://qyapi.weixin.qq.com/cgi-bin/'.freeze

    def initialize(appid, secret, token_file, agentid, timeout, skip_verify_ssl, jsapi_ticket_file)
      @client = HttpClient.new(API_BASE, timeout, skip_verify_ssl)
      @access_token = Token::CorpAccessToken.new(@client, appid, secret, token_file)
      @agentid = agentid
      @jsapi_ticket = Ticket::CorpJsapiTicket.new(@client, @access_token, jsapi_ticket_file)
    end

    def agent_list
      get 'agent/list'
    end

    def agent(agentid)
      get 'agent/get', params: { agentid: agentid }
    end

    def user(userid)
      get 'user/get', params: { userid: userid }
    end

    def getuserinfo(code)
      get 'user/getuserinfo', params: { code: code }
    end

    def oauth2_url(redirect_uri, appid)
      ActiveSupport::Deprecation.warn('oauth2_url is deprecated. use wechat_oauth2 instead.')

      redirect_uri = CGI.escape(redirect_uri)
      "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{appid}&redirect_uri=#{redirect_uri}&response_type=code&scope=snsapi_base#wechat_redirect"
    end

    def convert_to_openid(userid)
      post 'user/convert_to_openid', JSON.generate(userid: userid, agentid: agentid)
    end

    def invite_user(userid)
      post 'invite/send', JSON.generate(userid: userid)
    end

    def user_auth_success(userid)
      get 'user/authsucc', params: { userid: userid }
    end<commit_msg>Remove Deprecation oauth2_url<commit_after>require 'wechat/api_base'
require 'wechat/http_client'
require 'wechat/token/corp_access_token'
require 'wechat/ticket/corp_jsapi_ticket'

module Wechat
  class CorpApi < ApiBase
    attr_reader :agentid

    API_BASE = 'https://qyapi.weixin.qq.com/cgi-bin/'.freeze

    def initialize(appid, secret, token_file, agentid, timeout, skip_verify_ssl, jsapi_ticket_file)
      @client = HttpClient.new(API_BASE, timeout, skip_verify_ssl)
      @access_token = Token::CorpAccessToken.new(@client, appid, secret, token_file)
      @agentid = agentid
      @jsapi_ticket = Ticket::CorpJsapiTicket.new(@client, @access_token, jsapi_ticket_file)
    end

    def agent_list
      get 'agent/list'
    end

    def agent(agentid)
      get 'agent/get', params: { agentid: agentid }
    end

    def user(userid)
      get 'user/get', params: { userid: userid }
    end

    def getuserinfo(code)
      get 'user/getuserinfo', params: { code: code }
    end

    def convert_to_openid(userid)
      post 'user/convert_to_openid', JSON.generate(userid: userid, agentid: agentid)
    end

    def invite_user(userid)
      post 'invite/send', JSON.generate(userid: userid)
    end

    def user_auth_success(userid)
      get 'user/authsucc', params: { userid: userid }
    end
{'fraction_non_alphanumeric': 0.10679283541737074, 'fraction_numerical': 0.0016897600540723217, 'mean_word_length': 3.7208931419457736, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7282904', 'n_tokens_mistral': 1064, 'n_tokens_neox': 1019, 'n_words': 204}