marceloboeira / spotify.cr

:headphones: A Crystal wrapper for the Spotify Web API
MIT License
35 stars 5 forks source link

Abstractions #4

Open marceloboeira opened 8 years ago

marceloboeira commented 8 years ago

Currently we have shitty abstractions for the resource, the request and the API setup.

Basically we have to improve this parts of the code: https://github.com/marceloboeira/spotify.cr/blob/master/src/spotify/resource.cr

I'm not sure currently what is the best way to do this, @gabrielalmir10 @bronzdoc any suggestions?

Desired 'DSL':

module Spotify
  class Albums < Resource
    resource_for("albums")
    attributes({
       id:   String,
       name: String,
       genres: { type: Array(String), default: [], nilable: true } 
     })
  end
end

Where: resource_for is a macro that registers and identify the resource attributes is a macro for the JSON.mapping

Some available methods, coming from the resource inheritance: