# Path: qiniu/http.py
# USER_AGENT = 'QiniuPython/{0} ({1}; ) Python/{2}'.format(
#     __version__, _sys_info, _python_ver)
# def __return_wrapper(resp):
# def _init():
# def _post(url, data, files, auth, headers=None):
# def _put(url, data, files, auth, headers=None):
# def _get(url, params, auth, headers=None):
#     def __init__(self, token):
#     def __call__(self, r):
# def _post_with_token(url, data, token):
# def _post_with_token_and_headers(url, data, token, headers):
# def _post_file(url, data, files):
# def _post_with_auth(url, data, auth):
# def _get_with_auth(url, data, auth):
# def _post_with_auth_and_headers(url, data, auth, headers):
# def _get_with_auth_and_headers(url, data, auth, headers):
# def _post_with_qiniu_mac_and_headers(url, data, auth, headers):
# def _put_with_auth(url, data, auth):
# def _put_with_token_and_headers(url, data, auth, headers):
# def _put_with_auth_and_headers(url, data, auth, headers):
# def _put_with_qiniu_mac_and_headers(url, data, auth, headers):
# def _post_with_qiniu_mac(url, data, auth):
# def _get_with_qiniu_mac(url, params, auth):
# def _get_with_qiniu_mac_and_headers(url, params, auth, headers):
# def _delete_with_qiniu_mac(url, params, auth):
# def _delete_with_qiniu_mac_and_headers(url, params, auth, headers):
#     def __init__(self, response, exception=None):
#     def ok(self):
#     def need_retry(self):
#     def connect_failed(self):
#     def __str__(self):
#     def __repr__(self):
#     def __check_json(self, reponse):
# class _TokenAuth(AuthBase):
# class ResponseInfo(object):


from qiniu import http
import json

    def sendMessage(self, template_id, mobiles, parameters):
        """
        发送短信
        :param template_id:  模板 ID
        :param mobiles: 手机号
        :param parameters: 自定义魔法变量，变量设置在创建模板时，参数template指定
        :return:{
            "job_id": string
        }
        """
        url = '{0}/v1/message'.format(self.server)
        req = {}
        req['template_id'] = template_id
        req['mobiles'] = mobiles
        req['parameters'] = parameters
        body = json.dumps(req)
        return self.__post(url, body)

    def get_messages_info(self):
        """
        查询发送记录，文档：https://developer.qiniu.com/sms/api/5852/query-send-sms
        :return:
            {}
        """
        url = "{0}/v1/messages".format(self.server)
        return self.__get(url)

    def __post(self, url, data=None):
        headers = {'Content-Type': 'application/json'}

# Path: qiniu/http.py
# USER_AGENT = 'QiniuPython/{0} ({1}; ) Python/{2}'.format(
#     __version__, _sys_info, _python_ver)
# def __return_wrapper(resp):
# def _init():
# def _post(url, data, files, auth, headers=None):
# def _put(url, data, files, auth, headers=None):
# def _get(url, params, auth, headers=None):
#     def __init__(self, token):
#     def __call__(self, r):
# def _post_with_token(url, data, token):
# def _post_with_token_and_headers(url, data, token, headers):
# def _post_file(url, data, files):
# def _post_with_auth(url, data, auth):
# def _get_with_auth(url, data, auth):
# def _post_with_auth_and_headers(url, data, auth, headers):
# def _get_with_auth_and_headers(url, data, auth, headers):
# def _post_with_qiniu_mac_and_headers(url, data, auth, headers):
# def _put_with_auth(url, data, auth):
# def _put_with_token_and_headers(url, data, auth, headers):
# def _put_with_auth_and_headers(url, data, auth, headers):
# def _put_with_qiniu_mac_and_headers(url, data, auth, headers):
# def _post_with_qiniu_mac(url, data, auth):
# def _get_with_qiniu_mac(url, params, auth):
# def _get_with_qiniu_mac_and_headers(url, params, auth, headers):
# def _delete_with_qiniu_mac(url, params, auth):
# def _delete_with_qiniu_mac_and_headers(url, params, auth, headers):
#     def __init__(self, response, exception=None):
#     def ok(self):
#     def need_retry(self):
#     def connect_failed(self):
#     def __str__(self):
#     def __repr__(self):
#     def __check_json(self, reponse):
# class _TokenAuth(AuthBase):
# class ResponseInfo(object):


# Path: qiniu/services/sms/sms.py
from qiniu import http
import json


    def sendMessage(self, template_id, mobiles, parameters):
        """
        发送短信
        :param template_id:  模板 ID
        :param mobiles: 手机号
        :param parameters: 自定义魔法变量，变量设置在创建模板时，参数template指定
        :return:{
            "job_id": string
        }
        """
        url = '{0}/v1/message'.format(self.server)
        req = {}
        req['template_id'] = template_id
        req['mobiles'] = mobiles
        req['parameters'] = parameters
        body = json.dumps(req)
        return self.__post(url, body)

    def get_messages_info(self):
        """
        查询发送记录，文档：https://developer.qiniu.com/sms/api/5852/query-send-sms
        :return:
            {}
        """
        url = "{0}/v1/messages".format(self.server)
        return self.__get(url)

    def __post(self, url, data=None):
        headers = {'Content-Type': 'application/json'}

        return http._post_with_qiniu_mac_and_headers(url, data, self.auth, headers)