const buildQueryString = (queryObject) => {
  if (!queryObject || typeof queryObject !== 'object') {
    throw new Error('Input must be a valid object');
  }

  const queryParams = [];

  for (const key in queryObject) {
    if (Object.prototype.hasOwnProperty.call(queryObject, key)) {
      const value = queryObject[key];
      if (value !== undefined && value !== null && value !== '') {
        queryParams.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
      }
    }
  }

  return queryParams.join('&');
};

export default buildQueryString;
