# Class VotingClient

Sub-client for voting records and speeches EP API endpoints.

#### Hierarchy (View Summary)

- BaseEPClient
  - VotingClient

- Defined in clients/ep/votingClient.ts:34

##### Index

### Constructors

constructor

### Properties

baseURL
cache
enableRetry
maxResponseBytes
maxRetries
rateLimiter
timeoutMs

### Methods

clearCache
evictFromCache
fetchVoteResultsForSession
fetchVoteResultsFromRecentMeetings
filterVotingRecords
get
getCacheStats
getSpeechById
getSpeeches
getVotingRecords
transformSpeech
transformVoteResult

## Constructors

### constructor

- new VotingClient(
  config?: EPClientConfig,
  shared?: EPSharedResources,
  ): VotingClient

  #### Parameters

  - config: EPClientConfig = {}
  - `Optional` shared: EPSharedResources

  #### Returns VotingClient

  Overrides BaseEPClient.constructor

  - Defined in clients/ep/votingClient.ts:35

## Properties

### `Protected` `Readonly` baseURL

baseURL: string

European Parliament API base URL.

Inherited from BaseEPClient.baseURL

- Defined in clients/ep/baseClient.ts:217

### `Protected` `Readonly` cache

cache: LRUCache<string, Record<string, unknown>>

LRU cache for API responses.

Inherited from BaseEPClient.cache

- Defined in clients/ep/baseClient.ts:215

### `Protected` `Readonly` enableRetry

enableRetry: boolean

Enable automatic retry on transient failures.

Inherited from BaseEPClient.enableRetry

- Defined in clients/ep/baseClient.ts:223

### `Protected` `Readonly` maxResponseBytes

maxResponseBytes: number

Maximum allowed response body size in bytes.

Inherited from BaseEPClient.maxResponseBytes

- Defined in clients/ep/baseClient.ts:227

### `Protected` `Readonly` maxRetries

maxRetries: number

Maximum number of retry attempts.

Inherited from BaseEPClient.maxRetries

- Defined in clients/ep/baseClient.ts:225

### `Protected` `Readonly` rateLimiter

rateLimiter: RateLimiter

Token bucket rate limiter.

Inherited from BaseEPClient.rateLimiter

- Defined in clients/ep/baseClient.ts:219

### `Protected` `Readonly` timeoutMs

timeoutMs: number

Request timeout in milliseconds.

Inherited from BaseEPClient.timeoutMs

- Defined in clients/ep/baseClient.ts:221

## Methods

### clearCache

- clearCache(): void

  Clears all entries from the LRU cache.

  #### Returns void

  Inherited from BaseEPClient.clearCache

  - Defined in clients/ep/baseClient.ts:666

### `Protected` evictFromCache

- evictFromCache(endpoint: string, params?: Record<string, unknown>): void

  Evicts a single cache entry matching the given endpoint and params. Sub-clients use this when they detect that a successfully-fetched payload is a content-pending sentinel that must not be served from cache for the remainder of the TTL — eviction lets availability recover as soon as the upstream document is enriched.

  #### Parameters

  - endpoint: string

    API endpoint path (same value passed to get)

  - `Optional` params: Record<string, unknown>

    Optional query parameters (same value passed to get)

  #### Returns void

  #### Protected

  Inherited from BaseEPClient.evictFromCache

  - Defined in clients/ep/baseClient.ts:681

### `Private` fetchVoteResultsForSession

- fetchVoteResultsForSession(
  sessionId: string,
  apiParams: Record<string, unknown>,
  ): Promise<VotingRecord[]>

  Fetches vote results for a specific sitting/session.

  #### Parameters

  - sessionId: string
  - apiParams: Record<string, unknown>

  #### Returns Promise<VotingRecord[]>

  #### Private

  - Defined in clients/ep/votingClient.ts:54

### `Private` fetchVoteResultsFromRecentMeetings

- fetchVoteResultsFromRecentMeetings(
  params: { dateFrom?: string; limit?: number },
  ): Promise<VotingRecord[]>

  Fetches vote results from recent meetings when no sessionId is given.

  #### Parameters

  - params: { dateFrom?: string; limit?: number }

  #### Returns Promise<VotingRecord[]>

  #### Private

  - Defined in clients/ep/votingClient.ts:69

### `Private` filterVotingRecords

