Skip to content

whatsapie/schema_generator/location_schema.py

generate_location_schema(body, message)

Generate schema for Location.

Parameters:

Name Type Description Default
body dict

Parent api schema object.

required
message Location

Location instance.

required

Returns:

Name Type Description
body

Schema body

Source code in whatsapie/schema_generator/location_schema.py
def generate_location_schema(body: dict, message: Location):
    """Generate schema for Location.

    Args:
        body: Parent api schema object.
        message: Location instance.

    Returns:
        body: Schema body
    """
    body["type"] = "location"
    body["location"] = {
        "longitude": message.long,
        "latitude": message.lat,
        "name": message.name,
        "address": message.address,
    }

    return body