/*
 * 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 UpdateItemsGlobals = {
  /**
   * 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 UpdateItemsRequest = {
  /**
   * 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 section
   */
  sectionId: string;
  type?: string | undefined;
  /**
   * The filters to apply to determine which items should be modified
   */
  filters?: string | undefined;
  /**
   * Set the specified field to a new value
   */
  fieldValue?: string | undefined;
  /**
   * Set the specified field to locked (or unlocked if set to 0)
   */
  fieldLocked?: shared.BoolInt | undefined;
  /**
   * This field is treated specially by albums or artists and may be used for implicit reparenting.
   */
  titleValue?: string | undefined;
  /**
   * Reparents set of Tracks or Albums - used with album.title.* in the case of tracks
   */
  artistTitleValue?: string | undefined;
  /**
   * Reparents set of Tracks or Albums - used with album.title.* in the case of tracks
   */
  artistTitleId?: string | undefined;
  /**
   * Reparents set of Tracks - Must be used in conjunction with artist.title.value or id
   */
  albumTitleValue?: string | undefined;
  /**
   * Reparents set of Tracks - Must be used in conjunction with artist.title.value or id
   */
  albumTitleId?: string | undefined;
  /**
   * Creates tag and associates it with each item in the set. - [idx] links this and the next parameters together
   */
  tagtypeIdxTagTag?: string | undefined;
  /**
   * Here `object` may be text/thumb/art/theme - Optionally used in conjunction with tag.tag, to update association info across the set.
   */
  tagtypeIdxTaggingObject?: string | undefined;
  /**
   * Remove comma separated tags from the set of items
   */
  tagtypeTagTag?: string | undefined;
  /**
   * Remove associations of this type (e.g. genre) from the set of items
   */
  tagtypeTag?: string | undefined;
};

export type UpdateItemsResponse = {
  /**
   * 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 type UpdateItemsRequest$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;
  sectionId: string;
  type?: string | undefined;
  filters?: string | undefined;
  "field.value"?: string | undefined;
  "field.locked": number;
  "title.value"?: string | undefined;
  "artist.title.value"?: string | undefined;
  "artist.title.id"?: string | undefined;
  "album.title.value"?: string | undefined;
  "album.title.id"?: string | undefined;
  "tagtype[idx].tag.tag"?: string | undefined;
  "tagtype[idx].tagging.object"?: string | undefined;
  "tagtype[].tag.tag-"?: string | undefined;
  "tagtype[].tag"?: string | undefined;
};

/** @internal */
export const UpdateItemsRequest$outboundSchema: z.ZodType<
  UpdateItemsRequest$Outbound,
  z.ZodTypeDef,
  UpdateItemsRequest
> = 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(),
  sectionId: z.string(),
  type: z.string().optional(),
  filters: z.string().optional(),
  fieldValue: z.string().optional(),
  fieldLocked: shared.BoolInt$outboundSchema.default(shared.BoolInt.False),
  titleValue: z.string().optional(),
  artistTitleValue: z.string().optional(),
  artistTitleId: z.string().optional(),
  albumTitleValue: z.string().optional(),
  albumTitleId: z.string().optional(),
  tagtypeIdxTagTag: z.string().optional(),
  tagtypeIdxTaggingObject: z.string().optional(),
  tagtypeTagTag: z.string().optional(),
  tagtypeTag: z.string().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",
    fieldValue: "field.value",
    fieldLocked: "field.locked",
    titleValue: "title.value",
    artistTitleValue: "artist.title.value",
    artistTitleId: "artist.title.id",
    albumTitleValue: "album.title.value",
    albumTitleId: "album.title.id",
    tagtypeIdxTagTag: "tagtype[idx].tag.tag",
    tagtypeIdxTaggingObject: "tagtype[idx].tagging.object",
    tagtypeTagTag: "tagtype[].tag.tag-",
    tagtypeTag: "tagtype[].tag",
  });
});

export function updateItemsRequestToJSON(
  updateItemsRequest: UpdateItemsRequest,
): string {
  return JSON.stringify(
    UpdateItemsRequest$outboundSchema.parse(updateItemsRequest),
  );
}

/** @internal */
export const UpdateItemsResponse$inboundSchema: z.ZodType<
  UpdateItemsResponse,
  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",
  });
});

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