/*
 * 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 GetTokenByPinIdServerList = [
  "https://plex.tv/api/v2",
] as const;

export type GetTokenByPinIdGlobals = {
  /**
   * 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 GetTokenByPinIdRequest = {
  /**
   * The PinID to retrieve an access token for
   */
  pinID: number;
  /**
   * 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 GetTokenByPinIdGeoData = {
  /**
   * 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;
};

/**
 * The Pin with a non-null authToken when it has been verified by the user
 */
export type GetTokenByPinIdAuthPinContainer = {
  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: GetTokenByPinIdGeoData;
  /**
   * 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 GetTokenByPinIdResponse = {
  /**
   * 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;
  /**
   * The Pin with a non-null authToken when it has been verified by the user
   */
  authPinContainer?: GetTokenByPinIdAuthPinContainer | undefined;
};

/** @internal */
export const GetTokenByPinIdGlobals$inboundSchema: z.ZodType<
  GetTokenByPinIdGlobals,
  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 GetTokenByPinIdGlobals$Outbound = {
  ClientID?: string | undefined;
  ClientName?: string | undefined;
  DeviceNickname?: string | undefined;
  ClientVersion?: string | undefined;
  Platform?: string | undefined;
};

/** @internal */
export const GetTokenByPinIdGlobals$outboundSchema: z.ZodType<
  GetTokenByPinIdGlobals$Outbound,
  z.ZodTypeDef,
  GetTokenByPinIdGlobals
> = 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 GetTokenByPinIdGlobals$ {
  /** @deprecated use `GetTokenByPinIdGlobals$inboundSchema` instead. */
  export const inboundSchema = GetTokenByPinIdGlobals$inboundSchema;
  /** @deprecated use `GetTokenByPinIdGlobals$outboundSchema` instead. */
  export const outboundSchema = GetTokenByPinIdGlobals$outboundSchema;
  /** @deprecated use `GetTokenByPinIdGlobals$Outbound` instead. */
  export type Outbound = GetTokenByPinIdGlobals$Outbound;
}

/** @internal */
export const GetTokenByPinIdRequest$inboundSchema: z.ZodType<
  GetTokenByPinIdRequest,
  z.ZodTypeDef,
  unknown
> = z.object({
  pinID: z.number().int(),
  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 GetTokenByPinIdRequest$Outbound = {
  pinID: number;
  ClientID?: string | undefined;
  ClientName?: string | undefined;
  DeviceNickname?: string | undefined;
  ClientVersion?: string | undefined;
  Platform?: string | undefined;
};

/** @internal */
export const GetTokenByPinIdRequest$outboundSchema: z.ZodType<
  GetTokenByPinIdRequest$Outbound,
  z.ZodTypeDef,
  GetTokenByPinIdRequest
> = z.object({
  pinID: z.number().int(),
  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 GetTokenByPinIdRequest$ {
  /** @deprecated use `GetTokenByPinIdRequest$inboundSchema` instead. */
  export const inboundSchema = GetTokenByPinIdRequest$inboundSchema;
  /** @deprecated use `GetTokenByPinIdRequest$outboundSchema` instead. */
  export const outboundSchema = GetTokenByPinIdRequest$outboundSchema;
  /** @deprecated use `GetTokenByPinIdRequest$Outbound` instead. */
  export type Outbound = GetTokenByPinIdRequest$Outbound;
}

/** @internal */
export const GetTokenByPinIdGeoData$inboundSchema: z.ZodType<
  GetTokenByPinIdGeoData,
  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 GetTokenByPinIdGeoData$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 GetTokenByPinIdGeoData$outboundSchema: z.ZodType<
  GetTokenByPinIdGeoData$Outbound,
  z.ZodTypeDef,
  GetTokenByPinIdGeoData
> = 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 GetTokenByPinIdGeoData$ {
  /** @deprecated use `GetTokenByPinIdGeoData$inboundSchema` instead. */
  export const inboundSchema = GetTokenByPinIdGeoData$inboundSchema;
  /** @deprecated use `GetTokenByPinIdGeoData$outboundSchema` instead. */
  export const outboundSchema = GetTokenByPinIdGeoData$outboundSchema;
  /** @deprecated use `GetTokenByPinIdGeoData$Outbound` instead. */
  export type Outbound = GetTokenByPinIdGeoData$Outbound;
}

/** @internal */
export const GetTokenByPinIdAuthPinContainer$inboundSchema: z.ZodType<
  GetTokenByPinIdAuthPinContainer,
  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(() => GetTokenByPinIdGeoData$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 GetTokenByPinIdAuthPinContainer$Outbound = {
  id: number;
  code: string;
  product: string;
  trusted: boolean;
  qr: string;
  clientIdentifier: string;
  location: GetTokenByPinIdGeoData$Outbound;
  expiresIn: number;
  createdAt: string;
  expiresAt: string;
  authToken?: string | null | undefined;
  newRegistration?: any | null | undefined;
};

/** @internal */
export const GetTokenByPinIdAuthPinContainer$outboundSchema: z.ZodType<
  GetTokenByPinIdAuthPinContainer$Outbound,
  z.ZodTypeDef,
  GetTokenByPinIdAuthPinContainer
> = 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(() => GetTokenByPinIdGeoData$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 GetTokenByPinIdAuthPinContainer$ {
  /** @deprecated use `GetTokenByPinIdAuthPinContainer$inboundSchema` instead. */
  export const inboundSchema = GetTokenByPinIdAuthPinContainer$inboundSchema;
  /** @deprecated use `GetTokenByPinIdAuthPinContainer$outboundSchema` instead. */
  export const outboundSchema = GetTokenByPinIdAuthPinContainer$outboundSchema;
  /** @deprecated use `GetTokenByPinIdAuthPinContainer$Outbound` instead. */
  export type Outbound = GetTokenByPinIdAuthPinContainer$Outbound;
}

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

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

/** @internal */
export const GetTokenByPinIdResponse$outboundSchema: z.ZodType<
  GetTokenByPinIdResponse$Outbound,
  z.ZodTypeDef,
  GetTokenByPinIdResponse
> = z.object({
  contentType: z.string(),
  statusCode: z.number().int(),
  rawResponse: z.instanceof(Response).transform(() => {
    throw new Error("Response cannot be serialized");
  }),
  authPinContainer: z.lazy(() => GetTokenByPinIdAuthPinContainer$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 GetTokenByPinIdResponse$ {
  /** @deprecated use `GetTokenByPinIdResponse$inboundSchema` instead. */
  export const inboundSchema = GetTokenByPinIdResponse$inboundSchema;
  /** @deprecated use `GetTokenByPinIdResponse$outboundSchema` instead. */
  export const outboundSchema = GetTokenByPinIdResponse$outboundSchema;
  /** @deprecated use `GetTokenByPinIdResponse$Outbound` instead. */
  export type Outbound = GetTokenByPinIdResponse$Outbound;
}
