Skip to content

Commit

Permalink
fix: adds ENDED AdGroup status (#803)
Browse files Browse the repository at this point in the history
* fix: updating test for adgroups undocumented cases and expanding AdGroupServingStatus type to handle the same undocumented cases

* fix: updating test for campaigns undocumented cases and expanding CampaignServingStatus type to handle the same undocumented cases

* fix: linting error
  • Loading branch information
mayan-jbsmith authored Jul 30, 2021
1 parent 0a0b574 commit e56f46b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 8 deletions.
34 changes: 34 additions & 0 deletions src/operations/ad-groups/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,37 @@ describe('AdGroupResponse', () => {
expect(isRight(res)).toBeTruthy()
})
})

describe('AdGroupExtendedEdgeCase1', () => {
it('should pass getAdGroupEx response when servingStatus is "ENDED"', () => {
const res = t.AdGroupExtended.decode({
adGroupId: 138818764235694,
name: 'New Name',
campaignId: 31299234922913,
defaultBid: 1,
state: 'archived',
servingStatus: 'ENDED',
creationDate: 1550902562000,
lastUpdatedDate: 1550904242000,
})

expect(isRight(res)).toBeTruthy()
})
})

describe('AdGroupExtendedEdgeCase2', () => {
it('should pass getAdGroupEx response when servingStatus is "AD_GROUP_INCOMPLETE"', () => {
const res = t.AdGroupExtended.decode({
adGroupId: 138818764235694,
name: 'New Name',
campaignId: 31299234922913,
defaultBid: 1,
state: 'archived',
servingStatus: 'AD_GROUP_INCOMPLETE',
creationDate: 1550902562000,
lastUpdatedDate: 1550904242000,
})

expect(isRight(res)).toBeTruthy()
})
})
2 changes: 2 additions & 0 deletions src/operations/ad-groups/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export type AdGroupResponseStatus = t.TypeOf<typeof AdGroupResponseStatus>
*/
export const AdGroupServingStatus = t.union([
t.literal('AD_GROUP_ARCHIVED'),
t.literal('AD_GROUP_INCOMPLETE'), // The docs don't mention about this type
t.literal('AD_GROUP_PAUSED'),
t.literal('AD_GROUP_STATUS_ENABLED'),
t.literal('AD_POLICING_SUSPENDED'),
Expand All @@ -48,6 +49,7 @@ export const AdGroupServingStatus = t.union([
t.literal('ADVERTISER_PAYMENT_FAILURE'),
t.literal('PORTFOLIO_PENDING_START_DATE'), // The docs don't mention about this type
t.literal('PORTFOLIO_ENDED'), // The docs don't mention about this type
t.literal('ENDED'), // The docs don't mention about this type
])
export type AdGroupServingStatus = t.TypeOf<typeof AdGroupServingStatus>

Expand Down
28 changes: 23 additions & 5 deletions src/operations/campaigns/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,29 @@ describe('Campaign Edge Case', () => {
dailyBudget: 1,
startDate: '20161024',
state: 'archived',
bidding: { adjustments: [] }
});
expect(isRight(edgecaseFragment)).toBeTruthy();
});
});
bidding: { adjustments: [] },
})
expect(isRight(edgecaseFragment)).toBeTruthy()
})
})

describe('Campaign Extended Edge Case', () => {
it('should pass getCampaignEx when servingStatus is "ENDED"', () => {
const edgecaseFragment = t.CampaignExtended.decode({
campaignId: 108971111858080,
name: 'test',
campaignType: 'sponsoredProducts',
targetingType: 'auto',
premiumBidAdjustment: false,
dailyBudget: 1,
startDate: '20161024',
state: 'archived',
servingStatus: 'ENDED',
bidding: { adjustments: [] },
})
expect(isRight(edgecaseFragment)).toBeTruthy()
})
})

/**
* TODO: Update test script:
Expand Down
7 changes: 4 additions & 3 deletions src/operations/campaigns/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ export type CampaignState = t.TypeOf<typeof CampaignState>

export const CampaignBidding = t.intersection([
t.type({
adjustments: CampaignBiddingAdjustments
adjustments: CampaignBiddingAdjustments,
}),
t.partial({
strategy: CampaignBiddingStrategy
})
strategy: CampaignBiddingStrategy,
}),
])
export type CampaignBidding = t.TypeOf<typeof CampaignBidding>

Expand Down Expand Up @@ -287,6 +287,7 @@ export const CampaignServingStatus = t.union([
t.literal('PORTFOLIO_ENDED'), // The docs don't say about this type
t.literal('CAMPAIGN_INCOMPLETE'), // The docs don't say about this type
t.literal('PENDING_START_DATE'), // The docs don't say about this type
t.literal('ENDED'), // The docs don't say about this type
])
export type CampaignServingStatus = t.TypeOf<typeof CampaignServingStatus>

Expand Down

0 comments on commit e56f46b

Please sign in to comment.