<commit_before>from __future__ import absolute_import

from messente.api import api
from messente.api import utils
from messente.api.response import Response
from messente.api.error import ERROR_CODES


sms_error_map = ERROR_CODES.copy()
sms_error_map.update({
    "ERROR 104": " ".join([
        "Destination country for this number was not found."
    ]),
    "ERROR 105": " ".join([
        "No such country or area code or invalid phone number format."
    ]),
    "ERROR 106": " ".join(["Destination country is not supported."]),
    "ERROR 107": " ".join(["Not enough credit on account."]),
    "ERROR 108": " ".join(["Number is blacklisted."]),
    "ERROR 111": " ".join([
        "Sender parameter 'from' is invalid.",
        "You have not activated this sender name on Messente.com.",
    ]),
})

cancel_sms_error_map = ERROR_CODES.copy()
cancel_sms_error_map.update({
    "ERROR 107": "Could not find message with provided message ID."
})


class SmsResponse(Response):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def _get_error_map(self):
        return sms_error_map

    def get_sms_id(self):
        if self.is_ok():
            return self.get_raw_text().split(" ")[1]
        return None


class CancelSmsResponse(Response):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def _get_error_map(self):
        return cancel_sms_error_map


class SmsAPI(api.API):
    """
    Documentation:
    http://messente.com/documentation/sending-sms
    """

    def __init__(self, **kwargs):
        super().__init__("sms", **kwargs)

    def send(self, data, **kwargs):
        self.adapt()
        if kwargs.pop("validate", True):
            self.validate(data, fatal=True)

        r = SmsResponse(self.call_api("send_sms", **data))
        self.log_response(r)
        return r

    def cancel(self, sms_id):
        r = CancelSmsResponse(self.call_api("cancel_sms", sms_unique_id=sms_id))<commit_msg>adapt phone number in sms api<commit_after>from __future__ import absolute_import

from messente.api import api
from messente.api import utils
from messente.api.response import Response
from messente.api.error import ERROR_CODES


sms_error_map = ERROR_CODES.copy()
sms_error_map.update({
    "ERROR 104": " ".join([
        "Destination country for this number was not found."
    ]),
    "ERROR 105": " ".join([
        "No such country or area code or invalid phone number format."
    ]),
    "ERROR 106": " ".join(["Destination country is not supported."]),
    "ERROR 107": " ".join(["Not enough credit on account."]),
    "ERROR 108": " ".join(["Number is blacklisted."]),
    "ERROR 111": " ".join([
        "Sender parameter 'from' is invalid.",
        "You have not activated this sender name on Messente.com.",
    ]),
})

cancel_sms_error_map = ERROR_CODES.copy()
cancel_sms_error_map.update({
    "ERROR 107": "Could not find message with provided message ID."
})


class SmsResponse(Response):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def _get_error_map(self):
        return sms_error_map

    def get_sms_id(self):
        if self.is_ok():
            return self.get_raw_text().split(" ")[1]
        return None


class CancelSmsResponse(Response):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def _get_error_map(self):
        return cancel_sms_error_map


class SmsAPI(api.API):
    """
    Documentation:
    http://messente.com/documentation/sending-sms
    """

    def __init__(self, **kwargs):
        super().__init__("sms", **kwargs)

    def send(self, data, **kwargs):
        self.adapt(data)
        if kwargs.pop("validate", True):
            self.validate(data, fatal=True)

        r = SmsResponse(self.call_api("send_sms", **data))
        self.log_response(r)
        return r

    def cancel(self, sms_id):
        r = CancelSmsResponse(self.call_api("cancel_sms", sms_unique_id=sms_id))
{'fraction_non_alphanumeric': 0.13566084788029925, 'fraction_numerical': 0.010972568578553617, 'mean_word_length': 3.1012269938650308, 'pattern_counts': {'":': 14, '<': 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': '7277623', 'n_tokens_mistral': 1332, 'n_tokens_neox': 1268, 'n_words': 326}