chargify 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -8,6 +8,14 @@ Ruby wrapper for the chargify.com SAAS and billing API
8
8
  gem tumble
9
9
  sudo gem install chargify
10
10
 
11
+ ## Example Usage
12
+
13
+ ### Create, cancel, then reactivate subscription
14
+ attributes = { :product_handle => 'basic' ... }
15
+ @client = Chargify::Client.new('InDhcXAAAAAg7juDD', 'xxx-test')
16
+ subscription = @client.create_subscription(attributes)
17
+ @client.cancel_subscription(subscription[:id], "Canceled due to bad customer service.")
18
+ @client.reactivate_subscription(subscription[:id]) #Made him an offer he couldn't refuse!
11
19
 
12
20
  ## Note on Patches/Pull Requests
13
21
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.3
data/chargify.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{chargify}
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wynn Netherland", "Nash Kabbara"]
@@ -106,6 +106,13 @@ module Chargify
106
106
  (response.subscription || response).update(:success? => deleted)
107
107
  end
108
108
 
109
+ def reactivate_subscription(sub_id)
110
+ raw_response = self.class.put("/subscriptions/#{sub_id}/reactivate.json", :body => "")
111
+ reactivated = true if raw_response.code == 200
112
+ response = Hashie::Mash.new(raw_response) rescue Hashie::Mash.new
113
+ (response.subscription || response).update(:success? => reactivated)
114
+ end
115
+
109
116
  def list_products
110
117
  products = self.class.get("/products.json")
111
118
  products.map{|p| Hashie::Mash.new p['product']}
@@ -179,6 +179,27 @@ class TestChargify < Test::Unit::TestCase
179
179
  subscription.success?.should == nil
180
180
  end
181
181
 
182
+ should "reactivate a subscription" do
183
+ stub_put "https://OU812:x@pengwynn.chargify.com/subscriptions/123/reactivate.json", "subscription.json", 200
184
+ subscription = @client.reactivate_subscription(123)
185
+
186
+ subscription.state.should == "active"
187
+ end
188
+
189
+ should "set success? to nil when subscription is not reactivated successfully" do
190
+ stub_put "https://OU812:x@pengwynn.chargify.com/subscriptions/123/reactivate.json", "subscription_not_found.json", 500
191
+ subscription = @client.reactivate_subscription(123)
192
+
193
+ subscription.success?.should == nil
194
+ end
195
+
196
+ should "set success? to false when subscription is reactivated successfully" do
197
+ stub_put "https://OU812:x@pengwynn.chargify.com/subscriptions/123/reactivate.json", "subscription.json", 200
198
+ subscription = @client.reactivate_subscription(123)
199
+
200
+ subscription.success?.should == true
201
+ end
202
+
182
203
  should "cancel subscription" do
183
204
  stub_delete "https://OU812:x@pengwynn.chargify.com/subscriptions/123.json", "deleted_subscription.json", 200
184
205
  subscription = @client.cancel_subscription(123)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 2
9
- version: 0.2.2
8
+ - 3
9
+ version: 0.2.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Wynn Netherland