From 5ea0ba9f5565328abb6a20c5f8a603c3f879cf9a Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Wed, 15 Apr 2020 22:42:22 +0700 Subject: [PATCH] feat: add sb search term report --- src/operations/reports/metrics/index.ts | 1 + ...sored-brands-search-term-report-metrics.ts | 58 +++++++++++++++++++ src/operations/reports/report-types-enum.ts | 1 + .../reports/sponsored-brands/index.ts | 1 + .../sponsored-brands-report-operation.ts | 12 ++-- ...nsored-brands-search-term-report-params.ts | 8 +++ 6 files changed, 77 insertions(+), 4 deletions(-) create mode 100644 src/operations/reports/metrics/sponsored-brands-search-term-report-metrics.ts create mode 100644 src/operations/reports/sponsored-brands/sponsored-brands-search-term-report-params.ts diff --git a/src/operations/reports/metrics/index.ts b/src/operations/reports/metrics/index.ts index 20f19fcd2..5e035eebe 100644 --- a/src/operations/reports/metrics/index.ts +++ b/src/operations/reports/metrics/index.ts @@ -8,3 +8,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' diff --git a/src/operations/reports/metrics/sponsored-brands-search-term-report-metrics.ts b/src/operations/reports/metrics/sponsored-brands-search-term-report-metrics.ts new file mode 100644 index 000000000..e9db381a4 --- /dev/null +++ b/src/operations/reports/metrics/sponsored-brands-search-term-report-metrics.ts @@ -0,0 +1,58 @@ +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-enum.ts b/src/operations/reports/report-types-enum.ts index 3f1295f00..0b8e20356 100644 --- a/src/operations/reports/report-types-enum.ts +++ b/src/operations/reports/report-types-enum.ts @@ -18,4 +18,5 @@ export enum SponsoredBrandsReportTypeEnum { AD_GROUPS = 'adGroups', KEYWORDS = 'keywords', HEADLINE_SEARCH = 'headlineSearch', + SEARCH_TERM = 'searchTerms', } diff --git a/src/operations/reports/sponsored-brands/index.ts b/src/operations/reports/sponsored-brands/index.ts index 850e1a5d0..482aa388a 100644 --- a/src/operations/reports/sponsored-brands/index.ts +++ b/src/operations/reports/sponsored-brands/index.ts @@ -2,3 +2,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' 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 423b5ece3..ef5ad6efe 100644 --- a/src/operations/reports/sponsored-brands/sponsored-brands-report-operation.ts +++ b/src/operations/reports/sponsored-brands/sponsored-brands-report-operation.ts @@ -2,16 +2,20 @@ import { omit } from 'lodash' import { Decode } from '../../../decorators' import { BaseReportOperation } from '../base-report-operation' import { ReportResponse } from '../report-response' -import { SponsoredBrandsAdGroupReportParams } from './sponsored-brands-ad-group-report-params' -import { SponsoredBrandsCampaignReportParams } from './sponsored-brands-campaign-report-params' -import { SponsoredBrandsKeywordReportParams } from './sponsored-brands-keyword-report-params' -import { SponsoredBrandsHeadlineSearchReportParams } from './sponsored-brands-headline-search-report-params' +import { + SponsoredBrandsAdGroupReportParams, + SponsoredBrandsCampaignReportParams, + SponsoredBrandsKeywordReportParams, + SponsoredBrandsHeadlineSearchReportParams, + SponsoredBrandsSearchTermReportParams, +} from './index' type SponsoredBrandsReportParams = | SponsoredBrandsAdGroupReportParams | SponsoredBrandsCampaignReportParams | SponsoredBrandsKeywordReportParams | SponsoredBrandsHeadlineSearchReportParams + | SponsoredBrandsSearchTermReportParams export class SponsoredBrandsReportOperation< ReportParams extends SponsoredBrandsReportParams 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 new file mode 100644 index 000000000..316ba4bed --- /dev/null +++ b/src/operations/reports/sponsored-brands/sponsored-brands-search-term-report-params.ts @@ -0,0 +1,8 @@ +import { BaseReportParams } from '../base-report-params' +import { SponsoredBrandsReportTypeEnum } from '../report-types-enum' +import { SponsoredBrandsSearchTermReportMetrics } from '../metrics' + +export interface SponsoredBrandsSearchTermReportParams + extends BaseReportParams { + recordType: SponsoredBrandsReportTypeEnum.SEARCH_TERM +}