/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { remap as remap$ } from "../../../lib/primitives.js";
import { safeParse } from "../../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import * as shared from "../shared/index.js";

export type ModifyPlaylistGeneratorGlobals = {
  /**
   * Indicates the client accepts the indicated media types
   */
  accepts?: shared.Accepts | undefined;
  /**
   * An opaque identifier unique to the client
   */
  clientIdentifier?: string | undefined;
  /**
   * The name of the client product
   */
  product?: string | undefined;
  /**
   * The version of the client application
   */
  version?: string | undefined;
  /**
   * The platform of the client
   */
  platform?: string | undefined;
  /**
   * The version of the platform
   */
  platformVersion?: string | undefined;
  /**
   * A relatively friendly name for the client device
   */
  device?: string | undefined;
  /**
   * A potentially less friendly identifier for the device model
   */
  model?: string | undefined;
  /**
   * The device vendor
   */
  deviceVendor?: string | undefined;
  /**
   * A friendly name for the client
   */
  deviceName?: string | undefined;
  /**
   * The marketplace on which the client application is distributed
   */
  marketplace?: string | undefined;
};

export type ModifyPlaylistGeneratorLocation = {
  uri?: string | undefined;
};

export enum ModifyPlaylistGeneratorScope {
  All = "all",
  Count = "count",
}

export type ModifyPlaylistGeneratorPolicy = {
  value?: number | undefined;
  scope?: ModifyPlaylistGeneratorScope | undefined;
  unwatched?: shared.BoolInt | undefined;
};

/**
 * Note: OpenAPI cannot properly render this query parameter example ([See GHI](https://github.com/OAI/OpenAPI-Specification/issues/1706)).  It should be rendered as:
 *
 * @remarks
 *
 * Item[type]=42&Item[title]=Jack-Jack Attack&Item[target]=&Item[targetTagID]=1&Item[locationID]=-1&Item[Location][uri]=library://82503060-0d68-4603-b594-8b071d54819e/item//library/metadata/146&Item[Policy][scope]=all&Item[Policy][value]=&Item[Policy][unwatched]=0
 */
export type ModifyPlaylistGeneratorItem = {
  location?: ModifyPlaylistGeneratorLocation | undefined;
  locationID?: number | undefined;
  policy?: ModifyPlaylistGeneratorPolicy | undefined;
  target?: string | undefined;
  targetTagID?: number | undefined;
  title?: string | undefined;
  type?: number | undefined;
};

export type ModifyPlaylistGeneratorRequest = {
  /**
   * Indicates the client accepts the indicated media types
   */
  accepts?: shared.Accepts | undefined;
  /**
   * An opaque identifier unique to the client
   */
  clientIdentifier?: string | undefined;
  /**
   * The name of the client product
   */
  product?: string | undefined;
  /**
   * The version of the client application
   */
  version?: string | undefined;
  /**
   * The platform of the client
   */
  platform?: string | undefined;
  /**
   * The version of the platform
   */
  platformVersion?: string | undefined;
  /**
   * A relatively friendly name for the client device
   */
  device?: string | undefined;
  /**
   * A potentially less friendly identifier for the device model
   */
  model?: string | undefined;
  /**
   * The device vendor
   */
  deviceVendor?: string | undefined;
  /**
   * A friendly name for the client
   */
  deviceName?: string | undefined;
  /**
   * The marketplace on which the client application is distributed
   */
  marketplace?: string | undefined;
  /**
   * The ID of the playlist
   */
  playlistId: number;
  /**
   * The generator item ID to modify.
   */
  generatorId: number;
  /**
   * Note: OpenAPI cannot properly render this query parameter example ([See GHI](https://github.com/OAI/OpenAPI-Specification/issues/1706)).  It should be rendered as:
   *
   * @remarks
   *
   * Item[type]=42&Item[title]=Jack-Jack Attack&Item[target]=&Item[targetTagID]=1&Item[locationID]=-1&Item[Location][uri]=library://82503060-0d68-4603-b594-8b071d54819e/item//library/metadata/146&Item[Policy][scope]=all&Item[Policy][value]=&Item[Policy][unwatched]=0
   */
  item?: ModifyPlaylistGeneratorItem | undefined;
};

export type ModifyPlaylistGeneratorResponse = {
  /**
   * HTTP response content type for this operation
   */
  contentType: string;
  /**
   * HTTP response status code for this operation
   */
  statusCode: number;
  /**
   * Raw HTTP response; suitable for custom response parsing
   */
  rawResponse: Response;
  /**
   * OK
   */
  mediaContainerWithPlaylistMetadata?:
    | shared.MediaContainerWithPlaylistMetadata
    | undefined;
};

/** @internal */
export type ModifyPlaylistGeneratorLocation$Outbound = {
  uri?: string | undefined;
};

/** @internal */
export const ModifyPlaylistGeneratorLocation$outboundSchema: z.ZodType<
  ModifyPlaylistGeneratorLocation$Outbound,
  z.ZodTypeDef,
  ModifyPlaylistGeneratorLocation
> = z.object({
  uri: z.string().optional(),
});

export function modifyPlaylistGeneratorLocationToJSON(
  modifyPlaylistGeneratorLocation: ModifyPlaylistGeneratorLocation,
): string {
  return JSON.stringify(
    ModifyPlaylistGeneratorLocation$outboundSchema.parse(
      modifyPlaylistGeneratorLocation,
    ),
  );
}

/** @internal */
export const ModifyPlaylistGeneratorScope$outboundSchema: z.ZodNativeEnum<
  typeof ModifyPlaylistGeneratorScope
> = z.nativeEnum(ModifyPlaylistGeneratorScope);

