hugofirth / laravel-mailchimp

A composer package for the MailChimp API PHP class (as provided by MailChimp) which supports the Laravel 4 framework.
96 stars 27 forks source link

Updated wrapper to use magic __call instead of tightly coupled methods #18

Closed lookitsatravis closed 10 years ago

lookitsatravis commented 10 years ago

This pull request fixes #3 in that it maps calls directly to the API instead of relying on hard coded methods. This should map any property or method called on the Mailchimp API class.

hugofirth commented 10 years ago

Hi @lookitsatravis,

Thanks for contributing! I've been meaning to get around to this for a while but a) getting distracted; and b) not knowing a good solution to the 'auto-complete' problem has stopped me.

Your PR will give me the kick I need to implement a couple of tests, try and find a nice solution to the lack of auto complete with __call(), and merge this in.

On that last - you don't happen to know a good method do you?

EDIT: It turns out that I can use the @method tag of PHPDoc ... which isn't ideal, but better than nothing I suppose.

lookitsatravis commented 10 years ago

@hugofirth,

No problem! I am using the library, so I thought I'd help. I didn't implement any tests, but I did just add another commit that includes @method for each of the properties and methods in the base Mailchimp class. As you say, for it to remain accurate, the declaractions will need to be updated to track the API. But I guess that's the trade off for removing the coupling. It's inconvenient, but it can be put off for some time and shouldn't break wrapping any new Mailchimp releases. I also added a note in the usage on the Readme for how to hint to the IDE to use autocompletion on the facade. It seems to work pretty well!

Let me know if you need anything else...

Thanks,

Travis

hugofirth commented 10 years ago

@lookitsatravis - awesome - beat me to it! I'll merge in the changes now and then tag a minor version release over the weekend.