Skip to content

Commit

Permalink
Adding example for looking up all coupons for a product family
Browse files Browse the repository at this point in the history
  • Loading branch information
shayfrendt committed Oct 20, 2011
1 parent 5b8ef66 commit b511935
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions samples/coupons.rb
Expand Up @@ -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"
Expand All @@ -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.