/*
 * 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";

export type Activity = {
  /**
   * Indicates whether this activity can be cancelled
   */
  cancellable?: boolean | undefined;
  /**
   * An object with additional values
   */
  context?: { [k: string]: any } | undefined;
  /**
   * A progress percentage.  A value of -1 means the progress is indeterminate
   */
  progress?: number | undefined;
  /**
   * An object with the response to the async opperation
   */
  response?: { [k: string]: any } | undefined;
  /**
   * A user-friendly sub-title for this activity
   */
  subtitle?: string | undefined;
  /**
   * A user-friendly title for this activity
   */
  title?: string | undefined;
  /**
   * The type of activity
   */
  type?: string | undefined;
  /**
   * The user this activity belongs to
   */
  userID?: number | undefined;
  /**
   * The ID of the activity
   */
  uuid?: string | undefined;
};

export type ListActivitiesMediaContainer = {
  activity?: Array<Activity> | undefined;
};

/**
 * OK
 */
export type ListActivitiesResponseBody = {
  mediaContainer?: ListActivitiesMediaContainer | undefined;
};

export type ListActivitiesResponse = {
  /**
   * 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
   */
  object?: ListActivitiesResponseBody | undefined;
};

/** @internal */
export const Activity$inboundSchema: z.ZodType<
  Activity,
  z.ZodTypeDef,
  unknown
> = z.object({
  cancellable: z.boolean().optional(),
  Context: z.record(z.any()).optional(),
  progress: z.number().optional(),
  Response: z.record(z.any()).optional(),
  subtitle: z.string().optional(),
  title: z.string().optional(),
  type: z.string().optional(),
  userID: z.number().int().optional(),
  uuid: z.string().optional(),
}).transform((v) => {
  return remap$(v, {
    "Context": "context",
    "Response": "response",
  });
});

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

/** @internal */
export const ListActivitiesMediaContainer$inboundSchema: z.ZodType<
  ListActivitiesMediaContainer,
  z.ZodTypeDef,
  unknown
> = z.object({
  Activity: z.array(z.lazy(() => Activity$inboundSchema)).optional(),
}).transform((v) => {
  return remap$(v, {
    "Activity": "activity",
  });
});

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

/** @internal */
export const ListActivitiesResponseBody$inboundSchema: z.ZodType<
  ListActivitiesResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  MediaContainer: z.lazy(() => ListActivitiesMediaContainer$inboundSchema)
    .optional(),
}).transform((v) => {
  return remap$(v, {
    "MediaContainer": "mediaContainer",
  });
});

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

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

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