<commit_before>require 'jsonclient'

class Wechat::Core::AccessToken

  extend Wechat::Core::Common

  # 获取 Access Token
  # http://mp.weixin.qq.com/wiki/11/0e4b294685f817b95cbed85ba5e82b8f.html
  #
  # Return hash format if success:
  # {
  #   access_token: <ACCESS_TOKEN>,
  #   expires_in: 7200
  # }
  # The ACCESS_TOKEN is 107 characters in 2015.
  def self.load(app_id, app_secret)
    message = ::JSONClient.new.get 'https://api.weixin.qq.com/cgi-bin/token',
      {
        grant_type: 'client_credential',
        appid:      app_id,     # Rails.application.secrets.wechat_app_id,
        secret:     app_secret, # Rails.application.secrets.wechat_app_secret
      }
    message.body
  end

  # 获取 Access Token
  # http://mp.weixin.qq.com/wiki/11/0e4b294685f817b95cbed85ba5e82b8f.html
  #<commit_msg>1, Improve the Access Token wrapper class for the document.<commit_after>require 'jsonclient'

class Wechat::Core::AccessToken

  extend Wechat::Core::Common

  ##
  # 获取 Access Token
  # http://mp.weixin.qq.com/wiki/11/0e4b294685f817b95cbed85ba5e82b8f.html
  #
  # Return hash format if success:
  # {
  #   access_token: <ACCESS_TOKEN>,
  #   expires_in: 7200
  # }
  # The ACCESS_TOKEN is 107 characters in 2015.
  def self.load(app_id, app_secret)
    message = ::JSONClient.new.get 'https://api.weixin.qq.com/cgi-bin/token',
      {
        grant_type: 'client_credential',
        appid:      app_id,     # Rails.application.secrets.wechat_app_id,
        secret:     app_secret, # Rails.application.secrets.wechat_app_secret
      }
    message.body
  end

  # 获取 Access Token
  # http://mp.weixin.qq.com/wiki/11/0e4b294685f817b95cbed85ba5e82b8f.html
  #
{'fraction_non_alphanumeric': 0.11609814482345901, 'fraction_numerical': 0.06403351286654697, 'mean_word_length': 3.1182266009852215, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '1984056', 'n_tokens_mistral': 709, 'n_tokens_neox': 647, 'n_words': 101}