Longtime rubyist, I’m very new to Elixir and have been looking for projects to experiment on. Our company does a fair amount of work building app integrations on the Shopify platform, and when we want to scaffold out REST API clients in ruby we often use a fairly simple metaprogramming pattern, which works best on APIs that have relatively uniform naming / return values.
As an experiment I tried to sort of port this metaprogramming idea to an Elixir Shopify API client (the only existing one I could find is boulevard/shopify and lacks most of the endpoints). The library I built is here: https://github.com/themgt/shopify
I’m still just starting to wrap my head around Elixir metaprogramming, but you can see in the quite brief code it basically loops through all the first-level Shopify API endpoints and defines CRUD methods for accessing them and returning the JSON data.
I was mainly looking for some comments / examples of best practices for REST API clients in Elixir. I’m assuming I should use {:ok, _} vs {:error, _} return signatures?
Coming from ruby I find it a bit awkward passing around the struct with domain/token - any way around that, or should I change the arity so that’s first in all the methods?
Also just curious in general on the Elixir community’s thoughts on using metaprogramming in a situation like this - a lot of the documentation has a big flashing “only if you need it!” warning - wondering if it’s generally frowned upon?