/** @internal */
export type ModifyPlaylistGeneratorPolicy$Outbound = {
  value?: number | undefined;
  scope?: string | undefined;
  unwatched: number;
};

/** @internal */
export const ModifyPlaylistGeneratorPolicy$outboundSchema: z.ZodType<
  ModifyPlaylistGeneratorPolicy$Outbound,
  z.ZodTypeDef,
  ModifyPlaylistGeneratorPolicy
> = z.object({
  value: z.number().int().optional(),
  scope: ModifyPlaylistGeneratorScope$outboundSchema.optional(),
  unwatched: shared.BoolInt$outboundSchema.default(shared.BoolInt.False),
});

export function modifyPlaylistGeneratorPolicyToJSON(
  modifyPlaylistGeneratorPolicy: ModifyPlaylistGeneratorPolicy,
): string {
  return JSON.stringify(
    ModifyPlaylistGeneratorPolicy$outboundSchema.parse(
      modifyPlaylistGeneratorPolicy,
    ),
  );
}

/** @internal */
export type ModifyPlaylistGeneratorItem$Outbound = {
  Location?: ModifyPlaylistGeneratorLocation$Outbound | undefined;
  locationID?: number | undefined;
  Policy?: ModifyPlaylistGeneratorPolicy$Outbound | undefined;
  target?: string | undefined;
  targetTagID?: number | undefined;
  title?: string | undefined;
  type?: number | undefined;
};

/** @internal */
export const ModifyPlaylistGeneratorItem$outboundSchema: z.ZodType<
  ModifyPlaylistGeneratorItem$Outbound,
  z.ZodTypeDef,
  ModifyPlaylistGeneratorItem
> = z.object({
  location: z.lazy(() => ModifyPlaylistGeneratorLocation$outboundSchema)
    .optional(),
  locationID: z.number().int().optional(),
  policy: z.lazy(() => ModifyPlaylistGeneratorPolicy$outboundSchema).optional(),
  target: z.string().optional(),
  targetTagID: z.number().int().optional(),
  title: z.string().optional(),
  type: z.number().int().optional(),
}).transform((v) => {
  return remap$(v, {
    location: "Location",
    policy: "Policy",
  });
});

export function modifyPlaylistGeneratorItemToJSON(
  modifyPlaylistGeneratorItem: ModifyPlaylistGeneratorItem,
): string {
  return JSON.stringify(
    ModifyPlaylistGeneratorItem$outboundSchema.parse(
      modifyPlaylistGeneratorItem,
    ),
  );
}

/** @internal */
export type ModifyPlaylistGeneratorRequest$Outbound = {
  accepts: string;
  "Client-Identifier"?: string | undefined;
  Product?: string | undefined;
  Version?: string | undefined;
  Platform?: string | undefined;
  "Platform-Version"?: string | undefined;
  Device?: string | undefined;
  Model?: string | undefined;
  "Device-Vendor"?: string | undefined;
  "Device-Name"?: string | undefined;
  Marketplace?: string | undefined;
  playlistId: number;
  generatorId: number;
  Item?: ModifyPlaylistGeneratorItem$Outbound | undefined;
};

/** @internal */
export const ModifyPlaylistGeneratorRequest$outboundSchema: z.ZodType<
  ModifyPlaylistGeneratorRequest$Outbound,
  z.ZodTypeDef,
  ModifyPlaylistGeneratorRequest
> = z.object({
  accepts: shared.Accepts$outboundSchema.default(shared.Accepts.ApplicationXml),
  clientIdentifier: z.string().optional(),
  product: z.string().optional(),
  version: z.string().optional(),
  platform: z.string().optional(),
  platformVersion: z.string().optional(),
  device: z.string().optional(),
  model: z.string().optional(),
  deviceVendor: z.string().optional(),
  deviceName: z.string().optional(),
  marketplace: z.string().optional(),
  playlistId: z.number().int(),
  generatorId: z.number().int(),
  item: z.lazy(() => ModifyPlaylistGeneratorItem$outboundSchema).optional(),
}).transform((v) => {
  return remap$(v, {
    clientIdentifier: "Client-Identifier",
    product: "Product",
    version: "Version",
    platform: "Platform",
    platformVersion: "Platform-Version",
    device: "Device",
    model: "Model",
    deviceVendor: "Device-Vendor",
    deviceName: "Device-Name",
    marketplace: "Marketplace",
    item: "Item",
  });
});

export function modifyPlaylistGeneratorRequestToJSON(
  modifyPlaylistGeneratorRequest: ModifyPlaylistGeneratorRequest,
): string {
  return JSON.stringify(
    ModifyPlaylistGeneratorRequest$outboundSchema.parse(
      modifyPlaylistGeneratorRequest,
    ),
  );
}

/** @internal */
export const ModifyPlaylistGeneratorResponse$inboundSchema: z.ZodType<
  ModifyPlaylistGeneratorResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  ContentType: z.string(),
  StatusCode: z.number().int(),
  RawResponse: z.instanceof(Response),
  MediaContainerWithPlaylistMetadata: shared
    .MediaContainerWithPlaylistMetadata$inboundSchema.optional(),
}).transform((v) => {
  return remap$(v, {
    "ContentType": "contentType",
    "StatusCode": "statusCode",
    "RawResponse": "rawResponse",
    "MediaContainerWithPlaylistMetadata": "mediaContainerWithPlaylistMetadata",
  });
});

export function modifyPlaylistGeneratorResponseFromJSON(
  jsonString: string,
): SafeParseResult<ModifyPlaylistGeneratorResponse, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ModifyPlaylistGeneratorResponse$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ModifyPlaylistGeneratorResponse' from JSON`,
  );
}
