Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Report return Params. #642

Open
kingkong404 opened this issue Dec 1, 2020 · 2 comments
Open

Better Report return Params. #642

kingkong404 opened this issue Dec 1, 2020 · 2 comments

Comments

@kingkong404
Copy link

kingkong404 commented Dec 1, 2020

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(),
    };
@moltar
Copy link
Contributor

moltar commented Dec 1, 2020

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.

@kingkong404
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants