import {z} from 'zod' export type CommonEnablingState = 'UNSPECIFIED' | 'ENABLED' | 'DISABLED'; export type AudienceTargetingConditionPlacementReason = 'UNKNOWN_PLACEMENT_REASON' | 'REASON_BRAND_SAFETY' | 'REASON_PERFORMANCE_IMPROVEMENT' | 'REASON_AGE_RESTRICTION' | 'REASON_FRAUD' | 'REASON_OWN_APP_CROSS_PROMOTION_BLOCKING' | 'REASON_NOT_OPERATING_IN_A_SPECIFIC_LOCATION' | 'REASON_INCREMENTALITY_TESTING' | 'REASON_OTHER'; export type AdcloudcommonCreativeType = 'UNKNOWN_CREATIVE_TYPE' | 'IMAGE_BANNER' | 'IMAGE_INTERSTITIAL' | 'VIDEO_BANNER' | 'VIDEO_INTERSTITIAL' | 'NATIVE_LOGO' | 'NATIVE_VIDEO' | 'NATIVE_IMAGE' | 'CUSTOM_HTML_BANNER' | 'CUSTOM_HTML_INTERSTITIAL' | 'TEMPLATE_HTML_BANNER' | 'TEMPLATE_HTML_INTERSTITIAL' | 'RICH_CUSTOM_HTML_BANNER' | 'RICH_CUSTOM_HTML_INTERSTITIAL' | 'DYNAMIC_HTML_BANNER' | 'DYNAMIC_HTML_INTERSTITIAL'; export type CommonLatLng = {latitude?: number | undefined, longitude?: number | undefined}; export type CommonCircle = {center?: CommonLatLng | undefined, radius?: number | undefined}; export type CommonAdExchange = 'UNKNOWN_AD_EXCHANGE' | 'MOPUB' | 'ADX' | 'ADMIXER' | 'SMAATO' | 'RUBICON' | 'EXELBID' | 'BRIGHTROLL' | 'CAULYRTB' | 'ADLIB' | 'ORION' | 'MOLOCO' | 'ADOP' | 'APPLOVIN' | 'FYBER' | 'SAMSUNG' | 'ADCOLONY' | 'POLYMORPH' | 'CHARTBOOST' | 'MANPLUS' | 'KAKAO' | 'UNITY' | 'FYBERCORE' | 'ADGENERATION' | 'SAMSUNGPAY' | 'NHN' | 'ADPOPCORN' | 'OPENX' | 'VUNGLE' | 'ADALPHA' | 'BYTEDANCE' | 'NAVER' | 'INMOBI' | 'SIGNALPLAY' | 'ACUITY' | 'IRONSOURCE' | 'PUBMATIC' | 'BAIDU' | 'FLUCT' | 'FIVE' | 'APPODEAL' | 'ADPIE' | 'MOBILITYWARE' | 'TPMN' | 'PUBNATIVE' | 'TAPJOY' | 'MOMENTO' | 'BIDENCE' | 'APS' | 'INDEX' | 'IQZONE' | 'STARTIO' | 'FLOWER' | 'ONESTORE' | 'NIMBUS' | 'AEQUUS' | 'MCTV' | 'MINTEGRAL' | 'MOLOCO_SDK_APPLOVIN' | 'MOLOCO_SDK_IRONSOURCE' | 'PANGLE' | 'MAGNITE' | 'MOLOCO_SDK_X3MADS' | 'FREE_WHEEL' | 'MOLOCO_SDK_ADMOB' | 'ADX_RTB' | 'XIAOMI' | 'MOLOCO_SDK_CREATIVE_TEST' | 'MOLOCO_SDK_MAX' | 'MOLOCO_SDK_LEVELPLAY' | 'NEXXEN' | 'MOLOCO_SDK_ADMOB_MEDIATION' | 'MOLOCO_SDK' | 'MOLOCO_SDK_IN_HOUSE_MEDIATION' | 'TABOOLA' | 'CRITEO' | 'MOLOCO_SDK_DIRECT_AD' | 'APX1' | 'DIRECT_AD' | 'BIGO' | 'CAS' | 'TUBI' | 'SPRINGSERVE' | 'PUBLICA'; export type CommonDeviceType = 'UNKNOWN_DEVICE_TYPE' | 'MOBILE' | 'PERSONAL_COMPUTER' | 'CONNECTED_TV' | 'HIGHEND_PHONE' | 'TABLET' | 'CONNECTED_DEVICE' | 'SET_TOP_BOX'; export type AdcloudcommonEventType = 'UNKNOWN_EVENT_TYPE' | 'BID_MADE' | 'BID_WON' | 'IMPRESSION' | 'IMPRESSION_EXTRA' | 'CLICK' | 'INSTALL' | 'CUSTOM'; export type AudienceTargetingConditionRecentCampaignActivityFilter = {event: AdcloudcommonEventType, campaign_id: string, last_n_days: number}; export type AudienceTargetingConditionLocationFilter = {cities?: Array | undefined, regions?: Array | undefined, zipcodes?: Array | undefined, geofences?: Array | undefined}; export type CommonGender = 'UNKNOWN_GENDER' | 'FEMALE' | 'MALE'; export type CommonDeviceOs = 'UNKNOWN_DEVICE_OS' | 'ANDROID' | 'IOS' | 'VERSATILE' | 'MOBILE_WEB' | 'MACOS' | 'WINDOWS' | 'NEXT_VERSATILE'; export type AudienceTargetingConditionDeviceOsFilter = {os: CommonDeviceOs, min_version?: string | undefined, max_version?: string | undefined}; export type AudienceTargetingConditionMediaChannelType = 'UNKNOWN_MEDIA_CHANNEL_TYPE' | 'APP' | 'WEB'; export type AudienceTargetingConditionNewUserFilter = {last_n_days: number}; export type CommonAdvertiserIdType = 'UNKNOWN_ADVERTISER_ID_TYPE' | 'ANDROID_IDFA' | 'IOS_IDFA' | 'GENERIC_USER_ID' | 'GENERIC_DEVICE_ID' | 'ANDROID_LAT_IDFA' | 'IOS_LAT_IDFA'; export type DspAudienceTargetingConditionVideoType = 'UNKNOWN_VIDEO_TYPE' | 'REWARD_VIDEO' | 'NON_REWARD_VIDEO' | 'NON_VIDEO'; export type AdcloudcommonTimezonePolicy = 'UNKNOWN_TIME' | 'DEVICE_TIME' | 'UTC_TIME' | 'AD_ACCOUNT_TIME' | 'ADVERTISER_TIME'; export type AdcloudcommonInterval = {start?: number | undefined, end?: number | undefined}; export type AdcloudcommonDayOfWeek = 'UNKNOWN_DAY_OF_WEEK' | 'MON' | 'TUE' | 'WED' | 'THU' | 'FRI' | 'SAT' | 'SUN'; export type AudienceTargetingConditionWeeklyScheduleFilter = {timezone_policy?: AdcloudcommonTimezonePolicy | undefined, hour_range?: AdcloudcommonInterval | undefined, days: Array}; export type AdcloudcommonFloatingPointRange = {start?: number | undefined, end?: number | undefined}; export type CommonBannerApi = 'UNKNOWN_BANNER_API' | 'MRAID_2'; export type CommonTimeInterval = {start?: string | undefined, end?: string | undefined}; export type CommonAudienceData = {provider?: string | undefined, condition?: string | undefined}; export type CommonPostbackEventCount = {app_bundle?: string | undefined, range?: AdcloudcommonInterval | undefined, events?: Array | undefined}; export type CommonTagsThrottleCondition = {tags?: Array | undefined, throttle_rate?: number | undefined}; export type CommonDisplayManagerVersion = {min?: string | undefined, max?: string | undefined}; export type CommonTimeUnit = 'UNKNOWN_TIME_UNIT' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK'; export type CommonPostbackEventsCondition = {audiences?: Array | undefined, events?: Array | undefined, past_time_range?: AdcloudcommonInterval | undefined, past_time_range_unit?: CommonTimeUnit | undefined, range?: CommonTimeInterval | undefined, short_term_user_profile?: boolean | undefined, count_range?: AdcloudcommonInterval | undefined}; export type LocationSetZipCodeSet = {zipcodes?: Array | undefined, country?: string | undefined}; export type AudienceTargetingConditionLocationSet = {osm_ids?: Array | undefined, zipcodes?: Array | undefined}; export type AudienceTargetingConditionCoppaAcceptance = 'UNKNOWN_COPPA' | 'ACCEPT_COPPA_ONLY' | 'DENY_COPPA'; export type AudienceTargetingConditionSkanTraffic = 'UNKNOWN_SKAN' | 'TARGET_SKAN_ONLY' | 'TARGET_NON_SKAN'; export type CommonTimeDuration = {amount?: unknown | undefined, unit?: CommonTimeUnit | undefined}; export type CustomAudienceSetAppEvent = {product_id?: string | undefined, event?: string | undefined, sliding_window_duration?: CommonTimeDuration | undefined}; export type CustomAudienceSetApp = {product_id?: string | undefined, sliding_window_duration?: CommonTimeDuration | undefined}; export type CustomAudienceSetCustomAudienceCondition = {app_events?: Array | undefined, user_lists?: Array | undefined, apps?: Array | undefined}; export type AudienceTargetingConditionCustomAudienceSet = {include_having_all?: CustomAudienceSetCustomAudienceCondition | undefined, include_having_any?: CustomAudienceSetCustomAudienceCondition | undefined, exclude_having_all?: CustomAudienceSetCustomAudienceCondition | undefined, exclude_having_any?: CustomAudienceSetCustomAudienceCondition | undefined}; export type DspAudienceTargetingCondition = {allowed_countries?: Array | undefined, blocked_countries?: Array | undefined, placement_reasons?: Array | undefined, custom_placement_reason?: string | undefined, allowed_app_bundles?: Array | undefined, blocked_app_bundles?: Array | undefined, allowed_content_categories?: Array | undefined, blocked_content_categories?: Array | undefined, allowed_cities?: Array | undefined, blocked_cities?: Array | undefined, allowed_creative_types?: Array | undefined, blocked_creative_types?: Array | undefined, allowed_websites?: Array | undefined, blocked_websites?: Array | undefined, allowed_geofences?: Array | undefined, blocked_geofences?: Array | undefined, allowed_exchanges?: Array | undefined, blocked_exchanges?: Array | undefined, allowed_idfas?: Array | undefined, blocked_idfas?: Array | undefined, allowed_zipcodes?: Array | undefined, blocked_zipcodes?: Array | undefined, allowed_device_models?: Array | undefined, blocked_device_models?: Array | undefined, allowed_user_audience_tags?: Array | undefined, blocked_user_audience_tags?: Array | undefined, allowed_languages?: Array | undefined, blocked_languages?: Array | undefined, allowed_device_types?: Array | undefined, blocked_device_types?: Array | undefined, allowed_mostly_visited_countries?: Array | undefined, blocked_mostly_visited_countries?: Array | undefined, allowed_regions?: Array | undefined, blocked_regions?: Array | undefined, allowed_recent_campaign_activities?: Array | undefined, blocked_recent_campaign_activities?: Array | undefined, allowed_locations?: Array | undefined, blocked_locations?: Array | undefined, genders?: Array | undefined, connection_types?: Array | undefined, allowed_direct_deal_ids?: Array | undefined, blocked_direct_deal_ids?: Array | undefined, device_oses?: Array | undefined, media_channel_type?: AudienceTargetingConditionMediaChannelType | undefined, new_users?: AudienceTargetingConditionNewUserFilter | undefined, advertiser_id_types?: Array | undefined, allowed_video_types?: Array | undefined, blocked_video_types?: Array | undefined, weekly_schedules?: Array | undefined, allowed_gender_score?: AdcloudcommonFloatingPointRange | undefined, blocked_gender_score?: AdcloudcommonFloatingPointRange | undefined, allowed_ages?: Array | undefined, blocked_ages?: Array | undefined, allowed_ip_ranges?: Array | undefined, blocked_ip_ranges?: Array | undefined, allowed_device_carriers?: Array | undefined, blocked_device_carriers?: Array | undefined, allowed_keywords?: Array | undefined, blocked_keywords?: Array | undefined, user_buckets?: Array | undefined, allowed_ad_units?: Array | undefined, blocked_ad_units?: Array | undefined, allowed_placements?: Array | undefined, blocked_placements?: Array | undefined, allowed_banner_apis?: Array | undefined, blocked_banner_apis?: Array | undefined, schedule?: CommonTimeInterval | undefined, audience_data?: CommonAudienceData | undefined, allowed_apps_by_checksum?: Array | undefined, blocked_apps_by_checksum?: Array | undefined, allowed_postback_event_counts?: Array | undefined, auction_types?: Array | undefined, throttle_apt_tags?: CommonTagsThrottleCondition | undefined, allowed_dev_makes?: Array | undefined, blocked_dev_makes?: Array | undefined, display_manager_versions?: Array | undefined, allowed_audiences?: Array | undefined, blocked_audiences?: Array | undefined, allowed_postback_has_all_events_conditions?: Array | undefined, blocked_postback_has_all_events_conditions?: Array | undefined, allowed_postback_has_any_events_conditions?: Array | undefined, blocked_postback_has_any_events_conditions?: Array | undefined, allowed_location_set?: AudienceTargetingConditionLocationSet | undefined, blocked_location_set?: AudienceTargetingConditionLocationSet | undefined, allowed_apt_tags?: Array | undefined, blocked_apt_tags?: Array | undefined, coppa_acceptance?: AudienceTargetingConditionCoppaAcceptance | undefined, skan_traffic?: AudienceTargetingConditionSkanTraffic | undefined, contains_custom_audience?: boolean | undefined, custom_audience_set?: AudienceTargetingConditionCustomAudienceSet | undefined}; export type AdclouddspAudience = {shared_audience_target_ids?: Array | undefined, targeting_condition?: DspAudienceTargetingCondition | undefined}; export type AdclouddspAdCapper = {imp_interval?: CommonTimeDuration | undefined}; export type DspAdGroupAudienceExtension = {paired_ad_group_id?: string | undefined, is_secondary?: boolean | undefined}; export type DspAdGroup = {id?: string | undefined, title: string, campaign_id?: string | undefined, product_id?: string | undefined, ad_account_id?: string | undefined, experiment_id?: string | undefined, enabling_state?: CommonEnablingState | undefined, audience?: AdclouddspAudience | undefined, capper?: AdclouddspAdCapper | undefined, pricing_model_id?: string | undefined, creative_group_ids?: Array | undefined, user_buckets?: Array | undefined, audience_extension?: DspAdGroupAudienceExtension | undefined, created_at?: string | undefined, updated_at?: string | undefined, aud_size?: unknown | undefined, matchable_aud_size?: unknown | undefined, last_aud_size_computed_at?: string | undefined}; export type CreateApiCmV1AdGroupsArgs = {campaign_id: string, body: DspAdGroup}; export type CreateApiCmV1AdGroupsOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const commonEnablingState = z.enum(["UNSPECIFIED", "ENABLED", "DISABLED"]); export const audienceTargetingConditionPlacementReason = z.enum(["UNKNOWN_PLACEMENT_REASON", "REASON_BRAND_SAFETY", "REASON_PERFORMANCE_IMPROVEMENT", "REASON_AGE_RESTRICTION", "REASON_FRAUD", "REASON_OWN_APP_CROSS_PROMOTION_BLOCKING", "REASON_NOT_OPERATING_IN_A_SPECIFIC_LOCATION", "REASON_INCREMENTALITY_TESTING", "REASON_OTHER"]); export const adcloudcommonCreativeType = z.enum(["UNKNOWN_CREATIVE_TYPE", "IMAGE_BANNER", "IMAGE_INTERSTITIAL", "VIDEO_BANNER", "VIDEO_INTERSTITIAL", "NATIVE_LOGO", "NATIVE_VIDEO", "NATIVE_IMAGE", "CUSTOM_HTML_BANNER", "CUSTOM_HTML_INTERSTITIAL", "TEMPLATE_HTML_BANNER", "TEMPLATE_HTML_INTERSTITIAL", "RICH_CUSTOM_HTML_BANNER", "RICH_CUSTOM_HTML_INTERSTITIAL", "DYNAMIC_HTML_BANNER", "DYNAMIC_HTML_INTERSTITIAL"]); export const commonLatLng = z.object({latitude: z.number().optional(), longitude: z.number().optional()}); export const commonCircle = z.object({center: commonLatLng.optional(), radius: z.number().optional()}); export const commonAdExchange = z.enum(["UNKNOWN_AD_EXCHANGE", "MOPUB", "ADX", "ADMIXER", "SMAATO", "RUBICON", "EXELBID", "BRIGHTROLL", "CAULYRTB", "ADLIB", "ORION", "MOLOCO", "ADOP", "APPLOVIN", "FYBER", "SAMSUNG", "ADCOLONY", "POLYMORPH", "CHARTBOOST", "MANPLUS", "KAKAO", "UNITY", "FYBERCORE", "ADGENERATION", "SAMSUNGPAY", "NHN", "ADPOPCORN", "OPENX", "VUNGLE", "ADALPHA", "BYTEDANCE", "NAVER", "INMOBI", "SIGNALPLAY", "ACUITY", "IRONSOURCE", "PUBMATIC", "BAIDU", "FLUCT", "FIVE", "APPODEAL", "ADPIE", "MOBILITYWARE", "TPMN", "PUBNATIVE", "TAPJOY", "MOMENTO", "BIDENCE", "APS", "INDEX", "IQZONE", "STARTIO", "FLOWER", "ONESTORE", "NIMBUS", "AEQUUS", "MCTV", "MINTEGRAL", "MOLOCO_SDK_APPLOVIN", "MOLOCO_SDK_IRONSOURCE", "PANGLE", "MAGNITE", "MOLOCO_SDK_X3MADS", "FREE_WHEEL", "MOLOCO_SDK_ADMOB", "ADX_RTB", "XIAOMI", "MOLOCO_SDK_CREATIVE_TEST", "MOLOCO_SDK_MAX", "MOLOCO_SDK_LEVELPLAY", "NEXXEN", "MOLOCO_SDK_ADMOB_MEDIATION", "MOLOCO_SDK", "MOLOCO_SDK_IN_HOUSE_MEDIATION", "TABOOLA", "CRITEO", "MOLOCO_SDK_DIRECT_AD", "APX1", "DIRECT_AD", "BIGO", "CAS", "TUBI", "SPRINGSERVE", "PUBLICA"]); export const commonDeviceType = z.enum(["UNKNOWN_DEVICE_TYPE", "MOBILE", "PERSONAL_COMPUTER", "CONNECTED_TV", "HIGHEND_PHONE", "TABLET", "CONNECTED_DEVICE", "SET_TOP_BOX"]); export const adcloudcommonEventType = z.enum(["UNKNOWN_EVENT_TYPE", "BID_MADE", "BID_WON", "IMPRESSION", "IMPRESSION_EXTRA", "CLICK", "INSTALL", "CUSTOM"]); export const audienceTargetingConditionRecentCampaignActivityFilter = z.object({event: adcloudcommonEventType, campaign_id: z.string(), last_n_days: z.number().int()}); export const audienceTargetingConditionLocationFilter = z.object({cities: z.array(z.string()).optional(), regions: z.array(z.string()).optional(), zipcodes: z.array(z.string()).optional(), geofences: z.array(commonCircle).optional()}); export const commonGender = z.enum(["UNKNOWN_GENDER", "FEMALE", "MALE"]); export const commonDeviceOs = z.enum(["UNKNOWN_DEVICE_OS", "ANDROID", "IOS", "VERSATILE", "MOBILE_WEB", "MACOS", "WINDOWS", "NEXT_VERSATILE"]); export const audienceTargetingConditionDeviceOsFilter = z.object({os: commonDeviceOs, min_version: z.string().optional(), max_version: z.string().optional()}); export const audienceTargetingConditionMediaChannelType = z.enum(["UNKNOWN_MEDIA_CHANNEL_TYPE", "APP", "WEB"]); export const audienceTargetingConditionNewUserFilter = z.object({last_n_days: z.number().int()}); export const commonAdvertiserIdType = z.enum(["UNKNOWN_ADVERTISER_ID_TYPE", "ANDROID_IDFA", "IOS_IDFA", "GENERIC_USER_ID", "GENERIC_DEVICE_ID", "ANDROID_LAT_IDFA", "IOS_LAT_IDFA"]); export const dspAudienceTargetingConditionVideoType = z.enum(["UNKNOWN_VIDEO_TYPE", "REWARD_VIDEO", "NON_REWARD_VIDEO", "NON_VIDEO"]); export const adcloudcommonTimezonePolicy = z.enum(["UNKNOWN_TIME", "DEVICE_TIME", "UTC_TIME", "AD_ACCOUNT_TIME", "ADVERTISER_TIME"]); export const adcloudcommonInterval = z.object({start: z.number().int().optional(), end: z.number().int().optional()}); export const adcloudcommonDayOfWeek = z.enum(["UNKNOWN_DAY_OF_WEEK", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]); export const audienceTargetingConditionWeeklyScheduleFilter = z.object({timezone_policy: adcloudcommonTimezonePolicy.optional(), hour_range: adcloudcommonInterval.optional(), days: z.array(adcloudcommonDayOfWeek)}); export const adcloudcommonFloatingPointRange = z.object({start: z.number().optional(), end: z.number().optional()}); export const commonBannerApi = z.enum(["UNKNOWN_BANNER_API", "MRAID_2"]); export const commonTimeInterval = z.object({start: z.string().optional(), end: z.string().optional()}); export const commonAudienceData = z.object({provider: z.string().optional(), condition: z.string().optional()}); export const commonPostbackEventCount = z.object({app_bundle: z.string().optional(), range: adcloudcommonInterval.optional(), events: z.array(z.string()).optional()}); export const commonTagsThrottleCondition = z.object({tags: z.array(z.string()).optional(), throttle_rate: z.number().optional()}); export const commonDisplayManagerVersion = z.object({min: z.string().optional(), max: z.string().optional()}); export const commonTimeUnit = z.enum(["UNKNOWN_TIME_UNIT", "MINUTE", "HOUR", "DAY", "WEEK"]); export const commonPostbackEventsCondition = z.object({audiences: z.array(z.string()).optional(), events: z.array(z.string()).optional(), past_time_range: adcloudcommonInterval.optional(), past_time_range_unit: commonTimeUnit.optional(), range: commonTimeInterval.optional(), short_term_user_profile: z.boolean().optional(), count_range: adcloudcommonInterval.optional()}); export const locationSetZipCodeSet = z.object({zipcodes: z.array(z.string()).optional(), country: z.string().optional()}); export const audienceTargetingConditionLocationSet = z.object({osm_ids: z.array(z.string()).optional(), zipcodes: z.array(locationSetZipCodeSet).optional()}); export const audienceTargetingConditionCoppaAcceptance = z.enum(["UNKNOWN_COPPA", "ACCEPT_COPPA_ONLY", "DENY_COPPA"]); export const audienceTargetingConditionSkanTraffic = z.enum(["UNKNOWN_SKAN", "TARGET_SKAN_ONLY", "TARGET_NON_SKAN"]); export const commonTimeDuration = z.object({amount: z.string().optional(), unit: commonTimeUnit.optional()}); export const customAudienceSetAppEvent = z.object({product_id: z.string().optional(), event: z.string().optional(), sliding_window_duration: commonTimeDuration.optional()}); export const customAudienceSetApp = z.object({product_id: z.string().optional(), sliding_window_duration: commonTimeDuration.optional()}); export const customAudienceSetCustomAudienceCondition = z.object({app_events: z.array(customAudienceSetAppEvent).optional(), user_lists: z.array(z.string()).optional(), apps: z.array(customAudienceSetApp).optional()}); export const audienceTargetingConditionCustomAudienceSet = z.object({include_having_all: customAudienceSetCustomAudienceCondition.optional(), include_having_any: customAudienceSetCustomAudienceCondition.optional(), exclude_having_all: customAudienceSetCustomAudienceCondition.optional(), exclude_having_any: customAudienceSetCustomAudienceCondition.optional()}); export const dspAudienceTargetingCondition = z.object({allowed_countries: z.array(z.string()).optional(), blocked_countries: z.array(z.string()).optional(), placement_reasons: z.array(audienceTargetingConditionPlacementReason).optional(), custom_placement_reason: z.string().optional(), allowed_app_bundles: z.array(z.string()).optional(), blocked_app_bundles: z.array(z.string()).optional(), allowed_content_categories: z.array(z.string()).optional(), blocked_content_categories: z.array(z.string()).optional(), allowed_cities: z.array(z.string()).optional(), blocked_cities: z.array(z.string()).optional(), allowed_creative_types: z.array(adcloudcommonCreativeType).optional(), blocked_creative_types: z.array(adcloudcommonCreativeType).optional(), allowed_websites: z.array(z.string()).optional(), blocked_websites: z.array(z.string()).optional(), allowed_geofences: z.array(commonCircle).optional(), blocked_geofences: z.array(commonCircle).optional(), allowed_exchanges: z.array(commonAdExchange).optional(), blocked_exchanges: z.array(commonAdExchange).optional(), allowed_idfas: z.array(z.string()).optional(), blocked_idfas: z.array(z.string()).optional(), allowed_zipcodes: z.array(z.string()).optional(), blocked_zipcodes: z.array(z.string()).optional(), allowed_device_models: z.array(z.string()).optional(), blocked_device_models: z.array(z.string()).optional(), allowed_user_audience_tags: z.array(z.string()).optional(), blocked_user_audience_tags: z.array(z.string()).optional(), allowed_languages: z.array(z.string()).optional(), blocked_languages: z.array(z.string()).optional(), allowed_device_types: z.array(commonDeviceType).optional(), blocked_device_types: z.array(commonDeviceType).optional(), allowed_mostly_visited_countries: z.array(z.string()).optional(), blocked_mostly_visited_countries: z.array(z.string()).optional(), allowed_regions: z.array(z.string()).optional(), blocked_regions: z.array(z.string()).optional(), allowed_recent_campaign_activities: z.array(audienceTargetingConditionRecentCampaignActivityFilter).optional(), blocked_recent_campaign_activities: z.array(audienceTargetingConditionRecentCampaignActivityFilter).optional(), allowed_locations: z.array(audienceTargetingConditionLocationFilter).optional(), blocked_locations: z.array(audienceTargetingConditionLocationFilter).optional(), genders: z.array(commonGender).optional(), connection_types: z.array(z.string()).optional(), allowed_direct_deal_ids: z.array(z.string()).optional(), blocked_direct_deal_ids: z.array(z.string()).optional(), device_oses: z.array(audienceTargetingConditionDeviceOsFilter).optional(), media_channel_type: audienceTargetingConditionMediaChannelType.optional(), new_users: audienceTargetingConditionNewUserFilter.optional(), advertiser_id_types: z.array(commonAdvertiserIdType).optional(), allowed_video_types: z.array(dspAudienceTargetingConditionVideoType).optional(), blocked_video_types: z.array(dspAudienceTargetingConditionVideoType).optional(), weekly_schedules: z.array(audienceTargetingConditionWeeklyScheduleFilter).optional(), allowed_gender_score: adcloudcommonFloatingPointRange.optional(), blocked_gender_score: adcloudcommonFloatingPointRange.optional(), allowed_ages: z.array(adcloudcommonInterval).optional(), blocked_ages: z.array(adcloudcommonInterval).optional(), allowed_ip_ranges: z.array(z.string()).optional(), blocked_ip_ranges: z.array(z.string()).optional(), allowed_device_carriers: z.array(z.string()).optional(), blocked_device_carriers: z.array(z.string()).optional(), allowed_keywords: z.array(z.string()).optional(), blocked_keywords: z.array(z.string()).optional(), user_buckets: z.array(adcloudcommonInterval).optional(), allowed_ad_units: z.array(z.string()).optional(), blocked_ad_units: z.array(z.string()).optional(), allowed_placements: z.array(z.string()).optional(), blocked_placements: z.array(z.string()).optional(), allowed_banner_apis: z.array(commonBannerApi).optional(), blocked_banner_apis: z.array(commonBannerApi).optional(), schedule: commonTimeInterval.optional(), audience_data: commonAudienceData.optional(), allowed_apps_by_checksum: z.array(z.string()).optional(), blocked_apps_by_checksum: z.array(z.string()).optional(), allowed_postback_event_counts: z.array(commonPostbackEventCount).optional(), auction_types: z.array(z.string()).optional(), throttle_apt_tags: commonTagsThrottleCondition.optional(), allowed_dev_makes: z.array(z.string()).optional(), blocked_dev_makes: z.array(z.string()).optional(), display_manager_versions: z.array(commonDisplayManagerVersion).optional(), allowed_audiences: z.array(z.string()).optional(), blocked_audiences: z.array(z.string()).optional(), allowed_postback_has_all_events_conditions: z.array(commonPostbackEventsCondition).optional(), blocked_postback_has_all_events_conditions: z.array(commonPostbackEventsCondition).optional(), allowed_postback_has_any_events_conditions: z.array(commonPostbackEventsCondition).optional(), blocked_postback_has_any_events_conditions: z.array(commonPostbackEventsCondition).optional(), allowed_location_set: audienceTargetingConditionLocationSet.optional(), blocked_location_set: audienceTargetingConditionLocationSet.optional(), allowed_apt_tags: z.array(z.string()).optional(), blocked_apt_tags: z.array(z.string()).optional(), coppa_acceptance: audienceTargetingConditionCoppaAcceptance.optional(), skan_traffic: audienceTargetingConditionSkanTraffic.optional(), contains_custom_audience: z.boolean().optional(), custom_audience_set: audienceTargetingConditionCustomAudienceSet.optional()}); export const adclouddspAudience = z.object({shared_audience_target_ids: z.array(z.string()).optional(), targeting_condition: dspAudienceTargetingCondition.optional()}); export const adclouddspAdCapper = z.object({imp_interval: commonTimeDuration.optional()}); export const dspAdGroupAudienceExtension = z.object({paired_ad_group_id: z.string().optional(), is_secondary: z.boolean().optional()}); export const dspAdGroup = z.object({id: z.string().optional(), title: z.string(), campaign_id: z.string().optional(), product_id: z.string().optional(), ad_account_id: z.string().optional(), experiment_id: z.string().optional(), enabling_state: commonEnablingState.optional(), audience: adclouddspAudience.optional(), capper: adclouddspAdCapper.optional(), pricing_model_id: z.string().optional(), creative_group_ids: z.array(z.string()).optional(), user_buckets: z.array(adcloudcommonInterval).optional(), audience_extension: dspAdGroupAudienceExtension.optional(), created_at: z.string().optional(), updated_at: z.string().optional(), aud_size: z.string().optional(), matchable_aud_size: z.string().optional(), last_aud_size_computed_at: z.string().optional()}); export const messagesCreateAdGroupResponse = z.object({ad_group: dspAdGroup.optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Create a new AdGroup. * * POST /cm/v1/ad-groups */ export const createApiCmV1AdGroups = async (args: CreateApiCmV1AdGroupsArgs, options?: CreateApiCmV1AdGroupsOptions) => { const {baseUrl = "https://api.moloco.cloud", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.campaign_id != null) query.append("campaign_id", String(args.campaign_id)) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/cm/v1/ad-groups${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(messagesCreateAdGroupResponse, await res.json()) };