Public API and OTP application entry point for PingPong.
PingPong provides a small, consistent interface for sending notifications to
registered services. The built-in services are :discord, :telegram, and
:mock; additional services can be registered through application
configuration.
Results
Synchronous calls return either {:ok, response} or an error tuple. Unknown
services return {:error, {:unknown_service, service}}.
Asynchronous calls return {:ok, task} when a service is found. Awaiting the
task returns the service result:
{:ok, task} = PingPong.send_async(:mock, %{message: "Ping!"}, %{})
Task.await(task)
Summary
Types
A notification tuple accepted by send_multiple/1.
Notification identifier used by send_multiple/1.
Service-specific delivery options.
Service-specific notification payload.
Standard result returned by PingPong services.
Delivery mode used by PingPong.Notification.
Registered service key, such as :discord, :telegram, or :mock.
Functions
Sends a notification through a registered service.
Sends a notification in a supervised task.
Sends multiple named notifications synchronously.
Types
A notification tuple accepted by send_multiple/1.
@type id() :: atom()
Notification identifier used by send_multiple/1.
@type options() :: map()
Service-specific delivery options.
@type payload() :: map()
Service-specific notification payload.
Standard result returned by PingPong services.
@type send_type() :: :sync | :async
Delivery mode used by PingPong.Notification.
@type service() :: atom()
Registered service key, such as :discord, :telegram, or :mock.
Functions
Sends a notification through a registered service.
The payload and options maps are validated by the selected service.
Examples
iex> PingPong.send(:mock, %{message: "Ping!"}, %{})
{:ok, "Pong! 🏓"}
iex> PingPong.send(:unknown, %{}, %{})
{:error, {:unknown_service, :unknown}}
Sends a notification in a supervised task.
Returns {:ok, task} when the service exists. Use Task.await/1 to receive
the service result. Unknown services return an error immediately.
Examples
{:ok, task} = PingPong.send_async(:mock, %{message: "Ping!"}, %{})
{:ok, "Pong! 🏓"} = Task.await(task)
@spec send_multiple(Enumerable.t({id(), config()})) :: [{id(), result()}]
Sends multiple named notifications synchronously.
Accepts an enumerable of {id, notification} pairs, where each notification
is a {service, payload, options} tuple. The return value preserves each
notification ID alongside its result.
Examples
notifications = [
first: {:mock, %{message: "Ping!"}, %{}},
second: {:mock, %{}, %{}}
]
PingPong.send_multiple(notifications)