Gazler / rapidash

Rapidly develop your API client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Covert this to Elixir

victorlcampos opened this issue · comments

Hi,
Do you think It's possible to use this idea in Elixir? If yes, I could try do this?

Hi,

I haven't really thought about converting this to Elixir, it would certainly be possible to achieve something similar. If you look at https://github.com/edgurgel/httpoison#wrapping-httpoisonbase it has a little support for clients.

If you want to have a go at doing this then feel free to use this project as inspiration. :)

Yes,
I'm pretty new in Elixir, but I will try =)
This gem is awesome.

@victorlcampos Keep me posted if you make any progress on this.

@Gazler, Ok Gazler...
Sry for did not reply, now I'm working on https://phoenixcast.herokuapp.com/, but next year (it's a joke in brazil) I will take this...

I'm wating need use github api, that is on my roadmap for phoenixcast.

happy new year, I will start make this today =)

@Gazler, I'm going the right way?

@victorlcampos Your structs certainly make sense. Good idea on allowing resource to be nested in the struct.

@Gazler, thx... so I will continue on this path =)

@Gazler, hi...
here my progress:
https://github.com/victorlcampos/rapidax

Could you help me to find a better way for this:
defstruct Rapidax.Client.Http.client_struct ++ [site: "http://jsonplaceholder.typicode.com"]

When I started I thinked some thing like:
defstruct %Rapidax.Client.Http {site: "http://jsonplaceholder.typicode.com" }

@victorlcampos If all of the Client fields are required in the HTTP struct, why not nest the struct? It took me a while to work out where struct_fields came from. Don't forget that explicit is better than implicit:

defstruct client: %Rapidax.Client{}, username: nil, password: nil

Yes, i agree.
My initial idea was create new struct based on old struct. Some thing like this question:
http://stackoverflow.com/questions/32847464/struct-reuse-for-modules-in-elixir

defstruct %Rapidax.Client{} ++ [username: nil, password: nil]

Something like this...
becauce I want that %Rapidax.Client.Http{} has all Rapidax.Client attribute, not a client attribute with all attributes inside.

But I agree this is very(very) ugly...
I opened a topic on elixir group mailing for discovery the best way to sove this:

https://groups.google.com/forum/#!topic/elixir-lang-core/BH4N_OgtBWA