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

import * as z from "zod";
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";

/**
 * Force overwriting of duplicate playlists.
 *
 * @remarks
 * By default, a playlist file uploaded with the same path will overwrite the existing playlist.
 * The `force` argument is used to disable overwriting.
 * If the `force` argument is set to 0, a new playlist will be created suffixed with the date and time that the duplicate was uploaded.
 */
export enum QueryParamForce {
  Zero = 0,
  One = 1,
}

export type UploadPlaylistRequest = {
  /**
   * absolute path to a directory on the server where m3u files are stored, or the absolute path to a playlist file on the server.
   *
   * @remarks
   * If the `path` argument is a directory, that path will be scanned for playlist files to be processed.
   * Each file in that directory creates a separate playlist, with a name based on the filename of the file that created it.
   * The GUID of each playlist is based on the filename.
   * If the `path` argument is a file, that file will be used to create a new playlist, with the name based on the filename of the file that created it.
   * The GUID of each playlist is based on the filename.
   */
  path: string;
  /**
   * Force overwriting of duplicate playlists.
   *
   * @remarks
   * By default, a playlist file uploaded with the same path will overwrite the existing playlist.
   * The `force` argument is used to disable overwriting.
   * If the `force` argument is set to 0, a new playlist will be created suffixed with the date and time that the duplicate was uploaded.
   */
  force: QueryParamForce;
  /**
   * Possibly the section ID to upload the playlist to, we are not certain.
   */
  sectionID?: number | undefined;
};

export type UploadPlaylistResponse = {
  /**
   * 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;
};

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

/** @internal */
export const QueryParamForce$outboundSchema: z.ZodNativeEnum<
  typeof QueryParamForce
> = QueryParamForce$inboundSchema;

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace QueryParamForce$ {
  /** @deprecated use `QueryParamForce$inboundSchema` instead. */
  export const inboundSchema = QueryParamForce$inboundSchema;
  /** @deprecated use `QueryParamForce$outboundSchema` instead. */
  export const outboundSchema = QueryParamForce$outboundSchema;
}

/** @internal */
export const UploadPlaylistRequest$inboundSchema: z.ZodType<
  UploadPlaylistRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  path: z.string(),
  force: QueryParamForce$inboundSchema,
  sectionID: z.number().int().default(1),
});

/** @internal */
export type UploadPlaylistRequest$Outbound = {
  path: string;
  force: number;
  sectionID: number;
};

/** @internal */
export const UploadPlaylistRequest$outboundSchema: z.ZodType<
  UploadPlaylistRequest$Outbound,
  z.ZodTypeDef,
  UploadPlaylistRequest
> = z.object({
  path: z.string(),
  force: QueryParamForce$outboundSchema,
  sectionID: z.number().int().default(1),
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace UploadPlaylistRequest$ {
  /** @deprecated use `UploadPlaylistRequest$inboundSchema` instead. */
  export const inboundSchema = UploadPlaylistRequest$inboundSchema;
  /** @deprecated use `UploadPlaylistRequest$outboundSchema` instead. */
  export const outboundSchema = UploadPlaylistRequest$outboundSchema;
  /** @deprecated use `UploadPlaylistRequest$Outbound` instead. */
  export type Outbound = UploadPlaylistRequest$Outbound;
}

export function uploadPlaylistRequestToJSON(
  uploadPlaylistRequest: UploadPlaylistRequest,
): string {
  return JSON.stringify(
    UploadPlaylistRequest$outboundSchema.parse(uploadPlaylistRequest),
  );
}

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

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

/** @internal */
export type UploadPlaylistResponse$Outbound = {
  ContentType: string;
  StatusCode: number;
  RawResponse: never;
};

/** @internal */
export const UploadPlaylistResponse$outboundSchema: z.ZodType<
  UploadPlaylistResponse$Outbound,
  z.ZodTypeDef,
  UploadPlaylistResponse
> = z.object({
  contentType: z.string(),
  statusCode: z.number().int(),
  rawResponse: z.instanceof(Response).transform(() => {
    throw new Error("Response cannot be serialized");
  }),
}).transform((v) => {
  return remap$(v, {
    contentType: "ContentType",
    statusCode: "StatusCode",
    rawResponse: "RawResponse",
  });
});

/**
 * @internal
 * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
 */
export namespace UploadPlaylistResponse$ {
  /** @deprecated use `UploadPlaylistResponse$inboundSchema` instead. */
  export const inboundSchema = UploadPlaylistResponse$inboundSchema;
  /** @deprecated use `UploadPlaylistResponse$outboundSchema` instead. */
  export const outboundSchema = UploadPlaylistResponse$outboundSchema;
  /** @deprecated use `UploadPlaylistResponse$Outbound` instead. */
  export type Outbound = UploadPlaylistResponse$Outbound;
}

export function uploadPlaylistResponseToJSON(
  uploadPlaylistResponse: UploadPlaylistResponse,
): string {
  return JSON.stringify(
    UploadPlaylistResponse$outboundSchema.parse(uploadPlaylistResponse),
  );
}

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