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

import * as z from "zod";
import { remap as remap$ } from "../../../lib/primitives.js";

export const GetPinServerList = [
  "https://plex.tv/api/v2",
] as const;

export type GetPinGlobals = {
  /**
   * An opaque identifier unique to the client (UUID, serial number, or other unique device ID)
   */
  clientID?: string | undefined;
  /**
   * The name of the client application. (Plex Web, Plex Media Server, etc.)
   */
  clientName?: string | undefined;
  /**
   * A relatively friendly name for the client device
   */
  deviceNickname?: string | undefined;
  /**
   * The version of the client application.
   */
  clientVersion?: string | undefined;
  /**
   * The platform of the client application.
   */
  platform?: string | undefined;
};

export type GetPinRequest = {
  /**
   * Determines the kind of code returned by the API call
   *
   * @remarks
   * Strong codes are used for Pin authentication flows
   * Non-Strong codes are used for `Plex.tv/link`
   */
  strong?: boolean | undefined;
  /**
   * An opaque identifier unique to the client (UUID, serial number, or other unique device ID)
   */
  clientID?: string | undefined;
  /**
   * The name of the client application. (Plex Web, Plex Media Server, etc.)
   */
  clientName?: string | undefined;
  /**
   * A relatively friendly name for the client device
   */
  deviceNickname?: string | undefined;
  /**
   * The version of the client application.
   */
  clientVersion?: string | undefined;
  /**
   * The platform of the client application.
   */
  platform?: string | undefined;
};

/**
 * Geo location data
 */
export type GeoData = {
  /**
   * The ISO 3166-1 alpha-2 code of the country.
   */
  code: string;
  /**
   * The continent code where the country is located.
   */
  continentCode: string;
  /**
   * The official name of the country.
   */
  country: string;
  /**
   * The name of the city.
   */
  city: string;
  /**
   * Indicates if the country is a member of the European Union.
   */
  europeanUnionMember?: boolean | undefined;
  /**
   * The time zone of the country.
   */
  timeZone: string;
  /**
   * The postal code of the location.
   */
  postalCode: string;
  /**
   * Indicates if the country has privacy restrictions.
   */
  inPrivacyRestrictedCountry?: boolean | undefined;
  /**
   * Indicates if the region has privacy restrictions.
   */
  inPrivacyRestrictedRegion?: boolean | undefined;
  /**
   * The name of the primary administrative subdivision.
   */
  subdivisions: string;
  /**
   * The geographical coordinates (latitude, longitude) of the location.
   */
  coordinates: string;
};

/**
 * Requests a new pin id used in the authentication flow
 */
export type GetPinAuthPinContainer = {
  id: number;
  code: string;
  product: string;
  trusted?: boolean | undefined;
  qr: string;
  /**
   * The X-Client-Identifier used in the request
   */
  clientIdentifier: string;
  /**
   * Geo location data
   */
  location: GeoData;
  /**
   * The number of seconds this pin expires, by default 900 seconds
   */
  expiresIn?: number | undefined;
  createdAt: Date;
  expiresAt: Date;
  authToken?: string | null | undefined;
  newRegistration?: any | null | undefined;
};

export type GetPinResponse = {
  /**
   * 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;
  /**
   * Requests a new pin id used in the authentication flow
   */
  authPinContainer?: GetPinAuthPinContainer | undefined;
};

/** @internal */
export const GetPinGlobals$inboundSchema: z.ZodType<
  GetPinGlobals,
  z.ZodTypeDef,
  unknown
> = z.object({
  ClientID: z.string().optional(),
  ClientName: z.string().optional(),
  DeviceNickname: z.string().optional(),
  ClientVersion: z.string().optional(),
  Platform: z.string().optional(),
}).transform((v) => {
  return remap$(v, {
    "ClientID": "clientID",
    "ClientName": "clientName",
    "DeviceNickname": "deviceNickname",
    "ClientVersion": "clientVersion",
    "Platform": "platform",
  });
});

/** @internal */
export type GetPinGlobals$Outbound = {
  ClientID?: string | undefined;
  ClientName?: string | undefined;
  DeviceNickname?: string | undefined;
  ClientVersion?: string | undefined;
  Platform?: string | undefined;
};

/** @internal */
export const GetPinGlobals$outboundSchema: z.ZodType<
  GetPinGlobals$Outbound,
  z.ZodTypeDef,
  GetPinGlobals
> = z.object({
  clientID: z.string().optional(),
  clientName: z.string().optional(),
  deviceNickname: z.string().optional(),
  clientVersion: z.string().optional(),
  platform: z.string().optional(),
}).transform((v) => {
  return remap$(v, {
    clientID: "ClientID",
    clientName: "ClientName",
    deviceNickname: "DeviceNickname",
    clientVersion: "ClientVersion",
    platform: "Platform",
  });
});

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

/** @internal */
export const GetPinRequest$inboundSchema: z.ZodType<
  GetPinRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  strong: z.boolean().default(false),
  ClientID: z.string().optional(),
  ClientName: z.string().optional(),
  DeviceNickname: z.string().optional(),
  ClientVersion: z.string().optional(),
  Platform: z.string().optional(),
}).transform((v) => {
  return remap$(v, {
    "ClientID": "clientID",
    "ClientName": "clientName",
    "DeviceNickname": "deviceNickname",
    "ClientVersion": "clientVersion",
    "Platform": "platform",
  });
});

