Maybe move the above class into api.rb?