Create a catalog of books by fetching from an API, then add a new book and re-group and order books by user-selectable fields.
Implement the transformation after a successful API response. Input is a list of book dictionaries, one new book, a grouping field, an ordering field, and a direction. Return groups sorted by the grouping value, with each group's books sorted by the ordering value. Preserve the original order when ordering values tie.
Input: api_books, new_book, group_by, order_by, descending. Output: a list of {group, books} dictionaries.
def build_catalog(api_books, new_book, group_by, order_by, descending):