Class: Recurly::Redemption

Inherits:
Resource show all
Defined in:
lib/recurly/redemption.rb

Overview

Redemptions are not top-level resources, but they can be accessed (and created) through Coupon instances.

Examples:

coupon = Coupon.find "summer2011"
coupon.redemptions.each { |r| p r }
coupon.redeem Account.find("groupon_lover")

Instance Attribute Summary

Attributes inherited from Resource

#attributes, #etag, #response, #uri

Instance Method Summary collapse

Methods inherited from Resource

#==, all, associations, belongs_to, #changed, #changed?, #changed_attributes, #changes, collection_name, count, create, create!, define_attribute_methods, #destroy, #destroyed?, embedded!, #errors, find, find_each, first, from_response, from_xml, has_many, has_one, #initialize, #inspect, #marshal_dump, #marshal_load, member_name, member_path, #new_record?, paginate, #persist!, #persisted?, #previous_changes, #read_attribute, reflect_on_association, #reload, resource_name, #save!, scope, scopes, #to_param, #to_xml, #update_attributes, #update_attributes!, #valid?, #write_attribute

Constructor Details

This class inherits a constructor from Recurly::Resource

Instance Method Details

#accountAccount

Returns:



13
# File 'lib/recurly/redemption.rb', line 13

belongs_to :account, :readonly => false

#couponCoupon

Returns:



11
# File 'lib/recurly/redemption.rb', line 11

belongs_to :coupon

#saveObject



22
23
24
25
26
27
28
29
# File 'lib/recurly/redemption.rb', line 22

def save
  return false if persisted?
  copy_from coupon.redeem , currency
  true
rescue Recurly::API::UnprocessableEntity => e
  apply_errors e
  false
end