karls / gocardless-clj

Clojure client library for the GoCardless API
MIT License
4 stars 1 forks source link

API suggestions #1

Closed weavejester closed 10 years ago

weavejester commented 10 years ago

I ran across your library, and the API seems a little unusual in its design. I guess you've come from an OOP background?

In Clojure, APIs tend to be styled in a way like:

(require '[gocardless-clj.core :as gocardless])

(def account {...})

(gocardless/bills account)
(gocardless/details account)
(gocardless/new-bill account {:amount 10})

Curiously, your API actually allows for that, but you also have a make-account function, which seems to have the purpose of hiding the account data and rearranging the order of the arguments to a more OO style.

I'd suggest dropping make-account completely, and changing the multimethods into just plain functions that expect a map as the first argument.

karls commented 10 years ago

Hi James,

Thanks for the feedback.

Indeed, that whole make-account business was an attempt to hide the fact that you'll need to pass the account details in for every API call. In the initial version, it worked precisely the way you just described it - by passing in the account details every time, but I wanted to see if I could do it without. Leaving the option to use it without make-account was intentional.

I agree with you that I probably went a bit overboard with it, as it doesn't really need that crazy make-account machinery. Removing that will make it much clearer and more intuitive to understand.

I'll definitely take your suggestion into account in the next version. Luckily it's not a very popular library, so I can play around with the API a bit.

Thanks!