lib/stripe/customer.rb in stripe-1.18.0 vs lib/stripe/customer.rb in stripe-1.19.0

- old
+ new

@@ -4,61 +4,55 @@ include Stripe::APIOperations::Delete include Stripe::APIOperations::Update include Stripe::APIOperations::List def add_invoice_item(params, opts={}) - opts[:api_key] = @api_key + opts = @opts.merge(Util.normalize_opts(opts)) InvoiceItem.create(params.merge(:customer => id), opts) end def invoices - Invoice.all({ :customer => id }, @api_key) + Invoice.all({ :customer => id }, @opts) end def invoice_items - InvoiceItem.all({ :customer => id }, @api_key) + InvoiceItem.all({ :customer => id }, @opts) end def upcoming_invoice - Invoice.upcoming({ :customer => id }, @api_key) + Invoice.upcoming({ :customer => id }, @opts) end def charges - Charge.all({ :customer => id }, @api_key) + Charge.all({ :customer => id }, @opts) end def create_upcoming_invoice(params={}, opts={}) - opts[:api_key] = @api_key + opts = @opts.merge(Util.normalize_opts(opts)) Invoice.create(params.merge(:customer => id), opts) end def cancel_subscription(params={}, opts={}) - api_key, headers = Util.parse_opts(opts) - response, api_key = Stripe.request( - :delete, subscription_url, api_key || @api_key, params, headers) - refresh_from({ :subscription => response }, api_key, true) + response, opts = request(:delete, subscription_url, params, opts) + refresh_from({ :subscription => response }, opts, true) subscription end def update_subscription(params={}, opts={}) - api_key, headers = Util.parse_opts(opts) - response, api_key = Stripe.request( - :post, subscription_url, api_key || @api_key, params, headers) - refresh_from({ :subscription => response }, api_key, true) + response, opts = request(:post, subscription_url, params, opts) + refresh_from({ :subscription => response }, opts, true) subscription end def create_subscription(params={}, opts={}) - api_key, headers = Util.parse_opts(opts) - response, api_key = Stripe.request( - :post, subscriptions_url, api_key || @api_key, params, headers) - refresh_from({ :subscription => response }, api_key, true) + response, opts = request(:post, subscriptions_url, params, opts) + refresh_from({ :subscription => response }, opts, true) subscription end def delete_discount - Stripe.request(:delete, discount_url, @api_key) - refresh_from({ :discount => nil }, api_key, true) + _, opts = request(:delete, discount_url) + refresh_from({ :discount => nil }, opts, true) end private def discount_url