chargebee 1.3.5 → 1.3.6
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/CHANGELOG.md +16 -8
- data/LICENSE +1 -1
- data/chargebee.gemspec +2 -2
- data/lib/chargebee.rb +10 -10
- data/lib/chargebee/models/addon.rb +4 -0
- data/lib/chargebee/models/coupon.rb +7 -2
- data/lib/chargebee/models/hosted_page.rb +1 -1
- data/lib/chargebee/models/plan.rb +4 -0
- data/lib/chargebee/util.rb +6 -1
- data/spec/chargebee_spec.rb +22 -19
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### v1.3.6 (2014-03-10)
|
2
|
+
* * *
|
3
|
+
* Support for creating coupons on the fly via API
|
4
|
+
|
5
|
+
* Support for updating the plans & addons.
|
6
|
+
|
7
|
+
* Now our hosted pages can be shown as popup checkout using our javascript API.
|
8
|
+
|
1
9
|
### v1.3.5 (2014-02-19)
|
2
10
|
* * *
|
3
11
|
* Support for passing shipping address for create subscription & update subscription API.
|
@@ -8,23 +16,23 @@
|
|
8
16
|
* * *
|
9
17
|
* New resource Download added to expose the URLs from which you can download resources like invoice PDFs.
|
10
18
|
|
11
|
-
* Update card hosted page now support pass_thru_parameter like the checkout pages.
|
19
|
+
* Update card hosted page now support pass_thru_parameter like the checkout pages.
|
12
20
|
|
13
21
|
* Support for downloading invoice as PDF.
|
14
22
|
|
15
23
|
* Transaction resource now exposes the void description for transactions that are voided.
|
16
24
|
|
17
|
-
### v1.3.3 (2014-02-02)
|
18
|
-
* * *
|
25
|
+
### v1.3.3 (2014-02-02)
|
26
|
+
* * *
|
19
27
|
Support for refund invoice and transaction.
|
20
28
|
|
21
|
-
### v1.3.2 (2014-01-26)
|
22
|
-
* * *
|
29
|
+
### v1.3.2 (2014-01-26)
|
30
|
+
* * *
|
23
31
|
Support for creating plans & addons on the fly via API.
|
24
32
|
|
25
|
-
### v1.3.1 (2014-01-16)
|
26
|
-
* * *
|
27
|
-
* Adding object that represent comments resource. Now comments can be added to the entities - Subscription, Invoice, Transaction, Plan, Addon & Coupon.
|
33
|
+
### v1.3.1 (2014-01-16)
|
34
|
+
* * *
|
35
|
+
* Adding object that represent comments resource. Now comments can be added to the entities - Subscription, Invoice, Transaction, Plan, Addon & Coupon.
|
28
36
|
|
29
37
|
* API to fetch multiple subscriptions of a customer.
|
30
38
|
|
data/LICENSE
CHANGED
data/chargebee.gemspec
CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
5
|
|
6
6
|
s.name = 'chargebee'
|
7
|
-
s.version = '1.3.
|
8
|
-
s.date = '2014-
|
7
|
+
s.version = '1.3.6'
|
8
|
+
s.date = '2014-03-10'
|
9
9
|
|
10
10
|
s.summary = "Ruby client for Chargebee API."
|
11
11
|
s.description = "Subscription Billing - Simple. Secure. Affordable. More details at www.chargebee.com."
|
data/lib/chargebee.rb
CHANGED
@@ -26,31 +26,31 @@ require File.dirname(__FILE__) + '/chargebee/models/download'
|
|
26
26
|
|
27
27
|
module ChargeBee
|
28
28
|
|
29
|
-
VERSION = '1.3.
|
30
|
-
|
29
|
+
VERSION = '1.3.6'
|
30
|
+
|
31
31
|
@@default_env = nil
|
32
32
|
@@verify_ca_certs = true
|
33
33
|
@@ca_cert_path = File.join(File.dirname(__FILE__), '/ssl/ca-certs.crt')
|
34
|
-
|
34
|
+
|
35
35
|
def self.configure(options)
|
36
36
|
@@default_env = Environment.new(options)
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
def self.default_env
|
40
40
|
@@default_env
|
41
41
|
end
|
42
|
-
|
43
|
-
def self.verify_ca_certs=(verify)
|
42
|
+
|
43
|
+
def self.verify_ca_certs=(verify)
|
44
44
|
@@verify_ca_certs = verify
|
45
45
|
end
|
46
|
-
|
47
|
-
def self.verify_ca_certs?
|
46
|
+
|
47
|
+
def self.verify_ca_certs?
|
48
48
|
@@verify_ca_certs
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def self.ca_cert_path
|
52
52
|
@@ca_cert_path
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
end
|
56
56
|
|
@@ -11,6 +11,10 @@ module ChargeBee
|
|
11
11
|
Request.send('post', "/addons", params, env)
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.update(id, params={}, env=nil)
|
15
|
+
Request.send('post', "/addons/#{id.to_s}", params, env)
|
16
|
+
end
|
17
|
+
|
14
18
|
def self.list(params={}, env=nil)
|
15
19
|
Request.send('get', "/addons", params, env)
|
16
20
|
end
|
@@ -2,12 +2,17 @@ module ChargeBee
|
|
2
2
|
class Coupon < Model
|
3
3
|
|
4
4
|
attr_accessor :id, :name, :invoice_name, :discount_type, :discount_percentage, :discount_amount,
|
5
|
-
:discount_quantity, :duration_type, :duration_month, :
|
6
|
-
:apply_discount_on, :apply_on, :
|
5
|
+
:discount_quantity, :duration_type, :duration_month, :valid_till, :max_redemptions, :status,
|
6
|
+
:redemptions, :apply_discount_on, :apply_on, :plan_constraint, :addon_constraint, :created_at,
|
7
|
+
:archived_at, :plan_ids, :addon_ids
|
7
8
|
|
8
9
|
# OPERATIONS
|
9
10
|
#-----------
|
10
11
|
|
12
|
+
def self.create(params, env=nil)
|
13
|
+
Request.send('post', "/coupons", params, env)
|
14
|
+
end
|
15
|
+
|
11
16
|
def self.list(params={}, env=nil)
|
12
17
|
Request.send('get', "/coupons", params, env)
|
13
18
|
end
|
@@ -11,6 +11,10 @@ module ChargeBee
|
|
11
11
|
Request.send('post', "/plans", params, env)
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.update(id, params={}, env=nil)
|
15
|
+
Request.send('post', "/plans/#{id.to_s}", params, env)
|
16
|
+
end
|
17
|
+
|
14
18
|
def self.list(params={}, env=nil)
|
15
19
|
Request.send('get', "/plans", params, env)
|
16
20
|
end
|
data/lib/chargebee/util.rb
CHANGED
@@ -18,7 +18,12 @@ module ChargeBee
|
|
18
18
|
serialized.merge!(serialize(v, prefix, i))
|
19
19
|
end
|
20
20
|
else
|
21
|
-
|
21
|
+
if(idx != nil and prefix != nil)
|
22
|
+
key = "#{prefix}[#{idx.to_s}]"
|
23
|
+
serialized.merge!({key => (value!=nil)?value:''})
|
24
|
+
else
|
25
|
+
raise ArgumentError.new("only hash or arrays are allowed as value")
|
26
|
+
end
|
22
27
|
end
|
23
28
|
serialized
|
24
29
|
end
|
data/spec/chargebee_spec.rb
CHANGED
@@ -3,16 +3,17 @@ require 'rest_client'
|
|
3
3
|
require 'sample_response'
|
4
4
|
|
5
5
|
describe "chargebee" do
|
6
|
-
|
6
|
+
|
7
7
|
before(:all) do
|
8
8
|
@request = RestClient::Request
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
it "serialize should convert the hash to acceptable format" do
|
12
12
|
before = {
|
13
13
|
:id => "sub_KyVq7DNSNM7CSD",
|
14
14
|
:plan_id => "free",
|
15
15
|
:addons => [{:id => "monitor", :quantity => 2}, {:id => "ssl"}],
|
16
|
+
:addon_ids => ["addon_one", "addon_two"],
|
16
17
|
:card => {
|
17
18
|
:first_name => "Rajaraman",
|
18
19
|
:last_name => "Santhanam",
|
@@ -23,20 +24,22 @@ describe "chargebee" do
|
|
23
24
|
}
|
24
25
|
}
|
25
26
|
after = {
|
26
|
-
"id"=>"sub_KyVq7DNSNM7CSD",
|
27
|
-
"plan_id"=>"free",
|
28
|
-
"addons[id][0]"=>"monitor",
|
29
|
-
"addons[quantity][0]"=>2,
|
30
|
-
"addons[id][1]"=>"ssl",
|
31
|
-
"
|
32
|
-
"
|
33
|
-
"card[
|
34
|
-
"card[
|
35
|
-
"card[
|
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",
|
36
39
|
"card[cvv]"=>"007"}
|
37
40
|
ChargeBee::Util.serialize(before).should eq(after)
|
38
41
|
end
|
39
|
-
|
42
|
+
|
40
43
|
it "symbolize_keys should convert keys to symbols" do
|
41
44
|
before = {
|
42
45
|
'id' => 'sub_KyVq4P__dev__NTWxbJx1',
|
@@ -50,7 +53,7 @@ describe "chargebee" do
|
|
50
53
|
}
|
51
54
|
ChargeBee::Util.symbolize_keys(before).should eq(after)
|
52
55
|
end
|
53
|
-
|
56
|
+
|
54
57
|
it "should properly convert the response json into proper object" do
|
55
58
|
@request.expects(:execute).once.returns(mock_response(simple_subscription))
|
56
59
|
result = ChargeBee::Subscription.retrieve("simple_subscription")
|
@@ -61,7 +64,7 @@ describe "chargebee" do
|
|
61
64
|
c.first_name.should eq('simple')
|
62
65
|
c.last_name.should eq('subscription')
|
63
66
|
end
|
64
|
-
|
67
|
+
|
65
68
|
it "should properly convert the nested response json into proper object with sub types" do
|
66
69
|
@request.expects(:execute).once.returns(mock_response(nested_subscription))
|
67
70
|
result = ChargeBee::Subscription.retrieve("nested_subscription")
|
@@ -73,7 +76,7 @@ describe "chargebee" do
|
|
73
76
|
a[0].quantity.should eq("10")
|
74
77
|
a[1].id.should eq("ssl")
|
75
78
|
end
|
76
|
-
|
79
|
+
|
77
80
|
it "should properly convert the list response json into proper result object" do
|
78
81
|
@request.expects(:execute).once.returns(mock_response(list_subscriptions))
|
79
82
|
result = ChargeBee::Subscription.list({:limit => 2})
|
@@ -82,7 +85,7 @@ describe "chargebee" do
|
|
82
85
|
i.subscription.id.should eq('sample_subscription')
|
83
86
|
end
|
84
87
|
end
|
85
|
-
|
88
|
+
|
86
89
|
it "should parse event api response and provide the content properly" do
|
87
90
|
@request.expects(:execute).once.returns(mock_response(sample_event))
|
88
91
|
result = ChargeBee::Event.retrieve("sample_event")
|
@@ -91,7 +94,7 @@ describe "chargebee" do
|
|
91
94
|
event.id.should eq('ev_KyVqDX__dev__NTgtUgx1')
|
92
95
|
s.id.should eq('sample_subscription')
|
93
96
|
end
|
94
|
-
|
97
|
+
|
95
98
|
it "should raise APIError when error response is received" do
|
96
99
|
response = mock_response(sample_error, 400)
|
97
100
|
begin
|
@@ -101,6 +104,6 @@ describe "chargebee" do
|
|
101
104
|
e.http_code.should eq(400)
|
102
105
|
end
|
103
106
|
end
|
104
|
-
|
107
|
+
|
105
108
|
end
|
106
109
|
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: chargebee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.3.
|
5
|
+
version: 1.3.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Rajaraman S
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-03-10 00:00:00 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: json_pure
|