# GetNotificationTemplate

## Overview

GetNotificationTemplate retrieves a single NotificationTemplate row by exact lookup. Two input shapes are accepted: lookup by primary key `{ id }`, or lookup by the natural key triple `{ eventType, channelId, locale }`. Unlike `RenderNotificationTemplate`, this query performs **no default-locale fallback** — it is a literal row read used by admin authoring UIs and by tooling that needs to inspect a specific template definition.

## Business Rules

- Accepts either `{ id }` or the natural key triple `{ eventType, channelId, locale }`
- Returns null when no row matches the supplied key
- Does not fall back to the default-locale row when an exact-locale match is missing — callers that need fallback should use `RenderNotificationTemplate`
- Returned row carries `subject`, `body`, optional `htmlBody`, declared `variableSchema`, and the natural-key triple
- The `(eventType, channelId, locale)` triple is unique, so the natural-key form returns at most one row

## Process Flow

```mermaid
flowchart TD
    A[Receive id or eventType+channelId+locale] --> B{Input shape?}
    B -->|id| C[Load NotificationTemplate by id]
    B -->|eventType+channelId+locale| D[Load NotificationTemplate by natural key]
    C --> E{Row found?}
    D --> E
    E -->|No| F[Return null]
    E -->|Yes| G[Return NotificationTemplate row]
```

## External Dependencies

- None

## Error Scenarios

- **NO_MATCH**: No matching row exists for the supplied input; null or empty result is returned

> Returning `NO_MATCH` is a normal empty/null result rather than a thrown error — the query returns the null/empty value and does not raise `NoMatchError`.

## Test Cases

- returns NotificationTemplate when found by id
- returns NotificationTemplate when found by `(eventType, channelId, locale)` natural key
- returns null when id does not exist
- returns null when the natural-key triple has no matching row (no fallback to default locale)
- returns the row with `htmlBody` populated for EMAIL templates that declare it
- returns the row with `htmlBody` undefined / null for IN_APP templates that do not declare it
- returns the declared `variableSchema` on the row
