recurly 0.2.1 → 0.2.2

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.

Files changed (64) hide show
  1. data/README.md +3 -2
  2. data/lib/recurly/invoice.rb +1 -1
  3. data/lib/recurly/subscription.rb +1 -1
  4. data/lib/recurly/transaction.rb +1 -1
  5. data/lib/recurly/version.rb +1 -1
  6. data/spec/integration/subscription_spec.rb +29 -8
  7. data/spec/vcr/account/close/1286666929.yml +159 -0
  8. data/spec/vcr/account/create-blank/1286666929.yml +49 -0
  9. data/spec/vcr/account/create-duplicate/1286666929.yml +95 -0
  10. data/spec/vcr/account/create-min/1286666929.yml +63 -0
  11. data/spec/vcr/account/create/1286666929.yml +67 -0
  12. data/spec/vcr/account/find/1286666929.yml +122 -0
  13. data/spec/vcr/account/list/1286666929.yml +1565 -0
  14. data/spec/vcr/account/update/1286666929.yml +250 -0
  15. data/spec/vcr/billing/create/1286682213.yml +210 -0
  16. data/spec/vcr/billing/destroy/1286682213.yml +309 -0
  17. data/spec/vcr/billing/find/1286682213.yml +273 -0
  18. data/spec/vcr/billing/update/1286682213.yml +292 -0
  19. data/spec/vcr/charge/create/1286681273.yml +253 -0
  20. data/spec/vcr/charge/list-all/1286681273.yml +302 -0
  21. data/spec/vcr/charge/list-invoiced/1286681273.yml +445 -0
  22. data/spec/vcr/charge/list-pending/1286681273.yml +302 -0
  23. data/spec/vcr/charge/lookup/1286681273.yml +171 -0
  24. data/spec/vcr/credit/create/1286681343.yml +171 -0
  25. data/spec/vcr/credit/list/1286681343.yml +299 -0
  26. data/spec/vcr/credit/lookup/1286681343.yml +171 -0
  27. data/spec/vcr/invoice/create/1286679184.yml +337 -0
  28. data/spec/vcr/invoice/list/1286679184.yml +458 -0
  29. data/spec/vcr/invoice/lookup/1286679184.yml +341 -0
  30. data/spec/vcr/plan/all.yml +306 -0
  31. data/spec/vcr/plan/delete/1286677585.yml +217 -0
  32. data/spec/vcr/plan/find.yml +196 -0
  33. data/spec/vcr/plan/update.yml +197 -0
  34. data/spec/vcr/subscription/cancel/1287036910.yml +401 -0
  35. data/spec/vcr/subscription/cancel/1287037325.yml +401 -0
  36. data/spec/vcr/subscription/cancel/1287037363.yml +401 -0
  37. data/spec/vcr/subscription/change1/1287036910.yml +409 -0
  38. data/spec/vcr/subscription/change1/1287037152.yml +409 -0
  39. data/spec/vcr/subscription/change1/1287037325.yml +409 -0
  40. data/spec/vcr/subscription/change1/1287037363.yml +409 -0
  41. data/spec/vcr/subscription/change2/1287036910.yml +409 -0
  42. data/spec/vcr/subscription/change2/1287037152.yml +283 -0
  43. data/spec/vcr/subscription/change2/1287037325.yml +283 -0
  44. data/spec/vcr/subscription/change2/1287037363.yml +409 -0
  45. data/spec/vcr/subscription/create/1287036910.yml +224 -0
  46. data/spec/vcr/subscription/create/1287037152.yml +224 -0
  47. data/spec/vcr/subscription/create/1287037325.yml +224 -0
  48. data/spec/vcr/subscription/create/1287037363.yml +224 -0
  49. data/spec/vcr/subscription/find/1287036910.yml +283 -0
  50. data/spec/vcr/subscription/find/1287037152.yml +283 -0
  51. data/spec/vcr/subscription/find/1287037325.yml +283 -0
  52. data/spec/vcr/subscription/find/1287037363.yml +283 -0
  53. data/spec/vcr/subscription/refund/1287036910.yml +382 -0
  54. data/spec/vcr/subscription/refund/1287037325.yml +382 -0
  55. data/spec/vcr/subscription/refund/1287037363.yml +382 -0
  56. data/spec/vcr/transaction/all/1286674805.yml +387 -0
  57. data/spec/vcr/transaction/create-no-account/1286674805.yml +91 -0
  58. data/spec/vcr/transaction/create-with-account/1286674805.yml +220 -0
  59. data/spec/vcr/transaction/list-empty/1286674805.yml +212 -0
  60. data/spec/vcr/transaction/list-filled/1286674805.yml +476 -0
  61. data/spec/vcr/transaction/lookup/1286674805.yml +548 -0
  62. data/spec/vcr/transaction/refund/1286674805.yml +220 -0
  63. data/spec/vcr/transaction/void/1286674805.yml +668 -0
  64. metadata +118 -4
