Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adds ENDED AdGroup status #803

Merged
merged 3 commits into from
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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