<commit_before>import requests, json

from resources.urls import FACEBOOK_MESSAGES_POST_URL


class HttpClient():
    """
    Client which excutes the call to
    facebook's messenger api
    """

    def submit_request(self, path, method, payload, completion):

        assert len(path) > 0
        
        path = self.get_api_url(path)
        headers = self.get_headers()

        if method == 'GET':
            response = requests.get(path, headers=headers)

            if response.status_code is not 200:
                error = self.get_error_from_request(response)
                completion(None, error)
            else:
                json_ = self.get_json(response.text)
                completion(json_, None)

        elif method == 'POST':
            re

    def get_error_from_response(self, response):

        return {
            'error': self.get_json(response.text)
        }

    def get_json(self, string):

        return json.loads(string)

    def get_api_url(self, path):
            <commit_msg>Add POST ability to http_client<commit_after>import requests, json

from resources.urls import FACEBOOK_MESSAGES_POST_URL


class HttpClient():
    """
    Client which excutes the call to
    facebook's messenger api
    """

    def submit_request(self, path, method, payload, completion):

        assert len(path) > 0
        
        path = self.get_api_url(path)
        headers = self.get_headers()

        if method == 'GET':
            response = requests.get(path, headers=headers)

            if response.status_code is not 200:
                error = self.get_error_from_response(response)
                completion(None, error)
            else:
                json_ = self.get_json(response.text)
                completion(json_, None)

        elif method == 'POST':
            response = requests.post(path, data=payload, headers=headers)

            if response.status_code is not 201:
                error = self.get_error_from_response(response)
                completion(None, error)
            else:
                json_ = self.get_json(response.text)
                completion(json_, None)

    def get_error_from_response(self, response):

        return {
            'error': self.get_json(response.text)
        }

    def get_json(self, string):

        return json.loads(string)

    def get_api_url(self, path):
            
{'fraction_non_alphanumeric': 0.08684759916492693, 'fraction_numerical': 0.004592901878914405, 'mean_word_length': 1.9543773119605425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '3908041', 'n_tokens_mistral': 694, 'n_tokens_neox': 642, 'n_words': 159}