/** @internal */
export type GetPinRequest$Outbound = {
  strong: boolean;
  ClientID?: string | undefined;
  ClientName?: string | undefined;
  DeviceNickname?: string | undefined;
  ClientVersion?: string | undefined;
  Platform?: string | undefined;
};

/** @internal */
export const GetPinRequest$outboundSchema: z.ZodType<
  GetPinRequest$Outbound,
  z.ZodTypeDef,
  GetPinRequest
> = z.object({
  strong: z.boolean().default(false),
  clientID: z.string().optional(),
  clientName: z.string().optional(),
  deviceNickname: z.string().optional(),
  clientVersion: z.string().optional(),
  platform: z.string().optional(),
}).transform((v) => {
  return remap$(v, {
    clientID: "ClientID",
    clientName: "ClientName",
    deviceNickname: "DeviceNickname",
    clientVersion: "ClientVersion",
    platform: "Platform",
  });
});

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

/** @internal */
export const GeoData$inboundSchema: z.ZodType<GeoData, z.ZodTypeDef, unknown> =
  z.object({
    code: z.string(),
    continent_code: z.string(),
    country: z.string(),
    city: z.string(),
    european_union_member: z.boolean().default(false),
    time_zone: z.string(),
    postal_code: z.string(),
    in_privacy_restricted_country: z.boolean().default(false),
    in_privacy_restricted_region: z.boolean().default(false),
    subdivisions: z.string(),
    coordinates: z.string(),
  }).transform((v) => {
    return remap$(v, {
      "continent_code": "continentCode",
      "european_union_member": "europeanUnionMember",
      "time_zone": "timeZone",
      "postal_code": "postalCode",
      "in_privacy_restricted_country": "inPrivacyRestrictedCountry",
      "in_privacy_restricted_region": "inPrivacyRestrictedRegion",
    });
  });

/** @internal */
export type GeoData$Outbound = {
  code: string;
  continent_code: string;
  country: string;
  city: string;
  european_union_member: boolean;
  time_zone: string;
  postal_code: string;
  in_privacy_restricted_country: boolean;
  in_privacy_restricted_region: boolean;
  subdivisions: string;
  coordinates: string;
};

/** @internal */
export const GeoData$outboundSchema: z.ZodType<
  GeoData$Outbound,
  z.ZodTypeDef,
  GeoData
> = z.object({
  code: z.string(),
  continentCode: z.string(),
  country: z.string(),
  city: z.string(),
  europeanUnionMember: z.boolean().default(false),
  timeZone: z.string(),
  postalCode: z.string(),
  inPrivacyRestrictedCountry: z.boolean().default(false),
  inPrivacyRestrictedRegion: z.boolean().default(false),
  subdivisions: z.string(),
  coordinates: z.string(),
}).transform((v) => {
  return remap$(v, {
    continentCode: "continent_code",
    europeanUnionMember: "european_union_member",
    timeZone: "time_zone",
    postalCode: "postal_code",
    inPrivacyRestrictedCountry: "in_privacy_restricted_country",
    inPrivacyRestrictedRegion: "in_privacy_restricted_region",
  });
});

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

/** @internal */
export const GetPinAuthPinContainer$inboundSchema: z.ZodType<
  GetPinAuthPinContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.number().int(),
  code: z.string(),
  product: z.string(),
  trusted: z.boolean().default(false),
  qr: z.string(),
  clientIdentifier: z.string(),
  location: z.lazy(() => GeoData$inboundSchema),
  expiresIn: z.number().int().default(900),
  createdAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
  expiresAt: z.string().datetime({ offset: true }).transform(v => new Date(v)),
  authToken: z.nullable(z.string()).optional(),
  newRegistration: z.nullable(z.any()).optional(),
});

/** @internal */
export type GetPinAuthPinContainer$Outbound = {
  id: number;
  code: string;
  product: string;
  trusted: boolean;
  qr: string;
  clientIdentifier: string;
  location: GeoData$Outbound;
  expiresIn: number;
  createdAt: string;
  expiresAt: string;
  authToken?: string | null | undefined;
  newRegistration?: any | null | undefined;
};

/** @internal */
export const GetPinAuthPinContainer$outboundSchema: z.ZodType<
  GetPinAuthPinContainer$Outbound,
  z.ZodTypeDef,
  GetPinAuthPinContainer
> = z.object({
  id: z.number().int(),
  code: z.string(),
  product: z.string(),
  trusted: z.boolean().default(false),
  qr: z.string(),
  clientIdentifier: z.string(),
  location: z.lazy(() => GeoData$outboundSchema),
  expiresIn: z.number().int().default(900),
  createdAt: z.date().transform(v => v.toISOString()),
  expiresAt: z.date().transform(v => v.toISOString()),
  authToken: z.nullable(z.string()).optional(),
  newRegistration: z.nullable(z.any()).optional(),
});

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

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

/** @internal */
export type GetPinResponse$Outbound = {
  ContentType: string;
  StatusCode: number;
  RawResponse: never;
  AuthPinContainer?: GetPinAuthPinContainer$Outbound | undefined;
};

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

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