chargebee 1.7.2 → 1.7.3
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Rakefile +150 -150
- data/chargebee.gemspec +2 -2
- data/lib/chargebee.rb +1 -1
- data/lib/chargebee/list_result.rb +28 -28
- data/lib/chargebee/models/card.rb +6 -2
- data/lib/chargebee/models/transaction.rb +3 -3
- data/lib/chargebee/util.rb +56 -56
- 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 +2 -2
@@ -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: 1.7.
|
4
|
+
version: 1.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajaraman S
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-07-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_pure
|