From c587ba5718accbfab7a22275a0cd9866745460ad Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sun, 31 Jan 2021 22:54:22 +0700 Subject: [PATCH] fix: remove unsupported sb report types BREAKING CHANGE: remove headlineSearch and searchTerms sb report type --- .../reports/metrics/sponsored-brands/index.ts | 2 - ...d-brands-headline-search-report-metrics.ts | 171 ------------------ ...sored-brands-search-term-report-metrics.ts | 58 ------ src/operations/reports/report-types.ts | 2 - .../reports/sponsored-brands/index.ts | 2 - ...ed-brands-headline-search-report-params.ts | 8 - .../sponsored-brands-report-operation.ts | 5 - ...nsored-brands-search-term-report-params.ts | 8 - test/index.test.ts | 3 - .../sponsored-brands-report-operation.test.ts | 57 ------ 10 files changed, 316 deletions(-) delete mode 100644 src/operations/reports/metrics/sponsored-brands/sponsored-brands-headline-search-report-metrics.ts delete mode 100644 src/operations/reports/metrics/sponsored-brands/sponsored-brands-search-term-report-metrics.ts delete mode 100644 src/operations/reports/sponsored-brands/sponsored-brands-headline-search-report-params.ts delete mode 100644 src/operations/reports/sponsored-brands/sponsored-brands-search-term-report-params.ts diff --git a/src/operations/reports/metrics/sponsored-brands/index.ts b/src/operations/reports/metrics/sponsored-brands/index.ts index 78907fa53..503cf3bcd 100644 --- a/src/operations/reports/metrics/sponsored-brands/index.ts +++ b/src/operations/reports/metrics/sponsored-brands/index.ts @@ -1,6 +1,4 @@ export * from './sponsored-brands-ad-group-report-metrics' 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/sponsored-brands-headline-search-report-metrics.ts b/src/operations/reports/metrics/sponsored-brands/sponsored-brands-headline-search-report-metrics.ts deleted file mode 100644 index 0fa2f29a8..000000000 --- a/src/operations/reports/metrics/sponsored-brands/sponsored-brands-headline-search-report-metrics.ts +++ /dev/null @@ -1,171 +0,0 @@ -import * as t from 'io-ts' - -export const SponsoredBrandsHeadlineSearchReportMetrics = t.union([ - /** - * Advertiser created campaign name - */ - t.literal('campaignName'), - - /** - * Unique campaign ID - */ - t.literal('campaignId'), - - /** - * Current status of the campaign - */ - t.literal('campaignStatus'), - - /** - * The campaign budget - */ - t.literal('campaignBudget'), - - /** - * One of: daily or lifetime - */ - t.literal('campaignBudgetType'), - - /** - * Unique AdGroup name - */ - t.literal('adGroupName'), - - /** - * Unique AdGroup ID - */ - t.literal('adGroupId'), - - /** - * Keyword or phrase used in bid - */ - t.literal('keywordText'), - - /** - * User-set bid value for keyword. - */ - t.literal('keywordBid'), - - /** - * Keyword state. - */ - t.literal('keywordStatus'), - - /** - * The product target identifier - */ - t.literal('targetId'), - - /** - * The product targeting expression. Not available for search term report. - */ - t.literal('targetingExpression'), - - /** - * The product targeting text. Not available for search term report. - */ - t.literal('targetingText'), - - /** - * The product targeting type. One of: asinCategorySameAs, asinBrandSameAs, asinPriceLessThan, asinPriceBetween, asinPriceGreaterThan, asinReviewRatingLessThan, asinReviewRatingBetween, asinReviewRatingGreaterThan, asinSameAs. Not available for search term report. - */ - t.literal('targetingType'), - - /** - * One of: broad, phrase, or exact - */ - t.literal('matchType'), - - /** - * Total ad impressions. - */ - t.literal('impressions'), - - /** - * Total ad clicks. - */ - t.literal('clicks'), - - /** - * Total cost of all clicks. Can be divided by clicks to obtain average CPC. - */ - t.literal('cost'), - - /** - * The number of detail page view conversions attributed to ad click-throughs within 14 days. Not available for search term report. - */ - t.literal('attributedDetailPageViewsClicks14d'), - - /** - * Number of attributed sales occurring within 14 days of click on an ad. - */ - t.literal('attributedSales14d'), - - /** - * Aggregate value of attributed sales occurring within 14 days of click on ad where the purchased SKU was the same as the one advertised. Not available for search term report. - */ - t.literal('attributedSales14dSameSKU'), - - /** - * Number of attributed conversion events occurring within 14 days of click on ad. - */ - t.literal('attributedConversions14d'), - - /** - * Number of attributed conversion events occurring within 14 days of click on ad where the purchased SKU was the same as the one advertised. Not available for search term report. - */ - t.literal('attributedConversions14dSameSKU'), - - /** - * The number of first-time orders for products within the brand over a one-year lookback window. Not available for search term report. - */ - t.literal('attributedOrdersNewToBrand14d'), - - /** - * The percentage of total orders that are new-to-brand orders. Not available for search term report. - */ - t.literal('attributedOrdersNewToBrandPercentage14d'), - - /** - * The number of new-to-brand orders relative to the number of clicks. New-to-brand order rate = new-to-brand orders / clicks. Not available for search term report. - */ - t.literal('attributedOrderRateNewToBrand14d'), - - /** - * The total sales of new-to-brand orders. Not available for search term report. - */ - t.literal('attributedSalesNewToBrand14d'), - - /** - * The percentage of total sales of new-to-brand purchases. Not available for search term report. - */ - t.literal('attributedSalesNewToBrandPercentage14d'), - - /** - * The number of units from first-time orders for products within the brand over a one-year lookback window. Not available for search term report. - */ - t.literal('attributedUnitsOrderedNewToBrand14d'), - - /** - * The percentage of total units that are units from new-to-brand orders. Not available for search term report. - */ - t.literal('attributedUnitsOrderedNewToBrandPercentage14d'), - - /** - * Number of attributed units sold occurring within 14 days of click on an ad. Not available for search term report. - */ - t.literal('unitsSold14d'), - - /** - * Number of attributed detail page views occurring within 14 days of click on an ad. Not available for search term report. - */ - t.literal('dpv14d'), - - /** - * A user’s search term on Amazon. Only available for keyword reports with query segment defined. Note that you do not need to define this in your metric list. This will be added automatically if you have the query segment defined. - */ - t.literal('query'), -]) -export type SponsoredBrandsHeadlineSearchReportMetrics = t.TypeOf< - typeof SponsoredBrandsHeadlineSearchReportMetrics -> diff --git a/src/operations/reports/metrics/sponsored-brands/sponsored-brands-search-term-report-metrics.ts b/src/operations/reports/metrics/sponsored-brands/sponsored-brands-search-term-report-metrics.ts deleted file mode 100644 index e9db381a4..000000000 --- a/src/operations/reports/metrics/sponsored-brands/sponsored-brands-search-term-report-metrics.ts +++ /dev/null @@ -1,58 +0,0 @@ -import * as t from 'io-ts' - -export const SponsoredBrandsSearchTermReportMetrics = 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'), - - t.literal('campaignBudgetType'), - - /** - * Status of the campaign - */ - t.literal('campaignStatus'), - - /** - * ID of the keyword used in bid - */ - t.literal('keywordId'), - - /** - * Keyword state. - */ - t.literal('keywordStatus'), - - /** - * User-set bid value for keyword. - */ - t.literal('keywordBid'), - - /** - * Text of the keyword or phrase used in bid - */ - t.literal('keywordText'), - - /** - * Type of matching for the keyword or phrase used in bid. Must be one of: broad, phrase, or exact - */ - t.literal('matchType'), -]) -export type SponsoredBrandsSearchTermReportMetrics = t.TypeOf< - typeof SponsoredBrandsSearchTermReportMetrics -> diff --git a/src/operations/reports/report-types.ts b/src/operations/reports/report-types.ts index cfd9175f0..3249c7278 100644 --- a/src/operations/reports/report-types.ts +++ b/src/operations/reports/report-types.ts @@ -20,8 +20,6 @@ export const SponsoredBrandsReportType = t.union([ t.literal('campaigns'), t.literal('adGroups'), t.literal('keywords'), - t.literal('headlineSearch'), - t.literal('searchTerms'), t.literal('targets'), ]) export type SponsoredBrandsReportType = t.TypeOf diff --git a/src/operations/reports/sponsored-brands/index.ts b/src/operations/reports/sponsored-brands/index.ts index 28a974d03..85eaef69f 100644 --- a/src/operations/reports/sponsored-brands/index.ts +++ b/src/operations/reports/sponsored-brands/index.ts @@ -1,6 +1,4 @@ export * from './sponsored-brands-ad-group-report-params' 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-headline-search-report-params.ts b/src/operations/reports/sponsored-brands/sponsored-brands-headline-search-report-params.ts deleted file mode 100644 index 5979bcf0b..000000000 --- a/src/operations/reports/sponsored-brands/sponsored-brands-headline-search-report-params.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { BaseReportParams } from '../base-report-params' -import { SponsoredBrandsReportType } from '../report-types' -import { SponsoredBrandsHeadlineSearchReportMetrics } from '../metrics' - -export interface SponsoredBrandsHeadlineSearchReportParams - extends BaseReportParams { - recordType: 'headlineSearch' -} 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 5859a3026..e4659e3bd 100644 --- a/src/operations/reports/sponsored-brands/sponsored-brands-report-operation.ts +++ b/src/operations/reports/sponsored-brands/sponsored-brands-report-operation.ts @@ -6,8 +6,6 @@ import { SponsoredBrandsAdGroupReportParams, SponsoredBrandsCampaignReportParams, SponsoredBrandsKeywordReportParams, - SponsoredBrandsHeadlineSearchReportParams, - SponsoredBrandsSearchTermReportParams, SponsoredBrandsTargetReportParams, } from './index' @@ -15,9 +13,6 @@ export type SponsoredBrandsReportParams = | SponsoredBrandsAdGroupReportParams | SponsoredBrandsCampaignReportParams | SponsoredBrandsKeywordReportParams - | SponsoredBrandsHeadlineSearchReportParams - | SponsoredBrandsSearchTermReportParams - | SponsoredBrandsSearchTermReportParams | SponsoredBrandsTargetReportParams export class SponsoredBrandsReportOperation< diff --git a/src/operations/reports/sponsored-brands/sponsored-brands-search-term-report-params.ts b/src/operations/reports/sponsored-brands/sponsored-brands-search-term-report-params.ts deleted file mode 100644 index 50ebb0bf7..000000000 --- a/src/operations/reports/sponsored-brands/sponsored-brands-search-term-report-params.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { BaseReportParams } from '../base-report-params' -import { SponsoredBrandsReportType } from '../report-types' -import { SponsoredBrandsSearchTermReportMetrics } from '../metrics' - -export interface SponsoredBrandsSearchTermReportParams - extends BaseReportParams { - recordType: 'searchTerms' -} diff --git a/test/index.test.ts b/test/index.test.ts index 5e737c6a5..4ab6d1ee4 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -179,9 +179,6 @@ describe('index', () => { expect(index.SponsoredBrandsCampaignReportMetrics).toEqual( reportTypes.SponsoredBrandsCampaignReportMetrics, ) - expect(index.SponsoredBrandsHeadlineSearchReportMetrics).toEqual( - reportTypes.SponsoredBrandsHeadlineSearchReportMetrics, - ) expect(index.SponsoredBrandsKeywordReportMetrics).toEqual( reportTypes.SponsoredBrandsKeywordReportMetrics, ) 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 c04ff650c..a61ae0333 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 @@ -103,63 +103,6 @@ describe('SponsoredBrandsReportOperation', () => { expect(res.statusDetails).toBeDefined() }) - /** - * TODO: Need check on Production API again. Sandbox API returns an error: - * Could not find resource for full path: https://advertising-api-test.amazon.com/v2/hsa/headlineSearch/report - */ - it.skip(`should return a in progress status with headline search report`, async () => { - const res = await reportOperation.requestReport({ - recordType: 'headlineSearch', - metrics: [ - 'campaignName', - 'campaignId', - 'campaignStatus', - 'campaignBudget', - 'campaignBudgetType', - 'adGroupName', - 'adGroupId', - 'keywordText', - 'keywordBid', - 'keywordStatus', - ], - reportDate: '20200314', - }) - - expect(res.reportId).toBeDefined() - expect(res.recordType).toBeDefined() - expect(res.status).toBe('IN_PROGRESS') - expect(res.statusDetails).toBeDefined() - }) - - /** - * TODO: Need check on Production API again. Sandbox API returns an error: - * Could not find resource for full path: https://advertising-api-test.amazon.com/v2/hsa/searchTerms/report - */ - it.skip(`should return a in progress status with search term report`, async () => { - const res = await reportOperation.requestReport({ - recordType: 'searchTerms', - metrics: [ - 'campaignId', - 'campaignName', - 'adGroupId', - 'adGroupName', - 'campaignBudgetType', - 'campaignStatus', - 'keywordId', - 'keywordStatus', - 'keywordBid', - 'keywordText', - 'matchType', - ], - reportDate: '20200314', - }) - - expect(res.reportId).toBeDefined() - expect(res.recordType).toBeDefined() - expect(res.status).toBe('IN_PROGRESS') - expect(res.statusDetails).toBeDefined() - }) - it(`should return a in progress status with target report`, async () => { const res = await reportOperation.requestReport({ recordType: 'targets',