chargify_api_ares 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f9213ec824f1ee7c2a35e641fb313ae36fc2e77
4
- data.tar.gz: aa6fcc1c79d21bb64a9ce44054b9e60f2afbe4ce
3
+ metadata.gz: c515698fa8c8e719aa022e1bb143c236fdddc446
4
+ data.tar.gz: 1ae9b90d69b22894710339581f96a613d2fa3ab4
5
5
  SHA512:
6
- metadata.gz: 3206b4db9d7f546698dd91438a2dfdf74881854f73d28c8afb68203bae95b060b37f3d73aea7f7c977a5c7ae09a627bb15cac323343082c028139cdc1cbf8daa
7
- data.tar.gz: 3248a345d6bb9b7a24bd230e11599b86383f0fa3b4960487eabcee9e622c63e5ed78ccf7bfbfa05cca50a93b85c3b6c7bdf15df4dda7f10b00aab735e5018ad6
6
+ metadata.gz: 37397b10804eac6f36a94535ba832b182a5e1d16763c614f228d2819e395fcc0adb485642a170011f2fa2dc1d9c4fbc9478067bbf7fc73b8f5333b446347ed87
7
+ data.tar.gz: 5cc270208d6326272d5cccebb41cbb38cac0466fc1acdcea10085b1f64f0cc7ae41591795e8db5f1cd0dfa4be236478102d71b32af468357274721529782266f
data/.travis.yml CHANGED
@@ -1,12 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.1.3
4
- - 2.1.2
5
4
  - 2.0.0
6
5
  - 1.9.3
7
- - 1.9.2
8
- - 1.8.7
9
- - ree
10
6
  - jruby
11
7
  - ruby-head
12
8
  - rbx-2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- chargify_api_ares (1.3.1)
4
+ chargify_api_ares (1.3.2)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
data/HISTORY.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.3.2 / Dec 15 2014
2
+
3
+ * `product_change` and `cancel_delayed_product_change` added to Subscription
4
+ resource
5
+
1
6
  ## 1.3.1 / Dec 15 2014
2
7
 
3
8
  * Update metadata / metafield endpoints to work with activeresource 4+
@@ -4,11 +4,11 @@ Gem::Specification.new do |s|
4
4
  s.rubygems_version = '1.3.7'
5
5
 
6
6
  s.name = 'chargify_api_ares'
7
- s.version = '1.3.1'
8
- s.date = '2014-12-15'
7
+ s.version = '1.3.2'
8
+ s.date = '2015-02-20'
9
9
  s.summary = 'A Chargify API wrapper for Ruby using ActiveResource'
10
10
  s.description = ''
11
- s.authors = ["Michael Klett", "Nathan Verni", "Jeremy W. Rowe", "Eric Farkas"]
11
+ s.authors = ["Michael Klett", "Nathan Verni", "Jeremy W. Rowe", "Eric Farkas", "Wendy Smoak"]
12
12
  s.email = 'support@chargify.com'
13
13
  s.homepage = 'http://github.com/chargify/chargify_api_ares'
14
14
 
@@ -52,3 +52,19 @@ subscription.charge(:amount => 10.00, :memo => 'Extra service')
52
52
  subscription.cancel
53
53
  subscription.reload
54
54
  # => #<Chargify::Subscription:0x1020ed4b0 @prefix_options={}, @attributes={"cancellation_message"=>nil, "activated_at"=>Tue Nov 17 16:00:17 UTC 2009, "expires_at"=>nil, "updated_at"=>Tue Nov 17 16:00:17 UTC 2009, "credit_card"=>#<Chargify::Subscription::CreditCard:0x10234f168 @prefix_options={}, @attributes={"card_type"=>"bogus", "expiration_year"=>2015, "masked_card_number"=>"XXXX-XXXX-XXXX-2", "first_name"=>"Michael", "expiration_month"=>1, "last_name"=>"Klett"}>, "product"=>#<Chargify::Product:0x10234f370 @prefix_options={}, @attributes={"price_in_cents"=>0, "name"=>"Chargify API Ares Test", "handle"=>"chargify-api-ares-test", "product_family"=>#<Chargify::Product::ProductFamily:0x102354708 @prefix_options={}, @attributes={"name"=>"Chargify API ARes Test", "handle"=>"chargify-api-ares-test", "id"=>79, "accounting_code"=>nil}>, "id"=>153, "accounting_code"=>nil, "interval_unit"=>"month", "interval"=>1}>, "credit_card_attributes"=>{:full_number=>"2", :expiration_year=>"2015"}, "trial_ended_at"=>nil, "id"=>331, "current_period_ends_at"=>Thu Dec 17 16:00:17 UTC 2009, "product_handle"=>"chargify-api-ares-test", "customer"=>#<Chargify::Customer:0x10234f730 @prefix_options={}, @attributes={"reference"=>"moklett", "updated_at"=>Tue Nov 17 15:51:02 UTC 2009, "id"=>331, "first_name"=>"Michael", "organization"=>"Chargify", "last_name"=>"Klett", "email"=>"moklett@example.com", "created_at"=>Tue Nov 17 15:51:02 UTC 2009}>, "trial_started_at"=>nil, "balance_in_cents"=>0, "current_period_started_at"=>Tue Nov 17 16:00:17 UTC 2009, "state"=>"canceled", "created_at"=>Tue Nov 17 16:00:17 UTC 2009, "customer_reference"=>"moklett"}>
