<commit_before>from flask import current_app
from monotonic import monotonic
from requests import (request, RequestException, HTTPError)
from app.clients import (STATISTICS_DELIVERED, STATISTICS_FAILURE)
from app.clients.sms import (SmsClient, SmsClientException)

mmg_response_map = {
    '00': {
        "message": 'Delivered',
        "notification_statistics_status": STATISTICS_DELIVERED,
        "success": True,
        "notification_status": 'delivered'
    },
    'default': {
        "message": 'Declined',
        "success": False,
        "notification_statistics_status": STATISTICS_FAILURE,
        "notification_status": 'failed'
    }
}


def get_mmg_responses(status):
    return mmg_response_map.get(status, mmg_response_map.get('default'))


class MMGClientException(SmsClientException):
    def __init__(self, error_response):
        self.code = error_response['Error']
        self.description = error_response['Description']

    def __str__(self):
        return "Code {} description {}".format(self.code, self.description)


class MMGClient(SmsClient):
    '''
    MMG sms client
    '''

    def init_app(self, config, *args, **kwargs):
        super(SmsClient, self).__init__(*args, **kwargs)
        self.api_key = config.get('MMG_API_KEY')
        self.from_number = config.get('MMG_FROM_NUMBER')
        self.name = 'MMG'

    def get_name(self):
        return self.name

    def send_sms(self, to, content, reference):
        data = {
            "reqType": "BULK",
            "MSISDN": to,
            "msg": content,
            "sender": self.from_number,
            "cid": reference
        }

        start_time = monotonic()
        try:
            import json<commit_msg>Added multi parameter for sending messages.<commit_after>import json
from flask import current_app
from monotonic import monotonic
from requests import (request, RequestException, HTTPError)
from app.clients import (STATISTICS_DELIVERED, STATISTICS_FAILURE)
from app.clients.sms import (SmsClient, SmsClientException)

mmg_response_map = {
    '00': {
        "message": 'Delivered',
        "notification_statistics_status": STATISTICS_DELIVERED,
        "success": True,
        "notification_status": 'delivered'
    },
    'default': {
        "message": 'Declined',
        "success": False,
        "notification_statistics_status": STATISTICS_FAILURE,
        "notification_status": 'failed'
    }
}


def get_mmg_responses(status):
    return mmg_response_map.get(status, mmg_response_map.get('default'))


class MMGClientException(SmsClientException):
    def __init__(self, error_response):
        self.code = error_response['Error']
        self.description = error_response['Description']

    def __str__(self):
        return "Code {} description {}".format(self.code, self.description)


class MMGClient(SmsClient):
    '''
    MMG sms client
    '''

    def init_app(self, config, *args, **kwargs):
        super(SmsClient, self).__init__(*args, **kwargs)
        self.api_key = config.get('MMG_API_KEY')
        self.from_number = config.get('MMG_FROM_NUMBER')
        self.name = 'MMG'

    def get_name(self):
        return self.name

    def send_sms(self, to, content, reference, multi=True):
        data = {
            "reqType": "BULK",
            "MSISDN": to,
            "msg": content,
            "sender": self.from_number,
            "cid": reference,
            "multi": multi
        }

        start_time = monotonic()
        try:
{'fraction_non_alphanumeric': 0.11617900172117039, 'fraction_numerical': 0.0011474469305794606, 'mean_word_length': 2.917977528089888, 'pattern_counts': {'":': 27, '<': 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': '3476497', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1051, 'n_words': 223}