Sends data to the API.

        This call is similar to ``fetch``, but **sends** data to the API instead
        of retrieving it.

        Returned data will appear in the ``items`` key of the resulting
        dictionary.

        Sending data **requires** that the ``token`` is set.

        :param endpoint: (string) **(Required)** The API end point being called. Available endpoints are listed on
            the official `API Documentation <https://github.com/Charcoal-SE/metasmoke/wiki/API-Documentation>`__.

            If no end point is passed, a ``ValueError`` will be raised
        :param kwargs: Parameters accepted by individual endpoints. These parameters
            **must** be named the same as described in the endpoint documentation
        :rtype: (dictionary) A dictionary containing wrapper data regarding the API call
            and the results of the call in the `items` key. If multiple
            pages were received, all of the results will appear in the
            ``items`` tag.

def send_data(self, endpoint=None,  **kwargs):
        """Sends data to the API.

        This call is similar to ``fetch``, but **sends** data to the API instead
        of retrieving it.

        Returned data will appear in the ``items`` key of the resulting
        dictionary.

        Sending data **requires** that the ``token`` is set.

        :param endpoint: (string) **(Required)** The API end point being called. Available endpoints are listed on
            the official `API Documentation <https://github.com/Charcoal-SE/metasmoke/wiki/API-Documentation>`__.

            If no end point is passed, a ``ValueError`` will be raised
        :param kwargs: Parameters accepted by individual endpoints. These parameters
            **must** be named the same as described in the endpoint documentation
        :rtype: (dictionary) A dictionary containing wrapper data regarding the API call
            and the results of the call in the `items` key. If multiple
            pages were received, all of the results will appear in the
            ``items`` tag.
        """
        if not endpoint:
            raise ValueError('No end point provided.')

        if not self.token:
            raise ValueError('A write token has not been set. This is required for all MetaSmoke API routes. This can\n'
                             'be set by setting the "token" parameter of your SmokeAPI object.')

        self._endpoint = endpoint

        params = {
            "key": self._api_key,
            "token": self.token
        }

        if 'ids' in kwargs:
            ids = ';'.join(str(x) for x in kwargs['ids'])
            kwargs.pop('ids', None)
        else:
            ids = None

        params.update(kwargs)

        data = []

        base_url = "{}{}/".format(self._base_url, endpoint)
        response = requests.post(base_url, data=params, proxies=self.proxy)
        self._previous_call = response.url
        response = response.json()

        try:
            code = response["error_code"]
            name = response["error_name"]
            message = response["error_message"]
            raise SmokeAPIError(self._previous_call, code, name, message)
        except KeyError:
            pass  # This means there is no error

        data.append(response)
        r = []
        for d in data:
            r.extend(d['items'])
        items = list(chain(r))
        result = {'has_more': data[-1]['has_more'],
                  'page': params['page'],
                  'total': len(items),
                  'items': items}

        return result