
from volworld_aws_api_common.api.AA import AA
from volworld_aws_api_common.api.Aws import Aws
from volworld_aws_api_common.api.url import authUrl
from volworld_aws_api_common.test.aws.ATestRequest import ATestRequest
from volworld_aws_api_common.test.request import post_request


def post__signup(
        name: str, pw: str,
        req: ATestRequest,
        ):
    resp_json, resp = post_request(
        authUrl.doSignupUrl, {
            AA.Name: name,
            AA.Password: pw,
        }, req,
        )

    data = None
    error = None

    if Aws.Message in resp_json.keys():
        error = resp_json[Aws.Message]
    elif AA.___Error___ in resp_json.keys():
        error = resp_json[AA.___Error___]
    else:
        data = resp_json[AA.Data]

    return {
        AA.Data: data,
        AA.___Error___: error,
        AA.HttpStatus: resp.status_code,
        AA.Response: resp
    }
