recurly 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of recurly might be problematic. Click here for more details.
- data/Manifest +2 -0
- data/Rakefile +1 -1
- data/lib/recurly.rb +2 -1
- data/lib/recurly/subscription.rb +2 -1
- data/lib/recurly/transaction.rb +6 -0
- data/recurly.gemspec +5 -5
- data/test/subscription_test.rb +13 -12
- data/test/test_helper.rb +24 -1
- data/test/transaction_test.rb +19 -0
- metadata +7 -4
data/Manifest
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('recurly', '0.1.
|
5
|
+
Echoe.new('recurly', '0.1.4') do |p|
|
6
6
|
p.description = "A Ruby API wrapper for Recurly. Super Simple Subscription billing."
|
7
7
|
p.url = "http://github.com/recurly/recurly-client-ruby"
|
8
8
|
p.author = "Isaac Hall"
|
data/lib/recurly.rb
CHANGED
@@ -7,4 +7,5 @@ require File.dirname(__FILE__) + '/recurly/charge'
|
|
7
7
|
require File.dirname(__FILE__) + '/recurly/credit'
|
8
8
|
require File.dirname(__FILE__) + '/recurly/invoice'
|
9
9
|
require File.dirname(__FILE__) + '/recurly/plan'
|
10
|
-
require File.dirname(__FILE__) + '/recurly/subscription'
|
10
|
+
require File.dirname(__FILE__) + '/recurly/subscription'
|
11
|
+
require File.dirname(__FILE__) + '/recurly/transaction'
|
data/lib/recurly/subscription.rb
CHANGED
@@ -25,7 +25,8 @@ module Recurly
|
|
25
25
|
def change(timeframe, options = {})
|
26
26
|
raise "Timeframe must be :full or :partial." unless timeframe == 'now' or timeframe == 'renewal'
|
27
27
|
options[:timeframe] = timeframe
|
28
|
-
|
28
|
+
path = "/accounts/#{CGI::escape(self.subscription_account_code || '')}/subscription.xml"
|
29
|
+
connection.put(path,
|
29
30
|
self.class.format.encode(options, :root => :subscription),
|
30
31
|
self.class.headers)
|
31
32
|
end
|
data/recurly.gemspec
CHANGED
@@ -2,22 +2,22 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{recurly}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Isaac Hall"]
|
9
|
-
s.date = %q{2010-
|
9
|
+
s.date = %q{2010-04-01}
|
10
10
|
s.description = %q{A Ruby API wrapper for Recurly. Super Simple Subscription billing.}
|
11
11
|
s.email = %q{support@recurly.com}
|
12
|
-
s.extra_rdoc_files = ["LICENSE", "README.md", "lib/recurly.rb", "lib/recurly/account.rb", "lib/recurly/base.rb", "lib/recurly/billing_info.rb", "lib/recurly/charge.rb", "lib/recurly/credit.rb", "lib/recurly/invoice.rb", "lib/recurly/plan.rb", "lib/recurly/subscription.rb"]
|
13
|
-
s.files = ["LICENSE", "README.md", "Rakefile", "init.rb", "lib/recurly.rb", "lib/recurly/account.rb", "lib/recurly/base.rb", "lib/recurly/billing_info.rb", "lib/recurly/charge.rb", "lib/recurly/credit.rb", "lib/recurly/invoice.rb", "lib/recurly/plan.rb", "lib/recurly/subscription.rb", "test/account_test.rb", "test/billing_info_test.rb", "test/charge_test.rb", "test/credit_test.rb", "test/plan_test.rb", "test/subscription_test.rb", "test/test_helper.rb", "Manifest", "
|
12
|
+
s.extra_rdoc_files = ["LICENSE", "README.md", "lib/recurly.rb", "lib/recurly/account.rb", "lib/recurly/base.rb", "lib/recurly/billing_info.rb", "lib/recurly/charge.rb", "lib/recurly/credit.rb", "lib/recurly/invoice.rb", "lib/recurly/plan.rb", "lib/recurly/subscription.rb", "lib/recurly/transaction.rb"]
|
13
|
+
s.files = ["LICENSE", "README.md", "Rakefile", "init.rb", "lib/recurly.rb", "lib/recurly/account.rb", "lib/recurly/base.rb", "lib/recurly/billing_info.rb", "lib/recurly/charge.rb", "lib/recurly/credit.rb", "lib/recurly/invoice.rb", "lib/recurly/plan.rb", "lib/recurly/subscription.rb", "lib/recurly/transaction.rb", "recurly.gemspec", "test/account_test.rb", "test/billing_info_test.rb", "test/charge_test.rb", "test/credit_test.rb", "test/plan_test.rb", "test/subscription_test.rb", "test/test_helper.rb", "Manifest", "test/transaction_test.rb"]
|
14
14
|
s.homepage = %q{http://github.com/recurly/recurly-client-ruby}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Recurly", "--main", "README.md"]
|
16
16
|
s.require_paths = ["lib"]
|
17
17
|
s.rubyforge_project = %q{recurly}
|
18
18
|
s.rubygems_version = %q{1.3.6}
|
19
19
|
s.summary = %q{A Ruby API wrapper for Recurly. Super Simple Subscription billing.}
|
20
|
-
s.test_files = ["test/account_test.rb", "test/billing_info_test.rb", "test/charge_test.rb", "test/credit_test.rb", "test/plan_test.rb", "test/subscription_test.rb", "test/test_helper.rb"]
|
20
|
+
s.test_files = ["test/account_test.rb", "test/billing_info_test.rb", "test/charge_test.rb", "test/credit_test.rb", "test/plan_test.rb", "test/subscription_test.rb", "test/test_helper.rb", "test/transaction_test.rb"]
|
21
21
|
|
22
22
|
if s.respond_to? :specification_version then
|
23
23
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
data/test/subscription_test.rb
CHANGED
@@ -11,7 +11,7 @@ class SubscriptionTest < Test::Unit::TestCase
|
|
11
11
|
:email => 'verena@test.com',
|
12
12
|
:company_name => 'Recurly Ruby Gem')
|
13
13
|
|
14
|
-
sub = create_subscription(account
|
14
|
+
sub = create_subscription(account)
|
15
15
|
assert_not_nil sub
|
16
16
|
assert_nil sub.canceled_at
|
17
17
|
assert_equal sub.state, 'active'
|
@@ -20,14 +20,14 @@ class SubscriptionTest < Test::Unit::TestCase
|
|
20
20
|
|
21
21
|
def test_create_subscription_existing_account
|
22
22
|
account = create_account('existing-account')
|
23
|
-
sub = create_subscription(account
|
23
|
+
sub = create_subscription(account)
|
24
24
|
|
25
25
|
assert_equal sub.state, 'active'
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_update_subscription
|
29
29
|
account = create_account('update-subscription')
|
30
|
-
sub = create_subscription(account
|
30
|
+
sub = create_subscription(account)
|
31
31
|
|
32
32
|
sub.change('now', :quantity => 2)
|
33
33
|
|
@@ -37,7 +37,7 @@ class SubscriptionTest < Test::Unit::TestCase
|
|
37
37
|
|
38
38
|
def test_cancel_subscription
|
39
39
|
account = create_account('cancel-subscription')
|
40
|
-
subscription = create_subscription(account
|
40
|
+
subscription = create_subscription(account)
|
41
41
|
|
42
42
|
subscription.cancel(account.account_code)
|
43
43
|
|
@@ -48,7 +48,7 @@ class SubscriptionTest < Test::Unit::TestCase
|
|
48
48
|
|
49
49
|
def test_refund_subscription
|
50
50
|
account = create_account('refund-subscription')
|
51
|
-
subscription = create_subscription(account
|
51
|
+
subscription = create_subscription(account)
|
52
52
|
|
53
53
|
subscription.refund(:full)
|
54
54
|
|
@@ -57,7 +57,7 @@ class SubscriptionTest < Test::Unit::TestCase
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def create_subscription(account,
|
60
|
+
def create_subscription(account, subscription_attrs={})
|
61
61
|
account.billing_info = Recurly::BillingInfo.new(
|
62
62
|
:first_name => account.first_name,
|
63
63
|
:last_name => account.last_name,
|
@@ -75,12 +75,13 @@ class SubscriptionTest < Test::Unit::TestCase
|
|
75
75
|
:ip_address => '127.0.0.1'
|
76
76
|
)
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
)
|
78
|
+
params = {:account_code => account.account_code,
|
79
|
+
:plan_code => TEST_PLAN_CODE,
|
80
|
+
:quantity => 1,
|
81
|
+
:account => account}.merge subscription_attrs
|
82
|
+
|
83
|
+
sub = Recurly::Subscription.create(params)
|
84
|
+
|
84
85
|
end
|
85
86
|
|
86
87
|
end
|
data/test/test_helper.rb
CHANGED
@@ -9,7 +9,7 @@ Recurly.configure do |c|
|
|
9
9
|
c.site = ''
|
10
10
|
end
|
11
11
|
|
12
|
-
TEST_PLAN_CODE = '
|
12
|
+
TEST_PLAN_CODE = 'trial'
|
13
13
|
|
14
14
|
def create_account(account_code)
|
15
15
|
account = Recurly::Account.create(
|
@@ -18,4 +18,27 @@ def create_account(account_code)
|
|
18
18
|
:last_name => 'Test',
|
19
19
|
:email => 'verena@test.com',
|
20
20
|
:company_name => 'Recurly Ruby Gem')
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_account_with_billing_info(account_code)
|
24
|
+
|
25
|
+
account = create_account(account_code)
|
26
|
+
|
27
|
+
billing_info = Recurly::BillingInfo.create(
|
28
|
+
:account_code => account.account_code,
|
29
|
+
:first_name => account.first_name,
|
30
|
+
:last_name => account.last_name,
|
31
|
+
:address1 => '123 Test St',
|
32
|
+
:city => 'San Francisco',
|
33
|
+
:state => 'CA',
|
34
|
+
:zip => '94115',
|
35
|
+
:credit_card => {
|
36
|
+
:number => '1',
|
37
|
+
:year => Time.now.year + 1,
|
38
|
+
:month => Time.now.month,
|
39
|
+
:verification_value => '123'
|
40
|
+
}
|
41
|
+
)
|
42
|
+
|
43
|
+
account
|
21
44
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require "test/unit"
|
3
|
+
|
4
|
+
class TransactionTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_create_transaction
|
7
|
+
account = create_account_with_billing_info('transaction')
|
8
|
+
|
9
|
+
trans = Recurly::Transaction.create(
|
10
|
+
:account => { :account_code => account.account_code },
|
11
|
+
:amount_in_cents => 500,
|
12
|
+
:description => "test transaction for $5"
|
13
|
+
)
|
14
|
+
|
15
|
+
assert_not_nil trans.id
|
16
|
+
assert_equal trans.amount_in_cents, 500
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Isaac Hall
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-04-01 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -36,6 +36,7 @@ extra_rdoc_files:
|
|
36
36
|
- lib/recurly/invoice.rb
|
37
37
|
- lib/recurly/plan.rb
|
38
38
|
- lib/recurly/subscription.rb
|
39
|
+
- lib/recurly/transaction.rb
|
39
40
|
files:
|
40
41
|
- LICENSE
|
41
42
|
- README.md
|
@@ -50,6 +51,8 @@ files:
|
|
50
51
|
- lib/recurly/invoice.rb
|
51
52
|
- lib/recurly/plan.rb
|
52
53
|
- lib/recurly/subscription.rb
|
54
|
+
- lib/recurly/transaction.rb
|
55
|
+
- recurly.gemspec
|
53
56
|
- test/account_test.rb
|
54
57
|
- test/billing_info_test.rb
|
55
58
|
- test/charge_test.rb
|
@@ -58,7 +61,6 @@ files:
|
|
58
61
|
- test/subscription_test.rb
|
59
62
|
- test/test_helper.rb
|
60
63
|
- Manifest
|
61
|
-
- recurly.gemspec
|
62
64
|
has_rdoc: true
|
63
65
|
homepage: http://github.com/recurly/recurly-client-ruby
|
64
66
|
licenses: []
|
@@ -103,3 +105,4 @@ test_files:
|
|
103
105
|
- test/plan_test.rb
|
104
106
|
- test/subscription_test.rb
|
105
107
|
- test/test_helper.rb
|
108
|
+
- test/transaction_test.rb
|