data/README.md CHANGED
@@ -21,6 +21,7 @@ This library can be installed as a gem or a plugin. Your choice.
21
21
  gem 'recurly'
22
22
 
23
23
  **Bleeding Edge Version:**
24
+
24
25
  gem 'recurly', :git => "http://github.com/recurly/recurly-client-ruby.git"
25
26
 
26
27
 
@@ -66,9 +67,9 @@ The Recurly Configuration YAML is in the format of:
66
67
  Clearing test data (Rails3)
67
68
  ----------------
68
69
 
69
- The Recurly Railtie (for rails3) includes a rake task that allows you to easily clear out the test data on your Account. This is useful when automating the testing of the api interation within your own app.
70
+ The Recurly Railtie (for rails3) includes a rake task that allows you to easily clear out the test data on your Account. This is useful when automating the testing of the api interation within your own app.
70
71
 
71
- rake recurly:clear_test_data
72
+ rake recurly:clear_test_data
72
73
 
73
74
 
74
75
  Rails Demo Application
@@ -17,7 +17,7 @@ module Recurly
17
17
  # postprocess generated element url.
18
18
  # changes /accounts/:account_code/invoices/:id to /invoices/:id
19
19
  # this breaks update, however I dont believe recurly allows invoice updates anyways
20
- path.sub("/accounts/#{CGI::escape(prefix_options[:account_code] || '')}/invoices/", "/invoices/")
20
+ path.sub("/accounts/#{CGI::escape(prefix_options[:account_code].to_s)}/invoices/", "/invoices/")
21
21
  end
22
22
 
23
23
  end
@@ -24,7 +24,7 @@ module Recurly
24
24
  def change(timeframe, options = {})
25
25
  raise "Timeframe must be :full or :renewal." unless timeframe == 'now' or timeframe == 'renewal'
26
26
  options[:timeframe] = timeframe
27
- path = "/accounts/#{CGI::escape(self.subscription_account_code || '')}/subscription.xml"
27
+ path = "/accounts/#{CGI::escape(self.subscription_account_code.to_s)}/subscription.xml"
28
28
  connection.put(path,
29
29
  self.class.format.encode(options, :root => :subscription),
30
30
  self.class.headers)
@@ -14,7 +14,7 @@ module Recurly
14
14
  end
15
15
 
16
16
  def self.list_for_account(account_code, status = :all)
17
- results = find(:all, :from => "/accounts/#{CGI::escape(account_code || '')}/transactions")
17
+ results = find(:all, :from => "/accounts/#{CGI::escape(account_code.to_s)}/transactions")
18
18
 
19
19
  # filter by status
20
20
  if status != :all
@@ -1,3 +1,3 @@
1
1
  module Recurly #:nodoc
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -49,19 +49,40 @@ module Recurly
49
49
  end
50
50
 
51
51
  describe "updates and downgrades" do
52
- use_vcr_cassette "subscription/update/#{timestamp}"
53
52
 
54
- let(:account){ Factory.create_account("subscription-update-#{timestamp}") }
53
+ context "normal case" do
54
+ use_vcr_cassette "subscription/change1/#{timestamp}"
55
55
 
56
- before(:each) do
57
- Factory.create_subscription(account, :paid)
58
- @subscription = Subscription.find(account.account_code)
56
+ let(:account){ Factory.create_account("subscription-change1-#{timestamp}") }
57
+
58
+ before(:each) do
59
+ Factory.create_subscription(account, :paid)
60
+ @subscription = Subscription.find(account.account_code)
61
+
62
+ @subscription.change('now', :quantity => 2)
63
+ end
59
64
 
60
- @subscription.change('now', :quantity => 2)
65
+ it "should update the subscription quantity" do
66
+ Subscription.find(account.account_code).quantity.should == 2
67
+ end
61
68
  end
62
69
 
