// Rippling API Types

export interface RipplingConfig {
  apiKey?: string;
  accessToken?: string;
  baseUrl?: string;
}

export interface Employee {
  id: string;
  firstName: string;
  lastName: string;
  email: string;
  personalEmail?: string;
  phoneNumber?: string;
  employeeId?: string;
  department?: string;
  title?: string;
  manager?: string;
  managerId?: string;
  startDate?: string;
  employmentType?: string;
  status?: 'ACTIVE' | 'INACTIVE' | 'TERMINATED';
  workLocationId?: string;
  homeAddress?: Address;
  compensation?: Compensation;
  customFields?: Record<string, any>;
}

export interface Address {
  street1?: string;
  street2?: string;
  city?: string;
  state?: string;
  zipCode?: string;
  country?: string;
}

export interface Compensation {
  amount?: number;
  currency?: string;
  frequency?: 'HOURLY' | 'ANNUALLY' | 'MONTHLY';
  effectiveDate?: string;
}

export interface Company {
  id: string;
  name: string;
  legalName?: string;
  ein?: string;
  address?: Address;
  createdAt?: string;
  updatedAt?: string;
}

export interface Department {
  id: string;
  name: string;
  parentId?: string;
  headId?: string;
  createdAt?: string;
  updatedAt?: string;
}

export interface Location {
  id: string;
  name: string;
  address?: Address;
  timezone?: string;
  isHeadquarters?: boolean;
}

export interface Team {
  id: string;
  name: string;
  description?: string;
  managerId?: string;
  memberIds?: string[];
}

export interface PayRun {
  id: string;
  payPeriodStart: string;
  payPeriodEnd: string;
  payDate: string;
  status: 'DRAFT' | 'APPROVED' | 'PROCESSING' | 'COMPLETED' | 'CANCELLED';
  type?: 'REGULAR' | 'OFF_CYCLE' | 'BONUS';
  totalGrossPay?: number;
  totalNetPay?: number;
  employeeCount?: number;
}

export interface PayStatement {
  id: string;
  employeeId: string;
  payRunId: string;
  payDate: string;
  grossPay: number;
  netPay: number;
  taxes: number;
  deductions: number;
  earnings?: EarningsLine[];
  taxLines?: TaxLine[];
  deductionLines?: DeductionLine[];
}

export interface EarningsLine {
  type: string;
  description?: string;
  amount: number;
  hours?: number;
  rate?: number;
}

export interface TaxLine {
  type: string;
  description?: string;
  amount: number;
  employeeContribution?: number;
  employerContribution?: number;
}

export interface DeductionLine {
  type: string;
  description?: string;
  amount: number;
}

export interface TimeEntry {
  id: string;
  employeeId: string;
  date: string;
  clockIn?: string;
  clockOut?: string;
  hours: number;
  breakMinutes?: number;
  status?: 'PENDING' | 'APPROVED' | 'REJECTED';
  notes?: string;
}

export interface Timesheet {
  id: string;
  employeeId: string;
  periodStart: string;
  periodEnd: string;
  totalHours: number;
  status: 'DRAFT' | 'SUBMITTED' | 'APPROVED' | 'REJECTED';
  entries?: TimeEntry[];
  approverId?: string;
  approvedAt?: string;
}

export interface TimeOffRequest {
  id: string;
  employeeId: string;
  type: string;
  startDate: string;
  endDate: string;
  days: number;
  hours?: number;
  status: 'PENDING' | 'APPROVED' | 'DENIED' | 'CANCELLED';
  reason?: string;
  approverId?: string;
  approvedAt?: string;
  deniedReason?: string;
}

export interface BenefitsPlan {
  id: string;
  name: string;
  type: 'HEALTH' | 'DENTAL' | 'VISION' | '401K' | 'FSA' | 'HSA' | 'LIFE' | 'DISABILITY' | 'OTHER';
  carrier?: string;
  planYear?: string;
  isActive?: boolean;
  employeeCost?: number;
  employerCost?: number;
}

