From e51ba8574115f4ba0e08430ca2d85663c4b19327 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sat, 22 Aug 2020 10:58:17 +0700 Subject: [PATCH 01/22] feat: implement create sd targeting method --- src/amazon-advertising.ts | 6 ++ src/index.ts | 1 + .../sponsored-display-targeting-operation.ts | 20 +++++ src/operations/product-targeting/types.ts | 82 +++++++++++++++++++ ...nsored-display-targeting-operation.test.ts | 34 ++++++++ 5 files changed, 143 insertions(+) create mode 100644 src/operations/product-targeting/sponsored-display-targeting-operation.ts create mode 100644 test/operations/product-targeting/sponsored-display-targeting-operation.test.ts diff --git a/src/amazon-advertising.ts b/src/amazon-advertising.ts index 7f9428801..1f5fedc7e 100644 --- a/src/amazon-advertising.ts +++ b/src/amazon-advertising.ts @@ -20,6 +20,7 @@ import { SponsoredProductsSuggestedKeywordsOperation } from './operations/keywor import { PortfolioOperation } from './operations/portfolios/portfolio-operation' import { SponsoredProductsProductAdsOperation } from './operations/product-ads/sponsored-products-product-ads-operation' import { SponsoredBrandsProductTargetingOperation } from './operations/product-targeting/sponsored-brands-product-targeting-operation' +import { SponsoredDisplayTargetingOperation } from './operations/product-targeting/sponsored-display-targeting-operation' import { SponsoredProductsProductTargetingOperation } from './operations/product-targeting/sponsored-products-product-targeting-operation' import { ProfileOperation } from './operations/profiles/profile-operation' import { SponsoredBrandsBidRecommendationsOperation } from './operations/recommendations/sponsored-brands-bid-recommendations-operation' @@ -130,6 +131,11 @@ export class AmazonAdvertising { return this.operationProvider.create(SponsoredBrandsProductTargetingOperation) } + @LazyGetter() + get sponsoredDisplayTargeting() { + return this.operationProvider.create(SponsoredDisplayTargetingOperation) + } + @LazyGetter() get sponsoredProductsProductTargeting() { return this.operationProvider.create(SponsoredProductsProductTargetingOperation) diff --git a/src/index.ts b/src/index.ts index 1271c3eb8..5a2a47f44 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,6 +19,7 @@ export * from './operations/keywords/sponsored-products-suggested-keywords-opera export * from './operations/portfolios/portfolio-operation' export * from './operations/product-ads/sponsored-products-product-ads-operation' export * from './operations/product-targeting/sponsored-brands-product-targeting-operation' +export * from './operations/product-targeting/sponsored-display-targeting-operation' export * from './operations/product-targeting/sponsored-products-product-targeting-operation' export * from './operations/profiles/profile-operation' export * from './operations/recommendations/sponsored-brands-bid-recommendations-operation' diff --git a/src/operations/product-targeting/sponsored-display-targeting-operation.ts b/src/operations/product-targeting/sponsored-display-targeting-operation.ts new file mode 100644 index 000000000..f9744fdbe --- /dev/null +++ b/src/operations/product-targeting/sponsored-display-targeting-operation.ts @@ -0,0 +1,20 @@ +import { Operation } from '../operation' +import { DecodeArray } from '../../decorators' +import { AmazonAdTypeURIPrefix } from '../amazon-ad-type-uri-prefix' + +import { TargetingClauseResponse, CreateSponsoredDisplayTargetingClausesParams } from './types' + +export class SponsoredDisplayTargetingOperation extends Operation { + protected resource = `${this.version}/${AmazonAdTypeURIPrefix.SponsoredDisplay}/targets` + + /** + * Creates one or more targeting clauses. + * + * @param params - + * @returns + */ + @DecodeArray(TargetingClauseResponse) + public createTargetingClauses(params: CreateSponsoredDisplayTargetingClausesParams[]) { + return this.client.post(this.resource, params) + } +} diff --git a/src/operations/product-targeting/types.ts b/src/operations/product-targeting/types.ts index 3df1f0250..be56a3020 100644 --- a/src/operations/product-targeting/types.ts +++ b/src/operations/product-targeting/types.ts @@ -1081,3 +1081,85 @@ export const SponsoredBrandsBatchGetNegativeTargetsResponse = t.strict({ export type SponsoredBrandsBatchGetNegativeTargetsResponse = t.TypeOf< typeof SponsoredBrandsBatchGetNegativeTargetsResponse > + +// Sponsored Display Types + +export const SponsoredDisplayTargetingPredicateType = t.union([ + t.literal('asinSameAs'), + t.literal('asinCategorySameAs'), + t.literal('asinBrandSameAs'), + t.literal('asinPriceBetween'), + t.literal('asinPriceGreaterThan'), + t.literal('asinPriceLessThan'), + t.literal('asinReviewRatingLessThan'), + t.literal('asinReviewRatingGreaterThan'), + t.literal('asinReviewRatingBetween'), + t.literal('similarProduct'), + t.literal('exactProduct'), + t.literal('asinIsPrimeShippingEligible'), + t.literal('asinAgeRangeSameAs'), + t.literal('asinGenreSameAs'), + t.literal('lookback'), + t.literal('negative'), +]) +export type SponsoredDisplayTargetingPredicateType = t.TypeOf< + typeof SponsoredDisplayTargetingPredicateType +> + +export const SponsoredDisplayTargetingPredicate = t.strict({ + type: SponsoredDisplayTargetingPredicateType, + + /** + * The value to be targeted. + */ + value: t.string, +}) +export type SponsoredDisplayTargetingPredicate = t.TypeOf + +export const SponsoredDisplayTargetingPredicateNested = t.strict({ + type: t.literal('views'), + + value: t.array(SponsoredDisplayTargetingPredicate), +}) +export type SponsoredDisplayTargetingPredicateNested = t.TypeOf< + typeof SponsoredDisplayTargetingPredicateNested +> + +export const SponsoredDisplayTargetingExpression = t.union([ + SponsoredDisplayTargetingPredicate, + SponsoredDisplayTargetingPredicateNested, +]) +export type SponsoredDisplayTargetingExpression = t.TypeOf< + typeof SponsoredDisplayTargetingExpression +> + +export const CreateSponsoredDisplayTargetingClausesParams = t.strict({ + /** + * The ID of the ad group to which this target belongs. + */ + adGroupId: AdGroupId, + + /** + * Advertiser-specified state of the target + */ + state: TargetingClauseState, + + /** + * The type of expression. + * Tactic T00020 ad groups only allow manual targeting. + */ + expressionType: ExpressionType, + + /** + * The bid will override the adGroup bid if specified. Bid is not allowed in negative targeting clauses. + */ + bid: t.number, + + /** + * The targeting expression to match against. + */ + expression: t.array(SponsoredDisplayTargetingExpression), +}) +export type CreateSponsoredDisplayTargetingClausesParams = t.TypeOf< + typeof CreateSponsoredDisplayTargetingClausesParams +> diff --git a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts new file mode 100644 index 000000000..746538712 --- /dev/null +++ b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts @@ -0,0 +1,34 @@ +import { SANDBOX_URI, auth } from '../../http-client-factory' +import { OperationProvider, HttpClient } from '../../../src' +import { SponsoredDisplayTargetingOperation } from '../../../src/operations/product-targeting/sponsored-display-targeting-operation' +import { CreateSponsoredDisplayTargetingClausesParams } from '../../../src/operations/product-targeting/types' + +describe('SponsoredDisplayTargetingOperation', () => { + const client = new HttpClient(SANDBOX_URI, { ...auth, scope: 2973802954634317 }, true) + const operationProvider = new OperationProvider(client) + const operation = operationProvider.create(SponsoredDisplayTargetingOperation) + const AD_GROUP_ID = 164444192239500 + const ASINS = ['B07663Z46Z', 'B07H8QMZWV', 'B07C65XFBB'] + + describe('createTargetingClauses', () => { + it(`should create one or more targeting expressions`, async () => { + const params: CreateSponsoredDisplayTargetingClausesParams[] = [ + { + adGroupId: AD_GROUP_ID, + state: 'paused', + expressionType: 'manual', + expression: [ + { + type: 'asinSameAs', + value: ASINS[0], + }, + ], + bid: 10, + }, + ] + const [res] = await operation.createTargetingClauses(params) + + expect(res.code).toBe('SUCCESS') + }) + }) +}) From 66792b32e81111c35afbaac3925df51091dc5474 Mon Sep 17 00:00:00 2001 From: Scale Bot Date: Sat, 22 Aug 2020 03:59:33 +0000 Subject: [PATCH 02/22] test: adds Polly recordings [skip ci] --- .../recording.har | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har new file mode 100644 index 000000000..b4f52da8a --- /dev/null +++ b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har @@ -0,0 +1,147 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "60844d68ce6439736438cde6281cc7eb", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 141, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "141" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 955, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "adGroupId": 164444192239500, + "bid": 10, + "expression": [ + { + "type": "asinSameAs", + "value": "B07663Z46Z" + } + ], + "expressionType": "manual", + "state": "paused" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/targets" + }, + "response": { + "bodySize": 80, + "content": { + "mimeType": "application/json", + "size": 80, + "text": { + "code": "403", + "details": "HTTP 403 Forbidden", + "requestId": "H41RRHZ7TXFT18VRWP4F" + } + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sat, 22 Aug 2020 03:59:32 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 403, + "statusText": "Forbidden" + }, + "startedDateTime": "2020-08-22T03:59:31.915Z", + "time": 159, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 159 + } + } + ], + "pages": [], + "version": "1.2" + } +} From 164a6dc60fa9bb3bb9846b63d9f7273ba76c8ab0 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sat, 22 Aug 2020 17:07:11 +0700 Subject: [PATCH 03/22] test: create T00020 sd campaign tactic --- .../sponsored-display-campaign-operation.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/operations/campaigns/sponsored-display-campaign-operation.test.ts b/test/operations/campaigns/sponsored-display-campaign-operation.test.ts index 4c9f14fe4..cbc7e57ab 100644 --- a/test/operations/campaigns/sponsored-display-campaign-operation.test.ts +++ b/test/operations/campaigns/sponsored-display-campaign-operation.test.ts @@ -97,6 +97,22 @@ describe('SponsoredDisplayCampaignOperation', () => { expect(res.code).toBe('SUCCESS') }) + + it(`should create a campaign with T00020 tactic`, async () => { + const [res] = await operation.createCampaigns([ + { + name: 'test sd campaign 2020/08/22 17:00', + tactic: 'T00020', + state: 'enabled', + budget: 1, + startDate, + budgetType: 'daily', + endDate: '20201211', + }, + ]) + + expect(res.code).toBe('SUCCESS') + }) }) describe('getCampaign', () => { From 4eb71c5f525c201ce65880aef62789345455c8b3 Mon Sep 17 00:00:00 2001 From: Scale Bot Date: Sat, 22 Aug 2020 10:09:03 +0000 Subject: [PATCH 04/22] test: adds Polly recordings [skip ci] --- .../recording.har | 145 ++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00020-tactic_3877743697/recording.har diff --git a/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00020-tactic_3877743697/recording.har b/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00020-tactic_3877743697/recording.har new file mode 100644 index 000000000..d8daf895c --- /dev/null +++ b/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00020-tactic_3877743697/recording.har @@ -0,0 +1,145 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayCampaignOperation/createCampaigns/should create a campaign with T00020 tactic", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "ee28850e027bf306b3b31be95bacbdae", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 158, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "158" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 957, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "budget": 1, + "budgetType": "daily", + "endDate": "20201211", + "name": "test sd campaign 2020/08/22 17:00", + "startDate": "20201210", + "state": "enabled", + "tactic": "T00020" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/campaigns" + }, + "response": { + "bodySize": 81, + "content": { + "mimeType": "application/json", + "size": 81, + "text": [ + { + "code": "INVALID_ARGUMENT", + "description": "Tactic must be one of [remarketing]" + } + ] + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sat, 22 Aug 2020 10:08:49 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 207, + "statusText": "Multi-Status" + }, + "startedDateTime": "2020-08-22T10:08:48.955Z", + "time": 127, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 127 + } + } + ], + "pages": [], + "version": "1.2" + } +} From 7e97ad5add3cb676144a0159df44fc1dc313215c Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sat, 22 Aug 2020 17:16:14 +0700 Subject: [PATCH 05/22] test: try to create sd campaign T00001 and T00030 tactic --- .../recording.har | 145 ------------------ ...onsored-display-campaign-operation.test.ts | 22 ++- 2 files changed, 19 insertions(+), 148 deletions(-) delete mode 100644 test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00020-tactic_3877743697/recording.har diff --git a/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00020-tactic_3877743697/recording.har b/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00020-tactic_3877743697/recording.har deleted file mode 100644 index d8daf895c..000000000 --- a/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00020-tactic_3877743697/recording.har +++ /dev/null @@ -1,145 +0,0 @@ -{ - "log": { - "_recordingName": "SponsoredDisplayCampaignOperation/createCampaigns/should create a campaign with T00020 tactic", - "creator": { - "comment": "persister:fs", - "name": "Polly.JS", - "version": "5.0.0" - }, - "entries": [ - { - "_id": "ee28850e027bf306b3b31be95bacbdae", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 158, - "cookies": [], - "headers": [ - { - "_fromType": "array", - "name": "content-type", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "accept", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "user-agent", - "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" - }, - { - "_fromType": "array", - "name": "amazon-advertising-api-scope", - "value": "2973802954634317" - }, - { - "_fromType": "array", - "name": "bidding_controls_on", - "value": "true" - }, - { - "_fromType": "array", - "name": "accept-encoding", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "content-length", - "value": "158" - }, - { - "_fromType": "array", - "name": "connection", - "value": "close" - }, - { - "name": "host", - "value": "advertising-api-test.amazon.com" - } - ], - "headersSize": 957, - "httpVersion": "HTTP/1.1", - "method": "POST", - "postData": { - "mimeType": "application/json", - "params": [], - "text": [ - { - "budget": 1, - "budgetType": "daily", - "endDate": "20201211", - "name": "test sd campaign 2020/08/22 17:00", - "startDate": "20201210", - "state": "enabled", - "tactic": "T00020" - } - ] - }, - "queryString": [], - "url": "https://advertising-api-test.amazon.com/v2/sd/campaigns" - }, - "response": { - "bodySize": 81, - "content": { - "mimeType": "application/json", - "size": 81, - "text": [ - { - "code": "INVALID_ARGUMENT", - "description": "Tactic must be one of [remarketing]" - } - ] - }, - "cookies": [], - "headers": [ - { - "name": "server", - "value": "Server" - }, - { - "name": "date", - "value": "Sat, 22 Aug 2020 10:08:49 GMT" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "transfer-encoding", - "value": "chunked" - }, - { - "name": "connection", - "value": "close" - }, - { - "name": "vary", - "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" - } - ], - "headersSize": 251, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 207, - "statusText": "Multi-Status" - }, - "startedDateTime": "2020-08-22T10:08:48.955Z", - "time": 127, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 127 - } - } - ], - "pages": [], - "version": "1.2" - } -} diff --git a/test/operations/campaigns/sponsored-display-campaign-operation.test.ts b/test/operations/campaigns/sponsored-display-campaign-operation.test.ts index cbc7e57ab..d995c6def 100644 --- a/test/operations/campaigns/sponsored-display-campaign-operation.test.ts +++ b/test/operations/campaigns/sponsored-display-campaign-operation.test.ts @@ -98,11 +98,27 @@ describe('SponsoredDisplayCampaignOperation', () => { expect(res.code).toBe('SUCCESS') }) - it(`should create a campaign with T00020 tactic`, async () => { + it(`should create a campaign with T00001 tactic`, async () => { const [res] = await operation.createCampaigns([ { - name: 'test sd campaign 2020/08/22 17:00', - tactic: 'T00020', + name: 'test sd campaign T00001 2020/08/22 17:01', + tactic: 'T00001', + state: 'enabled', + budget: 1, + startDate, + budgetType: 'daily', + endDate: '20201211', + }, + ]) + + expect(res.code).toBe('SUCCESS') + }) + + it(`should create a campaign with T00030 tactic`, async () => { + const [res] = await operation.createCampaigns([ + { + name: 'test sd campaign T00030 2020/08/22 17:03', + tactic: 'T00030', state: 'enabled', budget: 1, startDate, From 164dfb936454ee76e90fb76f6b6fe401b4962cce Mon Sep 17 00:00:00 2001 From: Scale Bot Date: Sat, 22 Aug 2020 10:17:41 +0000 Subject: [PATCH 06/22] test: adds Polly recordings [skip ci] --- .../recording.har | 145 ++++++++++++++++++ .../recording.har | 145 ++++++++++++++++++ 2 files changed, 290 insertions(+) create mode 100644 test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00001-tactic_1571303190/recording.har create mode 100644 test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00030-tactic_3950395706/recording.har diff --git a/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00001-tactic_1571303190/recording.har b/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00001-tactic_1571303190/recording.har new file mode 100644 index 000000000..afd6ec1b2 --- /dev/null +++ b/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00001-tactic_1571303190/recording.har @@ -0,0 +1,145 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayCampaignOperation/createCampaigns/should create a campaign with T00001 tactic", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "ee28850e027bf306b3b31be95bacbdae", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 165, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "165" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 957, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "budget": 1, + "budgetType": "daily", + "endDate": "20201211", + "name": "test sd campaign T00001 2020/08/22 17:01", + "startDate": "20201210", + "state": "enabled", + "tactic": "T00001" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/campaigns" + }, + "response": { + "bodySize": 81, + "content": { + "mimeType": "application/json", + "size": 81, + "text": [ + { + "code": "INVALID_ARGUMENT", + "description": "Tactic must be one of [remarketing]" + } + ] + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sat, 22 Aug 2020 10:17:28 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 207, + "statusText": "Multi-Status" + }, + "startedDateTime": "2020-08-22T10:17:28.688Z", + "time": 133, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 133 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00030-tactic_3950395706/recording.har b/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00030-tactic_3950395706/recording.har new file mode 100644 index 000000000..0c7495756 --- /dev/null +++ b/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00030-tactic_3950395706/recording.har @@ -0,0 +1,145 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayCampaignOperation/createCampaigns/should create a campaign with T00030 tactic", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "ee28850e027bf306b3b31be95bacbdae", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 165, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "165" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 957, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "budget": 1, + "budgetType": "daily", + "endDate": "20201211", + "name": "test sd campaign T00030 2020/08/22 17:03", + "startDate": "20201210", + "state": "enabled", + "tactic": "T00030" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/campaigns" + }, + "response": { + "bodySize": 81, + "content": { + "mimeType": "application/json", + "size": 81, + "text": [ + { + "code": "INVALID_ARGUMENT", + "description": "Tactic must be one of [remarketing]" + } + ] + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sat, 22 Aug 2020 10:17:28 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 207, + "statusText": "Multi-Status" + }, + "startedDateTime": "2020-08-22T10:17:28.829Z", + "time": 115, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 115 + } + } + ], + "pages": [], + "version": "1.2" + } +} From 8a5b26fd663fbd9917f5723aa92a8b61e6b64d31 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sat, 22 Aug 2020 17:23:58 +0700 Subject: [PATCH 07/22] test: remove create unavailable sd campaign tactic --- .../recording.har | 145 ------------------ .../recording.har | 145 ------------------ ...onsored-display-campaign-operation.test.ts | 32 ---- 3 files changed, 322 deletions(-) delete mode 100644 test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00001-tactic_1571303190/recording.har delete mode 100644 test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00030-tactic_3950395706/recording.har diff --git a/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00001-tactic_1571303190/recording.har b/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00001-tactic_1571303190/recording.har deleted file mode 100644 index afd6ec1b2..000000000 --- a/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00001-tactic_1571303190/recording.har +++ /dev/null @@ -1,145 +0,0 @@ -{ - "log": { - "_recordingName": "SponsoredDisplayCampaignOperation/createCampaigns/should create a campaign with T00001 tactic", - "creator": { - "comment": "persister:fs", - "name": "Polly.JS", - "version": "5.0.0" - }, - "entries": [ - { - "_id": "ee28850e027bf306b3b31be95bacbdae", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 165, - "cookies": [], - "headers": [ - { - "_fromType": "array", - "name": "content-type", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "accept", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "user-agent", - "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" - }, - { - "_fromType": "array", - "name": "amazon-advertising-api-scope", - "value": "2973802954634317" - }, - { - "_fromType": "array", - "name": "bidding_controls_on", - "value": "true" - }, - { - "_fromType": "array", - "name": "accept-encoding", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "content-length", - "value": "165" - }, - { - "_fromType": "array", - "name": "connection", - "value": "close" - }, - { - "name": "host", - "value": "advertising-api-test.amazon.com" - } - ], - "headersSize": 957, - "httpVersion": "HTTP/1.1", - "method": "POST", - "postData": { - "mimeType": "application/json", - "params": [], - "text": [ - { - "budget": 1, - "budgetType": "daily", - "endDate": "20201211", - "name": "test sd campaign T00001 2020/08/22 17:01", - "startDate": "20201210", - "state": "enabled", - "tactic": "T00001" - } - ] - }, - "queryString": [], - "url": "https://advertising-api-test.amazon.com/v2/sd/campaigns" - }, - "response": { - "bodySize": 81, - "content": { - "mimeType": "application/json", - "size": 81, - "text": [ - { - "code": "INVALID_ARGUMENT", - "description": "Tactic must be one of [remarketing]" - } - ] - }, - "cookies": [], - "headers": [ - { - "name": "server", - "value": "Server" - }, - { - "name": "date", - "value": "Sat, 22 Aug 2020 10:17:28 GMT" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "transfer-encoding", - "value": "chunked" - }, - { - "name": "connection", - "value": "close" - }, - { - "name": "vary", - "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" - } - ], - "headersSize": 251, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 207, - "statusText": "Multi-Status" - }, - "startedDateTime": "2020-08-22T10:17:28.688Z", - "time": 133, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 133 - } - } - ], - "pages": [], - "version": "1.2" - } -} diff --git a/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00030-tactic_3950395706/recording.har b/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00030-tactic_3950395706/recording.har deleted file mode 100644 index 0c7495756..000000000 --- a/test/__recordings__/SponsoredDisplayCampaignOperation_2282500349/createCampaigns_3568576568/should-create-a-campaign-with-T00030-tactic_3950395706/recording.har +++ /dev/null @@ -1,145 +0,0 @@ -{ - "log": { - "_recordingName": "SponsoredDisplayCampaignOperation/createCampaigns/should create a campaign with T00030 tactic", - "creator": { - "comment": "persister:fs", - "name": "Polly.JS", - "version": "5.0.0" - }, - "entries": [ - { - "_id": "ee28850e027bf306b3b31be95bacbdae", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 165, - "cookies": [], - "headers": [ - { - "_fromType": "array", - "name": "content-type", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "accept", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "user-agent", - "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" - }, - { - "_fromType": "array", - "name": "amazon-advertising-api-scope", - "value": "2973802954634317" - }, - { - "_fromType": "array", - "name": "bidding_controls_on", - "value": "true" - }, - { - "_fromType": "array", - "name": "accept-encoding", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "content-length", - "value": "165" - }, - { - "_fromType": "array", - "name": "connection", - "value": "close" - }, - { - "name": "host", - "value": "advertising-api-test.amazon.com" - } - ], - "headersSize": 957, - "httpVersion": "HTTP/1.1", - "method": "POST", - "postData": { - "mimeType": "application/json", - "params": [], - "text": [ - { - "budget": 1, - "budgetType": "daily", - "endDate": "20201211", - "name": "test sd campaign T00030 2020/08/22 17:03", - "startDate": "20201210", - "state": "enabled", - "tactic": "T00030" - } - ] - }, - "queryString": [], - "url": "https://advertising-api-test.amazon.com/v2/sd/campaigns" - }, - "response": { - "bodySize": 81, - "content": { - "mimeType": "application/json", - "size": 81, - "text": [ - { - "code": "INVALID_ARGUMENT", - "description": "Tactic must be one of [remarketing]" - } - ] - }, - "cookies": [], - "headers": [ - { - "name": "server", - "value": "Server" - }, - { - "name": "date", - "value": "Sat, 22 Aug 2020 10:17:28 GMT" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "transfer-encoding", - "value": "chunked" - }, - { - "name": "connection", - "value": "close" - }, - { - "name": "vary", - "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" - } - ], - "headersSize": 251, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 207, - "statusText": "Multi-Status" - }, - "startedDateTime": "2020-08-22T10:17:28.829Z", - "time": 115, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 115 - } - } - ], - "pages": [], - "version": "1.2" - } -} diff --git a/test/operations/campaigns/sponsored-display-campaign-operation.test.ts b/test/operations/campaigns/sponsored-display-campaign-operation.test.ts index d995c6def..4c9f14fe4 100644 --- a/test/operations/campaigns/sponsored-display-campaign-operation.test.ts +++ b/test/operations/campaigns/sponsored-display-campaign-operation.test.ts @@ -97,38 +97,6 @@ describe('SponsoredDisplayCampaignOperation', () => { expect(res.code).toBe('SUCCESS') }) - - it(`should create a campaign with T00001 tactic`, async () => { - const [res] = await operation.createCampaigns([ - { - name: 'test sd campaign T00001 2020/08/22 17:01', - tactic: 'T00001', - state: 'enabled', - budget: 1, - startDate, - budgetType: 'daily', - endDate: '20201211', - }, - ]) - - expect(res.code).toBe('SUCCESS') - }) - - it(`should create a campaign with T00030 tactic`, async () => { - const [res] = await operation.createCampaigns([ - { - name: 'test sd campaign T00030 2020/08/22 17:03', - tactic: 'T00030', - state: 'enabled', - budget: 1, - startDate, - budgetType: 'daily', - endDate: '20201211', - }, - ]) - - expect(res.code).toBe('SUCCESS') - }) }) describe('getCampaign', () => { From 92caed2c035b6f2bdfe5cce09c46b1fb6fca61ca Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sat, 22 Aug 2020 17:33:11 +0700 Subject: [PATCH 08/22] test: re-create sd ad group --- .../recording.har | 146 ----------------- .../recording.har | 147 ------------------ ...nsored-display-targeting-operation.test.ts | 2 +- 3 files changed, 1 insertion(+), 294 deletions(-) delete mode 100644 test/__recordings__/SponsoredDisplayAdGroupOperation_3544596599/createAdGroups_767840800/should-create-an-ad-group_2863360381/recording.har delete mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har diff --git a/test/__recordings__/SponsoredDisplayAdGroupOperation_3544596599/createAdGroups_767840800/should-create-an-ad-group_2863360381/recording.har b/test/__recordings__/SponsoredDisplayAdGroupOperation_3544596599/createAdGroups_767840800/should-create-an-ad-group_2863360381/recording.har deleted file mode 100644 index a7fdea335..000000000 --- a/test/__recordings__/SponsoredDisplayAdGroupOperation_3544596599/createAdGroups_767840800/should-create-an-ad-group_2863360381/recording.har +++ /dev/null @@ -1,146 +0,0 @@ -{ - "log": { - "_recordingName": "SponsoredDisplayAdGroupOperation/createAdGroups/should create an ad group", - "creator": { - "comment": "persister:fs", - "name": "Polly.JS", - "version": "5.0.0" - }, - "entries": [ - { - "_id": "613d5cf6d341466d8867dd9006a2a244", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 107, - "cookies": [], - "headers": [ - { - "_fromType": "array", - "name": "content-type", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "accept", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "user-agent", - "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" - }, - { - "_fromType": "array", - "name": "amazon-advertising-api-scope", - "value": "2973802954634317" - }, - { - "_fromType": "array", - "name": "bidding_controls_on", - "value": "true" - }, - { - "_fromType": "array", - "name": "accept-encoding", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "content-length", - "value": "107" - }, - { - "_fromType": "array", - "name": "connection", - "value": "close" - }, - { - "name": "host", - "value": "advertising-api-test.amazon.com" - } - ], - "headersSize": 956, - "httpVersion": "HTTP/1.1", - "method": "POST", - "postData": { - "mimeType": "application/json", - "params": [], - "text": [ - { - "campaignId": 169989740510339, - "defaultBid": 1, - "name": "test sd ad group 2020/08/16 22:22", - "state": "paused" - } - ] - }, - "queryString": [], - "url": "https://advertising-api-test.amazon.com/v2/sp/adGroups" - }, - "response": { - "bodySize": 47, - "content": { - "mimeType": "application/json", - "size": 47, - "text": [ - { - "adGroupId": 83691965128172, - "code": "SUCCESS" - } - ] - }, - "cookies": [], - "headers": [ - { - "name": "server", - "value": "Server" - }, - { - "name": "date", - "value": "Sun, 16 Aug 2020 15:31:22 GMT" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "transfer-encoding", - "value": "chunked" - }, - { - "name": "connection", - "value": "close" - }, - { - "name": "x-amz-request-id", - "value": "GGAFQ77G4ZTQPE1SZKX7" - }, - { - "name": "vary", - "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" - } - ], - "headersSize": 291, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 207, - "statusText": "Multi-Status" - }, - "startedDateTime": "2020-08-16T15:31:22.703Z", - "time": 203, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 203 - } - } - ], - "pages": [], - "version": "1.2" - } -} diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har deleted file mode 100644 index b4f52da8a..000000000 --- a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har +++ /dev/null @@ -1,147 +0,0 @@ -{ - "log": { - "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions", - "creator": { - "comment": "persister:fs", - "name": "Polly.JS", - "version": "5.0.0" - }, - "entries": [ - { - "_id": "60844d68ce6439736438cde6281cc7eb", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 141, - "cookies": [], - "headers": [ - { - "_fromType": "array", - "name": "content-type", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "accept", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "user-agent", - "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" - }, - { - "_fromType": "array", - "name": "amazon-advertising-api-scope", - "value": "2973802954634317" - }, - { - "_fromType": "array", - "name": "bidding_controls_on", - "value": "true" - }, - { - "_fromType": "array", - "name": "accept-encoding", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "content-length", - "value": "141" - }, - { - "_fromType": "array", - "name": "connection", - "value": "close" - }, - { - "name": "host", - "value": "advertising-api-test.amazon.com" - } - ], - "headersSize": 955, - "httpVersion": "HTTP/1.1", - "method": "POST", - "postData": { - "mimeType": "application/json", - "params": [], - "text": [ - { - "adGroupId": 164444192239500, - "bid": 10, - "expression": [ - { - "type": "asinSameAs", - "value": "B07663Z46Z" - } - ], - "expressionType": "manual", - "state": "paused" - } - ] - }, - "queryString": [], - "url": "https://advertising-api-test.amazon.com/v2/sd/targets" - }, - "response": { - "bodySize": 80, - "content": { - "mimeType": "application/json", - "size": 80, - "text": { - "code": "403", - "details": "HTTP 403 Forbidden", - "requestId": "H41RRHZ7TXFT18VRWP4F" - } - }, - "cookies": [], - "headers": [ - { - "name": "server", - "value": "Server" - }, - { - "name": "date", - "value": "Sat, 22 Aug 2020 03:59:32 GMT" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "transfer-encoding", - "value": "chunked" - }, - { - "name": "connection", - "value": "close" - }, - { - "name": "vary", - "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" - } - ], - "headersSize": 251, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 403, - "statusText": "Forbidden" - }, - "startedDateTime": "2020-08-22T03:59:31.915Z", - "time": 159, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 159 - } - } - ], - "pages": [], - "version": "1.2" - } -} diff --git a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts index 746538712..2ed130e30 100644 --- a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts +++ b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts @@ -10,7 +10,7 @@ describe('SponsoredDisplayTargetingOperation', () => { const AD_GROUP_ID = 164444192239500 const ASINS = ['B07663Z46Z', 'B07H8QMZWV', 'B07C65XFBB'] - describe('createTargetingClauses', () => { + describe.skip('createTargetingClauses', () => { it(`should create one or more targeting expressions`, async () => { const params: CreateSponsoredDisplayTargetingClausesParams[] = [ { From 27cb34efc270680da31079e14f429e1a464e4f9b Mon Sep 17 00:00:00 2001 From: Scale Bot Date: Sat, 22 Aug 2020 10:34:37 +0000 Subject: [PATCH 09/22] test: adds Polly recordings [skip ci] --- .../recording.har | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 test/__recordings__/SponsoredDisplayAdGroupOperation_3544596599/createAdGroups_767840800/should-create-an-ad-group_2863360381/recording.har diff --git a/test/__recordings__/SponsoredDisplayAdGroupOperation_3544596599/createAdGroups_767840800/should-create-an-ad-group_2863360381/recording.har b/test/__recordings__/SponsoredDisplayAdGroupOperation_3544596599/createAdGroups_767840800/should-create-an-ad-group_2863360381/recording.har new file mode 100644 index 000000000..9f2f6b87c --- /dev/null +++ b/test/__recordings__/SponsoredDisplayAdGroupOperation_3544596599/createAdGroups_767840800/should-create-an-ad-group_2863360381/recording.har @@ -0,0 +1,146 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayAdGroupOperation/createAdGroups/should create an ad group", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "613d5cf6d341466d8867dd9006a2a244", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 107, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "107" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 956, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "campaignId": 169989740510339, + "defaultBid": 1, + "name": "test sd ad group 2020/08/16 22:22", + "state": "paused" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sp/adGroups" + }, + "response": { + "bodySize": 48, + "content": { + "mimeType": "application/json", + "size": 48, + "text": [ + { + "adGroupId": 257081908560802, + "code": "SUCCESS" + } + ] + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sat, 22 Aug 2020 10:34:20 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "x-amz-request-id", + "value": "R6KGFJ3BW61GJ0MS5HKX" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 291, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 207, + "statusText": "Multi-Status" + }, + "startedDateTime": "2020-08-22T10:34:20.757Z", + "time": 156, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 156 + } + } + ], + "pages": [], + "version": "1.2" + } +} From 1632dacedeba800a19893a3108b462bf08b7b9d7 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sat, 22 Aug 2020 17:37:14 +0700 Subject: [PATCH 10/22] test: re-create sd targeting --- .../sponsored-display-targeting-operation.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts index 2ed130e30..54638d39a 100644 --- a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts +++ b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts @@ -7,10 +7,10 @@ describe('SponsoredDisplayTargetingOperation', () => { const client = new HttpClient(SANDBOX_URI, { ...auth, scope: 2973802954634317 }, true) const operationProvider = new OperationProvider(client) const operation = operationProvider.create(SponsoredDisplayTargetingOperation) - const AD_GROUP_ID = 164444192239500 + const AD_GROUP_ID = 257081908560802 const ASINS = ['B07663Z46Z', 'B07H8QMZWV', 'B07C65XFBB'] - describe.skip('createTargetingClauses', () => { + describe('createTargetingClauses', () => { it(`should create one or more targeting expressions`, async () => { const params: CreateSponsoredDisplayTargetingClausesParams[] = [ { From e7723476166613d53e93fa500a1fbe1f4617eca1 Mon Sep 17 00:00:00 2001 From: Scale Bot Date: Sat, 22 Aug 2020 10:38:34 +0000 Subject: [PATCH 11/22] test: adds Polly recordings [skip ci] --- .../recording.har | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har new file mode 100644 index 000000000..840a44478 --- /dev/null +++ b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har @@ -0,0 +1,147 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "60844d68ce6439736438cde6281cc7eb", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 141, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "141" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 955, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "adGroupId": 257081908560802, + "bid": 10, + "expression": [ + { + "type": "asinSameAs", + "value": "B07663Z46Z" + } + ], + "expressionType": "manual", + "state": "paused" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/targets" + }, + "response": { + "bodySize": 80, + "content": { + "mimeType": "application/json", + "size": 80, + "text": { + "code": "403", + "details": "HTTP 403 Forbidden", + "requestId": "YBY8B5K0DRJK9C5X1K60" + } + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sat, 22 Aug 2020 10:38:33 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 403, + "statusText": "Forbidden" + }, + "startedDateTime": "2020-08-22T10:38:32.884Z", + "time": 306, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 306 + } + } + ], + "pages": [], + "version": "1.2" + } +} From 438a0a765ecb432601b4df46e176ced277b19844 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sun, 23 Aug 2020 16:10:55 +0700 Subject: [PATCH 12/22] feat: send campaign id when create sd targeting --- src/operations/product-targeting/types.ts | 1 + .../recording.har | 147 ------------------ ...nsored-display-targeting-operation.test.ts | 2 + 3 files changed, 3 insertions(+), 147 deletions(-) delete mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har diff --git a/src/operations/product-targeting/types.ts b/src/operations/product-targeting/types.ts index be56a3020..1159774d4 100644 --- a/src/operations/product-targeting/types.ts +++ b/src/operations/product-targeting/types.ts @@ -1134,6 +1134,7 @@ export type SponsoredDisplayTargetingExpression = t.TypeOf< > export const CreateSponsoredDisplayTargetingClausesParams = t.strict({ + campaignId: t.number, /** * The ID of the ad group to which this target belongs. */ diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har deleted file mode 100644 index 840a44478..000000000 --- a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har +++ /dev/null @@ -1,147 +0,0 @@ -{ - "log": { - "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions", - "creator": { - "comment": "persister:fs", - "name": "Polly.JS", - "version": "5.0.0" - }, - "entries": [ - { - "_id": "60844d68ce6439736438cde6281cc7eb", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 141, - "cookies": [], - "headers": [ - { - "_fromType": "array", - "name": "content-type", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "accept", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "user-agent", - "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" - }, - { - "_fromType": "array", - "name": "amazon-advertising-api-scope", - "value": "2973802954634317" - }, - { - "_fromType": "array", - "name": "bidding_controls_on", - "value": "true" - }, - { - "_fromType": "array", - "name": "accept-encoding", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "content-length", - "value": "141" - }, - { - "_fromType": "array", - "name": "connection", - "value": "close" - }, - { - "name": "host", - "value": "advertising-api-test.amazon.com" - } - ], - "headersSize": 955, - "httpVersion": "HTTP/1.1", - "method": "POST", - "postData": { - "mimeType": "application/json", - "params": [], - "text": [ - { - "adGroupId": 257081908560802, - "bid": 10, - "expression": [ - { - "type": "asinSameAs", - "value": "B07663Z46Z" - } - ], - "expressionType": "manual", - "state": "paused" - } - ] - }, - "queryString": [], - "url": "https://advertising-api-test.amazon.com/v2/sd/targets" - }, - "response": { - "bodySize": 80, - "content": { - "mimeType": "application/json", - "size": 80, - "text": { - "code": "403", - "details": "HTTP 403 Forbidden", - "requestId": "YBY8B5K0DRJK9C5X1K60" - } - }, - "cookies": [], - "headers": [ - { - "name": "server", - "value": "Server" - }, - { - "name": "date", - "value": "Sat, 22 Aug 2020 10:38:33 GMT" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "transfer-encoding", - "value": "chunked" - }, - { - "name": "connection", - "value": "close" - }, - { - "name": "vary", - "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" - } - ], - "headersSize": 251, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 403, - "statusText": "Forbidden" - }, - "startedDateTime": "2020-08-22T10:38:32.884Z", - "time": 306, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 306 - } - } - ], - "pages": [], - "version": "1.2" - } -} diff --git a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts index 54638d39a..f1d2cac53 100644 --- a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts +++ b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts @@ -7,6 +7,7 @@ describe('SponsoredDisplayTargetingOperation', () => { const client = new HttpClient(SANDBOX_URI, { ...auth, scope: 2973802954634317 }, true) const operationProvider = new OperationProvider(client) const operation = operationProvider.create(SponsoredDisplayTargetingOperation) + const CAMPAIGN_ID = 169989740510339 const AD_GROUP_ID = 257081908560802 const ASINS = ['B07663Z46Z', 'B07H8QMZWV', 'B07C65XFBB'] @@ -14,6 +15,7 @@ describe('SponsoredDisplayTargetingOperation', () => { it(`should create one or more targeting expressions`, async () => { const params: CreateSponsoredDisplayTargetingClausesParams[] = [ { + campaignId: CAMPAIGN_ID, adGroupId: AD_GROUP_ID, state: 'paused', expressionType: 'manual', From ac9e31c50d25637687f276ed58794e98eef4c00d Mon Sep 17 00:00:00 2001 From: Scale Bot Date: Sun, 23 Aug 2020 09:12:21 +0000 Subject: [PATCH 13/22] test: adds Polly recordings [skip ci] --- .../recording.har | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har new file mode 100644 index 000000000..a44b3057d --- /dev/null +++ b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har @@ -0,0 +1,148 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "60844d68ce6439736438cde6281cc7eb", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 170, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "170" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 955, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "adGroupId": 257081908560802, + "bid": 10, + "campaignId": 169989740510339, + "expression": [ + { + "type": "asinSameAs", + "value": "B07663Z46Z" + } + ], + "expressionType": "manual", + "state": "paused" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/targets" + }, + "response": { + "bodySize": 95, + "content": { + "mimeType": "application/json", + "size": 95, + "text": { + "code": "422", + "details": "Unrecognized field \"campaignId\"", + "requestId": "0JK9R71EGGR4PQA9VB2Y" + } + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sun, 23 Aug 2020 09:12:19 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 422, + "statusText": "Unprocessable Entity" + }, + "startedDateTime": "2020-08-23T09:12:19.213Z", + "time": 177, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 177 + } + } + ], + "pages": [], + "version": "1.2" + } +} From fef2412c6a82f82b76e6c4817295d2d8c00e0026 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sun, 23 Aug 2020 16:13:03 +0700 Subject: [PATCH 14/22] Revert "feat: send campaign id when create sd targeting" This reverts commit 438a0a765ecb432601b4df46e176ced277b19844. --- src/operations/product-targeting/types.ts | 1 - .../recording.har | 147 ++++++++++++++++++ ...nsored-display-targeting-operation.test.ts | 2 - 3 files changed, 147 insertions(+), 3 deletions(-) create mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har diff --git a/src/operations/product-targeting/types.ts b/src/operations/product-targeting/types.ts index 1159774d4..be56a3020 100644 --- a/src/operations/product-targeting/types.ts +++ b/src/operations/product-targeting/types.ts @@ -1134,7 +1134,6 @@ export type SponsoredDisplayTargetingExpression = t.TypeOf< > export const CreateSponsoredDisplayTargetingClausesParams = t.strict({ - campaignId: t.number, /** * The ID of the ad group to which this target belongs. */ diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har new file mode 100644 index 000000000..840a44478 --- /dev/null +++ b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har @@ -0,0 +1,147 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "60844d68ce6439736438cde6281cc7eb", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 141, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "141" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 955, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "adGroupId": 257081908560802, + "bid": 10, + "expression": [ + { + "type": "asinSameAs", + "value": "B07663Z46Z" + } + ], + "expressionType": "manual", + "state": "paused" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/targets" + }, + "response": { + "bodySize": 80, + "content": { + "mimeType": "application/json", + "size": 80, + "text": { + "code": "403", + "details": "HTTP 403 Forbidden", + "requestId": "YBY8B5K0DRJK9C5X1K60" + } + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sat, 22 Aug 2020 10:38:33 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 403, + "statusText": "Forbidden" + }, + "startedDateTime": "2020-08-22T10:38:32.884Z", + "time": 306, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 306 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts index f1d2cac53..54638d39a 100644 --- a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts +++ b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts @@ -7,7 +7,6 @@ describe('SponsoredDisplayTargetingOperation', () => { const client = new HttpClient(SANDBOX_URI, { ...auth, scope: 2973802954634317 }, true) const operationProvider = new OperationProvider(client) const operation = operationProvider.create(SponsoredDisplayTargetingOperation) - const CAMPAIGN_ID = 169989740510339 const AD_GROUP_ID = 257081908560802 const ASINS = ['B07663Z46Z', 'B07H8QMZWV', 'B07C65XFBB'] @@ -15,7 +14,6 @@ describe('SponsoredDisplayTargetingOperation', () => { it(`should create one or more targeting expressions`, async () => { const params: CreateSponsoredDisplayTargetingClausesParams[] = [ { - campaignId: CAMPAIGN_ID, adGroupId: AD_GROUP_ID, state: 'paused', expressionType: 'manual', From 5de944d57b32c9d3c71cb30b5f99105240521c5c Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sun, 23 Aug 2020 16:28:31 +0700 Subject: [PATCH 15/22] test: skip create sd targeting test --- .../recording.har | 147 ------------------ ...nsored-display-targeting-operation.test.ts | 6 +- 2 files changed, 5 insertions(+), 148 deletions(-) delete mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har deleted file mode 100644 index 840a44478..000000000 --- a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har +++ /dev/null @@ -1,147 +0,0 @@ -{ - "log": { - "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions", - "creator": { - "comment": "persister:fs", - "name": "Polly.JS", - "version": "5.0.0" - }, - "entries": [ - { - "_id": "60844d68ce6439736438cde6281cc7eb", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 141, - "cookies": [], - "headers": [ - { - "_fromType": "array", - "name": "content-type", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "accept", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "user-agent", - "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" - }, - { - "_fromType": "array", - "name": "amazon-advertising-api-scope", - "value": "2973802954634317" - }, - { - "_fromType": "array", - "name": "bidding_controls_on", - "value": "true" - }, - { - "_fromType": "array", - "name": "accept-encoding", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "content-length", - "value": "141" - }, - { - "_fromType": "array", - "name": "connection", - "value": "close" - }, - { - "name": "host", - "value": "advertising-api-test.amazon.com" - } - ], - "headersSize": 955, - "httpVersion": "HTTP/1.1", - "method": "POST", - "postData": { - "mimeType": "application/json", - "params": [], - "text": [ - { - "adGroupId": 257081908560802, - "bid": 10, - "expression": [ - { - "type": "asinSameAs", - "value": "B07663Z46Z" - } - ], - "expressionType": "manual", - "state": "paused" - } - ] - }, - "queryString": [], - "url": "https://advertising-api-test.amazon.com/v2/sd/targets" - }, - "response": { - "bodySize": 80, - "content": { - "mimeType": "application/json", - "size": 80, - "text": { - "code": "403", - "details": "HTTP 403 Forbidden", - "requestId": "YBY8B5K0DRJK9C5X1K60" - } - }, - "cookies": [], - "headers": [ - { - "name": "server", - "value": "Server" - }, - { - "name": "date", - "value": "Sat, 22 Aug 2020 10:38:33 GMT" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "transfer-encoding", - "value": "chunked" - }, - { - "name": "connection", - "value": "close" - }, - { - "name": "vary", - "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" - } - ], - "headersSize": 251, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 403, - "statusText": "Forbidden" - }, - "startedDateTime": "2020-08-22T10:38:32.884Z", - "time": 306, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 306 - } - } - ], - "pages": [], - "version": "1.2" - } -} diff --git a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts index 54638d39a..78d74f695 100644 --- a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts +++ b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts @@ -10,7 +10,11 @@ describe('SponsoredDisplayTargetingOperation', () => { const AD_GROUP_ID = 257081908560802 const ASINS = ['B07663Z46Z', 'B07H8QMZWV', 'B07C65XFBB'] - describe('createTargetingClauses', () => { + /** + * Sandbox API returns "HTTP 403 Forbidden" error when request. + * TODO: Need check again on Production API. + */ + describe.skip('createTargetingClauses', () => { it(`should create one or more targeting expressions`, async () => { const params: CreateSponsoredDisplayTargetingClausesParams[] = [ { From 0d0c3184851dff3967afb29dc5d08e45911893ae Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sun, 23 Aug 2020 22:19:40 +0700 Subject: [PATCH 16/22] feat: implement get, list, update and archive sd targeting --- .../sponsored-display-targeting-operation.ts | 85 ++++++++++++++++++- src/operations/product-targeting/types.ts | 69 +++++++++++++++ 2 files changed, 152 insertions(+), 2 deletions(-) diff --git a/src/operations/product-targeting/sponsored-display-targeting-operation.ts b/src/operations/product-targeting/sponsored-display-targeting-operation.ts index f9744fdbe..85c6fa8a2 100644 --- a/src/operations/product-targeting/sponsored-display-targeting-operation.ts +++ b/src/operations/product-targeting/sponsored-display-targeting-operation.ts @@ -1,12 +1,44 @@ import { Operation } from '../operation' -import { DecodeArray } from '../../decorators' +import { Decode, DecodeArray } from '../../decorators' import { AmazonAdTypeURIPrefix } from '../amazon-ad-type-uri-prefix' -import { TargetingClauseResponse, CreateSponsoredDisplayTargetingClausesParams } from './types' +import { + TargetingClauseResponse, + CreateSponsoredDisplayTargetingClausesParams, + TargetId, + SponsoredDisplayTargetingClause, + SponsoredDisplayTargetingClauseExtended, + UpdateSponsoredDisplayTargetingClausesParams, + ListTargetingClausesParams, +} from './types' export class SponsoredDisplayTargetingOperation extends Operation { protected resource = `${this.version}/${AmazonAdTypeURIPrefix.SponsoredDisplay}/targets` + /** + * Gets a targeting clause specified by identifier. + * + * @param targetId - + * @returns + */ + @Decode(SponsoredDisplayTargetingClause) + public getTargetingClause(targetId: TargetId) { + return this.client.get(`${this.resource}/${targetId}`) + } + + /** + * Gets extended information for a targeting clause. + * + * @param targetId - + * @returns + */ + @Decode(SponsoredDisplayTargetingClauseExtended) + public getTargetingClauseExtended(targetId: TargetId) { + return this.client.get( + `${this.resource}/extended/${targetId}`, + ) + } + /** * Creates one or more targeting clauses. * @@ -17,4 +49,53 @@ export class SponsoredDisplayTargetingOperation extends Operation { public createTargetingClauses(params: CreateSponsoredDisplayTargetingClausesParams[]) { return this.client.post(this.resource, params) } + + /** + * Update one or more targeting clauses. + * + * @param params - + * @returns + */ + @DecodeArray(TargetingClauseResponse) + public updateTargetingClauses(params: UpdateSponsoredDisplayTargetingClausesParams[]) { + return this.client.put(this.resource, params) + } + + /** + * Gets a list of targeting clauses. + * + * @param params - + * @returns + */ + @DecodeArray(SponsoredDisplayTargetingClause) + public listTargetingClauses(params?: ListTargetingClausesParams) { + return this.client.get( + this.paramsFilterTransformer(this.resource, params), + ) + } + + /** + * Gets a list of targeting clause objects with extended fields. + * + * @param params - + * @returns + */ + @DecodeArray(SponsoredDisplayTargetingClauseExtended) + public listTargetingClausesExtended(params?: ListTargetingClausesParams) { + return this.client.get( + this.paramsFilterTransformer(`${this.resource}/extended`, params), + ) + } + + /** + * Set the status of targeting clauses to archived. + * Equivalent to using the updateTargetingClauses operation to set the state property of a targeting clause to archived. + * + * @param targetId - + * @returns + */ + @Decode(TargetingClauseResponse) + public archiveTargetingClause(targetId: TargetId) { + return this.client.delete(`${this.resource}/${targetId}`) + } } diff --git a/src/operations/product-targeting/types.ts b/src/operations/product-targeting/types.ts index be56a3020..f2d29a20f 100644 --- a/src/operations/product-targeting/types.ts +++ b/src/operations/product-targeting/types.ts @@ -1116,6 +1116,23 @@ export const SponsoredDisplayTargetingPredicate = t.strict({ }) export type SponsoredDisplayTargetingPredicate = t.TypeOf +export const SponsoredDisplayTargetingPredicateLegacy = t.strict({ + type: SponsoredDisplayTargetingPredicateType, + + /** + * The value to be targeted. + */ + value: t.string, + + /** + * The type of event that the value applies to. Only available for similarProduct and exactProduct currently. + */ + eventType: t.literal('views'), +}) +export type SponsoredDisplayTargetingPredicateLegacy = t.TypeOf< + typeof SponsoredDisplayTargetingPredicateLegacy +> + export const SponsoredDisplayTargetingPredicateNested = t.strict({ type: t.literal('views'), @@ -1127,6 +1144,7 @@ export type SponsoredDisplayTargetingPredicateNested = t.TypeOf< export const SponsoredDisplayTargetingExpression = t.union([ SponsoredDisplayTargetingPredicate, + SponsoredDisplayTargetingPredicateLegacy, SponsoredDisplayTargetingPredicateNested, ]) export type SponsoredDisplayTargetingExpression = t.TypeOf< @@ -1163,3 +1181,54 @@ export const CreateSponsoredDisplayTargetingClausesParams = t.strict({ export type CreateSponsoredDisplayTargetingClausesParams = t.TypeOf< typeof CreateSponsoredDisplayTargetingClausesParams > + +export const UpdateSponsoredDisplayTargetingClausesParams = t.intersection([ + t.strict({ + targetId: TargetId, + }), + t.partial({ + /** + * The bid will override the adGroup bid if specified. Bid is not allowed in negative targeting clauses. + */ + bid: t.number, + + /** + * Advertiser-specified state of the target + */ + state: TargetingClauseState, + }), +]) +export type UpdateSponsoredDisplayTargetingClausesParams = t.TypeOf< + typeof UpdateSponsoredDisplayTargetingClausesParams +> + +export const SponsoredDisplayTargetingClause = t.intersection([ + CreateSponsoredDisplayTargetingClausesParams, + t.strict({ + targetId: TargetId, + }), +]) +export type SponsoredDisplayTargetingClause = t.TypeOf + +export const SponsoredDisplayTargetingClauseExtended = t.intersection([ + SponsoredDisplayTargetingClause, + t.strict({ + /** + * The date the ad group was created as epoch time in milliseconds. + */ + creationDate: DateFromNumber, + + /** + * The date the ad group was last updated as epoch time in milliseconds. + */ + lastUpdatedDate: DateFromNumber, + + /** + * The computed status, accounting for out of budget, policy violations, etc. See developer notes for more information. + */ + servingStatus: TargetingClauseServingStatus, + }), +]) +export type SponsoredDisplayTargetingClauseExtended = t.TypeOf< + typeof SponsoredDisplayTargetingClauseExtended +> From 1c63ed2b61321e1c692179cbbc93289c2aa04343 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sun, 23 Aug 2020 22:23:31 +0700 Subject: [PATCH 17/22] test: re-record create sd targeting --- .../sponsored-display-targeting-operation.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts index 78d74f695..36f64d96d 100644 --- a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts +++ b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts @@ -14,7 +14,7 @@ describe('SponsoredDisplayTargetingOperation', () => { * Sandbox API returns "HTTP 403 Forbidden" error when request. * TODO: Need check again on Production API. */ - describe.skip('createTargetingClauses', () => { + describe('createTargetingClauses', () => { it(`should create one or more targeting expressions`, async () => { const params: CreateSponsoredDisplayTargetingClausesParams[] = [ { From e62ef9ab7fc481137c7231bf681eaed3ba4d7656 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sun, 23 Aug 2020 22:26:42 +0700 Subject: [PATCH 18/22] test: remove create sd targeting recordings --- .../recording.har | 148 ------------------ 1 file changed, 148 deletions(-) delete mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har deleted file mode 100644 index a44b3057d..000000000 --- a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har +++ /dev/null @@ -1,148 +0,0 @@ -{ - "log": { - "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions", - "creator": { - "comment": "persister:fs", - "name": "Polly.JS", - "version": "5.0.0" - }, - "entries": [ - { - "_id": "60844d68ce6439736438cde6281cc7eb", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 170, - "cookies": [], - "headers": [ - { - "_fromType": "array", - "name": "content-type", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "accept", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "user-agent", - "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" - }, - { - "_fromType": "array", - "name": "amazon-advertising-api-scope", - "value": "2973802954634317" - }, - { - "_fromType": "array", - "name": "bidding_controls_on", - "value": "true" - }, - { - "_fromType": "array", - "name": "accept-encoding", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "content-length", - "value": "170" - }, - { - "_fromType": "array", - "name": "connection", - "value": "close" - }, - { - "name": "host", - "value": "advertising-api-test.amazon.com" - } - ], - "headersSize": 955, - "httpVersion": "HTTP/1.1", - "method": "POST", - "postData": { - "mimeType": "application/json", - "params": [], - "text": [ - { - "adGroupId": 257081908560802, - "bid": 10, - "campaignId": 169989740510339, - "expression": [ - { - "type": "asinSameAs", - "value": "B07663Z46Z" - } - ], - "expressionType": "manual", - "state": "paused" - } - ] - }, - "queryString": [], - "url": "https://advertising-api-test.amazon.com/v2/sd/targets" - }, - "response": { - "bodySize": 95, - "content": { - "mimeType": "application/json", - "size": 95, - "text": { - "code": "422", - "details": "Unrecognized field \"campaignId\"", - "requestId": "0JK9R71EGGR4PQA9VB2Y" - } - }, - "cookies": [], - "headers": [ - { - "name": "server", - "value": "Server" - }, - { - "name": "date", - "value": "Sun, 23 Aug 2020 09:12:19 GMT" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "transfer-encoding", - "value": "chunked" - }, - { - "name": "connection", - "value": "close" - }, - { - "name": "vary", - "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" - } - ], - "headersSize": 251, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 422, - "statusText": "Unprocessable Entity" - }, - "startedDateTime": "2020-08-23T09:12:19.213Z", - "time": 177, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 177 - } - } - ], - "pages": [], - "version": "1.2" - } -} From 7fa159ad415b34d95dd3bcbe7ebf661cc4473e9c Mon Sep 17 00:00:00 2001 From: Scale Bot Date: Sun, 23 Aug 2020 15:28:06 +0000 Subject: [PATCH 19/22] test: adds Polly recordings [skip ci] --- .../recording.har | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har new file mode 100644 index 000000000..d31b99bd0 --- /dev/null +++ b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har @@ -0,0 +1,147 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "60844d68ce6439736438cde6281cc7eb", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 141, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "141" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 955, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "adGroupId": 257081908560802, + "bid": 10, + "expression": [ + { + "type": "asinSameAs", + "value": "B07663Z46Z" + } + ], + "expressionType": "manual", + "state": "paused" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/targets" + }, + "response": { + "bodySize": 80, + "content": { + "mimeType": "application/json", + "size": 80, + "text": { + "code": "403", + "details": "HTTP 403 Forbidden", + "requestId": "PXG61XYDKK6V77R8TMGK" + } + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sun, 23 Aug 2020 15:28:05 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 403, + "statusText": "Forbidden" + }, + "startedDateTime": "2020-08-23T15:28:05.233Z", + "time": 148, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 148 + } + } + ], + "pages": [], + "version": "1.2" + } +} From 9668b6185ea5f11dede5b581b42ca4f910d162a1 Mon Sep 17 00:00:00 2001 From: Toan Nguyen Date: Sun, 23 Aug 2020 22:39:57 +0700 Subject: [PATCH 20/22] test: try to create sd targeting with other expression --- .../recording.har | 147 ------------------ ...nsored-display-targeting-operation.test.ts | 62 +++++++- 2 files changed, 61 insertions(+), 148 deletions(-) delete mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har deleted file mode 100644 index d31b99bd0..000000000 --- a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions_349492656/recording.har +++ /dev/null @@ -1,147 +0,0 @@ -{ - "log": { - "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions", - "creator": { - "comment": "persister:fs", - "name": "Polly.JS", - "version": "5.0.0" - }, - "entries": [ - { - "_id": "60844d68ce6439736438cde6281cc7eb", - "_order": 0, - "cache": {}, - "request": { - "bodySize": 141, - "cookies": [], - "headers": [ - { - "_fromType": "array", - "name": "content-type", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "accept", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "user-agent", - "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" - }, - { - "_fromType": "array", - "name": "amazon-advertising-api-scope", - "value": "2973802954634317" - }, - { - "_fromType": "array", - "name": "bidding_controls_on", - "value": "true" - }, - { - "_fromType": "array", - "name": "accept-encoding", - "value": "application/json" - }, - { - "_fromType": "array", - "name": "content-length", - "value": "141" - }, - { - "_fromType": "array", - "name": "connection", - "value": "close" - }, - { - "name": "host", - "value": "advertising-api-test.amazon.com" - } - ], - "headersSize": 955, - "httpVersion": "HTTP/1.1", - "method": "POST", - "postData": { - "mimeType": "application/json", - "params": [], - "text": [ - { - "adGroupId": 257081908560802, - "bid": 10, - "expression": [ - { - "type": "asinSameAs", - "value": "B07663Z46Z" - } - ], - "expressionType": "manual", - "state": "paused" - } - ] - }, - "queryString": [], - "url": "https://advertising-api-test.amazon.com/v2/sd/targets" - }, - "response": { - "bodySize": 80, - "content": { - "mimeType": "application/json", - "size": 80, - "text": { - "code": "403", - "details": "HTTP 403 Forbidden", - "requestId": "PXG61XYDKK6V77R8TMGK" - } - }, - "cookies": [], - "headers": [ - { - "name": "server", - "value": "Server" - }, - { - "name": "date", - "value": "Sun, 23 Aug 2020 15:28:05 GMT" - }, - { - "name": "content-type", - "value": "application/json" - }, - { - "name": "transfer-encoding", - "value": "chunked" - }, - { - "name": "connection", - "value": "close" - }, - { - "name": "vary", - "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" - } - ], - "headersSize": 251, - "httpVersion": "HTTP/1.1", - "redirectURL": "", - "status": 403, - "statusText": "Forbidden" - }, - "startedDateTime": "2020-08-23T15:28:05.233Z", - "time": 148, - "timings": { - "blocked": -1, - "connect": -1, - "dns": -1, - "receive": 0, - "send": 0, - "ssl": -1, - "wait": 148 - } - } - ], - "pages": [], - "version": "1.2" - } -} diff --git a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts index 36f64d96d..1c0b12302 100644 --- a/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts +++ b/test/operations/product-targeting/sponsored-display-targeting-operation.test.ts @@ -15,7 +15,7 @@ describe('SponsoredDisplayTargetingOperation', () => { * TODO: Need check again on Production API. */ describe('createTargetingClauses', () => { - it(`should create one or more targeting expressions`, async () => { + it(`should create one or more targeting expressions with similarProduct type`, async () => { const params: CreateSponsoredDisplayTargetingClausesParams[] = [ { adGroupId: AD_GROUP_ID, @@ -34,5 +34,65 @@ describe('SponsoredDisplayTargetingOperation', () => { expect(res.code).toBe('SUCCESS') }) + + it(`should create one or more targeting expressions with exactProduct type`, async () => { + const params: CreateSponsoredDisplayTargetingClausesParams[] = [ + { + adGroupId: AD_GROUP_ID, + state: 'enabled', + expressionType: 'manual', + expression: [ + { + type: 'exactProduct', + value: ASINS[0], + }, + ], + bid: 10, + }, + ] + const [res] = await operation.createTargetingClauses(params) + + expect(res.code).toBe('SUCCESS') + }) + + it(`should create one or more targeting expressions with lookback type`, async () => { + const params: CreateSponsoredDisplayTargetingClausesParams[] = [ + { + adGroupId: AD_GROUP_ID, + state: 'enabled', + expressionType: 'manual', + expression: [ + { + type: 'lookback', + value: ASINS[0], + }, + ], + bid: 10, + }, + ] + const [res] = await operation.createTargetingClauses(params) + + expect(res.code).toBe('SUCCESS') + }) + + it(`should create one or more targeting expressions with negative type`, async () => { + const params: CreateSponsoredDisplayTargetingClausesParams[] = [ + { + adGroupId: AD_GROUP_ID, + state: 'enabled', + expressionType: 'manual', + expression: [ + { + type: 'negative', + value: ASINS[0], + }, + ], + bid: 10, + }, + ] + const [res] = await operation.createTargetingClauses(params) + + expect(res.code).toBe('SUCCESS') + }) }) }) From a69eeeacc122a02df3a16810e57e4783af1c6f9b Mon Sep 17 00:00:00 2001 From: Scale Bot Date: Sun, 23 Aug 2020 15:41:22 +0000 Subject: [PATCH 21/22] test: adds Polly recordings [skip ci] --- .../recording.har | 147 ++++++++++++++++++ .../recording.har | 147 ++++++++++++++++++ .../recording.har | 147 ++++++++++++++++++ .../recording.har | 147 ++++++++++++++++++ 4 files changed, 588 insertions(+) create mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-exactProduct-type_1301488206/recording.har create mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-lookback-type_2142683412/recording.har create mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-negative-type_3269812077/recording.har create mode 100644 test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-similarProduct-type_1987201904/recording.har diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-exactProduct-type_1301488206/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-exactProduct-type_1301488206/recording.har new file mode 100644 index 000000000..96d8b7a17 --- /dev/null +++ b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-exactProduct-type_1301488206/recording.har @@ -0,0 +1,147 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions with exactProduct type", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "60844d68ce6439736438cde6281cc7eb", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 144, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "144" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 955, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "adGroupId": 257081908560802, + "bid": 10, + "expression": [ + { + "type": "exactProduct", + "value": "B07663Z46Z" + } + ], + "expressionType": "manual", + "state": "enabled" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/targets" + }, + "response": { + "bodySize": 80, + "content": { + "mimeType": "application/json", + "size": 80, + "text": { + "code": "403", + "details": "HTTP 403 Forbidden", + "requestId": "25BEZRV4H274KR5R8AAQ" + } + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sun, 23 Aug 2020 15:41:12 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 403, + "statusText": "Forbidden" + }, + "startedDateTime": "2020-08-23T15:41:12.763Z", + "time": 45, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 45 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-lookback-type_2142683412/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-lookback-type_2142683412/recording.har new file mode 100644 index 000000000..b5c641783 --- /dev/null +++ b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-lookback-type_2142683412/recording.har @@ -0,0 +1,147 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions with lookback type", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "60844d68ce6439736438cde6281cc7eb", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 140, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "140" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 955, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "adGroupId": 257081908560802, + "bid": 10, + "expression": [ + { + "type": "lookback", + "value": "B07663Z46Z" + } + ], + "expressionType": "manual", + "state": "enabled" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/targets" + }, + "response": { + "bodySize": 80, + "content": { + "mimeType": "application/json", + "size": 80, + "text": { + "code": "403", + "details": "HTTP 403 Forbidden", + "requestId": "KT5AKPH31JBTD15X19TX" + } + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sun, 23 Aug 2020 15:41:12 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 403, + "statusText": "Forbidden" + }, + "startedDateTime": "2020-08-23T15:41:12.815Z", + "time": 44, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 44 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-negative-type_3269812077/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-negative-type_3269812077/recording.har new file mode 100644 index 000000000..9b6c286d3 --- /dev/null +++ b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-negative-type_3269812077/recording.har @@ -0,0 +1,147 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions with negative type", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "60844d68ce6439736438cde6281cc7eb", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 140, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "140" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 955, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "adGroupId": 257081908560802, + "bid": 10, + "expression": [ + { + "type": "negative", + "value": "B07663Z46Z" + } + ], + "expressionType": "manual", + "state": "enabled" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/targets" + }, + "response": { + "bodySize": 80, + "content": { + "mimeType": "application/json", + "size": 80, + "text": { + "code": "403", + "details": "HTTP 403 Forbidden", + "requestId": "FSDXHPQ06CWFYTQX36WV" + } + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sun, 23 Aug 2020 15:41:12 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 403, + "statusText": "Forbidden" + }, + "startedDateTime": "2020-08-23T15:41:12.865Z", + "time": 35, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 35 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-similarProduct-type_1987201904/recording.har b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-similarProduct-type_1987201904/recording.har new file mode 100644 index 000000000..5eaced389 --- /dev/null +++ b/test/__recordings__/SponsoredDisplayTargetingOperation_1019933930/createTargetingClauses_290560290/should-create-one-or-more-targeting-expressions-with-similarProduct-type_1987201904/recording.har @@ -0,0 +1,147 @@ +{ + "log": { + "_recordingName": "SponsoredDisplayTargetingOperation/createTargetingClauses/should create one or more targeting expressions with similarProduct type", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.0.0" + }, + "entries": [ + { + "_id": "60844d68ce6439736438cde6281cc7eb", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 141, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "@scaleleap/amazon-advertising-api-sdk/0.0.0" + }, + { + "_fromType": "array", + "name": "amazon-advertising-api-scope", + "value": "2973802954634317" + }, + { + "_fromType": "array", + "name": "bidding_controls_on", + "value": "true" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "141" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "advertising-api-test.amazon.com" + } + ], + "headersSize": 955, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": [ + { + "adGroupId": 257081908560802, + "bid": 10, + "expression": [ + { + "type": "asinSameAs", + "value": "B07663Z46Z" + } + ], + "expressionType": "manual", + "state": "paused" + } + ] + }, + "queryString": [], + "url": "https://advertising-api-test.amazon.com/v2/sd/targets" + }, + "response": { + "bodySize": 80, + "content": { + "mimeType": "application/json", + "size": 80, + "text": { + "code": "403", + "details": "HTTP 403 Forbidden", + "requestId": "ZWK74DJDW8958F4RJQWW" + } + }, + "cookies": [], + "headers": [ + { + "name": "server", + "value": "Server" + }, + { + "name": "date", + "value": "Sun, 23 Aug 2020 15:41:12 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "transfer-encoding", + "value": "chunked" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent" + } + ], + "headersSize": 251, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 403, + "statusText": "Forbidden" + }, + "startedDateTime": "2020-08-23T15:41:12.579Z", + "time": 161, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 161 + } + } + ], + "pages": [], + "version": "1.2" + } +} From 36337d2d254cb4c5f818b082c6afec2180a55133 Mon Sep 17 00:00:00 2001 From: Roman Filippov Date: Sat, 29 Aug 2020 14:23:22 +0700 Subject: [PATCH 22/22] feat: adds ForbiddenError class --- src/errors.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/errors.ts b/src/errors.ts index 5a50e2f1d..30e1a6e2d 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -76,6 +76,8 @@ export class ResourceNotFoundError extends GenericError {} export class NotAcceptableError extends GenericError {} +export class ForbiddenError extends GenericError {} + export function apiErrorFactory(err: ErrorObject, headers: Headers): GenericError { switch (err.code) { case 'UNAUTHORIZED': @@ -84,6 +86,8 @@ export function apiErrorFactory(err: ErrorObject, headers: Headers): GenericErro return new ResourceNotFoundError(err, headers) case '400': return new BadRequestError(err, headers) + case '403': + return new ForbiddenError(err, headers) case '406': return new NotAcceptableError(err, headers) case '422':