chargify / chargify_api_ares

A Chargify API wrapper for Ruby using ActiveResource
http://chargify.com
MIT License
161 stars 96 forks source link

Coupon 'lookup' vs 'find' API endpoints #46

Closed joshferrara closed 9 years ago

joshferrara commented 12 years ago

It seems that the gem uses this endpoint http://DOMAIN.chargify.com/coupons/lookup.xml?code=COUPON&product_family_id=FAMILY_ID when using the gem function Chargify::Coupon.find_by_product_family_id_and_code.

I'm not sure if this is a legacy API endpoint, as the current Chargify docs list an endpoint such as http://DOMAIN.chargify.com/coupons/find.xml?code=COUPON to use instead.

My two main points of curiosity are this:

  1. The lookup method returns a 404: Not found when I lookup a secondary coupon code, whereas the find method returns the valid coupon details.
  2. The lookup method requires a product_family_id while the find method only requires the coupon_code.

I wanted to see if there was a reason for this before I submit a pull request. Thanks!

14to9 commented 12 years ago

+1 on this. We're getting the same problem with our environment, and have confirmed the stock API works great.

14to9 commented 12 years ago

Josh, I don't see a patch in your fork. Have you got something implemented that you're willing to share? :)

joshferrara commented 12 years ago

@14to9 I haven't yet, I was mostly waiting to hear from someone at Chargify to see if I was missing something. But if you're having the issue as well I think that's all the confirmation I need to patch it myself :) I'll let you know when I get something worked out.

14to9 commented 12 years ago

That sounds great, Josh. Thanks. If you get stalled out on it, pls just shout out and we'll fork-and-hack on this end :)

On Jun 6, 2012, at 12:25 PM, Josh Ferrara wrote:

@14to9 I haven't yet, I was mostly waiting to hear from someone at Chargify to see if I was missing something. But if you're having the issue as well I think that's all the confirmation I need to patch it myself :) I'll let you know when I get something worked out.


Reply to this email directly or view it on GitHub: https://github.com/chargify/chargify_api_ares/issues/46#issuecomment-6155425

chase439 commented 11 years ago

I was wondering about the reason too. I was able to hack the new API endpoint using

coupon = Chargify::Coupon.find(:first, :params => {:code => "MYCODE"})

chase439 commented 11 years ago

I think the hint to the reason is in http://docs.chargify.com/api-coupons#api-coupon-find

Coupon's attribute -- "product_family_id. The ID of the product family to which the coupon belongs. The coupon can be applied only to products in this product family."

However, I find that the find by code is easier to use.