/*
 * 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 AddSectionGlobals = {
  /**
   * 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 preferences for this section
 */
export type AddSectionPrefs = {};

export type AddSectionRequest = {
  /**
   * 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 name of the new section
   */
  name: string;
  /**
   * The type of library section
   */
  type: number;
  /**
   * The scanner this section should use
   */
  scanner?: string | undefined;
  /**
   * The agent this section should use for metadata
   */
  agent: string;
  /**
   * The agent group id for this section
   */
  metadataAgentProviderGroupId?: string | undefined;
  /**
   * The language of this section
   */
  language: string;
  /**
   * The locations on disk to add to this section
   */
  locations?: Array<string> | undefined;
  /**
   * The preferences for this section
   */
  prefs?: AddSectionPrefs | undefined;
  /**
   * If set, paths are relative to `Media Upload` path
   */
  relative?: shared.BoolInt | undefined;
  /**
   * If set, import media from iTunes.
   */
  importFromiTunes?: shared.BoolInt | undefined;
};

export type AddSectionResponse = {
  /**
   * 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
   */
  slashGetResponses200?: shared.SlashGetResponses200 | undefined;
};

/** @internal */
export type AddSectionPrefs$Outbound = {};

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

export function addSectionPrefsToJSON(
  addSectionPrefs: AddSectionPrefs,
): string {
  return JSON.stringify(AddSectionPrefs$outboundSchema.parse(addSectionPrefs));
}

/** @internal */
export type AddSectionRequest$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;
  name: string;
  type: number;
  scanner?: string | undefined;
  agent: string;
  metadataAgentProviderGroupId?: string | undefined;
  language: string;
  locations?: Array<string> | undefined;
  prefs?: AddSectionPrefs$Outbound | undefined;
  relative: number;
  importFromiTunes: number;
};

/** @internal */
export const AddSectionRequest$outboundSchema: z.ZodType<
  AddSectionRequest$Outbound,
  z.ZodTypeDef,
  AddSectionRequest
> = 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(),
  name: z.string(),
  type: z.number().int(),
  scanner: z.string().optional(),
  agent: z.string(),
  metadataAgentProviderGroupId: z.string().optional(),
  language: z.string(),
  locations: z.array(z.string()).optional(),
  prefs: z.lazy(() => AddSectionPrefs$outboundSchema).optional(),
  relative: shared.BoolInt$outboundSchema.default(shared.BoolInt.False),
  importFromiTunes: shared.BoolInt$outboundSchema.default(shared.BoolInt.False),
}).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",
  });
});

export function addSectionRequestToJSON(
  addSectionRequest: AddSectionRequest,
): string {
  return JSON.stringify(
    AddSectionRequest$outboundSchema.parse(addSectionRequest),
  );
}

/** @internal */
export const AddSectionResponse$inboundSchema: z.ZodType<
  AddSectionResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  ContentType: z.string(),
  StatusCode: z.number().int(),
  RawResponse: z.instanceof(Response),
  "slash-get-responses-200": shared.SlashGetResponses200$inboundSchema
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "ContentType": "contentType",
    "StatusCode": "statusCode",
    "RawResponse": "rawResponse",
    "slash-get-responses-200": "slashGetResponses200",
  });
});

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