import {z} from 'zod' export type GoogleAdsSearchads360V23ResourcesAccountBudgetProposal = {accountBudget?: string | undefined, approvalDateTime?: string | undefined, approvedEndDateTime?: string | undefined, approvedEndTimeType?: ('UNSPECIFIED' | 'UNKNOWN' | 'NOW' | 'FOREVER') | undefined, approvedSpendingLimitMicros?: unknown | undefined, approvedSpendingLimitType?: ('UNSPECIFIED' | 'UNKNOWN' | 'INFINITE') | undefined, approvedStartDateTime?: string | undefined, billingSetup?: string | undefined, creationDateTime?: string | undefined, id?: unknown | undefined, proposalType?: ('UNSPECIFIED' | 'UNKNOWN' | 'CREATE' | 'UPDATE' | 'END' | 'REMOVE') | undefined, proposedEndDateTime?: string | undefined, proposedEndTimeType?: ('UNSPECIFIED' | 'UNKNOWN' | 'NOW' | 'FOREVER') | undefined, proposedName?: string | undefined, proposedNotes?: string | undefined, proposedPurchaseOrderNumber?: string | undefined, proposedSpendingLimitMicros?: unknown | undefined, proposedSpendingLimitType?: ('UNSPECIFIED' | 'UNKNOWN' | 'INFINITE') | undefined, proposedStartDateTime?: string | undefined, proposedStartTimeType?: ('UNSPECIFIED' | 'UNKNOWN' | 'NOW' | 'FOREVER') | undefined, resourceName?: string | undefined, status?: ('UNSPECIFIED' | 'UNKNOWN' | 'PENDING' | 'APPROVED_HELD' | 'APPROVED' | 'CANCELLED' | 'REJECTED') | undefined}; export type GoogleAdsSearchads360V23ServicesAccountBudgetProposalOperation = {create?: GoogleAdsSearchads360V23ResourcesAccountBudgetProposal | undefined, remove?: string | undefined, updateMask?: unknown | undefined}; export type GoogleAdsSearchads360V23ServicesMutateAccountBudgetProposalRequest = {operation?: GoogleAdsSearchads360V23ServicesAccountBudgetProposalOperation | undefined, validateOnly?: boolean | undefined}; export type CreateApiV23CustomersCustomersIdAccountBudgetProposalsMutateArgs = {customersId: string, body: GoogleAdsSearchads360V23ServicesMutateAccountBudgetProposalRequest}; export type CreateApiV23CustomersCustomersIdAccountBudgetProposalsMutateOptions = {baseUrl?: string | undefined, Oauth2?: string | undefined, Oauth2c?: string | undefined, fetch?: typeof fetch | undefined}; export const googleAdsSearchads360V23ServicesMutateAccountBudgetProposalResult = z.object({resourceName: z.string().optional()}); export const googleAdsSearchads360V23ServicesMutateAccountBudgetProposalResponse = z.object({result: googleAdsSearchads360V23ServicesMutateAccountBudgetProposalResult.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, updates, or removes account budget proposals. Operation statuses are returned. List of thrown errors: [AccountBudgetProposalError]() [AuthenticationError]() [AuthorizationError]() [DatabaseError]() [DateError]() [FieldError]() [FieldMaskError]() [HeaderError]() [InternalError]() [MutateError]() [QuotaError]() [RequestError]() [StringLengthError]() * * POST /v23/customers/{customersId}/accountBudgetProposals:mutate */ export const createApiV23CustomersCustomersIdAccountBudgetProposalsMutate = async (args: CreateApiV23CustomersCustomersIdAccountBudgetProposalsMutateArgs, options?: CreateApiV23CustomersCustomersIdAccountBudgetProposalsMutateOptions) => { 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))}/accountBudgetProposals: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(googleAdsSearchads360V23ServicesMutateAccountBudgetProposalResponse, await res.json()) };