63
- it "should update the subscription quantity" do
64
- Subscription.find(account.account_code).quantity.should == 2
70
+ context "when account code is an integer (issue GH-4)" do
71
+ use_vcr_cassette "subscription/change2/#{timestamp}"
72
+
73
+ let(:account){ Factory.create_account(timestamp) }
74
+
75
+ before(:each) do
76
+ Factory.create_subscription(account, :paid)
77
+ @subscription = Subscription.find(account.account_code)
78
+
79
+ @subscription.id = account.account_code.to_i
80
+ @subscription.change('now', :quantity => 2)
81
+ end
82
+
83
+ it "should update the subscription quantity" do
84
+ Subscription.find(account.account_code).quantity.should == 2
85
+ end
65
86
  end
66
87
  end
67
88
 
@@ -0,0 +1,159 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/accounts.xml
6
+ body: |
7
+ <?xml version="1.0" encoding="UTF-8"?>
8
+ <account>
9
+ <company-name>Recurly Ruby Gem</company-name>
10
+ <account-code>account-close-1286666929</account-code>
11
+ <last-name>Test</last-name>
12
+ <email>verena@test.com</email>
13
+ <first-name>Verena</first-name>
14
+ </account>
15
+
16
+ headers:
17
+ accept:
18
+ - "*/*"
19
+ connection:
20
+ - close
21
+ content-type:
22
+ - application/xml
23
+ authorization:
24
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
25
+ response: !ruby/struct:VCR::Response
26
+ status: !ruby/struct:VCR::ResponseStatus
27
+ code: 201
28
+ message: Created
29
+ headers:
30
+ location:
31
+ - https://recurlytest3-test.recurly.com/accounts/account-close-1286666929
32
+ connection:
33
+ - close
34
+ content-type:
35
+ - application/xml; charset=utf-8
36
+ x-runtime:
37
+ - "568"
38
+ date:
39
+ - Thu, 14 Oct 2010 06:15:45 GMT
40
+ server:
41
+ - nginx/0.7.65
42
+ content-length:
43
+ - "581"
44
+ set-cookie:
45
+ - account_credentials=8171dfe4bd90db74de529ca5eaed0ff56f00e0aea9dc521fc8f8edcf2b07331ad2fce09b760ae0da68864875b1264defe18058dc980afb476fd7f1b757d5a6ea%3A%3A; domain=.recurly.com; path=/; secure; HttpOnly
46
+ - ""
47
+ - _recurly_session=e0596ab5fccf208e071f0695ddd56a64; domain=.recurly.com; path=/; Secure; HttpOnly
48
+ cache-control:
49
+ - no-cache
50
+ body: |
51
+ <?xml version="1.0" encoding="UTF-8"?>
52
+ <account>
53
+ <id>account-close-1286666929</id>
54
+ <account_code>account-close-1286666929</account_code>
55
+ <username></username>
56
+ <email>verena@test.com</email>
57
+ <first_name>Verena</first_name>
58
+ <last_name>Test</last_name>
59
+ <company_name>Recurly Ruby Gem</company_name>
60
+ <balance_in_cents type="integer">0</balance_in_cents>
61
+ <closed type="boolean">false</closed>
62
+ <hosted_login_token>06afe57039224882a15af1101f1d0c79</hosted_login_token>
63
+ <created_at type="datetime">2010-10-14T06:15:45Z</created_at>
64
+ <state>active</state>
65
+ </account>
66
+
67
+ http_version: "1.1"
68
+ - !ruby/struct:VCR::HTTPInteraction
69
+ request: !ruby/struct:VCR::Request
70
+ method: :delete
71
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/accounts/account-close-1286666929.xml
72
+ body:
73
+ headers:
74
+ accept:
75
+ - application/xml
76
+ connection:
77
+ - close
78
+ authorization:
79
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
80
+ response: !ruby/struct:VCR::Response
81
+ status: !ruby/struct:VCR::ResponseStatus
82
+ code: 200
83
+ message: OK
84
+ headers:
85
+ x-ua-compatible:
86
+ - IE=Edge
87
+ connection:
88
+ - close
89
+ content-type:
90
+ - application/xml; charset=utf-8
91
+ x-runtime:
92
+ - "64"
93
+ date:
94
+ - Thu, 14 Oct 2010 06:15:46 GMT
95
+ server:
96
+ - nginx/0.7.65
97
+ content-length:
98
+ - "1"
99
+ set-cookie:
100
+ - _recurly_session=2309d7d0061fd27d7c9b188e8d2ad903; domain=.recurly.com; path=/; Secure; HttpOnly
101
+ cache-control:
102
+ - no-cache
103
+ body: " "
104
+ http_version: "1.1"
105
+ - !ruby/struct:VCR::HTTPInteraction
106
+ request: !ruby/struct:VCR::Request
107
+ method: :get
108
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/accounts/account-close-1286666929.xml
109
+ body:
110
+ headers:
111
+ accept:
112
+ - application/xml
113
+ connection:
114
+ - close
115
+ authorization:
116
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
117
+ response: !ruby/struct:VCR::Response
118
+ status: !ruby/struct:VCR::ResponseStatus
119
+ code: 200
120
+ message: OK
121
+ headers:
122
+ x-ua-compatible:
123
+ - IE=Edge
124
+ etag:
125
+ - "\"316f3d6beaaba14f31d565352c12f739\""
126
+ connection:
127
+ - close
128
+ content-type:
129
+ - application/xml; charset=utf-8
130
+ x-runtime:
131
+ - "44"
132
+ date:
133
+ - Thu, 14 Oct 2010 06:15:47 GMT
134
+ server:
135
+ - nginx/0.7.65
136
+ content-length:
137
+ - "580"
138
+ set-cookie:
139
+ - _recurly_session=b0919023d9048fc518683695361697d8; domain=.recurly.com; path=/; Secure; HttpOnly
140
+ cache-control:
141
+ - private, max-age=0, must-revalidate
142
+ body: |
143
+ <?xml version="1.0" encoding="UTF-8"?>
144
+ <account>
145
+ <id>account-close-1286666929</id>
146
+ <account_code>account-close-1286666929</account_code>
147
+ <username></username>
148
+ <email>verena@test.com</email>
149
+ <first_name>Verena</first_name>
150
+ <last_name>Test</last_name>
151
+ <company_name>Recurly Ruby Gem</company_name>
152
+ <balance_in_cents type="integer">0</balance_in_cents>
153
+ <closed type="boolean">true</closed>
154
+ <hosted_login_token>06afe57039224882a15af1101f1d0c79</hosted_login_token>
155
+ <created_at type="datetime">2010-10-14T06:15:45Z</created_at>
156
+ <state>closed</state>
157
+ </account>
158
+
159
+ http_version: "1.1"
@@ -0,0 +1,49 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/accounts.xml
6
+ body: |
7
+ <?xml version="1.0" encoding="UTF-8"?>
8
+ <account>
9
+ <account-code></account-code>
10
+ </account>
11
+
12
+ headers:
13
+ accept:
14
+ - "*/*"
15
+ connection:
16
+ - close
17
+ content-type:
18
+ - application/xml
19
+ authorization:
20
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
21
+ response: !ruby/struct:VCR::Response
22
+ status: !ruby/struct:VCR::ResponseStatus
23
+ code: 422
24
+ message: ""
25
+ headers:
26
+ connection:
27
+ - close
28
+ content-type:
29
+ - application/xml; charset=utf-8
30
+ x-runtime:
31
+ - "18"
32
+ date:
33
+ - Thu, 14 Oct 2010 06:15:47 GMT
34
+ server:
35
+ - nginx/0.7.65
36
+ content-length:
37
+ - "186"
38
+ set-cookie:
39
+ - _recurly_session=5b48160d1ced437e9fcf8b8a6ef37ec9; domain=.recurly.com; path=/; Secure; HttpOnly
40
+ cache-control:
41
+ - no-cache
42
+ body: |
43
+ <?xml version="1.0" encoding="UTF-8"?>
44
+ <errors>
45
+ <error field="account_code">Account code can't be blank</error>
46
+ <error field="account_code">Account code is invalid</error>
47
+ </errors>
48
+
49
+ http_version: "1.1"
@@ -0,0 +1,95 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/accounts.xml
6
+ body: |
7
+ <?xml version="1.0" encoding="UTF-8"?>
8
+ <account>
9
+ <account-code>account-exists</account-code>
10
+ </account>
11
+
12
+ headers:
13
+ accept:
14
+ - "*/*"
15
+ connection:
16
+ - close
17
+ content-type:
18
+ - application/xml
19
+ authorization:
20
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
21
+ response: !ruby/struct:VCR::Response
22
+ status: !ruby/struct:VCR::ResponseStatus
23
+ code: 422
24
+ message: ""
25
+ headers:
26
+ connection:
27
+ - close
28
+ content-type:
29
+ - application/xml; charset=utf-8
30
+ x-runtime:
31
+ - "30"
32
+ date:
33
+ - Thu, 14 Oct 2010 06:15:48 GMT
34
+ server:
35
+ - nginx/0.7.65
36
+ content-length:
37
+ - "132"
38
+ set-cookie:
39
+ - _recurly_session=383e9b0854b010f9178cecd8a89f30fe; domain=.recurly.com; path=/; Secure; HttpOnly
40
+ cache-control:
41
+ - no-cache
42
+ body: |
43
+ <?xml version="1.0" encoding="UTF-8"?>
44
+ <errors>
45
+ <error field="account_code">Account code has already been taken</error>
46
+ </errors>
47
+
48
+ http_version: "1.1"
49
+ - !ruby/struct:VCR::HTTPInteraction
50
+ request: !ruby/struct:VCR::Request
51
+ method: :post
52
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/accounts.xml
53
+ body: |
54
+ <?xml version="1.0" encoding="UTF-8"?>
55
+ <account>
56
+ <account-code>account-exists</account-code>
57
+ </account>
58
+
59
+ headers:
60
+ accept:
61
+ - "*/*"
62
+ connection:
63
+ - close
64
+ content-type:
65
+ - application/xml
66
+ authorization:
67
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
68
+ response: !ruby/struct:VCR::Response
69
+ status: !ruby/struct:VCR::ResponseStatus
70
+ code: 422
71
+ message: ""
72
+ headers:
73
+ connection:
74
+ - close
75
+ content-type:
76
+ - application/xml; charset=utf-8
77
+ x-runtime:
78
+ - "18"
79
+ date:
80
+ - Thu, 14 Oct 2010 06:15:49 GMT
81
+ server:
82
+ - nginx/0.7.65
83
+ content-length:
84
+ - "132"
85
+ set-cookie:
86
+ - _recurly_session=5d4c19f3669a1ddde3c95819026f63df; domain=.recurly.com; path=/; Secure; HttpOnly
87
+ cache-control:
88
+ - no-cache
89
+ body: |
90
+ <?xml version="1.0" encoding="UTF-8"?>
91
+ <errors>
92
+ <error field="account_code">Account code has already been taken</error>
93
+ </errors>
94
+
95
+ http_version: "1.1"
@@ -0,0 +1,63 @@
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
+ method: :post
5
+ uri: https://railsjedi%40sogetthis.com:7PCB2mZC@recurlytest3-test.recurly.com:443/accounts.xml
6
+ body: |
7
+ <?xml version="1.0" encoding="UTF-8"?>
8
+ <account>
9
+ <account-code>d00d-1286666929</account-code>
10
+ </account>
11
+
12
+ headers:
13
+ accept:
14
+ - "*/*"
15
+ connection:
16
+ - close
17
+ content-type:
18
+ - application/xml
19
+ authorization:
20
+ - Basic cmFpbHNqZWRpQHNvZ2V0dGhpcy5jb206N1BDQjJtWkM=
21
+ response: !ruby/struct:VCR::Response
22
+ status: !ruby/struct:VCR::ResponseStatus
23
+ code: 201
24
+ message: Created
25
+ headers:
26
+ location:
27
+ - https://recurlytest3-test.recurly.com/accounts/d00d-1286666929
28
+ connection:
29
+ - close
30
+ content-type:
31
+ - application/xml; charset=utf-8
32
+ x-runtime:
33
+ - "567"
34
+ date:
35
+ - Thu, 14 Oct 2010 06:15:16 GMT
36
+ server:
37
+ - nginx/0.7.65
38
+ content-length:
39
+ - "522"
40
+ set-cookie:
41
+ - account_credentials=279a5d85932ab7f16c10dfd48b8a4ba39dd6fdab67a66480d7164cd6d9c8a30e7ed2e5cca7bb4450e7ad8ef283cb2e594213becdc25eb05b5f4660813fc24846%3A%3A; domain=.recurly.com; path=/; secure; HttpOnly
42
+ - ""
43
+ - _recurly_session=773baa0f87c9badfa95f2b5c192bea85; domain=.recurly.com; path=/; Secure; HttpOnly
44
+ cache-control:
45
+ - no-cache
46
+ body: |
47
+ <?xml version="1.0" encoding="UTF-8"?>
48
+ <account>
49
+ <id>d00d-1286666929</id>
50
+ <account_code>d00d-1286666929</account_code>
51
+ <username></username>
52
+ <email></email>
53
+ <first_name></first_name>
54
+ <last_name></last_name>
55
+ <company_name></company_name>
56
+ <balance_in_cents type="integer">0</balance_in_cents>
57
+ <closed type="boolean">false</closed>
58
+ <hosted_login_token>ad58f7eb915d44139f523a50e3882017</hosted_login_token>
59
+ <created_at type="datetime">2010-10-14T06:15:16Z</created_at>
60
+ <state>active</state>
61
+ </account>
62
+
63
+ http_version: "1.1"