danielberkompas/ex_twilio

protocol String.Chars not implemented for %{"mms" => false, "sms" => false, "voice" => true}

Closed this issue · 1 comments

Hi,

I am trying to update a phone number:

{:ok, phone} = ExTwilio.IncomingPhoneNumber.find(phone_sid, account: user.twilio_sid)

{:ok, updated_phone} = ExTwilio.IncomingPhoneNumber.update(
      phone.sid,
      %{ phone | voice_method: "GET", voice_url: @incoming_url}
 )

But I get this error.

** (exit) an exception was raised:
    ** (Protocol.UndefinedError) protocol String.Chars not implemented for %{"mms" => false, "sms" => false, "voice" => true}
        (elixir) lib/string/chars.ex:3: String.Chars.impl_for!/1
        (elixir) lib/string/chars.ex:17: String.Chars.to_string/1
        (elixir) lib/uri.ex:105: URI.encode_kv_pair/1
        (elixir) lib/enum.ex:1216: anonymous fn/4 in Enum.map_join/3
        (elixir) lib/enum.ex:1623: Enum."-reduce/3-lists^foldl/2-0-"/3
        (elixir) lib/enum.ex:1214: Enum.map_join/3
        (ex_twilio) lib/ex_twilio/api.ex:90: ExTwilio.Api.do_update/4
        (kokokog) web/controllers/api/incoming_phone_controller.ex:30: Kokokog.Api.IncomingPhonesController.create/2
        (kokokog) web/controllers/api/incoming_phone_controller.ex:1: Kokokog.Api.IncomingPhonesController.action/2
        (kokokog) web/controllers/api/incoming_phone_controller.ex:1: Kokokog.Api.IncomingPhonesController.phoenix_controller_pipeline/2
        (kokokog) lib/kokokog/endpoint.ex:1: Kokokog.Endpoint.instrument/4
        (kokokog) lib/phoenix/router.ex:261: Kokokog.Router.dispatch/2
        (kokokog) web/router.ex:1: Kokokog.Router.do_call/2
        (kokokog) lib/kokokog/endpoint.ex:1: Kokokog.Endpoint.phoenix_pipeline/1
        (kokokog) lib/plug/debugger.ex:122: Kokokog.Endpoint."call (overridable 3)"/2
        (kokokog) lib/kokokog/endpoint.ex:1: Kokokog.Endpoint.call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4

Am I doing something wrong ?

Best regards

You should update like this:

{:ok, phone} = ExTwilio.IncomingPhoneNumber.find(phone_sid, account: user.twilio_sid)

{:ok, updated_phone} = ExTwilio.IncomingPhoneNumber.update(
      phone.sid,
      %{voice_method: "GET", voice_url: @incoming_url}
 )