AirtelMoney.Webhooks.Parser (airtel_money v0.1.1)

Copy Markdown View Source

Parses Airtel Money webhook payloads.

Examples

iex> # This would normally parse the JSON, but for doctest we skip the actual parsing
iex> :ok
:ok

Summary

Functions

Extracts the hash from a webhook payload.

Parses a webhook payload.

Functions

extract_hash(payload)

@spec extract_hash(String.t()) :: {:ok, String.t()} | {:error, :missing_hash}

Extracts the hash from a webhook payload.

Parameters

  • payload - The raw JSON payload (string)

Returns

  • {:ok, hash} if hash is present
  • {:error, :missing_hash} if hash is not present

parse(payload)

@spec parse(String.t()) :: {:ok, map()} | {:error, :invalid_json}

Parses a webhook payload.

Parameters

  • payload - The raw JSON payload (string)

Returns

  • {:ok, map()} if parsing succeeds
  • {:error, :invalid_json} if parsing fails