akas 2.3.0

AKAS: API Key Authorization Server
from urllib import response
import requests
from robot.api.deco import keyword

__version__ = '1.0.0'


class ComplexRequests(object):
    ROBOT_LIBRARY_VERSION = __version__
    ROBOT_LIBRARY_SCOPE = 'GLOBAL'

    @keyword("Post File Json")
    def post_file_json(
        self, url, key, path, json
    ):
        """
        Sends a POST request with a file and JSON data

        ``url`` Base url of the server
        ``key`` Admin key
        ``path`` Path of the file to upload
        ``json`` JSON data. Example: `json={"format": "plain"}`

        return:
        ``response`` the output of the request
        """

        headers = {
            'Authorization': 'Bearer ' + key,
        }

        files = {
            'json': ('', json, 'application/json'),
            'file': open(path, 'rb')
        }

        response = requests.post(url, headers=headers, files=files)

        return response