Skip to content

Commit

Permalink
feat: change ReportSegments to use union string
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyentoanit committed Apr 20, 2020
1 parent a752f6c commit 53fe361
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/operations/reports/base-report-params.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReportSegmentsEnum } from './report-segments-enum'
import { ReportSegments } from './report-segments'

export interface BaseReportParams<RecordType, ReportMetrics> {
/**
Expand All @@ -10,7 +10,7 @@ export interface BaseReportParams<RecordType, ReportMetrics> {
* _Optional_. Dimension on which to segment the report. See segmentation details in the
* following table.
*/
segment?: ReportSegmentsEnum
segment?: ReportSegments

/**
* The date for which to retrieve the performance report in YYYYMMDD format.
Expand Down
2 changes: 1 addition & 1 deletion src/operations/reports/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ export * from './metrics/index'
export * from './sponsored-brands/index'
export * from './sponsored-products/index'
export * from './report-response'
export * from './report-segments-enum'
export * from './report-segments'
export * from './report-types-enum'
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
export enum ReportSegmentsEnum {
import * as t from 'io-ts'

export const ReportSegments = t.union([
/**
* The optional dimension on which to segment a keyword report.
* This is also referred to as the search terms report.
*/
QUERY = 'query',
t.literal('query'),

/**
* The optional dimension on which to segment a campaigns report.
* Placement refers to the location on a page where your ad appears.
*/
PLACEMENT = 'placement',
}
t.literal('placement'),
])
export type ReportSegments = t.TypeOf<typeof ReportSegments>
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('index', () => {
reportEnum.SponsoredProductsProductTargetingReportMetrics,
)
expect(index.ReportResponseStatus).toEqual(reportEnum.ReportResponseStatus)
expect(index.ReportSegmentsEnum).toEqual(reportEnum.ReportSegmentsEnum)
expect(index.ReportSegments).toEqual(reportEnum.ReportSegments)
expect(index.SponsoredBrandsReportTypeEnum).toEqual(reportEnum.SponsoredBrandsReportTypeEnum)
expect(index.SponsoredProductsReportTypeEnum).toEqual(
reportEnum.SponsoredProductsReportTypeEnum,
Expand Down

0 comments on commit 53fe361

Please sign in to comment.