# Services & API Integration

### Main API Service (`api.service.ts`)

The central service for API communication with the backend.

**Key Methods:**
- `getUser(username, password)` - User authentication
- `getUserDetails()` - Fetch user profile
- `guardianTokens()` - Validate JWT token
- Common HTTP methods with JWT authentication

**Configuration:**
```typescript
// API endpoints defined in addrezz.ts
OSAS_API = "https://testapi.ondelivery.id"
BOOKING_API = "https://demoapisat.ondelivery.id"
USAPI_API = "http://localhost:3621"
```

### Service Categories

#### 1. **Scanning Services**
Located in `services/incoming-scans/` and `services/outgoing-scans/`
- Handle barcode/QR code scanning
- Validate package information
- Update package status

#### 2. **Report Services**
Located in `services/reports/`
- Generate various reports
- Export to PDF/Excel
- Data aggregation and analytics

#### 3. **Business Services**
Located in `services/`
- Domain-specific business logic
- Data transformation
- Workflow management

### HTTP Interceptor Pattern

All services use JWT tokens for authentication:
```typescript
let customHeaders = new HttpHeaders({
  'Content-Type': 'application/json',
  'authorization': localStorage.getItem('jwt')!
});
```

### PDF & Excel Export Services

#### PDF Service (`pdf.service.ts`)
- Uses PDFMake library
- Generate reports as PDF
- Custom formatting and styling

#### Excel Export
- Uses ExcelJS library
- Export data to Excel format
- Multiple sheet support