Telephonist.OngoingCall

Stores the state of calls that are currently in progress in an ETS table.

Summary

delete(sid)

Delete a call status from the OngoingCall database

lookup(sid)

Lookup the state of an ongoing call

save(call)

Save the state of an ongoing call

Types

sid :: atom

error :: {:error, String.t}

Functions

delete(sid)

Specs:

Delete a call status from the OngoingCall database.

Parameters

  • call or sid: Either a call tuple or atom SID.

Examples

iex> Telephonist.OngoingCall.save({:delete, "in-progress", %{}})
...> Telephonist.OngoingCall.delete(:delete)
...> Telephonist.OngoingCall.lookup(:delete)
{:error, "No call with SID :delete is in progress."}

iex> Telephonist.OngoingCall.delete("invalid")
{:error, "SID must be an atom, was \"invalid\""}
lookup(sid)

Specs:

Lookup the state of an ongoing call.

Parameters

  • sid: An atom represnting the Twilio call SID.

Examples

iex> Telephonist.OngoingCall.save({:sid, "in-progress", %{}})
...> Telephonist.OngoingCall.lookup(:sid)
{:ok, {:sid, "in-progress", %{}}}

iex> Telephonist.OngoingCall.lookup(:nonexistent)
{:error, "No call with SID :nonexistent is in progress."}
save(call)

Specs:

Save the state of an ongoing call.

Parameters

  • call: A tuple in the format {sid, status, state} where:
    • sid is an atom representing the Twilio call SID.
    • status is a binary representing the Twilio status. (e.g., "in-progress")
    • state is a Telephonist.State.

Examples

iex> Telephonist.OngoingCall.save({:sid, "in-progress", %Telephonist.State{}})
:ok

iex> Telephonist.OngoingCall.save(:invalid)
{:error, "Call must be in format: {sid, status, state}, was :invalid"}