export interface BenefitsEnrollment {
  id: string;
  employeeId: string;
  planId: string;
  status: 'ACTIVE' | 'PENDING' | 'TERMINATED' | 'WAIVED';
  effectiveDate?: string;
  terminationDate?: string;
  coverageLevel?: string;
  dependents?: Dependent[];
}

export interface Dependent {
  id: string;
  firstName: string;
  lastName: string;
  dateOfBirth: string;
  relationship: string;
  ssn?: string;
}

export interface Candidate {
  id: string;
  firstName: string;
  lastName: string;
  email: string;
  phone?: string;
  resumeUrl?: string;
  currentStage?: string;
  currentJobId?: string;
  source?: string;
  appliedAt?: string;
  tags?: string[];
}

export interface Job {
  id: string;
  title: string;
  department?: string;
  location?: string;
  employmentType?: 'FULL_TIME' | 'PART_TIME' | 'CONTRACT' | 'INTERN';
  status: 'DRAFT' | 'OPEN' | 'CLOSED' | 'ON_HOLD';
  description?: string;
  requirements?: string;
  hiringManagerId?: string;
  openings?: number;
  createdAt?: string;
}

export interface Application {
  id: string;
  candidateId: string;
  jobId: string;
  stage: string;
  status: 'ACTIVE' | 'HIRED' | 'REJECTED' | 'WITHDRAWN';
  appliedAt: string;
  lastActivityAt?: string;
  interviews?: Interview[];
}

export interface Interview {
  id: string;
  applicationId: string;
  scheduledAt?: string;
  duration?: number;
  interviewerIds?: string[];
  type?: string;
  feedback?: string;
  outcome?: 'POSITIVE' | 'NEGATIVE' | 'NEUTRAL';
}

export interface Course {
  id: string;
  title: string;
  description?: string;
  category?: string;
  duration?: number;
  provider?: string;
  isRequired?: boolean;
  url?: string;
}

export interface CourseAssignment {
  id: string;
  employeeId: string;
  courseId: string;
  assignedAt: string;
  dueDate?: string;
  completedAt?: string;
  status: 'NOT_STARTED' | 'IN_PROGRESS' | 'COMPLETED' | 'OVERDUE';
  progress?: number;
  score?: number;
}

export interface Device {
  id: string;
  type: 'LAPTOP' | 'DESKTOP' | 'PHONE' | 'TABLET' | 'OTHER';
  make?: string;
  model?: string;
  serialNumber?: string;
  assignedTo?: string;
  assignedAt?: string;
  status: 'AVAILABLE' | 'ASSIGNED' | 'REPAIR' | 'RETIRED';
  purchaseDate?: string;
  warrantyExpiration?: string;
}

export interface AppLicense {
  id: string;
  name: string;
  vendor?: string;
  licenseType?: 'USER' | 'DEVICE' | 'ENTERPRISE';
  totalLicenses?: number;
  usedLicenses?: number;
  cost?: number;
  renewalDate?: string;
  assignedUsers?: string[];
}

export interface Group {
  id: string;
  name: string;
  description?: string;
  type?: string;
  memberIds?: string[];
  createdAt?: string;
  updatedAt?: string;
}

export interface CustomObject {
  id: string;
  objectType: string;
  fields: Record<string, any>;
  createdAt?: string;
  updatedAt?: string;
}

export interface CustomField {
  id: string;
  name: string;
  fieldType: 'TEXT' | 'NUMBER' | 'DATE' | 'BOOLEAN' | 'SELECT' | 'MULTI_SELECT';
  options?: string[];
  isRequired?: boolean;
  defaultValue?: any;
}

export interface PaginatedResponse<T> {
  data: T[];
  nextCursor?: string;
  hasMore: boolean;
  total?: number;
}

export interface RipplingError {
  message: string;
  code?: string;
  statusCode?: number;
  details?: any;
}
