Permalink
Browse files

Adding example for looking up all coupons for a product family

  • Loading branch information...
1 parent 5b8ef66 commit b51193518fe4255f58fef695d0f07702d960c827 @shayfrendt shayfrendt committed Oct 20, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 samples/coupons.rb
View
9 samples/coupons.rb
@@ -24,6 +24,9 @@
# Lookup up existing coupon using the product_family_id and the coupon code
coupon = Chargify::Subscription::Coupon.find_by_product_family_id_and_code(2,"10OFF")
+# Looking up all coupons for a product family
+coupons = Chargify::Coupon.find_all_by_product_family_id(12345)
+
# Update coupon information
coupon = Chargify::Coupon.find_by_product_family_id_and_code(2,"10OFF")
coupon.code = "FOO"
@@ -38,10 +41,10 @@
coupon.usage
#>> [{"name"=>"Product 1", "savings"=>0.0, "id"=>8, "signups"=>5, "revenue"=>0.0}, {"name"=>"Product 2", "savings"=>0.0, "id"=>9, "signups"=>0, "revenue"=>0.0}]
-#Apply coupon to subscription
+# Apply coupon to subscription
subscription = Subscription.find_by_customer_reference('moklett')
subscription.add_coupon('5OFF')
-#Remove coupon from subscription
+# Remove coupon from subscription
subscription = Subscription.find_by_customer_reference('moklett')
-subscription.remove_coupon('50OFF')
+subscription.remove_coupon('50OFF')

0 comments on commit b511935

Please sign in to comment.