{"size": 484, "ext": "js", "max_stars_repo_path": "server/lib/restAPI/get-assets.js", "max_stars_repo_name": "ryujimorimoto/app-starter", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/lib/restAPI/get-assets.js", "max_issues_repo_name": "ryujimorimoto/app-starter", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/lib/restAPI/get-assets.js", "max_forks_repo_name": "ryujimorimoto/app-starter", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 32.2666666667, "max_line_length": 77, "alphanum_fraction": 0.617768595}
import { RestClient, DataType } from "./rest-api";

export default async function getAssets({ shop, themeId, fileName = null }) {
  const client = await RestClient(shop);
  const params = fileName
    ? {
        path: `themes/${themeId}/assets`,
        query: { "asset[key]": fileName },
        dataType: DataType.JSON,
      }
    : { path: `themes/${themeId}/assets` };
  const { body } = await client.get(params);
  return fileName ? body.asset || null : body.assets || null;
}
