amazon-advertising-api-sdk icon indicating copy to clipboard operation
amazon-advertising-api-sdk copied to clipboard

Better Report return Params.

Open kingkong404 opened this issue 4 years ago • 2 comments

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(),
    };

kingkong404 avatar Dec 01 '20 11:12 kingkong404

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.

moltar avatar Dec 01 '20 12:12 moltar

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.

kingkong404 avatar Dec 01 '20 13:12 kingkong404