Skip to content

Commit

Permalink
feat: change enums of draft module to use union string
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyentoanit committed Apr 20, 2020
1 parent fb1fa27 commit 8356e9c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
9 changes: 3 additions & 6 deletions src/operations/drafts/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as t from 'io-ts'
import { ListPagination, createEnumType } from '../commons/types'
import { ListPagination } from '../commons/types'
import { PortfolioId } from '../portfolios/types'
import {
KeywordMatchType,
Expand All @@ -13,11 +13,8 @@ export type SponsoredBrandsDraftCampaignId = t.TypeOf<typeof SponsoredBrandsDraf
export const SponsoredBrandsDraftCampaignName = t.string
export type SponsoredBrandsDraftCampaignName = t.TypeOf<typeof SponsoredBrandsDraftCampaignName>

export enum BudgetTypeEnum {
LIFETIME = 'lifetime',
DAILY = 'daily',
}
export const BudgetType = createEnumType<BudgetTypeEnum>(BudgetTypeEnum)
export const BudgetType = t.union([t.literal('lifetime'), t.literal('daily')])
export type BudgetType = t.TypeOf<typeof BudgetType>

const SponsoredBrandsCreative = t.strict({
/**
Expand Down
4 changes: 2 additions & 2 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CampaignBiddingAdjustmentsPredicateEnum } from '../src/operations/biddi
import { CampaignBiddingStrategyEnum } from '../src/operations/bidding/campaign-bidding-strategy'
import * as biddingEnums from '../src/operations/bidding/types'
import * as campaignEnums from '../src/operations/campaigns/types'
import { BudgetTypeEnum } from '../src/operations/drafts/types'
import { BudgetType } from '../src/operations/drafts/types'
import * as keywordEnum from '../src/operations/keywords/types'
import * as portfolioEnum from '../src/operations/portfolios/types'
import * as productAdsEnum from '../src/operations/product-ads/types'
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('index', () => {

describe('draft', () => {
it('should export all enums', () => {
expect(index.BudgetTypeEnum).toEqual(BudgetTypeEnum)
expect(index.BudgetType).toEqual(BudgetType)
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { OperationProvider } from '../../../src'
import { SponsoredBrandsDraftsOperation } from '../../../src/operations/drafts/sponsored-brands-drafts-operation'
import {
SponsoredBrandsDraftCampaign,
BudgetTypeEnum,
SponsoredBrandsListDraftCampaignRequest,
SponsoredBrandsDraftCampaignId,
} from '../../../src/operations/drafts/types'
Expand Down Expand Up @@ -44,7 +43,7 @@ describe.skip('SponsoredBrandsDraftsOperation', () => {
{
name: DRAFT_CAMPAIGN_NAME,
budget: 1,
budgetType: BudgetTypeEnum.LIFETIME,
budgetType: 'lifetime',
startDate: '20201001',
endDate: '20201031',
bidOptimization: true,
Expand Down Expand Up @@ -90,7 +89,7 @@ describe.skip('SponsoredBrandsDraftsOperation', () => {
draftCampaignId: DRAFT_CAMPAIGN_ID,
name: DRAFT_CAMPAIGN_NAME,
budget: 1,
budgetType: BudgetTypeEnum.LIFETIME,
budgetType: 'lifetime',
startDate: '20201001',
endDate: '20201031',
bidOptimization: true,
Expand Down

0 comments on commit 8356e9c

Please sign in to comment.