diff --git a/src/operations/reports/metrics/index.ts b/src/operations/reports/metrics/index.ts index 5e035eebe..5885e24c2 100644 --- a/src/operations/reports/metrics/index.ts +++ b/src/operations/reports/metrics/index.ts @@ -9,3 +9,4 @@ export * from './sponsored-brands-campaign-report-metrics' export * from './sponsored-brands-headline-search-report-metrics' export * from './sponsored-brands-keyword-report-metrics' export * from './sponsored-brands-search-term-report-metrics' +export * from './sponsored-brands-target-report-metrics' diff --git a/src/operations/reports/metrics/sponsored-brands-target-report-metrics.ts b/src/operations/reports/metrics/sponsored-brands-target-report-metrics.ts new file mode 100644 index 000000000..6239b021d --- /dev/null +++ b/src/operations/reports/metrics/sponsored-brands-target-report-metrics.ts @@ -0,0 +1,61 @@ +import * as t from 'io-ts' + +export const SponsoredBrandsTargetReportMetrics = t.union([ + /** + * Unique numerical ID of the campaign + */ + t.literal('campaignId'), + + /** + * Unique name of the campaign + */ + t.literal('campaignName'), + + /** + * Unique numerical ID of the ad group + */ + t.literal('adGroupId'), + + /** + * Unique name of the ad group + */ + t.literal('adGroupName'), + + /** + * One of: daily or lifetime + */ + t.literal('campaignBudgetType'), + + /** + * Status of the campaign + */ + t.literal('campaignStatus'), + + /** + * The product target identifier + */ + t.literal('targetId'), + + /** + * The product targeting expression. Not available for search term report. + */ + t.literal('targetingExpression'), + + /** + * The product targeting type. + * One of: asinCategorySameAs, asinBrandSameAs, asinPriceLessThan, asinPriceBetween, asinPriceGreaterThan, asinReviewRatingLessThan, asinReviewRatingBetween, asinReviewRatingGreaterThan, asinSameAs. + * Not available for search term report. + */ + t.literal('targetingType'), + + /** + * The product targeting text. Not available for search term report. + */ + t.literal('targetingText'), + + /** + * Type of matching for the keyword or phrase used in bid. Must be one of: broad, phrase, or exact + */ + t.literal('matchType'), +]) +export type SponsoredBrandsTargetReportMetrics = t.TypeOf diff --git a/src/operations/reports/report-types-enum.ts b/src/operations/reports/report-types-enum.ts index 0b8e20356..4fe1c7507 100644 --- a/src/operations/reports/report-types-enum.ts +++ b/src/operations/reports/report-types-enum.ts @@ -19,4 +19,5 @@ export enum SponsoredBrandsReportTypeEnum { KEYWORDS = 'keywords', HEADLINE_SEARCH = 'headlineSearch', SEARCH_TERM = 'searchTerms', + TARGETS = 'targets', } diff --git a/src/operations/reports/sponsored-brands/index.ts b/src/operations/reports/sponsored-brands/index.ts index 482aa388a..28a974d03 100644 --- a/src/operations/reports/sponsored-brands/index.ts +++ b/src/operations/reports/sponsored-brands/index.ts @@ -3,3 +3,4 @@ export * from './sponsored-brands-campaign-report-params' export * from './sponsored-brands-keyword-report-params' export * from './sponsored-brands-headline-search-report-params' export * from './sponsored-brands-search-term-report-params' +export * from './sponsored-brands-target-report-params' diff --git a/src/operations/reports/sponsored-brands/sponsored-brands-report-operation.ts b/src/operations/reports/sponsored-brands/sponsored-brands-report-operation.ts index ef5ad6efe..164fe32c6 100644 --- a/src/operations/reports/sponsored-brands/sponsored-brands-report-operation.ts +++ b/src/operations/reports/sponsored-brands/sponsored-brands-report-operation.ts @@ -8,6 +8,7 @@ import { SponsoredBrandsKeywordReportParams, SponsoredBrandsHeadlineSearchReportParams, SponsoredBrandsSearchTermReportParams, + SponsoredBrandsTargetReportParams, } from './index' type SponsoredBrandsReportParams = @@ -16,6 +17,8 @@ type SponsoredBrandsReportParams = | SponsoredBrandsKeywordReportParams | SponsoredBrandsHeadlineSearchReportParams | SponsoredBrandsSearchTermReportParams + | SponsoredBrandsSearchTermReportParams + | SponsoredBrandsTargetReportParams export class SponsoredBrandsReportOperation< ReportParams extends SponsoredBrandsReportParams diff --git a/src/operations/reports/sponsored-brands/sponsored-brands-target-report-params.ts b/src/operations/reports/sponsored-brands/sponsored-brands-target-report-params.ts new file mode 100644 index 000000000..6d741a1c5 --- /dev/null +++ b/src/operations/reports/sponsored-brands/sponsored-brands-target-report-params.ts @@ -0,0 +1,8 @@ +import { BaseReportParams } from '../base-report-params' +import { SponsoredBrandsReportTypeEnum } from '../report-types-enum' +import { SponsoredBrandsTargetReportMetrics } from '../metrics' + +export interface SponsoredBrandsTargetReportParams + extends BaseReportParams { + recordType: SponsoredBrandsReportTypeEnum.TARGETS +} diff --git a/test/operations/reports/sponsored-brands/sponsored-brands-report-operation.test.ts b/test/operations/reports/sponsored-brands/sponsored-brands-report-operation.test.ts index 50f4ff99a..eb59ff814 100644 --- a/test/operations/reports/sponsored-brands/sponsored-brands-report-operation.test.ts +++ b/test/operations/reports/sponsored-brands/sponsored-brands-report-operation.test.ts @@ -127,6 +127,31 @@ describe('SponsoredBrandsReportOperation', () => { expect(res.status).toBe(ReportResponseStatusEnum.IN_PROGRESS) expect(res.statusDetails).toBeDefined() }) + + it(`should return a in progress status with target report`, async () => { + const res = await reportOperation.requestReport({ + recordType: SponsoredBrandsReportTypeEnum.TARGETS, + metrics: [ + 'campaignId', + 'campaignName', + 'adGroupId', + 'adGroupName', + 'campaignBudgetType', + 'campaignStatus', + 'targetId', + 'targetingExpression', + 'targetingType', + 'targetingText', + 'matchType', + ], + reportDate: '20200314', + }) + + expect(res.reportId).toBeDefined() + expect(res.recordType).toBeDefined() + expect(res.status).toBe(ReportResponseStatusEnum.IN_PROGRESS) + expect(res.statusDetails).toBeDefined() + }) }) describe('getReport', () => {