chargebee 2.11.2 → 2.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +35 -0
- data/LICENSE +1 -1
- data/Rakefile +150 -150
- data/chargebee.gemspec +2 -2
- data/lib/chargebee/list_result.rb +28 -28
- data/lib/chargebee/models/credit_note.rb +11 -3
- data/lib/chargebee/models/customer.rb +9 -5
- data/lib/chargebee/models/download.rb +1 -1
- data/lib/chargebee/models/export.rb +1 -1
- data/lib/chargebee/models/invoice.rb +10 -1
- data/lib/chargebee/models/tax_withheld.rb +2 -1
- data/lib/chargebee/result.rb +11 -5
- data/lib/chargebee/util.rb +56 -56
- data/lib/chargebee.rb +1 -1
- data/lib/ssl/ca-certs.crt +3385 -3385
- data/spec/chargebee/list_result_spec.rb +53 -53
- data/spec/chargebee_spec.rb +99 -99
- data/spec/spec_helper.rb +24 -24
- metadata +21 -20
@@ -1,53 +1,53 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe ChargeBee::ListResult do
|
4
|
-
let(:response) do
|
5
|
-
{:list=>
|
6
|
-
[{:customer=>
|
7
|
-
{:id=>"d0cus3orh6gnjgha1i",
|
8
|
-
:first_name=>"Test Name1",
|
9
|
-
:last_name=>"Test last name 1",
|
10
|
-
:email=>"name1@gmail.com",
|
11
|
-
:auto_collection=>"on",
|
12
|
-
:created_at=>1346258514,
|
13
|
-
:object=>"customer",
|
14
|
-
:card_status=>"valid"},
|
15
|
-
:card=>
|
16
|
-
{:customer_id=>"d0cus3orh6gnjgha1i",
|
17
|
-
:status=>"valid",
|
18
|
-
:gateway=>"chargebee",
|
19
|
-
:first_name=>"Test Name1",
|
20
|
-
:last_name=>"Test last name 1",
|
21
|
-
:iin=>"32122",
|
22
|
-
:last4=>"1333",
|
23
|
-
:card_type=>"visa",
|
24
|
-
:expiry_month=>8,
|
25
|
-
:expiry_year=>2013,
|
26
|
-
:billing_addr1=>"Flat 11",
|
27
|
-
:billing_addr2=>"51 Strit",
|
28
|
-
:billing_city=>"Bristol",
|
29
|
-
:billing_state=>"Somerset",
|
30
|
-
:billing_zip=>"BS1 4HQ",
|
31
|
-
:object=>"card",
|
32
|
-
:masked_number=>"21323****4323"}},
|
33
|
-
{:customer=>
|
34
|
-
{:id=>"cwtid6smh67tq3z51l",
|
35
|
-
:first_name=>"Test Name 2",
|
36
|
-
:last_name=>"Test last name 2",
|
37
|
-
:email=>"name2@gmail.com",
|
38
|
-
:auto_collection=>"on",
|
39
|
-
:created_at=>1345724673,
|
40
|
-
:object=>"customer",
|
41
|
-
:card_status=>"no_card"}}],
|
42
|
-
:next_offset=>"[\"1345724673000\",\"1510\"]"}
|
43
|
-
end
|
44
|
-
|
45
|
-
before do
|
46
|
-
ChargeBee::Rest.stubs(:request).returns(response)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "returns list object, with next offset attribute" do
|
50
|
-
list = ChargeBee::Request.send(:customer, "http://url.com", {:limit => 2})
|
51
|
-
list.next_offset.should =~ ["1345724673000", "1510"]
|
52
|
-
end
|
53
|
-
end
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ChargeBee::ListResult do
|
4
|
+
let(:response) do
|
5
|
+
{:list=>
|
6
|
+
[{:customer=>
|
7
|
+
{:id=>"d0cus3orh6gnjgha1i",
|
8
|
+
:first_name=>"Test Name1",
|
9
|
+
:last_name=>"Test last name 1",
|
10
|
+
:email=>"name1@gmail.com",
|
11
|
+
:auto_collection=>"on",
|
12
|
+
:created_at=>1346258514,
|
13
|
+
:object=>"customer",
|
14
|
+
:card_status=>"valid"},
|
15
|
+
:card=>
|
16
|
+
{:customer_id=>"d0cus3orh6gnjgha1i",
|
17
|
+
:status=>"valid",
|
18
|
+
:gateway=>"chargebee",
|
19
|
+
:first_name=>"Test Name1",
|
20
|
+
:last_name=>"Test last name 1",
|
21
|
+
:iin=>"32122",
|
22
|
+
:last4=>"1333",
|
23
|
+
:card_type=>"visa",
|
24
|
+
:expiry_month=>8,
|
25
|
+
:expiry_year=>2013,
|
26
|
+
:billing_addr1=>"Flat 11",
|
27
|
+
:billing_addr2=>"51 Strit",
|
28
|
+
:billing_city=>"Bristol",
|
29
|
+
:billing_state=>"Somerset",
|
30
|
+
:billing_zip=>"BS1 4HQ",
|
31
|
+
:object=>"card",
|
32
|
+
:masked_number=>"21323****4323"}},
|
33
|
+
{:customer=>
|
34
|
+
{:id=>"cwtid6smh67tq3z51l",
|
35
|
+
:first_name=>"Test Name 2",
|
36
|
+
:last_name=>"Test last name 2",
|
37
|
+
:email=>"name2@gmail.com",
|
38
|
+
:auto_collection=>"on",
|
39
|
+
:created_at=>1345724673,
|
40
|
+
:object=>"customer",
|
41
|
+
:card_status=>"no_card"}}],
|
42
|
+
:next_offset=>"[\"1345724673000\",\"1510\"]"}
|
43
|
+
end
|
44
|
+
|
45
|
+
before do
|
46
|
+
ChargeBee::Rest.stubs(:request).returns(response)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "returns list object, with next offset attribute" do
|
50
|
+
list = ChargeBee::Request.send(:customer, "http://url.com", {:limit => 2})
|
51
|
+
list.next_offset.should =~ ["1345724673000", "1510"]
|
52
|
+
end
|
53
|
+
end
|
data/spec/chargebee_spec.rb
CHANGED
@@ -1,99 +1,99 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rest_client'
|
3
|
-
require 'sample_response'
|
4
|
-
|
5
|
-
describe "chargebee" do
|
6
|
-
|
7
|
-
before(:all) do
|
8
|
-
@request = RestClient::Request
|
9
|
-
end
|
10
|
-
|
11
|
-
it "serialize should convert the hash to acceptable format" do
|
12
|
-
before = {
|
13
|
-
:id => "sub_KyVq7DNSNM7CSD",
|
14
|
-
:plan_id => "free",
|
15
|
-
:addons => [{:id => "monitor", :quantity => 2}, {:id => "ssl"}],
|
16
|
-
:addon_ids => ["addon_one", "addon_two"],
|
17
|
-
:card => {
|
18
|
-
:first_name => "Rajaraman",
|
19
|
-
:last_name => "Santhanam",
|
20
|
-
:number => "4111111111111111",
|
21
|
-
:expiry_month => "1",
|
22
|
-
:expiry_year => "2024",
|
23
|
-
:cvv => "007"
|
24
|
-
}
|
25
|
-
}
|
26
|
-
after = {
|
27
|
-
"id"=>"sub_KyVq7DNSNM7CSD",
|
28
|
-
"plan_id"=>"free",
|
29
|
-
"addons[id][0]"=>"monitor",
|
30
|
-
"addons[quantity][0]"=>"2",
|
31
|
-
"addons[id][1]"=>"ssl",
|
32
|
-
"addon_ids[0]"=>"addon_one",
|
33
|
-
"addon_ids[1]"=>"addon_two",
|
34
|
-
"card[first_name]"=>"Rajaraman",
|
35
|
-
"card[last_name]"=>"Santhanam",
|
36
|
-
"card[number]"=>"4111111111111111",
|
37
|
-
"card[expiry_month]"=>"1",
|
38
|
-
"card[expiry_year]"=>"2024",
|
39
|
-
"card[cvv]"=>"007"}
|
40
|
-
ChargeBee::Util.serialize(before).should eq(after)
|
41
|
-
end
|
42
|
-
|
43
|
-
it "symbolize_keys should convert keys to symbols" do
|
44
|
-
before = {
|
45
|
-
'id' => 'sub_KyVq4P__dev__NTWxbJx1',
|
46
|
-
'plan_id' => 'basic',
|
47
|
-
'addons' => [{ 'id' => 'ssl' }, {'id' => 'sms', 'quantity' => '10'}]
|
48
|
-
}
|
49
|
-
after = {
|
50
|
-
:id => 'sub_KyVq4P__dev__NTWxbJx1',
|
51
|
-
:plan_id => 'basic',
|
52
|
-
:addons => [{ :id => 'ssl' }, {:id => 'sms', :quantity => '10'}],
|
53
|
-
}
|
54
|
-
ChargeBee::Util.symbolize_keys(before).should eq(after)
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should properly convert the response json into proper object" do
|
58
|
-
@request.expects(:execute).once.returns(mock_response(simple_subscription))
|
59
|
-
result = ChargeBee::Subscription.retrieve("simple_subscription")
|
60
|
-
s = result.subscription
|
61
|
-
s.id.should eq("simple_subscription")
|
62
|
-
s.plan_id.should eq('basic')
|
63
|
-
c = result.customer
|
64
|
-
c.first_name.should eq('simple')
|
65
|
-
c.last_name.should eq('subscription')
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should properly convert the nested response json into proper object with sub types" do
|
69
|
-
@request.expects(:execute).once.returns(mock_response(nested_subscription))
|
70
|
-
result = ChargeBee::Subscription.retrieve("nested_subscription")
|
71
|
-
s = result.subscription
|
72
|
-
s.id.should eq("nested_subscription")
|
73
|
-
a = s.addons
|
74
|
-
a.length.should eq(2)
|
75
|
-
a[0].id.should eq("monitor")
|
76
|
-
a[0].quantity.should eq("10")
|
77
|
-
a[1].id.should eq("ssl")
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should properly convert the list response json into proper result object" do
|
81
|
-
@request.expects(:execute).once.returns(mock_response(list_subscriptions))
|
82
|
-
result = ChargeBee::Subscription.list({:limit => 2})
|
83
|
-
result.length.should eq(2)
|
84
|
-
result.each do |i|
|
85
|
-
i.subscription.id.should eq('sample_subscription')
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should parse event api response and provide the content properly" do
|
90
|
-
@request.expects(:execute).once.returns(mock_response(sample_event))
|
91
|
-
result = ChargeBee::Event.retrieve("sample_event")
|
92
|
-
event = result.event
|
93
|
-
s = event.content.subscription
|
94
|
-
event.id.should eq('ev_KyVqDX__dev__NTgtUgx1')
|
95
|
-
s.id.should eq('sample_subscription')
|
96
|
-
end
|
97
|
-
|
98
|
-
end
|
99
|
-
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'rest_client'
|
3
|
+
require 'sample_response'
|
4
|
+
|
5
|
+
describe "chargebee" do
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
@request = RestClient::Request
|
9
|
+
end
|
10
|
+
|
11
|
+
it "serialize should convert the hash to acceptable format" do
|
12
|
+
before = {
|
13
|
+
:id => "sub_KyVq7DNSNM7CSD",
|
14
|
+
:plan_id => "free",
|
15
|
+
:addons => [{:id => "monitor", :quantity => 2}, {:id => "ssl"}],
|
16
|
+
:addon_ids => ["addon_one", "addon_two"],
|
17
|
+
:card => {
|
18
|
+
:first_name => "Rajaraman",
|
19
|
+
:last_name => "Santhanam",
|
20
|
+
:number => "4111111111111111",
|
21
|
+
:expiry_month => "1",
|
22
|
+
:expiry_year => "2024",
|
23
|
+
:cvv => "007"
|
24
|
+
}
|
25
|
+
}
|
26
|
+
after = {
|
27
|
+
"id"=>"sub_KyVq7DNSNM7CSD",
|
28
|
+
"plan_id"=>"free",
|
29
|
+
"addons[id][0]"=>"monitor",
|
30
|
+
"addons[quantity][0]"=>"2",
|
31
|
+
"addons[id][1]"=>"ssl",
|
32
|
+
"addon_ids[0]"=>"addon_one",
|
33
|
+
"addon_ids[1]"=>"addon_two",
|
34
|
+
"card[first_name]"=>"Rajaraman",
|
35
|
+
"card[last_name]"=>"Santhanam",
|
36
|
+
"card[number]"=>"4111111111111111",
|
37
|
+
"card[expiry_month]"=>"1",
|
38
|
+
"card[expiry_year]"=>"2024",
|
39
|
+
"card[cvv]"=>"007"}
|
40
|
+
ChargeBee::Util.serialize(before).should eq(after)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "symbolize_keys should convert keys to symbols" do
|
44
|
+
before = {
|
45
|
+
'id' => 'sub_KyVq4P__dev__NTWxbJx1',
|
46
|
+
'plan_id' => 'basic',
|
47
|
+
'addons' => [{ 'id' => 'ssl' }, {'id' => 'sms', 'quantity' => '10'}]
|
48
|
+
}
|
49
|
+
after = {
|
50
|
+
:id => 'sub_KyVq4P__dev__NTWxbJx1',
|
51
|
+
:plan_id => 'basic',
|
52
|
+
:addons => [{ :id => 'ssl' }, {:id => 'sms', :quantity => '10'}],
|
53
|
+
}
|
54
|
+
ChargeBee::Util.symbolize_keys(before).should eq(after)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should properly convert the response json into proper object" do
|
58
|
+
@request.expects(:execute).once.returns(mock_response(simple_subscription))
|
59
|
+
result = ChargeBee::Subscription.retrieve("simple_subscription")
|
60
|
+
s = result.subscription
|
61
|
+
s.id.should eq("simple_subscription")
|
62
|
+
s.plan_id.should eq('basic')
|
63
|
+
c = result.customer
|
64
|
+
c.first_name.should eq('simple')
|
65
|
+
c.last_name.should eq('subscription')
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should properly convert the nested response json into proper object with sub types" do
|
69
|
+
@request.expects(:execute).once.returns(mock_response(nested_subscription))
|
70
|
+
result = ChargeBee::Subscription.retrieve("nested_subscription")
|
71
|
+
s = result.subscription
|
72
|
+
s.id.should eq("nested_subscription")
|
73
|
+
a = s.addons
|
74
|
+
a.length.should eq(2)
|
75
|
+
a[0].id.should eq("monitor")
|
76
|
+
a[0].quantity.should eq("10")
|
77
|
+
a[1].id.should eq("ssl")
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should properly convert the list response json into proper result object" do
|
81
|
+
@request.expects(:execute).once.returns(mock_response(list_subscriptions))
|
82
|
+
result = ChargeBee::Subscription.list({:limit => 2})
|
83
|
+
result.length.should eq(2)
|
84
|
+
result.each do |i|
|
85
|
+
i.subscription.id.should eq('sample_subscription')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should parse event api response and provide the content properly" do
|
90
|
+
@request.expects(:execute).once.returns(mock_response(sample_event))
|
91
|
+
result = ChargeBee::Event.retrieve("sample_event")
|
92
|
+
event = result.event
|
93
|
+
s = event.content.subscription
|
94
|
+
event.id.should eq('ev_KyVqDX__dev__NTgtUgx1')
|
95
|
+
s.id.should eq('sample_subscription')
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
data/spec/spec_helper.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../lib/chargebee'
|
2
|
-
|
3
|
-
require 'rspec'
|
4
|
-
require 'pp'
|
5
|
-
require 'mocha'
|
6
|
-
require 'json'
|
7
|
-
|
8
|
-
RSpec.configure do |config|
|
9
|
-
config.mock_with :mocha
|
10
|
-
end
|
11
|
-
|
12
|
-
def mock_response(body, code=200)
|
13
|
-
body = body.to_json if !(body.kind_of? String)
|
14
|
-
m = mock
|
15
|
-
m.instance_variable_set('@resp_values', { :body => body, :code => code })
|
16
|
-
def m.body; @resp_values[:body]; end
|
17
|
-
def m.code; @resp_values[:code]; end
|
18
|
-
m
|
19
|
-
end
|
20
|
-
|
21
|
-
ChargeBee.configure(
|
22
|
-
:api_key => "dummy_api_key",
|
23
|
-
:site => "dummy_site"
|
24
|
-
)
|
1
|
+
require File.dirname(__FILE__) + '/../lib/chargebee'
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
require 'pp'
|
5
|
+
require 'mocha'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.mock_with :mocha
|
10
|
+
end
|
11
|
+
|
12
|
+
def mock_response(body, code=200)
|
13
|
+
body = body.to_json if !(body.kind_of? String)
|
14
|
+
m = mock
|
15
|
+
m.instance_variable_set('@resp_values', { :body => body, :code => code })
|
16
|
+
def m.body; @resp_values[:body]; end
|
17
|
+
def m.code; @resp_values[:code]; end
|
18
|
+
m
|
19
|
+
end
|
20
|
+
|
21
|
+
ChargeBee.configure(
|
22
|
+
:api_key => "dummy_api_key",
|
23
|
+
:site => "dummy_site"
|
24
|
+
)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chargebee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajaraman S
|
@@ -9,88 +9,88 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-01-
|
12
|
+
date: 2022-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_pure
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '2.1'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '2.1'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rest-client
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '1.8'
|
35
|
-
- -
|
35
|
+
- - <=
|
36
36
|
- !ruby/object:Gem::Version
|
37
37
|
version: 2.0.2
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
requirements:
|
42
|
-
- -
|
42
|
+
- - '>='
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '1.8'
|
45
|
-
- -
|
45
|
+
- - <=
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 2.0.2
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: cgi
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.1.0
|
55
|
-
- -
|
55
|
+
- - <
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: 1.0.0
|
58
58
|
type: :runtime
|
59
59
|
prerelease: false
|
60
60
|
version_requirements: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
|
-
- -
|
62
|
+
- - '>='
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: 0.1.0
|
65
|
-
- -
|
65
|
+
- - <
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: 1.0.0
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: rspec
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
|
-
- -
|
72
|
+
- - ~>
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: 3.0.0
|
75
75
|
type: :development
|
76
76
|
prerelease: false
|
77
77
|
version_requirements: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ~>
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: 3.0.0
|
82
82
|
- !ruby/object:Gem::Dependency
|
83
83
|
name: mocha
|
84
84
|
requirement: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- -
|
86
|
+
- - '>='
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
91
|
version_requirements: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- -
|
93
|
+
- - '>='
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
description: Subscription Billing - Simple. Secure. Affordable. More details at www.chargebee.com.
|
@@ -178,21 +178,22 @@ licenses:
|
|
178
178
|
metadata: {}
|
179
179
|
post_install_message:
|
180
180
|
rdoc_options:
|
181
|
-
-
|
181
|
+
- --charset=UTF-8
|
182
182
|
require_paths:
|
183
183
|
- lib
|
184
184
|
required_ruby_version: !ruby/object:Gem::Requirement
|
185
185
|
requirements:
|
186
|
-
- -
|
186
|
+
- - '>='
|
187
187
|
- !ruby/object:Gem::Version
|
188
188
|
version: 1.9.3
|
189
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
190
|
requirements:
|
191
|
-
- -
|
191
|
+
- - '>='
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '0'
|
194
194
|
requirements: []
|
195
|
-
|
195
|
+
rubyforge_project:
|
196
|
+
rubygems_version: 2.4.5
|
196
197
|
signing_key:
|
197
198
|
specification_version: 2
|
198
199
|
summary: Ruby client for Chargebee API.
|