55
+
56
+ # Schedule a delayed cancellation
57
+ subscription.delayed_cancel
58
+ subscription.delayed_cancel(true)
59
+
60
+ # Unschedule a delayed cancellation
61
+ subscription.delayed_cancel(false)
62
+
63
+ # Change the product immediately
64
+ subscription.product_change('new-handle')
65
+
66
+ # Change the product at the end of the billing period
67
+ subscription.product_change('new-handle', true)
68
+
69
+ # Cancel a delayed product change
70
+ subscription.cancel_delayed_product_change
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- chargify_api_ares (1.3.0)
4
+ chargify_api_ares (1.3.2)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- chargify_api_ares (1.3.0)
4
+ chargify_api_ares (1.3.2)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../
3
3
  specs:
4
- chargify_api_ares (1.3.0)
4
+ chargify_api_ares (1.3.2)
5
5
  activeresource (>= 3.2.16)
6
6
 
7
7
  GEM
@@ -20,7 +20,7 @@ module Chargify
20
20
  if cancellation_message.nil?
21
21
  destroy
22
22
  else
23
- #Destory does not support body, must work around it to send verb DELETE
23
+ #Destroy does not support body, must work around it to send verb DELETE
24
24
  self.connection.post(element_path, {:cancellation_message => cancellation_message}.to_xml(:root => :subscription), self.class.headers.merge({'X-Http-Method-Override' => 'DELETE'}))
25
25
  end
26
26
  end
@@ -133,6 +133,22 @@ module Chargify
133
133
  end
134
134
  end
135
135
 
136
+ def delayed_cancel(cancel_at_end_of_period = true)
137
+ self.cancel_at_end_of_period = cancel_at_end_of_period
138
+ save
139
+ end
140
+
141
+ def product_change(handle, delayed = false)
142
+ self.product_handle = handle
143
+ self.product_change_delayed = delayed
144
+ save
145
+ end
146
+
147
+ def cancel_delayed_product_change
148
+ self.next_product_id = nil
149
+ save
150
+ end
151
+
136
152
  private
137
153
 
138
154
  class Component < Base
@@ -219,6 +219,27 @@ describe "Remote" do
219
219
  end
220
220
  end
221
221
 
222
+ describe "scheduling a subscription cancellation" do
223
+ before(:all) do
224
+ @subscription = Chargify::Subscription.create(
225
+ :product_handle => pro_plan.handle,
226
+ :customer_reference => johnadoe.reference,
227
+ :payment_profile_attributes => good_payment_profile_attributes)
228
+ end
229
+
230
+ it "schedules the cancellation" do
231
+ @subscription.delayed_cancel
232
+ Chargify::Subscription.find(@subscription.id).cancel_at_end_of_period.should == true
233
+ end
234
+
235
+ it "unschedules the cancellation" do
236
+ @subscription.delayed_cancel
237
+ Chargify::Subscription.find(@subscription.id).cancel_at_end_of_period.should == true
238
+ @subscription.delayed_cancel(false)
239
+ Chargify::Subscription.find(@subscription.id).cancel_at_end_of_period.should == false
240
+ end
241
+ end
242
+
222
243
  describe "reactivating a subscriptions" do
223
244
  before(:all) do
224
245
  @subscription = Chargify::Subscription.create(
@@ -107,4 +107,31 @@ describe Chargify::Subscription, :fake_resource do
107
107
  expect(response.errors.any?).to be_false
108
108
  expect(response).to be_a(Chargify::Migration)
109
109
  end
110
+
111
+ describe '#delayed_cancel' do
112
+ context 'argument provided' do
113
+ it 'schedules subscription cancellation' do
114
+ subscription = build(:subscription, :id => 1, :cancel_at_end_of_period => false)
115
+
116
+ subscription.delayed_cancel(true)
117
+ expect(subscription.cancel_at_end_of_period).to eq(true)
118
+ end
119
+
120
+ it 'unschedules subscription cancellation' do
121
+ subscription = build(:subscription, :id => 1, :cancel_at_end_of_period => true)
122
+
123
+ subscription.delayed_cancel(false)
124
+ expect(subscription.cancel_at_end_of_period).to eq(false)
125
+ end
126
+ end
127
+
128
+ context 'no argument provided' do
129
+ it 'schedules subscription cancellation' do
130
+ subscription = build(:subscription, :id => 1, :cancel_at_end_of_period => false)
131
+
132
+ subscription.delayed_cancel
133
+ expect(subscription.cancel_at_end_of_period).to eq(true)
134
+ end
135
+ end
136
+ end
110
137
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chargify_api_ares
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Klett
8
8
  - Nathan Verni
9
9
  - Jeremy W. Rowe
10
10
  - Eric Farkas
11
+ - Wendy Smoak
11
12
  autorequire:
12
13
  bindir: bin
13
14
  cert_chain: []
14
- date: 2014-12-15 00:00:00.000000000 Z
15
+ date: 2015-02-20 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: activeresource
@@ -305,7 +306,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
305
306
  version: '0'
306
307
  requirements: []
307
308
  rubyforge_project:
308
- rubygems_version: 2.2.2
309
+ rubygems_version: 2.4.5
309
310
  signing_key:
310
311
  specification_version: 3
311
312
  summary: A Chargify API wrapper for Ruby using ActiveResource