Why not just have a function that takes the type of struct? Something like
def get_generic(thing, args) do
data = get_from_api(args)
struct(thing, args)
end
Also note with this code you’re not using the API result for anything, and it’s essentially doing nothing, assuming there are no side effects from that API call.






















