Could you provide the code for the module where you define the struct, please? You might have defined it in Something.Something.Worker. In such a case if you don’t alias it, the compiler won’t be able to expand it.
btw, consider pattern-matching in the function head. Sometimes it makes the code cleaner:
def request(:get, url, %Worker{user: user, password: password}) do
auth = [basic_auth: {user, password}]
HTTPoison.get(url, %{"Accept" => "application/json"}, [hackney: auth])
end
I don’t know for sure, but I would guess that’s because in elixir explicitness is preferred. You can always use %__MODULE__{}, as @benwilson512 has already pointed out. That way, the __MODULE__ form will be substituted with the full module name (which will also be prefixed by Elixir.) at compile time.