lib/balanced/resources/debit.rb in balanced-0.3.4 vs lib/balanced/resources/debit.rb in balanced-0.3.5
- old
+ new
@@ -15,20 +15,24 @@
include Balanced::Resource
def initialize attributes = {}
Balanced::Utils.stringify_keys! attributes
unless attributes.has_key? 'uri'
- attributes['uri'] = Balanced::Marketplace.my_marketplace.send(self.class.collection_name + '_uri')
+ attributes['uri'] = self.class.uri
end
super attributes
end
# Refunds this Debit. If no amount is specified it will refund the entire
# amount of the Debit, you may create many Refunds up to the sum total
# of the original Debit's amount.
#
# @return [Refund]
- def refund amount=nil, description=nil
+ def refund *args
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ amount = args[0] || options.fetch(:amount) { nil }
+ description = args[1] || options.fetch(:description) { nil }
+
refund = Refund.new(
:uri => self.refunds_uri,
:debit_uri => self.uri,
:amount => amount,
:description => description,