Ejemplo n.º 1
0
def handler(event, context):
    body = get_json_body(event)
    if not body:
        raise RequestException("Request inválido!")

    user = UserBuilder().from_json(body, encrypt_password=True).build()

    UserFacade.create_user(user)

    return buid_default_response(status=201,
                                 body=json.dumps(user, cls=SWMJSONEncoder))
Ejemplo n.º 2
0
def handler(event, context):
    body = get_json_body(event)
    if not body:
        raise RequestException("Request inválido!")

    if not isinstance(body, list):
        raise RequestException("Esperado uma lista!")

    teams = TeamFacade.define_teams_position(body)

    return buid_default_response(status=200,
                                 body=json.dumps(teams, cls=SWMJSONEncoder))
Ejemplo n.º 3
0
def get_key_value_param(event):
    body = get_json_body(event)
    if not body:
        raise RequestException("Request inválido!")

    cellphone = body.get("cellphone")
    email = body.get("email")
    if not cellphone and not email:
        raise RequestException("Informe o e-mail ou o telefone")

    field = 'email' if email else 'cellphone'
    value = email if email else cellphone
    return field, value
Ejemplo n.º 4
0
def handler(event, context):
    body = get_json_body(event)
    phase_name = body.get('phase')

    old_phase, actual_phase, message = PhaseFacade.select_phase_by_name(
        phase_name)

    return buid_default_response(status=200,
                                 body=json.dumps(
                                     {
                                         'old_phase': old_phase,
                                         'actual_phase': actual_phase,
                                         'message': message
                                     },
                                     cls=SWMJSONEncoder))
Ejemplo n.º 5
0
def handler(event, context):
    body = get_json_body(event)
    if not body:
        raise RequestException("Request inválido!")

    oid_team = body.get('oid_team')
    if not oid_team:
        raise RequestException("Time não informado")

    session = SessionFacade.get_session_from_event(event)

    team_request = TeamRequestFacade.create_new_request(
        session.real_user, oid_team)

    return buid_default_response(status=201,
                                 body=json.dumps(team_request,
                                                 cls=SWMJSONEncoder))
Ejemplo n.º 6
0
def handler(event, context):
    body = get_json_body(event)
    if not body:
        raise RequestException("Request inválido!")

    path_params = get_path_params(event)
    oid = path_params.get('oid', None)
    if not oid:
        print(json.dumps(path_params))
        raise RequestException("ID inválido")

    pitch = PitchBuilder().from_json(body).build()

    oid_user = body.get('oid_user')
    PitchFacade.edit_pitch(oid, pitch, oid_user)

    return buid_default_response(status=201,
                                 body=json.dumps(pitch, cls=SWMJSONEncoder))