chargify_api_ares 1.3.1 → 1.3.2
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.
- checksums.yaml +4 -4
- data/.travis.yml +0 -4
- data/Gemfile.lock +1 -1
- data/HISTORY.md +5 -0
- data/chargify_api_ares.gemspec +3 -3
- data/examples/subscriptions.rb +16 -0
- data/gemfiles/rails_3.gemfile.lock +1 -1
- data/gemfiles/rails_4.1.gemfile.lock +1 -1
- data/gemfiles/rails_4.gemfile.lock +1 -1
- data/lib/chargify_api_ares/resources/subscription.rb +17 -1
- data/spec/remote/remote_spec.rb +21 -0
- data/spec/resources/subscription_spec.rb +27 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c515698fa8c8e719aa022e1bb143c236fdddc446
|
4
|
+
data.tar.gz: 1ae9b90d69b22894710339581f96a613d2fa3ab4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37397b10804eac6f36a94535ba832b182a5e1d16763c614f228d2819e395fcc0adb485642a170011f2fa2dc1d9c4fbc9478067bbf7fc73b8f5333b446347ed87
|
7
|
+
data.tar.gz: 5cc270208d6326272d5cccebb41cbb38cac0466fc1acdcea10085b1f64f0cc7ae41591795e8db5f1cd0dfa4be236478102d71b32af468357274721529782266f
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
data/HISTORY.md
CHANGED
data/chargify_api_ares.gemspec
CHANGED
@@ -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.
|
8
|
-
s.date = '
|
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
|
|
data/examples/subscriptions.rb
CHANGED
@@ -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
|
@@ -20,7 +20,7 @@ module Chargify
|
|
20
20
|
if cancellation_message.nil?
|
21
21
|
destroy
|
22
22
|
else
|
23
|
-
#
|
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
|
data/spec/remote/remote_spec.rb
CHANGED
@@ -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.
|
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:
|
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.
|
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
|