Better design pattern for creating a polymorphic API

Thinking out loud, I suppose behaviours could be a solution? If I’m willing to accept that passing the right parser as an argument is better than having a polymorphic parse/2 function.

I could declare parse/2 as a behaviour and implement it in each module (Parsers.User, and Parsers.AccessKey). I would then pass the right parser as an argument.

  def parse({:ok, %{body: xml, status_code: status} = resp}, action) when status in 200..299 do
    parsed_body = dispatch(xml, action)
    {:ok, %{resp | body: parsed_body}}
  end

Still, it would be nice to just call parse/2 and have the API figure out which module to call.