Make the ApiKey class more DRY by metaprogramming.