ColdFusion CheddarGetter API Wrapper
I've put together a basic ColdFusion API wrapper for
CheddarGetter. I hope this can be helpful to others in the
CheddarGetter community.
You can get the files for free at: http://cfcheddargetter.riaforge.org/
Discussions are closed to public comments.
If you need help with Cheddar please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Marc Guyer on 19 Jul, 2010 07:38 PM
That is great news, Will. We've had some inquiries about a CF wrapper in the past. Now we can tell them where to go. We'll probably blog about this in a bit. Anything you'd like us to include or mention?
2 Posted by will on 19 Jul, 2010 08:42 PM
Hey Marc, It's very basic at this point, but I hope that it will give people a starting point to work from.
Marc Guyer closed this discussion on 19 Jul, 2010 08:45 PM.
Marc Guyer re-opened this discussion on 19 Jul, 2010 08:53 PM
Support Staff 3 Posted by Marc Guyer on 19 Jul, 2010 08:53 PM
I couldn't download it. Do you have to register to download?
Support Staff 4 Posted by Marc Guyer on 19 Jul, 2010 09:25 PM
No download button like on other projects. I see the attached in both Chrome and FF.
5 Posted by will on 19 Jul, 2010 10:48 PM
Hi Mark, I'll check with them and get the download button fixed.
6 Posted by jeff on 20 Jul, 2010 05:16 AM
Cool thanks Will!
7 Posted by will on 21 Jul, 2010 02:30 PM
Hey I've had the link updated for the ColdFusion CheddarGetter files. You can check it out at http://cfcheddargetter.riaforge.org
Support Staff 8 Posted by Marc Guyer on 21 Jul, 2010 02:59 PM
Very cool, WIll. I just have one suggestion. I see that you have specified the arguments for all of the methods. While this is somewhat handy for "code is documentation" and potentially for error handling, it also limits the wrapper if the API changes to add some arguments for more functionality. We've run into this problem with one of the RubyGems. For example, in the current implementation, it doesn't appear to be possible to specify custom charges/credits or tracked item quantities with the CG_Create_a_New_Customer method.
9 Posted by Jordan Sitkin on 17 Aug, 2010 09:18 AM
Thanks for creating this cfc Will! I hope you don't mind, but I have reworked it a bit.
I addressed the problem pointed out by Marc above by simply passing any arguments given to each of the functions on to the CG service as query parameters. This should make it future proof against new API arguments. It also makes the code a lot smaller :).
I wrapped it in a cfcomponent tag and defined an init method. This makes it more suitable for my projects as I can just drop it in and call it like so: CG = CreateObject("component", "CheddarGetter").init();
CG.Get_a_Single_Customer(user_id="#id#");
Instead of using to return the values, I have used xmlParse. This gives everything back as a nice XMLdoc object that is easily traversed with XPath. For example, I can see how many specs a customer has racked up on their account with a few easy lines: CG = CreateObject("component", "Cheddar").init();
xml = CG.Get_a_Single_Customer(user_id="#id#");
allowedUsers = XmlSearch(xml, "//plans//item[@code='SPECS']/quantity")[1].XmlText;
My version includes less helpful comments because I am lazy, and also no longer throws CF errors when arguments are missing. With my version, you are expected to check the returned xml object for errors - they can be found simply by checking for xml.error.
Support Staff 10 Posted by Marc Guyer on 18 Aug, 2010 08:57 PM
That's fantastic, Jordan! Do you have any plans to publish your version on GitHub or some similar open source code repository?
11 Posted by Jordan Sitkin on 18 Aug, 2010 11:01 PM
On Wed, Aug 18, 2010 at 1:59 PM, Marc Guyer <
[email blocked]<tender%[email blocked]>
> wrote:
If Will gives his blessing id be happy to
12 Posted by will on 19 Aug, 2010 03:30 PM
That's awesome Jordan. It was my hope that someone would take what I created and run with it.
13 Posted by Jordan Sitkin on 19 Aug, 2010 08:23 PM
I put it up as a GitHub repo, for all to enjoy.
http://github.com/dustMason/Froide-au-Fromage
We have decided to go with a someone else for our recurring billing set-up
(cheddargetter's payment plans were not well-aligned with our business
plans), so I won't be contributing to the code any longer. Feel free to fork
away and run free, though!
Marc Guyer closed this discussion on 13 Aug, 2012 03:07 PM.