<commit_before>require 'jsonclient'

class Wechat::ShakeAround::DeviceGroupRelation

  extend Wechat::Core::Common
  extend Wechat::ShakeAround::Common

  # 从分组中移除设备
  # http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E4.BB.8E.E5.88.86.E7.BB.84.E4.B8.AD.E7.A7.BB.E9.99.A4.E8.AE.BE.E5.A4.87
  #
  # Return hash format if success:
  # {
  #   data:    {},
  #   errcode: 0,
  #   errmsg:  'success.'
  # }
  #
  # device_id is an integer or a hash like { uuid: <UUID>, major: <MAJOR>, minor: <MINOR> }.
  def self.destroy(access_token, device_id, group_id)

    assert_present! :access_token, access_token
    assert_present! :device_id,    device_id
    assert_present! :group_id,     group_id

    device_identifier = normalize_device_id device_id
    message = ::JSONClient.new.post "https://api.weixin.qq.com/shakearound/device/group/deletedevice?access_token=#{access_token}",
      {
        group_id:           group_id.to_i,
        device_identifiers: [ device_identifier ]
      }
    message.body
  end

  # 添加设备到分组
  # http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E6.B7.BB.E5.8A.A0.E8.AE.BE.E5.A4.87.E5.88.B0.E5.88.86.E7.BB.84
  #
  # Return hash format if success:
  # {
  #   data:    {},
  #   errcode: 0,
  #   errmsg:  'success.'
  # }
  #
  # device_id is an integer or a hash like { uuid: <UUID>, major: <MAJOR>, minor: <MINOR> }.
  # 每个分组能够持有的设备上限为10000，并且每次添加操作的添加上限为1000。
  def self.create(access_token, device_id, group_id)

    assert_present! :access_token, access_token
    assert_present! :device_id,    device_id
    assert_present! :group_id,     group_id

    device_identifier = normalize_device_id device_id<commit_msg>1, Improve the Device Group Relation wrapper class for the HTTP request.<commit_after>require 'jsonclient'

class Wechat::ShakeAround::DeviceGroupRelation

  extend Wechat::Core::Common
  extend Wechat::ShakeAround::Common

  # 从分组中移除设备
  # http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E4.BB.8E.E5.88.86.E7.BB.84.E4.B8.AD.E7.A7.BB.E9.99.A4.E8.AE.BE.E5.A4.87
  #
  # Return hash format if success:
  # {
  #   data:    {},
  #   errcode: 0,
  #   errmsg:  'success.'
  # }
  #
  # device_id is an integer or a hash like { uuid: <UUID>, major: <MAJOR>, minor: <MINOR> }.
  def self.destroy(access_token, device_id, group_id)

    assert_present! :access_token, access_token
    assert_present! :device_id,    device_id
    assert_present! :group_id,     group_id

    device_identifier = normalize_device_id device_id
    message = post_json "https://api.weixin.qq.com/shakearound/device/group/deletedevice?access_token=#{access_token}", body:
      {
        group_id:           group_id.to_i,
        device_identifiers: [ device_identifier ]
      }
    message.body
  end

  # 添加设备到分组
  # http://mp.weixin.qq.com/wiki/10/9f6b498b6aa0eb5ef6b9ab5a70cc8fba.html#.E6.B7.BB.E5.8A.A0.E8.AE.BE.E5.A4.87.E5.88.B0.E5.88.86.E7.BB.84
  #
  # Return hash format if success:
  # {
  #   data:    {},
  #   errcode: 0,
  #   errmsg:  'success.'
  # }
  #
  # device_id is an integer or a hash like { uuid: <UUID>, major: <MAJOR>, minor: <MINOR> }.
  # 每个分组能够持有的设备上限为10000，并且每次添加操作的添加上限为1000。
  def self.create(access_token, device_id, group_id)

    assert_present! :access_token, access_token
    assert_present! :device_id,    device_id
    assert_present! :group_id,     group_id

    device_identifier = normalize_device_id device_id
{'fraction_non_alphanumeric': 0.13018266164105538, 'fraction_numerical': 0.05131922296317773, 'mean_word_length': 3.259259259259259, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '247201', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1487, 'n_words': 215}