recurly 0.2.6 → 0.2.7
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/lib/recurly.rb +14 -0
- data/lib/recurly/rails3/railtie.rb +8 -2
- data/lib/recurly/version.rb +1 -1
- data/spec/config/test.yml +4 -0
- data/spec/spec_helper.rb +16 -4
- data/spec/unit/config_spec.rb +38 -0
- data/spec/vcr/account/close/1288381765.yml +159 -0
- data/spec/vcr/account/create-blank/1288381765.yml +49 -0
- data/spec/vcr/account/create-duplicate/1288381765.yml +95 -0
- data/spec/vcr/account/create-min/1288381765.yml +63 -0
- data/spec/vcr/account/create/1288381765.yml +67 -0
- data/spec/vcr/account/find/1288381765.yml +160 -0
- data/spec/vcr/account/list/1288381765.yml +1835 -0
- data/spec/vcr/account/update/1288381765.yml +250 -0
- metadata +24 -4
data/lib/recurly.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'active_resource'
|
2
2
|
require 'active_support/deprecation'
|
3
|
+
require 'active_support/json'
|
3
4
|
require 'cgi'
|
4
5
|
|
5
6
|
require 'recurly/version'
|
@@ -53,6 +54,8 @@ module Recurly
|
|
53
54
|
true
|
54
55
|
end
|
55
56
|
|
57
|
+
# allows configuration from a yml file that contains the fields:
|
58
|
+
# username,password,site
|
56
59
|
def configure_from_yaml(path = nil)
|
57
60
|
configure do |c|
|
58
61
|
# parse configuration from yml
|
@@ -65,5 +68,16 @@ module Recurly
|
|
65
68
|
end
|
66
69
|
end
|
67
70
|
end
|
71
|
+
|
72
|
+
# allows configuration from a json string that contains the fields:
|
73
|
+
# username,password,site
|
74
|
+
def configure_from_json(json_string)
|
75
|
+
config_data = ActiveSupport::JSON.decode(json_string)
|
76
|
+
configure do |c|
|
77
|
+
c.username = config_data['username']
|
78
|
+
c.password = config_data['password']
|
79
|
+
c.site = config_data['site']
|
80
|
+
end
|
81
|
+
end
|
68
82
|
end
|
69
83
|
end
|
@@ -5,8 +5,14 @@ module Recurly
|
|
5
5
|
end
|
6
6
|
|
7
7
|
config.after_initialize do
|
8
|
-
|
9
|
-
|
8
|
+
unless Recurly.configured?
|
9
|
+
if ENV["RECURLY_CONFIG"]
|
10
|
+
::Recurly.configure_from_json(ENV["RECURLY_CONFIG"])
|
11
|
+
else
|
12
|
+
# setup recurly authentication details for testing
|
13
|
+
::Recurly.configure_from_yaml
|
14
|
+
end
|
15
|
+
end
|
10
16
|
end
|
11
17
|
|
12
18
|
end
|
data/lib/recurly/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -6,11 +6,23 @@ Bundler.setup
|
|
6
6
|
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
7
7
|
require 'recurly'
|
8
8
|
|
9
|
-
Recurly.settings_path = "#{File.dirname(__FILE__)}/config/recurly.yml"
|
10
|
-
|
11
9
|
# Requires supporting files with custom matchers and macros, etc,
|
12
10
|
# in ./support/ and its subdirectories.
|
13
11
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
14
12
|
|
15
|
-
|
16
|
-
|
13
|
+
module SpecHelper
|
14
|
+
# add helper methods here
|
15
|
+
end
|
16
|
+
|
17
|
+
RSpec.configure do |config|
|
18
|
+
config.include SpecHelper
|
19
|
+
|
20
|
+
config.mock_with :rspec
|
21
|
+
|
22
|
+
config.before(:each) do
|
23
|
+
Recurly.settings_path = "#{File.dirname(__FILE__)}/config/recurly.yml"
|
24
|
+
Recurly.configure_from_yaml
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "RecurlyConfig" do
|
4
|
+
|
5
|
+
context "loading from YML" do
|
6
|
+
it "should load configuration from a YML file" do
|
7
|
+
Recurly.configure_from_yaml("#{File.dirname(__FILE__)}/../config/test.yml")
|
8
|
+
Recurly.username.should == "username1@recurly.com"
|
9
|
+
Recurly.password.should == "asdf4jk31"
|
10
|
+
Recurly.site.should == "https://site1.recurly.com"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context "loading from json" do
|
15
|
+
it "should load configuration from a json config string" do
|
16
|
+
Recurly.configure_from_json({
|
17
|
+
:username => "someuser@heroku.com",
|
18
|
+
:password => "somepass",
|
19
|
+
:site => "https://recurlytest3-test.recurly.com"
|
20
|
+
}.to_json)
|
21
|
+
Recurly.username.should == "someuser@heroku.com"
|
22
|
+
Recurly.password.should == "somepass"
|
23
|
+
Recurly.site.should == "https://recurlytest3-test.recurly.com"
|
24
|
+
|
25
|
+
# test with some crazy chars in the password
|
26
|
+
Recurly.configure_from_json({
|
27
|
+
:username => "api-someuser@heroku.com",
|
28
|
+
:password => "*$&!!::@&!)*)*_",
|
29
|
+
:site => "https://recurlytest3-test.recurly.com"
|
30
|
+
}.to_json)
|
31
|
+
|
32
|
+
Recurly.username.should == "api-someuser@heroku.com"
|
33
|
+
Recurly.password.should == "*$&!!::@&!)*)*_"
|
34
|
+
Recurly.site.should == "https://recurlytest3-test.recurly.com"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
@@ -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-1288381765</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-1288381765
|
32
|
+
connection:
|
33
|
+
- close
|
34
|
+
content-type:
|
35
|
+
- application/xml; charset=utf-8
|
36
|
+
x-runtime:
|
37
|
+
- "946"
|
38
|
+
date:
|
39
|
+
- Thu, 04 Nov 2010 23:28:30 GMT
|
40
|
+
server:
|
41
|
+
- nginx/0.7.65
|
42
|
+
content-length:
|
43
|
+
- "581"
|
44
|
+
set-cookie:
|
45
|
+
- account_credentials=a476384e263aeb19f519938bdeeadf93776dd15256d87acd8242ae19e3903967093a832aae26280d980bf4ab501ec9e72ef275793de0fd7b7c2f55965f637e86%3A%3A; domain=.recurly.com; path=/; secure; HttpOnly
|
46
|
+
- ""
|
47
|
+
- _recurly_session=ce022bfb19e67e52f921d472015fee74; 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-1288381765</id>
|
54
|
+
<account_code>account-close-1288381765</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>7278e28f910e44eb9cdff3f470d78d92</hosted_login_token>
|
63
|
+
<created_at type="datetime">2010-11-04T23:28:30Z</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-1288381765.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
|
+
- "41"
|
93
|
+
date:
|
94
|
+
- Thu, 04 Nov 2010 23:28:30 GMT
|
95
|
+
server:
|
96
|
+
- nginx/0.7.65
|
97
|
+
content-length:
|
98
|
+
- "1"
|
99
|
+
set-cookie:
|
100
|
+
- _recurly_session=7d783a8d7cde5200af2d020b05a91a81; 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-1288381765.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
|
+
- "\"dd45c48eab60e4d9a5477ce39c221a67\""
|
126
|
+
connection:
|
127
|
+
- close
|
128
|
+
content-type:
|
129
|
+
- application/xml; charset=utf-8
|
130
|
+
x-runtime:
|
131
|
+
- "65"
|
132
|
+
date:
|
133
|
+
- Thu, 04 Nov 2010 23:28:30 GMT
|
134
|
+
server:
|
135
|
+
- nginx/0.7.65
|
136
|
+
content-length:
|
137
|
+
- "580"
|
138
|
+
set-cookie:
|
139
|
+
- _recurly_session=74d09c3b165af34a8d66576a10648f1d; 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-1288381765</id>
|
146
|
+
<account_code>account-close-1288381765</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>7278e28f910e44eb9cdff3f470d78d92</hosted_login_token>
|
155
|
+
<created_at type="datetime">2010-11-04T23:28:30Z</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, 04 Nov 2010 23:28:31 GMT
|
34
|
+
server:
|
35
|
+
- nginx/0.7.65
|
36
|
+
content-length:
|
37
|
+
- "186"
|
38
|
+
set-cookie:
|
39
|
+
- _recurly_session=256704ef48861f2093da586621cf2def; 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
|
+
- "18"
|
32
|
+
date:
|
33
|
+
- Thu, 04 Nov 2010 23:28:32 GMT
|
34
|
+
server:
|
35
|
+
- nginx/0.7.65
|
36
|
+
content-length:
|
37
|
+
- "132"
|
38
|
+
set-cookie:
|
39
|
+
- _recurly_session=262a0b6ce0bef317c6cd308e5c567b83; 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
|
+
- "33"
|
79
|
+
date:
|
80
|
+
- Thu, 04 Nov 2010 23:28:32 GMT
|
81
|
+
server:
|
82
|
+
- nginx/0.7.65
|
83
|
+
content-length:
|
84
|
+
- "132"
|
85
|
+
set-cookie:
|
86
|
+
- _recurly_session=02f72a71d5bea4806c902d3e8991324b; 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-1288381765</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-1288381765
|
28
|
+
connection:
|
29
|
+
- close
|
30
|
+
content-type:
|
31
|
+
- application/xml; charset=utf-8
|
32
|
+
x-runtime:
|
33
|
+
- "696"
|
34
|
+
date:
|
35
|
+
- Thu, 04 Nov 2010 23:28:01 GMT
|
36
|
+
server:
|
37
|
+
- nginx/0.7.65
|
38
|
+
content-length:
|
39
|
+
- "522"
|
40
|
+
set-cookie:
|
41
|
+
- account_credentials=02decb7a373b176644e10195b3b28e05cc93ed199e524ab4a89bea8701dc277d7768e16ece52ffc314a600852ccd75386dacf8130365a5ebf2a5a9ee8a259553%3A%3A; domain=.recurly.com; path=/; secure; HttpOnly
|
42
|
+
- ""
|
43
|
+
- _recurly_session=7694025c0172b2f8376a356003464977; 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-1288381765</id>
|
50
|
+
<account_code>d00d-1288381765</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>ae169b31c14e4ecdaeca26cd42eb4819</hosted_login_token>
|
59
|
+
<created_at type="datetime">2010-11-04T23:28:01Z</created_at>
|
60
|
+
<state>active</state>
|
61
|
+
</account>
|
62
|
+
|
63
|
+
http_version: "1.1"
|