chargify / chargify_api_ares

A Chargify API wrapper for Ruby using ActiveResource
http://chargify.com
MIT License
161 stars 96 forks source link

Subscription Override Endpoint #162

Open blakeprudhomme opened 6 years ago

blakeprudhomme commented 6 years ago

API Reference https://reference.chargify.com/v1/subscriptions-override

Preferably with a method on the subscription object:

subscription.override(
  canceled_at: "2000-12-31",
  cancellation_message: "Original cancellation in 2000",
)
denisahearn commented 6 years ago

@blakeprudhomme I needed this too, and was able to achieve it by using built-in behavior in Rails ActiveResource. Just add the following code to your Chargify initializer.

# config/initializers/chargify.rb
module Chargify
  class Subscription < Base
    def override(fields)
      put(:override, subscription: fields)
    end
  end
end

Then you can use this new override method as you intended:

subscription = Chargify::Subscription.find('1234567')
subscription.override(activated_at: '2018-05-25')

Denis

blakeprudhomme commented 6 years ago

@denisahearn Thanks for this work around!