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
call :: {sid, status, Telephonist.State.t}
Functions
Specs:
Delete a call status from the OngoingCall database.
Parameters
call
orsid
: 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\""}
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."}
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 aTelephonist.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"}