[api] small refactor of expand_packages method when creating a request