Bandwidth.Resources.Calls

The Calls resource lets you make phone calls and view information about previous inbound and outbound calls.

Bandwidth Docs

Summary

create(client, call \\ %{})

Create an outbound phone call

find(client, id)

Get information about a call that was made or received

list(client, params \\ [])

Get a list of previous calls that were made or received

update(client, id, call)

Manage an active phone call

Functions

create(client, call \\ %{})

Specs:

  • create(Client.t, Map.t) :: Client.response

Create an outbound phone call.

Example:

case Bandwidth.Resources.Calls.create(client, %{ to: "+12223334444", from: "+19199993333" }) do
  {:ok, {201, _, _}} -> IO.puts "Call created"
  {:error, reason}   -> IO.puts "Error: #{reason}"
end

Bandwidth Docs

find(client, id)

Specs:

  • find(Client.t, binary) :: Client.response
Get information about a call that was made or received.

Example:

case Bandwidth.Resources.Calls.find(client, "some-call-id") do
  {:ok, {200, call, _}} -> IO.inspect call
  {:error, reason}      -> IO.puts "Error: #{reason}"
end

Bandwidth Docs

list(client, params \\ [])

Specs:

  • list(Client.t, Client.params) :: Client.response

Get a list of previous calls that were made or received.

Example:

case Bandwidth.Resources.Calls.list(client) do
  {:ok, {200, calls, _}} -> IO.inspect calls
  {:error, reason}       -> IO.puts "Error: #{reason}"
end

Bandwidth Docs

update(client, id, call)

Specs:

  • update(Client.t, binary, Map.t) :: Client.response

Manage an active phone call.

Example:

# Answer an incoming call
case Bandwidth.Resources.Calls.update(client, "some-call-id", %{ state: "active" }) do
  {:ok, {200, _, _}} -> IO.puts "Call answered"
  {:error, reason}   -> IO.puts "Error: #{reason}"
end

Bandwidth Docs