def build_pagination_metadata(pagination_obj):
    """Assemble the pagination metadata."""
    pagination_metadata = {
        'current_page': pagination_obj.page,
        'total_pages': pagination_obj.pages,
    }
    if pagination_obj.has_prev:
        pagination_metadata['previous_page'] = pagination_obj.prev_num

    if pagination_obj.has_next:
        pagination_metadata['next_page'] = pagination_obj.next_num

    return pagination_metadata