import {z} from 'zod' export type GoogleAdsSearchads360V23CommonUserListActionInfo = {conversionAction?: string | undefined, remarketingAction?: string | undefined}; export type GoogleAdsSearchads360V23CommonBasicUserListInfo = {actions?: Array | undefined}; export type GoogleAdsSearchads360V23CommonCrmBasedUserListInfo = {appId?: string | undefined, dataSourceType?: ('UNSPECIFIED' | 'UNKNOWN' | 'FIRST_PARTY' | 'THIRD_PARTY_CREDIT_BUREAU' | 'THIRD_PARTY_VOTER_FILE' | 'THIRD_PARTY_PARTNER_DATA') | undefined, uploadKeyType?: ('UNSPECIFIED' | 'UNKNOWN' | 'CONTACT_INFO' | 'CRM_ID' | 'MOBILE_ADVERTISING_ID') | undefined}; export type GoogleAdsSearchads360V23CommonLogicalUserListOperandInfo = {userList?: string | undefined}; export type GoogleAdsSearchads360V23CommonUserListLogicalRuleInfo = {operator?: ('UNSPECIFIED' | 'UNKNOWN' | 'ALL' | 'ANY' | 'NONE') | undefined, ruleOperands?: Array | undefined}; export type GoogleAdsSearchads360V23CommonLogicalUserListInfo = {rules?: Array | undefined}; export type GoogleAdsSearchads360V23CommonLookalikeUserListInfo = {countryCodes?: Array | undefined, expansionLevel?: ('UNSPECIFIED' | 'UNKNOWN' | 'NARROW' | 'BALANCED' | 'BROAD') | undefined, seedUserListIds?: Array | undefined}; export type GoogleAdsSearchads360V23CommonUserListDateRuleItemInfo = {offsetInDays?: unknown | undefined, operator?: ('UNSPECIFIED' | 'UNKNOWN' | 'EQUALS' | 'NOT_EQUALS' | 'BEFORE' | 'AFTER') | undefined, value?: string | undefined}; export type GoogleAdsSearchads360V23CommonUserListNumberRuleItemInfo = {operator?: ('UNSPECIFIED' | 'UNKNOWN' | 'GREATER_THAN' | 'GREATER_THAN_OR_EQUAL' | 'EQUALS' | 'NOT_EQUALS' | 'LESS_THAN' | 'LESS_THAN_OR_EQUAL') | undefined, value?: number | undefined}; export type GoogleAdsSearchads360V23CommonUserListStringRuleItemInfo = {operator?: ('UNSPECIFIED' | 'UNKNOWN' | 'CONTAINS' | 'EQUALS' | 'STARTS_WITH' | 'ENDS_WITH' | 'NOT_EQUALS' | 'NOT_CONTAINS' | 'NOT_STARTS_WITH' | 'NOT_ENDS_WITH') | undefined, value?: string | undefined}; export type GoogleAdsSearchads360V23CommonUserListRuleItemInfo = {dateRuleItem?: GoogleAdsSearchads360V23CommonUserListDateRuleItemInfo | undefined, name?: string | undefined, numberRuleItem?: GoogleAdsSearchads360V23CommonUserListNumberRuleItemInfo | undefined, stringRuleItem?: GoogleAdsSearchads360V23CommonUserListStringRuleItemInfo | undefined}; export type GoogleAdsSearchads360V23CommonUserListRuleItemGroupInfo = {ruleItems?: Array | undefined}; export type GoogleAdsSearchads360V23CommonUserListRuleInfo = {ruleItemGroups?: Array | undefined, ruleType?: ('UNSPECIFIED' | 'UNKNOWN' | 'AND_OF_ORS' | 'OR_OF_ANDS') | undefined}; export type GoogleAdsSearchads360V23CommonFlexibleRuleOperandInfo = {lookbackWindowDays?: unknown | undefined, rule?: GoogleAdsSearchads360V23CommonUserListRuleInfo | undefined}; export type GoogleAdsSearchads360V23CommonFlexibleRuleUserListInfo = {exclusiveOperands?: Array | undefined, inclusiveOperands?: Array | undefined, inclusiveRuleOperator?: ('UNSPECIFIED' | 'UNKNOWN' | 'AND' | 'OR') | undefined}; export type GoogleAdsSearchads360V23CommonRuleBasedUserListInfo = {flexibleRuleUserList?: GoogleAdsSearchads360V23CommonFlexibleRuleUserListInfo | undefined, prepopulationStatus?: ('UNSPECIFIED' | 'UNKNOWN' | 'REQUESTED' | 'FINISHED' | 'FAILED') | undefined}; export type GoogleAdsSearchads360V23CommonSimilarUserListInfo = {seedUserList?: string | undefined}; export type GoogleAdsSearchads360V23ResourcesUserList = {accessReason?: ('UNSPECIFIED' | 'UNKNOWN' | 'OWNED' | 'SHARED' | 'LICENSED' | 'SUBSCRIBED' | 'AFFILIATED') | undefined, accountUserListStatus?: ('UNSPECIFIED' | 'UNKNOWN' | 'ENABLED' | 'DISABLED') | undefined, basicUserList?: GoogleAdsSearchads360V23CommonBasicUserListInfo | undefined, closingReason?: ('UNSPECIFIED' | 'UNKNOWN' | 'UNUSED') | undefined, crmBasedUserList?: GoogleAdsSearchads360V23CommonCrmBasedUserListInfo | undefined, description?: string | undefined, eligibleForDisplay?: boolean | undefined, eligibleForSearch?: boolean | undefined, id?: unknown | undefined, integrationCode?: string | undefined, logicalUserList?: GoogleAdsSearchads360V23CommonLogicalUserListInfo | undefined, lookalikeUserList?: GoogleAdsSearchads360V23CommonLookalikeUserListInfo | undefined, matchRatePercentage?: number | undefined, membershipLifeSpan?: unknown | undefined, membershipStatus?: ('UNSPECIFIED' | 'UNKNOWN' | 'OPEN' | 'CLOSED') | undefined, name?: string | undefined, readOnly?: boolean | undefined, resourceName?: string | undefined, ruleBasedUserList?: GoogleAdsSearchads360V23CommonRuleBasedUserListInfo | undefined, similarUserList?: GoogleAdsSearchads360V23CommonSimilarUserListInfo | undefined, sizeForDisplay?: unknown | undefined, sizeForSearch?: unknown | undefined, sizeRangeForDisplay?: ('UNSPECIFIED' | 'UNKNOWN' | 'LESS_THAN_FIVE_HUNDRED' | 'LESS_THAN_ONE_THOUSAND' | 'ONE_THOUSAND_TO_TEN_THOUSAND' | 'TEN_THOUSAND_TO_FIFTY_THOUSAND' | 'FIFTY_THOUSAND_TO_ONE_HUNDRED_THOUSAND' | 'ONE_HUNDRED_THOUSAND_TO_THREE_HUNDRED_THOUSAND' | 'THREE_HUNDRED_THOUSAND_TO_FIVE_HUNDRED_THOUSAND' | 'FIVE_HUNDRED_THOUSAND_TO_ONE_MILLION' | 'ONE_MILLION_TO_TWO_MILLION' | 'TWO_MILLION_TO_THREE_MILLION' | 'THREE_MILLION_TO_FIVE_MILLION' | 'FIVE_MILLION_TO_TEN_MILLION' | 'TEN_MILLION_TO_TWENTY_MILLION' | 'TWENTY_MILLION_TO_THIRTY_MILLION' | 'THIRTY_MILLION_TO_FIFTY_MILLION' | 'OVER_FIFTY_MILLION') | undefined, sizeRangeForSearch?: ('UNSPECIFIED' | 'UNKNOWN' | 'LESS_THAN_FIVE_HUNDRED' | 'LESS_THAN_ONE_THOUSAND' | 'ONE_THOUSAND_TO_TEN_THOUSAND' | 'TEN_THOUSAND_TO_FIFTY_THOUSAND' | 'FIFTY_THOUSAND_TO_ONE_HUNDRED_THOUSAND' | 'ONE_HUNDRED_THOUSAND_TO_THREE_HUNDRED_THOUSAND' | 'THREE_HUNDRED_THOUSAND_TO_FIVE_HUNDRED_THOUSAND' | 'FIVE_HUNDRED_THOUSAND_TO_ONE_MILLION' | 'ONE_MILLION_TO_TWO_MILLION' | 'TWO_MILLION_TO_THREE_MILLION' | 'THREE_MILLION_TO_FIVE_MILLION' | 'FIVE_MILLION_TO_TEN_MILLION' | 'TEN_MILLION_TO_TWENTY_MILLION' | 'TWENTY_MILLION_TO_THIRTY_MILLION' | 'THIRTY_MILLION_TO_FIFTY_MILLION' | 'OVER_FIFTY_MILLION') | undefined, type?: ('UNSPECIFIED' | 'UNKNOWN' | 'REMARKETING' | 'LOGICAL' | 'EXTERNAL_REMARKETING' | 'RULE_BASED' | 'SIMILAR' | 'CRM_BASED' | 'LOOKALIKE') | undefined}; export type GoogleAdsSearchads360V23ServicesUserListOperation = {create?: GoogleAdsSearchads360V23ResourcesUserList | undefined, remove?: string | undefined, update?: GoogleAdsSearchads360V23ResourcesUserList | undefined, updateMask?: unknown | undefined}; export type GoogleAdsSearchads360V23ServicesMutateUserListsRequest = {operations?: Array | undefined, partialFailure?: boolean | undefined, validateOnly?: boolean | undefined}; export type CreateApiV23CustomersCustomersIdUserListsMutateArgs = {customersId: string, body: GoogleAdsSearchads360V23ServicesMutateUserListsRequest}; export type CreateApiV23CustomersCustomersIdUserListsMutateOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleRpcStatus = z.object({code: z.number().int().optional(), details: z.array(z.record(z.string(), z.unknown())).optional(), message: z.string().optional()}); export const googleAdsSearchads360V23ServicesMutateUserListResult = z.object({resourceName: z.string().optional()}); export const googleAdsSearchads360V23ServicesMutateUserListsResponse = z.object({partialFailureError: googleRpcStatus.optional(), results: z.array(googleAdsSearchads360V23ServicesMutateUserListResult).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 }; /** * Creates or updates user lists. Operation statuses are returned. List of thrown errors: [AuthenticationError]() [AuthorizationError]() [CollectionSizeError]() [DatabaseError]() [DistinctError]() [FieldError]() [FieldMaskError]() [HeaderError]() [InternalError]() [MutateError]() [NewResourceCreationError]() [NotAllowlistedError]() [NotEmptyError]() [OperationAccessDeniedError]() [QuotaError]() [RangeError]() [RequestError]() [StringFormatError]() [StringLengthError]() [UserListError]() * * POST /v23/customers/{customersId}/userLists:mutate */ export const createApiV23CustomersCustomersIdUserListsMutate = async (args: CreateApiV23CustomersCustomersIdUserListsMutateArgs, options?: CreateApiV23CustomersCustomersIdUserListsMutateOptions) => { const {baseUrl = "https://searchads360.googleapis.com", fetch: fetchFn = fetch, Oauth2, Oauth2c} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (Oauth2 !== undefined) headers.set('authorization', `Bearer ${Oauth2}`) if (Oauth2c !== undefined) headers.set('authorization', `Bearer ${Oauth2c}`) const url = `${baseUrl.replace(/\/+$/, '')}/v23/customers/${encodeURIComponent(String(args.customersId))}/userLists:mutate${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(googleAdsSearchads360V23ServicesMutateUserListsResponse, await res.json()) };