sproutbox-mousetrap 0.6.4
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.
- data/.document +5 -0
- data/.gitignore +10 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +36 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +26 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/lib/mousetrap.rb +25 -0
- data/lib/mousetrap/customer.rb +214 -0
- data/lib/mousetrap/invoice.rb +41 -0
- data/lib/mousetrap/plan.rb +34 -0
- data/lib/mousetrap/resource.rb +147 -0
- data/lib/mousetrap/subscription.rb +166 -0
- data/mousetrap.gemspec +91 -0
- data/script/authenticate.rb +3 -0
- data/script/cheddar_getter.example.yml +3 -0
- data/script/console +15 -0
- data/spec/factories.rb +42 -0
- data/spec/integration/settings.example.yml +6 -0
- data/spec/integration/smoke_test.rb +358 -0
- data/spec/integration/spike.rb +108 -0
- data/spec/mousetrap/customer_spec.rb +491 -0
- data/spec/mousetrap/plan_spec.rb +41 -0
- data/spec/mousetrap/resource_spec.rb +188 -0
- data/spec/mousetrap/subscription_spec.rb +164 -0
- data/spec/mousetrap_spec.rb +17 -0
- data/spec/spec_helper.rb +28 -0
- data/spec/support/fixtures.rb +189 -0
- data/spec/support/random_data.rb +21 -0
- metadata +174 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Mousetrap::Plan do
|
4
|
+
# name: Test
|
5
|
+
# billingFrequencyQuantity: "1"
|
6
|
+
# code: TEST
|
7
|
+
# recurringChargeAmount: "42.00"
|
8
|
+
# createdDatetime: "2009-08-25T04:24:34+00:00"
|
9
|
+
# id: 5fbb9a84-e27f-102c-a92d-40402145ee8b
|
10
|
+
# isActive: "1"
|
11
|
+
# billingFrequency: monthly
|
12
|
+
# description: Test
|
13
|
+
# trialDays: "0"
|
14
|
+
# setupChargeCode: TEST_SETUP
|
15
|
+
# recurringChargeCode: TEST_RECURRING
|
16
|
+
# billingFrequencyUnit: months
|
17
|
+
# setupChargeAmount: "0.00"
|
18
|
+
# billingFrequencyPer: month
|
19
|
+
|
20
|
+
describe ".all" do
|
21
|
+
before do
|
22
|
+
Mousetrap::Plan.stub :build_resources_from
|
23
|
+
end
|
24
|
+
|
25
|
+
it "gets all plans" do
|
26
|
+
Mousetrap::Plan.should_receive(:get_resources).with('plans').and_return('some hash')
|
27
|
+
Mousetrap::Plan.all
|
28
|
+
end
|
29
|
+
|
30
|
+
it "handles no-plans case" do
|
31
|
+
Mousetrap::Plan.stub :get_resources => { 'plans' => nil }
|
32
|
+
Mousetrap::Plan.all.should == []
|
33
|
+
end
|
34
|
+
|
35
|
+
it "builds resources from the response" do
|
36
|
+
Mousetrap::Plan.stub :get_resources => { 'plans' => 'some hash' }
|
37
|
+
Mousetrap::Plan.should_receive(:build_resources_from).with({ 'plans' => 'some hash' })
|
38
|
+
Mousetrap::Plan.all
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,188 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
module Mousetrap
|
4
|
+
class Widget < Resource
|
5
|
+
attr_accessor :id
|
6
|
+
attr_accessor :code
|
7
|
+
|
8
|
+
|
9
|
+
protected
|
10
|
+
|
11
|
+
def self.attributes_from_api(attributes)
|
12
|
+
{
|
13
|
+
:id => attributes['id'],
|
14
|
+
:code => attributes['code'],
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.plural_resource_name
|
19
|
+
'widgets'
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.singular_resource_name
|
23
|
+
'widget'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe Mousetrap::Resource do
|
29
|
+
before do
|
30
|
+
Mousetrap.product_code = 'my_product_code'
|
31
|
+
end
|
32
|
+
|
33
|
+
subject { Mousetrap::Resource }
|
34
|
+
|
35
|
+
describe "class" do
|
36
|
+
it "sets the base URI" do
|
37
|
+
subject.default_options[:base_uri].should == 'https://cheddargetter.com'
|
38
|
+
end
|
39
|
+
|
40
|
+
it "set the header to our client name" do
|
41
|
+
subject.headers['User-Agent'].should == 'Mousetrap Ruby Client'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".[]" do
|
46
|
+
before do
|
47
|
+
customer_hash = Factory.attributes_for :existing_customer
|
48
|
+
customer_hash = HashWithIndifferentAccess.new customer_hash
|
49
|
+
@code = customer_hash[:code]
|
50
|
+
@server_response_hash = { 'widgets' => { 'widget' => customer_hash } }
|
51
|
+
Mousetrap::Widget.stub(:get_resource => @server_response_hash)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "gets a resource with widget code" do
|
55
|
+
Mousetrap::Widget.should_receive(:get_resource).with('widgets', @code).and_return(@server_response_hash)
|
56
|
+
Mousetrap::Widget[@code]
|
57
|
+
end
|
58
|
+
|
59
|
+
context "returned widget instance" do
|
60
|
+
subject { Mousetrap::Widget[@code] }
|
61
|
+
it { should be_instance_of(Mousetrap::Widget) }
|
62
|
+
it { should_not be_new_record }
|
63
|
+
it { subject.code.should == @code }
|
64
|
+
end
|
65
|
+
|
66
|
+
context "when there's errors" do
|
67
|
+
it "handles kludgy 'Resource not found' response" do
|
68
|
+
Mousetrap::Widget.stub :get_resource => {
|
69
|
+
'error' => 'Resource not found: Customer not found for code=cantfindme within productCode=MOUSETRAP_TEST'
|
70
|
+
}
|
71
|
+
Mousetrap::Widget['cantfindme'].should be_nil
|
72
|
+
end
|
73
|
+
|
74
|
+
it "raises error if response has one" do
|
75
|
+
expect do
|
76
|
+
Mousetrap::Widget.stub :get_resource => { 'error' => 'some other error' }
|
77
|
+
Mousetrap::Widget['some_resource_code'].should be_nil
|
78
|
+
end.to raise_error(RuntimeError, 'some other error')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe ".destroy_all" do
|
84
|
+
it "destroys each resource" do
|
85
|
+
all_widgets = [stub, stub, stub]
|
86
|
+
Mousetrap::Widget.stub :all => all_widgets
|
87
|
+
all_widgets.each { |w| w.should_receive :destroy }
|
88
|
+
Mousetrap::Widget.destroy_all
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe ".exists?" do
|
93
|
+
it "gets by code" do
|
94
|
+
Mousetrap::Widget.should_receive(:[]).with('some_resource_code')
|
95
|
+
Mousetrap::Widget.exists? 'some_resource_code'
|
96
|
+
end
|
97
|
+
|
98
|
+
it "returns true when resource exists" do
|
99
|
+
Mousetrap::Widget.stub :[] => stub('some_widget')
|
100
|
+
Mousetrap::Widget.exists?('some_resource_code').should be_true
|
101
|
+
end
|
102
|
+
|
103
|
+
it "returns false when resource doesn't exist" do
|
104
|
+
Mousetrap::Widget.stub :[] => nil
|
105
|
+
Mousetrap::Widget.exists?('some_resource_code').should be_false
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe '#destroy' do
|
110
|
+
context "for existing records" do
|
111
|
+
it 'destroys' do
|
112
|
+
widget = Mousetrap::Widget.new
|
113
|
+
widget.stub :new_record? => false
|
114
|
+
widget.should_receive(:member_action).with('delete')
|
115
|
+
widget.destroy
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "for new records" do
|
120
|
+
it "does nothing" do
|
121
|
+
widget = Mousetrap::Widget.new
|
122
|
+
widget.stub :new_record? => true
|
123
|
+
Mousetrap::Customer.should_not_receive(:member_action)
|
124
|
+
widget.destroy
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "#exists?" do
|
130
|
+
it "calls .exists? with code" do
|
131
|
+
Mousetrap::Widget.should_receive(:exists?).with('some_resource_code')
|
132
|
+
r = Mousetrap::Widget.new :code => 'some_resource_code'
|
133
|
+
r.exists?
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '#new?' do
|
138
|
+
it 'is true if id is nil' do
|
139
|
+
s = Mousetrap::Widget.new
|
140
|
+
s.should be_new
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'is false if id exists' do
|
144
|
+
s = Mousetrap::Widget.new
|
145
|
+
s.stub :id => 'some_id'
|
146
|
+
s.should_not be_new
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "protected methods" do
|
151
|
+
describe ".delete_resource" do
|
152
|
+
it "gets /xml/<resource>/delete/productCode/<my_product_code>/code/<resource_code>" do
|
153
|
+
subject.should_receive(:post).with('/xml/widgets/delete/productCode/my_product_code/code/some_resource_code')
|
154
|
+
subject.delete_resource 'widgets', 'some_resource_code'
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
describe ".get_resource" do
|
159
|
+
it "gets /xml/<resource>/get/productCode/<my_product_code>/code/<resource_code>" do
|
160
|
+
subject.should_receive(:get).with('/xml/widgets/get/productCode/my_product_code/code/some%2Bresource%2Bcode')
|
161
|
+
subject.get_resource 'widgets', 'some+resource+code'
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
describe ".get_resources" do
|
166
|
+
it "gets /xml/<resource>/get/productCode/<my_product_code>" do
|
167
|
+
subject.should_receive(:get).with('/xml/widgets/get/productCode/my_product_code')
|
168
|
+
subject.get_resources 'widgets'
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe ".post_resource" do
|
173
|
+
it "posts to /xml/<resource>/<action>/productCode/<product_code>" do
|
174
|
+
subject.should_receive(:post).with('/xml/widgets/some_action/productCode/my_product_code', :body => 'some_hash')
|
175
|
+
subject.post_resource 'widgets', 'some_action', 'some_hash'
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe ".put_resource" do
|
180
|
+
it "puts to /xml/<resource>/<action>/productCode/<product_code>/code/<resource_code>" do
|
181
|
+
subject.should_receive(:post).with(
|
182
|
+
'/xml/widgets/some_action/productCode/my_product_code/code/some_widget_code',
|
183
|
+
:body => 'some_hash')
|
184
|
+
subject.put_resource 'widgets', 'some_action', 'some_widget_code', 'some_hash'
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
@@ -0,0 +1,164 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Mousetrap::Subscription do
|
4
|
+
include Fixtures
|
5
|
+
|
6
|
+
describe '.[]' do
|
7
|
+
it 'raises NotImplementedError' do
|
8
|
+
expect do
|
9
|
+
Mousetrap::Subscription['some_code']
|
10
|
+
end.to raise_error(NotImplementedError, Mousetrap::API_UNSUPPORTED)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.all' do
|
15
|
+
it 'raises NotImplementedError' do
|
16
|
+
expect do
|
17
|
+
Mousetrap::Subscription.all
|
18
|
+
end.to raise_error(NotImplementedError, Mousetrap::API_UNSUPPORTED)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.destroy_all' do
|
23
|
+
it 'raises NotImplementedError' do
|
24
|
+
expect do
|
25
|
+
Mousetrap::Subscription.destroy_all
|
26
|
+
end.to raise_error(NotImplementedError, Mousetrap::API_UNSUPPORTED)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '.exists?' do
|
31
|
+
it 'raises NotImplementedError' do
|
32
|
+
expect do
|
33
|
+
Mousetrap::Subscription.exists?('some_code')
|
34
|
+
end.to raise_error(NotImplementedError, Mousetrap::API_UNSUPPORTED)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "plan" do
|
39
|
+
it 'has the correct planCode populated' do
|
40
|
+
Mousetrap::Subscription.new_from_api(multiple_subscriptions.first).plan.code.should == "PLUS"
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'exists' do
|
44
|
+
Mousetrap::Subscription.new_from_api(multiple_subscriptions.first).plan.should_not be_nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#destroy' do
|
49
|
+
it "raises a NotImplementedError" do
|
50
|
+
expect do
|
51
|
+
Mousetrap::Subscription.new.destroy
|
52
|
+
end.to raise_error(NotImplementedError)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '.attributes_for_api' do
|
57
|
+
context "when month is set" do
|
58
|
+
it 'coerces the month to 2 digits' do
|
59
|
+
Mousetrap::Subscription.attributes_for_api(
|
60
|
+
:credit_card_expiration_month => 2
|
61
|
+
)[:ccExpMonth].should == '02'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context "when month is not set" do
|
66
|
+
it "is nil" do
|
67
|
+
Mousetrap::Subscription.attributes_for_api(
|
68
|
+
:credit_card_expiration_month => nil
|
69
|
+
)[:ccExpMonth].should == nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
["08", "09"].each do |number|
|
74
|
+
context "when month is set to #{number}" do
|
75
|
+
it 'should not raise error' do
|
76
|
+
lambda{
|
77
|
+
Mousetrap::Subscription.attributes_for_api(
|
78
|
+
:credit_card_expiration_month => number
|
79
|
+
)
|
80
|
+
}.should_not raise_error
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#exists?' do
|
87
|
+
it 'raises NotImplementedError' do
|
88
|
+
expect do
|
89
|
+
s = Mousetrap::Subscription.new
|
90
|
+
s.exists?
|
91
|
+
end.to raise_error(NotImplementedError, Mousetrap::API_UNSUPPORTED)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '.update' do
|
96
|
+
before do
|
97
|
+
Mousetrap::Subscription.stub :put_resource => { 'some' => 'hash' }
|
98
|
+
end
|
99
|
+
|
100
|
+
let (:mutated_attributes) do
|
101
|
+
{
|
102
|
+
:with => 'something',
|
103
|
+
:without => nil,
|
104
|
+
:also_without => ''
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
def do_update
|
109
|
+
Mousetrap::Subscription.update('some customer code', 'some attributes')
|
110
|
+
end
|
111
|
+
|
112
|
+
it "transforms the attribute names for CheddarGetter" do
|
113
|
+
Mousetrap::Subscription.should_receive(:attributes_for_api).with('some attributes').and_return({})
|
114
|
+
do_update
|
115
|
+
end
|
116
|
+
|
117
|
+
it "deletes unfilled attribute entries" do
|
118
|
+
|
119
|
+
Mousetrap::Subscription.stub :attributes_for_api => mutated_attributes
|
120
|
+
|
121
|
+
Mousetrap::Subscription.should_receive(:put_resource).with(
|
122
|
+
'customers',
|
123
|
+
'edit-subscription',
|
124
|
+
'some customer code',
|
125
|
+
{ :with => 'something' }
|
126
|
+
)
|
127
|
+
|
128
|
+
do_update
|
129
|
+
end
|
130
|
+
|
131
|
+
it "calls put_resource" do
|
132
|
+
Mousetrap::Subscription.stub :attributes_for_api => mutated_attributes
|
133
|
+
|
134
|
+
Mousetrap::Subscription.should_receive(:put_resource).with(
|
135
|
+
'customers',
|
136
|
+
'edit-subscription',
|
137
|
+
'some customer code',
|
138
|
+
{ :with => 'something' }
|
139
|
+
)
|
140
|
+
|
141
|
+
do_update
|
142
|
+
end
|
143
|
+
|
144
|
+
it "raises a CheddarGetter error if returned" do
|
145
|
+
Mousetrap::Subscription.stub \
|
146
|
+
:attributes_for_api => mutated_attributes,
|
147
|
+
:put_resource => { 'error' => 'some error message' }
|
148
|
+
|
149
|
+
expect { do_update }.to raise_error('some error message')
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
__END__
|
156
|
+
|
157
|
+
subscription:
|
158
|
+
ccExpirationDate: "2010-01-31T00:00:00+00:00"
|
159
|
+
gatewayToken:
|
160
|
+
createdDatetime: "2009-08-27T15:55:51+00:00"
|
161
|
+
ccType: visa
|
162
|
+
id: 46ad3f1c-e472-102c-a92d-40402145ee8b
|
163
|
+
ccLastFour: "1111"
|
164
|
+
canceledDatetime:
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe Mousetrap do
|
4
|
+
subject { Mousetrap }
|
5
|
+
|
6
|
+
it "stores product code" do
|
7
|
+
subject.product_code = 'my_product_code'
|
8
|
+
subject.product_code.should == 'my_product_code'
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#authenticate" do
|
12
|
+
it "sets basic auth based on the supplied user and password" do
|
13
|
+
Mousetrap::Resource.should_receive(:basic_auth).with('lark@example.com', 'abc123')
|
14
|
+
subject.authenticate 'lark@example.com', 'abc123'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
3
|
+
|
4
|
+
require 'mousetrap'
|
5
|
+
|
6
|
+
require "bundler"
|
7
|
+
Bundler.setup
|
8
|
+
|
9
|
+
require 'rspec'
|
10
|
+
require 'factories'
|
11
|
+
|
12
|
+
require 'active_support/core_ext/hash'
|
13
|
+
|
14
|
+
# Requires supporting files with custom matchers and macros, etc,
|
15
|
+
# in ./support/ and its subdirectories.
|
16
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
17
|
+
|
18
|
+
module Mousetrap
|
19
|
+
class Resource
|
20
|
+
def self.get(*args)
|
21
|
+
raise 'You must stub this, or should_receive at a higher level.'
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.post(*args)
|
25
|
+
raise 'You must stub this, or should_receive at a higher level.'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,189 @@
|
|
1
|
+
module Fixtures
|
2
|
+
def full_customer
|
3
|
+
{
|
4
|
+
"company"=>nil,
|
5
|
+
"lastName"=>"LasterName1255024322",
|
6
|
+
"code"=>"1255024322",
|
7
|
+
"gatewayToken"=>nil,
|
8
|
+
"createdDatetime"=>"2009-10-08T17:55:30+00:00",
|
9
|
+
"modifiedDatetime"=>"2009-10-08T17:55:30+00:00",
|
10
|
+
"subscriptions"=> {
|
11
|
+
"subscription" => [
|
12
|
+
{
|
13
|
+
"ccExpirationDate"=>"2010-01-31T00:00:00+00:00",
|
14
|
+
"plans"=> {
|
15
|
+
"plan"=> {
|
16
|
+
"name"=>"Plus",
|
17
|
+
"billingFrequencyQuantity"=>"1",
|
18
|
+
"code"=>"PLUS",
|
19
|
+
"recurringChargeAmount"=>"49.00",
|
20
|
+
"createdDatetime"=>"2009-10-06T14:54:24+00:00",
|
21
|
+
"id"=>"51a912d0-03d8-102d-a92d-40402145ee8b",
|
22
|
+
"isActive"=>"1",
|
23
|
+
"billingFrequency"=>"monthly",
|
24
|
+
"description"=>nil,
|
25
|
+
"trialDays"=>"0",
|
26
|
+
"setupChargeCode"=>"PLUS_SETUP",
|
27
|
+
"recurringChargeCode"=>"PLUS_RECURRING",
|
28
|
+
"billingFrequencyUnit"=>"months",
|
29
|
+
"setupChargeAmount"=>"49.00",
|
30
|
+
"billingFrequencyPer"=>"month"}},
|
31
|
+
"gatewayToken"=>nil,
|
32
|
+
"createdDatetime"=>"2009-10-08T17:55:31+00:00",
|
33
|
+
"ccType"=>"visa",
|
34
|
+
"id"=>"f426d5ae-0583-102d-a92d-40402145ee8b",
|
35
|
+
"ccLastFour"=>"2222",
|
36
|
+
"canceledDatetime"=>nil,
|
37
|
+
"invoices"=>
|
38
|
+
{"invoice"=>
|
39
|
+
{"number"=>"12",
|
40
|
+
"createdDatetime"=>"2009-10-08T17:55:30+00:00",
|
41
|
+
"type"=>"subscription",
|
42
|
+
"billingDatetime"=>"2009-11-08T17:55:30+00:00",
|
43
|
+
"id"=>"f3142928-0583-102d-a92d-40402145ee8b"}}},
|
44
|
+
|
45
|
+
{"ccExpirationDate"=>"2010-01-31T00:00:00+00:00",
|
46
|
+
"plans"=>
|
47
|
+
{"plan"=>
|
48
|
+
{"name"=>"Basic",
|
49
|
+
"billingFrequencyQuantity"=>"1",
|
50
|
+
"code"=>"BASIC",
|
51
|
+
"recurringChargeAmount"=>"24.00",
|
52
|
+
"createdDatetime"=>"2009-10-06T14:53:49+00:00",
|
53
|
+
"id"=>"3cd2e840-03d8-102d-a92d-40402145ee8b",
|
54
|
+
"isActive"=>"1",
|
55
|
+
"billingFrequency"=>"monthly",
|
56
|
+
"description"=>nil,
|
57
|
+
"trialDays"=>"0",
|
58
|
+
"setupChargeCode"=>"BASIC_SETUP",
|
59
|
+
"recurringChargeCode"=>"BASIC_RECURRING",
|
60
|
+
"billingFrequencyUnit"=>"months",
|
61
|
+
"setupChargeAmount"=>"24.00",
|
62
|
+
"billingFrequencyPer"=>"month"}},
|
63
|
+
"gatewayToken"=>nil,
|
64
|
+
"createdDatetime"=>"2009-10-08T17:55:30+00:00",
|
65
|
+
"ccType"=>"visa",
|
66
|
+
"id"=>"f30e0e94-0583-102d-a92d-40402145ee8b",
|
67
|
+
"ccLastFour"=>"2222",
|
68
|
+
"canceledDatetime"=>nil,
|
69
|
+
"invoices"=>
|
70
|
+
{"invoice"=>
|
71
|
+
{"number"=>"11",
|
72
|
+
"createdDatetime"=>"2009-10-08T17:55:30+00:00",
|
73
|
+
"transactions"=>
|
74
|
+
{"transaction"=>
|
75
|
+
{"response"=>"approved",
|
76
|
+
"code"=>"",
|
77
|
+
"createdDatetime"=>"2009-10-08T17:55:30+00:00",
|
78
|
+
"memo"=>"This is a simulated transaction",
|
79
|
+
"id"=>"f327b178-0583-102d-a92d-40402145ee8b",
|
80
|
+
"parentId"=>nil,
|
81
|
+
"amount"=>"24.00",
|
82
|
+
"transactedDatetime"=>"2009-10-08T17:55:30+00:00",
|
83
|
+
"gatewayAccount"=>
|
84
|
+
{"id"=>""},
|
85
|
+
"charges"=>
|
86
|
+
{"charge"=>
|
87
|
+
{"code"=>"BASIC_SETUP",
|
88
|
+
"createdDatetime"=>"2009-10-08T17:55:30+00:00",
|
89
|
+
"type"=>"setup",
|
90
|
+
"quantity"=>"1",
|
91
|
+
"id"=>"f325406e-0583-102d-a92d-40402145ee8b",
|
92
|
+
"description"=>nil,
|
93
|
+
"eachAmount"=>"24.00"}}}},
|
94
|
+
"type"=>"setup",
|
95
|
+
"billingDatetime"=>"2009-10-08T17:55:30+00:00",
|
96
|
+
"id"=>"f3125468-0583-102d-a92d-40402145ee8b"}}}]},
|
97
|
+
"id"=>"f30cd614-0583-102d-a92d-40402145ee8b",
|
98
|
+
"firstName"=>"FirsterName1",
|
99
|
+
"email"=>"example1@example.com"}
|
100
|
+
end
|
101
|
+
|
102
|
+
def multiple_subscriptions
|
103
|
+
[
|
104
|
+
{"ccExpirationDate"=>"2010-01-31T00:00:00+00:00",
|
105
|
+
"plans"=>
|
106
|
+
{"plan"=>
|
107
|
+
{"name"=>"Plus",
|
108
|
+
"billingFrequencyQuantity"=>"1",
|
109
|
+
"code"=>"PLUS",
|
110
|
+
"recurringChargeAmount"=>"49.00",
|
111
|
+
"createdDatetime"=>"2009-10-06T14:54:24+00:00",
|
112
|
+
"id"=>"51a912d0-03d8-102d-a92d-40402145ee8b",
|
113
|
+
"isActive"=>"1",
|
114
|
+
"billingFrequency"=>"monthly",
|
115
|
+
"description"=>nil,
|
116
|
+
"trialDays"=>"0",
|
117
|
+
"setupChargeCode"=>"PLUS_SETUP",
|
118
|
+
"recurringChargeCode"=>"PLUS_RECURRING",
|
119
|
+
"billingFrequencyUnit"=>"months",
|
120
|
+
"setupChargeAmount"=>"49.00",
|
121
|
+
"billingFrequencyPer"=>"month"}},
|
122
|
+
"gatewayToken"=>nil,
|
123
|
+
"createdDatetime"=>"2009-10-08T17:55:31+00:00",
|
124
|
+
"ccType"=>"visa",
|
125
|
+
"id"=>"f426d5ae-0583-102d-a92d-40402145ee8b",
|
126
|
+
"ccLastFour"=>"2222",
|
127
|
+
"canceledDatetime"=>nil,
|
128
|
+
"invoices"=>
|
129
|
+
{"invoice"=>
|
130
|
+
{"number"=>"12",
|
131
|
+
"createdDatetime"=>"2009-10-08T17:55:30+00:00",
|
132
|
+
"type"=>"subscription",
|
133
|
+
"billingDatetime"=>"2009-11-08T17:55:30+00:00",
|
134
|
+
"id"=>"f3142928-0583-102d-a92d-40402145ee8b"}}},
|
135
|
+
|
136
|
+
{"ccExpirationDate"=>"2010-01-31T00:00:00+00:00",
|
137
|
+
"plans"=>
|
138
|
+
{"plan"=>
|
139
|
+
{"name"=>"Basic",
|
140
|
+
"billingFrequencyQuantity"=>"1",
|
141
|
+
"code"=>"BASIC",
|
142
|
+
"recurringChargeAmount"=>"24.00",
|
143
|
+
"createdDatetime"=>"2009-10-06T14:53:49+00:00",
|
144
|
+
"id"=>"3cd2e840-03d8-102d-a92d-40402145ee8b",
|
145
|
+
"isActive"=>"1",
|
146
|
+
"billingFrequency"=>"monthly",
|
147
|
+
"description"=>nil,
|
148
|
+
"trialDays"=>"0",
|
149
|
+
"setupChargeCode"=>"BASIC_SETUP",
|
150
|
+
"recurringChargeCode"=>"BASIC_RECURRING",
|
151
|
+
"billingFrequencyUnit"=>"months",
|
152
|
+
"setupChargeAmount"=>"24.00",
|
153
|
+
"billingFrequencyPer"=>"month"}},
|
154
|
+
"gatewayToken"=>nil,
|
155
|
+
"createdDatetime"=>"2009-10-08T17:55:30+00:00",
|
156
|
+
"ccType"=>"visa",
|
157
|
+
"id"=>"f30e0e94-0583-102d-a92d-40402145ee8b",
|
158
|
+
"ccLastFour"=>"2222",
|
159
|
+
"canceledDatetime"=>nil,
|
160
|
+
"invoices"=>
|
161
|
+
{"invoice"=>
|
162
|
+
{"number"=>"11",
|
163
|
+
"createdDatetime"=>"2009-10-08T17:55:30+00:00",
|
164
|
+
"transactions"=>
|
165
|
+
{"transaction"=>
|
166
|
+
{"response"=>"approved",
|
167
|
+
"code"=>"",
|
168
|
+
"createdDatetime"=>"2009-10-08T17:55:30+00:00",
|
169
|
+
"memo"=>"This is a simulated transaction",
|
170
|
+
"id"=>"f327b178-0583-102d-a92d-40402145ee8b",
|
171
|
+
"parentId"=>nil,
|
172
|
+
"amount"=>"24.00",
|
173
|
+
"transactedDatetime"=>"2009-10-08T17:55:30+00:00",
|
174
|
+
"gatewayAccount"=>
|
175
|
+
{"id"=>""},
|
176
|
+
"charges"=>
|
177
|
+
{"charge"=>
|
178
|
+
{"code"=>"BASIC_SETUP",
|
179
|
+
"createdDatetime"=>"2009-10-08T17:55:30+00:00",
|
180
|
+
"type"=>"setup",
|
181
|
+
"quantity"=>"1",
|
182
|
+
"id"=>"f325406e-0583-102d-a92d-40402145ee8b",
|
183
|
+
"description"=>nil,
|
184
|
+
"eachAmount"=>"24.00"}}}},
|
185
|
+
"type"=>"setup",
|
186
|
+
"billingDatetime"=>"2009-10-08T17:55:30+00:00",
|
187
|
+
"id"=>"f3125468-0583-102d-a92d-40402145ee8b"}}}]
|
188
|
+
end
|
189
|
+
end
|