<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from wechatpy.client.api.base import BaseWeChatAPI
from wechatpy.utils import NotNoneDict


class WeChatDepartment(BaseWeChatAPI):

    def create(self, name, parent_id=1):
        """
        创建部门
        详情请参考 http://qydev.weixin.qq.com/wiki/index.php?title=管理部门

        :param name: 部门名称，长度限制为 1~64 个字符
        :param parent_id: 父亲部门 id ,根部门 id 为 1
        :return: 返回的 JSON 数据包
        """
        return self._post(
            'department/create',
            data={
                'name': name,
                'parentid': parent_id
            }
        )

    def update(self, id, name=None, parent_id=None, order=None):
        """
        更新部门
        详情请参考 http://qydev.weixin.qq.com/wiki/index.php?title=管理部门
<commit_msg>Update enterprise Department create API, add 'order' and 'id' parameter support<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from wechatpy.client.api.base import BaseWeChatAPI
from wechatpy.utils import NotNoneDict


class WeChatDepartment(BaseWeChatAPI):

    def create(self, name, parent_id=1, order=None, id=None):
        """
        创建部门
        详情请参考 http://qydev.weixin.qq.com/wiki/index.php?title=管理部门

        :param name: 部门名称，长度限制为 1~64 个字符
        :param parent_id: 父亲部门 id ,根部门 id 为 1
        :return: 返回的 JSON 数据包
        """
        department_data = NotNoneDict()
        department_data['name'] = name
        department_data['parentid'] = parent_id
        department_data['order'] = order
        department_data['id'] = id
        return self._post(
            'department/create',
            data=dict(department_data)
        )

    def update(self, id, name=None, parent_id=None, order=None):
        """
        更新部门
        详情请参考 http://qydev.weixin.qq.com/wiki/index.php?title=管理部门

{'fraction_non_alphanumeric': 0.11152219873150106, 'fraction_numerical': 0.006342494714587738, 'mean_word_length': 2.3864042933810374, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '6950915', 'n_tokens_mistral': 678, 'n_tokens_neox': 693, 'n_words': 136}