Skip to content

Commit

Permalink
feat: change AdGroupState to using union string
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyentoanit committed Apr 20, 2020
1 parent 293250e commit 2bbe4a8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/operations/keywords/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as t from 'io-ts'
import { createEnumType, ListPagination } from '../commons/types'
import { CampaignId, CampaignIds } from '../campaigns/types'
import { DateFromNumber } from 'io-ts-types/lib/DateFromNumber'
import { AdGroupId, AdGroupIds, AdGroupStateType } from '../ad-groups/types'
import { AdGroupId, AdGroupIds, AdGroupState } from '../ad-groups/types'

export const KeywordId = t.number
export type KeywordId = t.TypeOf<typeof KeywordId>
Expand Down Expand Up @@ -656,7 +656,7 @@ export const GetAdGroupSuggestedKeywordsParams = t.strict({
* Valid values are: enabled, paused, and archived.
* Default values are enabled and paused
*/
adStateFilter: t.array(AdGroupStateType),
adStateFilter: t.array(AdGroupState),
})
export type GetAdGroupSuggestedKeywordsParams = t.TypeOf<typeof GetAdGroupSuggestedKeywordsParams>

Expand Down
2 changes: 1 addition & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as snapshotEnum from '../src/operations/snapshots/types'
describe('index', () => {
describe('ad group', () => {
it('should export all enums', () => {
expect(index.AdGroupStateEnum).toEqual(adGroupEnums.AdGroupStateEnum)
expect(index.AdGroupState).toEqual(adGroupEnums.AdGroupState)
expect(index.AdGroupResponseStatus).toEqual(adGroupEnums.AdGroupResponseStatus)
expect(index.AdGroupServingStatusEnum).toEqual(adGroupEnums.AdGroupServingStatusEnum)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { OperationProvider } from '../../../src/operations/operation-provider'
import { SponsoredBrandsAdGroupOperation } from '../../../src/operations/ad-groups/sponsored-brands-ad-group-operation'
import { httpClientFactory } from '../../http-client-factory'
import { AdGroupStateEnum } from '../../../src/operations/ad-groups/types'

describe('SponsoredBrandsAdGroupOperation', () => {
const client = httpClientFactory()
Expand All @@ -20,7 +19,7 @@ describe('SponsoredBrandsAdGroupOperation', () => {
expect(res).toHaveProperty('campaignId')
expect(res).toHaveProperty('defaultBid')
expect(res.defaultBid).toBeGreaterThan(0.02)
expect(res.state).toBe(AdGroupStateEnum.ARCHIVED)
expect(res.state).toBe('archived')
})
})

Expand All @@ -37,7 +36,7 @@ describe('SponsoredBrandsAdGroupOperation', () => {
adGroupIdFilter: [ARCHIVED_AD_GROUP_ID],
campaignIdFilter: [CAMPAIGN_ID],
count: 1,
stateFilter: [AdGroupStateEnum.ARCHIVED],
stateFilter: ['archived'],
})

expect(res).toHaveLength(1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SponsoredProductsSuggestedKeywordsOperation } from '../../../src/operations/keywords/sponsored-products-suggested-keywords-operation'
import { httpClientFactory } from '../../http-client-factory'
import { OperationProvider, AdGroupStateEnum } from '../../../src'
import { OperationProvider } from '../../../src'
import {
GetAdGroupSuggestedKeywordsParams,
GetAdGroupSuggestedKeywordsExtendedParams,
Expand All @@ -26,7 +26,7 @@ describe('SponsoredProductsSuggestedKeywordsOperation', () => {
it(`should return suggested keyword data for the specified adGroupId, adStateFilter`, async () => {
const params: GetAdGroupSuggestedKeywordsParams = {
maxNumSuggestions: 1,
adStateFilter: [AdGroupStateEnum.ENABLED, AdGroupStateEnum.PAUSED, AdGroupStateEnum.PAUSED],
adStateFilter: ['enabled', 'paused', 'archived'],
}
const res = await operation.getAdGroupSuggestedKeywords(AD_GROUP_ID, params)

Expand All @@ -46,7 +46,7 @@ describe('SponsoredProductsSuggestedKeywordsOperation', () => {
const params: GetAdGroupSuggestedKeywordsExtendedParams = {
maxNumSuggestions: 1000,
suggestBids: SuggestBidsEnum.YES,
adStateFilter: [AdGroupStateEnum.ENABLED, AdGroupStateEnum.PAUSED, AdGroupStateEnum.PAUSED],
adStateFilter: ['enabled', 'paused', 'archived'],
}
const res = await operation.getAdGroupSuggestedKeywordsExtended(AD_GROUP_ID, params)

Expand Down

0 comments on commit 2bbe4a8

Please sign in to comment.