- filterVotingRecords(
  records: VotingRecord[],
  params: { dateFrom?: string; dateTo?: string; topic?: string },
  ): VotingRecord[]

  Applies client-side filters to voting records.

  #### Parameters

  - records: VotingRecord[]
  - params: { dateFrom?: string; dateTo?: string; topic?: string }

  #### Returns VotingRecord[]

  #### Private

  - Defined in clients/ep/votingClient.ts:112

### `Protected` get

- get<T extends Record<string, unknown>>(
  endpoint: string,
  params?: Record<string, unknown>,
  minimumTimeoutMs?: number,
  ): Promise<T>

  Executes a cached, rate-limited GET request to the EP API.

  #### Type Parameters

  - T extends Record<string, unknown>

    Expected response type (extends `Record<string, unknown>`)

  #### Parameters

  - endpoint: string

    API endpoint path (relative to `baseURL`)

  - `Optional` params: Record<string, unknown>

    Optional query parameters

  - `Optional` minimumTimeoutMs: number

    Optional per-request minimum timeout in milliseconds. When provided, the effective timeout is `Math.max(minimumTimeoutMs, this.timeoutMs)`, so the global timeout (set via `--timeout` or `EP_REQUEST_TIMEOUT_MS`) can still extend it beyond the per-endpoint minimum. Use for known slow EP API endpoints such as `procedures/feed`.

  #### Returns Promise<T>

  Promise resolving to the typed API response

  #### Throws

  On HTTP errors, network failures, or parse failures

  #### Protected

  Inherited from BaseEPClient.get

  - Defined in clients/ep/baseClient.ts:606

### getCacheStats

- getCacheStats(): {
  hitRate: number;
  hits: number;
  maxSize: number;
  misses: number;
  size: number;
  }

  Returns cache statistics for monitoring and debugging.

  #### Returns { hitRate: number; hits: number; maxSize: number; misses: number; size: number }

  `{ size, maxSize, hitRate, hits, misses }`

  Inherited from BaseEPClient.getCacheStats

  - Defined in clients/ep/baseClient.ts:690

### getSpeechById

- getSpeechById(speechId: string): Promise<Speech>

  Returns a single speech by ID. EP API Endpoint: `GET /speeches/{speech-id}`

  #### Parameters

  - speechId: string

  #### Returns Promise<Speech>

  - Defined in clients/ep/votingClient.ts:232

### getSpeeches

- getSpeeches(
  params?: {
  dateFrom?: string;
  dateTo?: string;
  limit?: number;
  offset?: number;
  },
  ): Promise<PaginatedResponse<Speech>>

  Returns plenary speeches. EP API Endpoint: `GET /speeches`

  Note: The EP API `/speeches` endpoint does not support a `year` query parameter. It supports `sitting-date` (range start) and `sitting-date-end` (range end) for date filtering.

  Use `dateFrom` / `dateTo` (YYYY-MM-DD) for date-range queries — these are mapped to `sitting-date` / `sitting-date-end`.

  #### Parameters

  - params: { dateFrom?: string; dateTo?: string; limit?: number; offset?: number } = {}

  #### Returns Promise<PaginatedResponse<Speech>>

  - Defined in clients/ep/votingClient.ts:204

### getVotingRecords

- getVotingRecords(
  params: {
  dateFrom?: string;
  dateTo?: string;
  limit?: number;
  offset?: number;
  sessionId?: string;
  topic?: string;
  },
  ): Promise<PaginatedResponse<VotingRecord>>

  Retrieves voting records with filtering by session, topic, and date.

  EP API Endpoint: `GET /meetings/{sitting-id}/vote-results`

  #### Parameters

  - params: {
    dateFrom?: string;
    dateTo?: string;
    limit?: number;
    offset?: number;
    sessionId?: string;
    topic?: string;
    }

    sessionId, topic, dateFrom, dateTo, limit, offset

  #### Returns Promise<PaginatedResponse<VotingRecord>>

  Paginated voting records list

  #### Security

  Audit logged per GDPR Article 30

  - Defined in clients/ep/votingClient.ts:143

### `Private` transformSpeech

- transformSpeech(apiData: Record<string, unknown>): Speech

  #### Parameters

  - apiData: Record<string, unknown>

  #### Returns Speech

  - Defined in clients/ep/votingClient.ts:46

### `Private` transformVoteResult

- transformVoteResult(
  apiData: Record<string, unknown>,
  sessionId: string,
  ): VotingRecord

  #### Parameters

  - apiData: Record<string, unknown>
  - sessionId: string

  #### Returns VotingRecord

  - Defined in clients/ep/votingClient.ts:39