# System.Net.Http

**Kind:** Service

**Source:** `Pams/Logic/Pams.CurrencyConverter/Pams.CurrencyConverter.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`System.Net.Http` is a NuGet package dependency declared by the `Pams.CurrencyConverter` project. It enables the service to send HTTP requests to external currency-rate sources and process their responses.

## Diagram

```mermaid
sequenceDiagram
    participant Converter as Pams.CurrencyConverter
    participant Http as System.Net.Http
    participant Rates as External Rate API

    Converter->>Http: Create HTTP request
    Http->>Rates: Send request
    Rates-->>Http: Return rate response
    Http-->>Converter: Return response content
```

## Usage

```ts
const baseUrl = process.env.CURRENCY_CONVERTER_URL;

async function convertCurrency(
  amount: number,
  fromCurrency: string,
  toCurrency: string,
) {
  const response = await fetch(`${baseUrl}/convert`, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      amount,
      fromCurrency,
      toCurrency,
    }),
  });

  if (!response.ok) {
    throw new Error("Currency conversion request failed");
  }

  return response.json();
}
```

## AI Coding Instructions

- Keep HTTP request creation and response handling inside the currency converter service boundary.
- Handle non-success HTTP responses before reading conversion data.
- Keep external rate-provider URLs and credentials in configuration rather than source code.
- Avoid exposing `System.Net.Http` response types through application-facing contracts.

## Used by

3 references from 3 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (3)

- `HelperTool` — `Pams/HelperTool/HelperTool.csproj`:1
- `Pams.Business` — `Pams/Logic/Pams.Business/Pams.Business.csproj`:1
- `Pams.CurrencyConverter` — `Pams/Logic/Pams.CurrencyConverter/Pams.CurrencyConverter.csproj`:1
