amazon-advertising-api-sdk
amazon-advertising-api-sdk copied to clipboard
Better Report return Params.
Is there a way to get better type support based on requested params on a report .
BaseReportOperation.downloadReport<string>(reportId: string): Promise<Partial<Record<string, "string" | "number">>[]>
So that if the following params were used the report type would come back as an array of objects with the keys used in params.
const params: SponsoredProductsReportParams = {
recordType: "keywords",
metrics: [
"adGroupId",
"adGroupName",
"campaignId",
"campaignName",
"clicks",
"cost",
"impressions",
"keywordId",
"keywordText",
"matchType",
"attributedSales1d",
"attributedUnitsOrdered1d",
],
reportDate: amazonDate.toString(),
};
Report generation is a two step async operation. First you request a report, then you need to download it. You might also need to check it's readiness status a few times in between.
How do you propose we retain the types in between these calls?
I did have some ideas before, like returning an object that encapsulates the report request and thereby can retain the types.
Hey @moltar
I did have some ideas before, like returning an object that encapsulates the report request and thereby can retain the types.
That sounds like a good idea. Then it would just be a matter of taking the return type from the request and applying it later on to the downloaded report.