chargebee 1.7.5 → 2.0.0
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 +111 -105
- data/README.rdoc +16 -14
- data/Rakefile +150 -150
- data/chargebee.gemspec +6 -3
- data/lib/chargebee.rb +5 -2
- data/lib/chargebee/environment.rb +1 -1
- data/lib/chargebee/list_result.rb +28 -28
- data/lib/chargebee/models/card.rb +2 -6
- data/lib/chargebee/models/credit_note.rb +44 -0
- data/lib/chargebee/models/credit_note_estimate.rb +23 -0
- data/lib/chargebee/models/customer.rb +7 -7
- data/lib/chargebee/models/estimate.rb +1 -15
- data/lib/chargebee/models/hosted_page.rb +0 -8
- data/lib/chargebee/models/invoice.rb +26 -10
- data/lib/chargebee/models/invoice_estimate.rb +23 -0
- data/lib/chargebee/models/model.rb +34 -3
- data/lib/chargebee/models/subscription_estimate.rb +10 -0
- data/lib/chargebee/models/transaction.rb +10 -10
- data/lib/chargebee/result.rb +75 -26
- 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/sample_response.rb +1 -1
- data/spec/spec_helper.rb +24 -24
- metadata +6 -3
- data/lib/chargebee/models/payment_intent.rb +0 -27
data/README.rdoc
CHANGED
@@ -1,32 +1,34 @@
|
|
1
|
-
= Chargebee Ruby Client Library - API
|
1
|
+
= Chargebee Ruby Client Library - API V2
|
2
2
|
|
3
3
|
The ruby library for integrating with Chargebee Recurring Billing and Subscription Management solution.
|
4
4
|
|
5
|
-
Chargebee now supports two API versions - {V1}[https://apidocs.chargebee.com/docs/api/v1] and {V2}[https://apidocs.chargebee.com/docs/api]
|
5
|
+
Chargebee now supports two API versions - {V1}[https://apidocs.chargebee.com/docs/api/v1] and {V2}[https://apidocs.chargebee.com/docs/api], of which V2 is the latest release and all future developments will happen in V2.
|
6
|
+
|
7
|
+
This library is for our <b>API version V2</b>. The library for V1 can be found in {chargebee-v1 branch}[https://github.com/chargebee/chargebee-ruby/tree/chargebee-v1].
|
6
8
|
|
7
|
-
You'd want to upgrade to V2 to benefit from the new functionality. Click here for the {API V2 Upgradation Guide}[https://apidocs.chargebee.com/docs/api/v1#api-v2-upgradation-guide].
|
8
9
|
|
9
10
|
== Installation
|
10
11
|
|
11
12
|
Install the latest version of the gem with the following command...
|
12
|
-
|
13
|
-
$ sudo gem install chargebee -v '~>
|
13
|
+
|
14
|
+
$ sudo gem install chargebee -v '~>2'
|
15
|
+
|
14
16
|
|
15
17
|
== Documentation
|
16
18
|
|
17
|
-
For API reference see {here}[https://apidocs.chargebee.com/docs/api
|
19
|
+
For API reference see {here}[https://apidocs.chargebee.com/docs/api?lang=ruby]
|
18
20
|
|
19
21
|
== Usage
|
20
22
|
|
21
23
|
To create a new subscription:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
|
25
|
+
ChargeBee.configure({:api_key => "your_api_key"}, {:site => "your_site"})
|
26
|
+
result = ChargeBee::Subscription.create({
|
27
|
+
:id => "sub_KyVqDh__dev__NTn4VZZ1",
|
28
|
+
:plan_id => "basic",
|
29
|
+
})
|
30
|
+
subscription = result.subscription
|
31
|
+
puts "created subscription is #{subscription}"
|
30
32
|
|
31
33
|
== License
|
32
34
|
|
data/Rakefile
CHANGED
@@ -1,150 +1,150 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'date'
|
4
|
-
|
5
|
-
#############################################################################
|
6
|
-
#
|
7
|
-
# Helper functions
|
8
|
-
#
|
9
|
-
#############################################################################
|
10
|
-
|
11
|
-
def name
|
12
|
-
@name ||= Dir['*.gemspec'].first.split('.').first
|
13
|
-
end
|
14
|
-
|
15
|
-
def version
|
16
|
-
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
-
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
-
end
|
19
|
-
|
20
|
-
def date
|
21
|
-
Date.today.to_s
|
22
|
-
end
|
23
|
-
|
24
|
-
def rubyforge_project
|
25
|
-
name
|
26
|
-
end
|
27
|
-
|
28
|
-
def gemspec_file
|
29
|
-
"#{name}.gemspec"
|
30
|
-
end
|
31
|
-
|
32
|
-
def gem_file
|
33
|
-
"#{name}-#{version}.gem"
|
34
|
-
end
|
35
|
-
|
36
|
-
def replace_header(head, header_name)
|
37
|
-
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
38
|
-
end
|
39
|
-
|
40
|
-
#############################################################################
|
41
|
-
#
|
42
|
-
# Standard tasks
|
43
|
-
#
|
44
|
-
#############################################################################
|
45
|
-
|
46
|
-
task :default => :test
|
47
|
-
|
48
|
-
require 'rake/testtask'
|
49
|
-
Rake::TestTask.new(:test) do |test|
|
50
|
-
test.libs << 'lib' << 'test'
|
51
|
-
test.pattern = 'test/**/test_*.rb'
|
52
|
-
test.verbose = true
|
53
|
-
end
|
54
|
-
|
55
|
-
desc "Generate RCov test coverage and open in your browser"
|
56
|
-
task :coverage do
|
57
|
-
require 'rcov'
|
58
|
-
sh "rm -fr coverage"
|
59
|
-
sh "rcov test/test_*.rb"
|
60
|
-
sh "open coverage/index.html"
|
61
|
-
end
|
62
|
-
|
63
|
-
# require 'rake/rdoctask'
|
64
|
-
# Rake::RDocTask.new do |rdoc|
|
65
|
-
# rdoc.rdoc_dir = 'rdoc'
|
66
|
-
# rdoc.title = "#{name} #{version}"
|
67
|
-
# rdoc.rdoc_files.include('README*')
|
68
|
-
# rdoc.rdoc_files.include('lib/**/*.rb')
|
69
|
-
# end
|
70
|
-
|
71
|
-
desc "Open an irb session preloaded with this library"
|
72
|
-
task :console do
|
73
|
-
sh "irb -rubygems -r ./lib/#{name}.rb"
|
74
|
-
end
|
75
|
-
|
76
|
-
#############################################################################
|
77
|
-
#
|
78
|
-
# Custom tasks (add your own tasks here)
|
79
|
-
#
|
80
|
-
#############################################################################
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
#############################################################################
|
85
|
-
#
|
86
|
-
# Packaging tasks
|
87
|
-
#
|
88
|
-
#############################################################################
|
89
|
-
|
90
|
-
desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
|
91
|
-
task :release => :build do
|
92
|
-
unless `git branch` =~ /^\* master$/
|
93
|
-
puts "You must be on the master branch to release!"
|
94
|
-
exit!
|
95
|
-
end
|
96
|
-
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
97
|
-
sh "git tag v#{version}"
|
98
|
-
sh "git push origin master"
|
99
|
-
sh "git push origin v#{version}"
|
100
|
-
sh "gem push pkg/#{name}-#{version}.gem"
|
101
|
-
end
|
102
|
-
|
103
|
-
desc "Build #{gem_file} into the pkg directory"
|
104
|
-
task :build => :gemspec do
|
105
|
-
sh "mkdir -p pkg"
|
106
|
-
sh "gem build #{gemspec_file}"
|
107
|
-
sh "mv #{gem_file} pkg"
|
108
|
-
end
|
109
|
-
|
110
|
-
desc "Generate #{gemspec_file}"
|
111
|
-
task :gemspec => :validate do
|
112
|
-
# read spec file and split out manifest section
|
113
|
-
spec = File.read(gemspec_file)
|
114
|
-
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
115
|
-
|
116
|
-
# replace name version and date
|
117
|
-
replace_header(head, :name)
|
118
|
-
replace_header(head, :version)
|
119
|
-
replace_header(head, :date)
|
120
|
-
#comment this out if your rubyforge_project has a different name
|
121
|
-
replace_header(head, :rubyforge_project)
|
122
|
-
|
123
|
-
# determine file list from git ls-files
|
124
|
-
files = `git ls-files`.
|
125
|
-
split("\n").
|
126
|
-
sort.
|
127
|
-
reject { |file| file =~ /^\./ }.
|
128
|
-
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
129
|
-
map { |file| " #{file}" }.
|
130
|
-
join("\n")
|
131
|
-
|
132
|
-
# piece file back together and write
|
133
|
-
manifest = " s.files = %w[\n#{files}\n ]\n"
|
134
|
-
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
135
|
-
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
136
|
-
puts "Updated #{gemspec_file}"
|
137
|
-
end
|
138
|
-
|
139
|
-
desc "Validate #{gemspec_file}"
|
140
|
-
task :validate do
|
141
|
-
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}", "lib/ssl"]
|
142
|
-
unless libfiles.empty?
|
143
|
-
puts "Directory `lib` should only contain a `#{name}.rb` file, `#{name}` dir and `lib/ssl` dir."
|
144
|
-
exit!
|
145
|
-
end
|
146
|
-
unless Dir['VERSION*'].empty?
|
147
|
-
puts "A `VERSION` file at root level violates Gem best practices."
|
148
|
-
exit!
|
149
|
-
end
|
150
|
-
end
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
#############################################################################
|
6
|
+
#
|
7
|
+
# Helper functions
|
8
|
+
#
|
9
|
+
#############################################################################
|
10
|
+
|
11
|
+
def name
|
12
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
17
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
18
|
+
end
|
19
|
+
|
20
|
+
def date
|
21
|
+
Date.today.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def rubyforge_project
|
25
|
+
name
|
26
|
+
end
|
27
|
+
|
28
|
+
def gemspec_file
|
29
|
+
"#{name}.gemspec"
|
30
|
+
end
|
31
|
+
|
32
|
+
def gem_file
|
33
|
+
"#{name}-#{version}.gem"
|
34
|
+
end
|
35
|
+
|
36
|
+
def replace_header(head, header_name)
|
37
|
+
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
|
38
|
+
end
|
39
|
+
|
40
|
+
#############################################################################
|
41
|
+
#
|
42
|
+
# Standard tasks
|
43
|
+
#
|
44
|
+
#############################################################################
|
45
|
+
|
46
|
+
task :default => :test
|
47
|
+
|
48
|
+
require 'rake/testtask'
|
49
|
+
Rake::TestTask.new(:test) do |test|
|
50
|
+
test.libs << 'lib' << 'test'
|
51
|
+
test.pattern = 'test/**/test_*.rb'
|
52
|
+
test.verbose = true
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Generate RCov test coverage and open in your browser"
|
56
|
+
task :coverage do
|
57
|
+
require 'rcov'
|
58
|
+
sh "rm -fr coverage"
|
59
|
+
sh "rcov test/test_*.rb"
|
60
|
+
sh "open coverage/index.html"
|
61
|
+
end
|
62
|
+
|
63
|
+
# require 'rake/rdoctask'
|
64
|
+
# Rake::RDocTask.new do |rdoc|
|
65
|
+
# rdoc.rdoc_dir = 'rdoc'
|
66
|
+
# rdoc.title = "#{name} #{version}"
|
67
|
+
# rdoc.rdoc_files.include('README*')
|
68
|
+
# rdoc.rdoc_files.include('lib/**/*.rb')
|
69
|
+
# end
|
70
|
+
|
71
|
+
desc "Open an irb session preloaded with this library"
|
72
|
+
task :console do
|
73
|
+
sh "irb -rubygems -r ./lib/#{name}.rb"
|
74
|
+
end
|
75
|
+
|
76
|
+
#############################################################################
|
77
|
+
#
|
78
|
+
# Custom tasks (add your own tasks here)
|
79
|
+
#
|
80
|
+
#############################################################################
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
#############################################################################
|
85
|
+
#
|
86
|
+
# Packaging tasks
|
87
|
+
#
|
88
|
+
#############################################################################
|
89
|
+
|
90
|
+
desc "Create tag v#{version} and build and push #{gem_file} to Rubygems"
|
91
|
+
task :release => :build do
|
92
|
+
unless `git branch` =~ /^\* master$/
|
93
|
+
puts "You must be on the master branch to release!"
|
94
|
+
exit!
|
95
|
+
end
|
96
|
+
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
97
|
+
sh "git tag v#{version}"
|
98
|
+
sh "git push origin master"
|
99
|
+
sh "git push origin v#{version}"
|
100
|
+
sh "gem push pkg/#{name}-#{version}.gem"
|
101
|
+
end
|
102
|
+
|
103
|
+
desc "Build #{gem_file} into the pkg directory"
|
104
|
+
task :build => :gemspec do
|
105
|
+
sh "mkdir -p pkg"
|
106
|
+
sh "gem build #{gemspec_file}"
|
107
|
+
sh "mv #{gem_file} pkg"
|
108
|
+
end
|
109
|
+
|
110
|
+
desc "Generate #{gemspec_file}"
|
111
|
+
task :gemspec => :validate do
|
112
|
+
# read spec file and split out manifest section
|
113
|
+
spec = File.read(gemspec_file)
|
114
|
+
head, manifest, tail = spec.split(" # = MANIFEST =\n")
|
115
|
+
|
116
|
+
# replace name version and date
|
117
|
+
replace_header(head, :name)
|
118
|
+
replace_header(head, :version)
|
119
|
+
replace_header(head, :date)
|
120
|
+
#comment this out if your rubyforge_project has a different name
|
121
|
+
replace_header(head, :rubyforge_project)
|
122
|
+
|
123
|
+
# determine file list from git ls-files
|
124
|
+
files = `git ls-files`.
|
125
|
+
split("\n").
|
126
|
+
sort.
|
127
|
+
reject { |file| file =~ /^\./ }.
|
128
|
+
reject { |file| file =~ /^(rdoc|pkg)/ }.
|
129
|
+
map { |file| " #{file}" }.
|
130
|
+
join("\n")
|
131
|
+
|
132
|
+
# piece file back together and write
|
133
|
+
manifest = " s.files = %w[\n#{files}\n ]\n"
|
134
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
135
|
+
File.open(gemspec_file, 'w') { |io| io.write(spec) }
|
136
|
+
puts "Updated #{gemspec_file}"
|
137
|
+
end
|
138
|
+
|
139
|
+
desc "Validate #{gemspec_file}"
|
140
|
+
task :validate do
|
141
|
+
libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}", "lib/ssl"]
|
142
|
+
unless libfiles.empty?
|
143
|
+
puts "Directory `lib` should only contain a `#{name}.rb` file, `#{name}` dir and `lib/ssl` dir."
|
144
|
+
exit!
|
145
|
+
end
|
146
|
+
unless Dir['VERSION*'].empty?
|
147
|
+
puts "A `VERSION` file at root level violates Gem best practices."
|
148
|
+
exit!
|
149
|
+
end
|
150
|
+
end
|
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 = '
|
8
|
-
s.date = '
|
7
|
+
s.version = '2.0.0'
|
8
|
+
s.date = '2016-04-11'
|
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."
|
@@ -43,18 +43,21 @@ Gem::Specification.new do |s|
|
|
43
43
|
lib/chargebee/models/comment.rb
|
44
44
|
lib/chargebee/models/coupon.rb
|
45
45
|
lib/chargebee/models/coupon_code.rb
|
46
|
+
lib/chargebee/models/credit_note.rb
|
47
|
+
lib/chargebee/models/credit_note_estimate.rb
|
46
48
|
lib/chargebee/models/customer.rb
|
47
49
|
lib/chargebee/models/download.rb
|
48
50
|
lib/chargebee/models/estimate.rb
|
49
51
|
lib/chargebee/models/event.rb
|
50
52
|
lib/chargebee/models/hosted_page.rb
|
51
53
|
lib/chargebee/models/invoice.rb
|
54
|
+
lib/chargebee/models/invoice_estimate.rb
|
52
55
|
lib/chargebee/models/model.rb
|
53
56
|
lib/chargebee/models/order.rb
|
54
|
-
lib/chargebee/models/payment_intent.rb
|
55
57
|
lib/chargebee/models/plan.rb
|
56
58
|
lib/chargebee/models/portal_session.rb
|
57
59
|
lib/chargebee/models/subscription.rb
|
60
|
+
lib/chargebee/models/subscription_estimate.rb
|
58
61
|
lib/chargebee/models/transaction.rb
|
59
62
|
lib/chargebee/request.rb
|
60
63
|
lib/chargebee/rest.rb
|
data/lib/chargebee.rb
CHANGED
@@ -15,7 +15,11 @@ require File.dirname(__FILE__) + '/chargebee/models/address'
|
|
15
15
|
require File.dirname(__FILE__) + '/chargebee/models/transaction'
|
16
16
|
require File.dirname(__FILE__) + '/chargebee/models/invoice'
|
17
17
|
require File.dirname(__FILE__) + '/chargebee/models/order'
|
18
|
+
require File.dirname(__FILE__) + '/chargebee/models/credit_note'
|
18
19
|
require File.dirname(__FILE__) + '/chargebee/models/estimate'
|
20
|
+
require File.dirname(__FILE__) + '/chargebee/models/subscription_estimate'
|
21
|
+
require File.dirname(__FILE__) + '/chargebee/models/invoice_estimate'
|
22
|
+
require File.dirname(__FILE__) + '/chargebee/models/credit_note_estimate'
|
19
23
|
require File.dirname(__FILE__) + '/chargebee/models/hosted_page'
|
20
24
|
require File.dirname(__FILE__) + '/chargebee/models/event'
|
21
25
|
require File.dirname(__FILE__) + '/chargebee/models/plan'
|
@@ -25,11 +29,10 @@ require File.dirname(__FILE__) + '/chargebee/models/coupon_code'
|
|
25
29
|
require File.dirname(__FILE__) + '/chargebee/models/comment'
|
26
30
|
require File.dirname(__FILE__) + '/chargebee/models/portal_session'
|
27
31
|
require File.dirname(__FILE__) + '/chargebee/models/download'
|
28
|
-
require File.dirname(__FILE__) + '/chargebee/models/payment_intent'
|
29
32
|
|
30
33
|
module ChargeBee
|
31
34
|
|
32
|
-
VERSION = '
|
35
|
+
VERSION = '2.0.0'
|
33
36
|
|
34
37
|
@@default_env = nil
|
35
38
|
@@verify_ca_certs = true
|
@@ -1,28 +1,28 @@
|
|
1
|
-
require 'forwardable'
|
2
|
-
|
3
|
-
module ChargeBee
|
4
|
-
class ListResult
|
5
|
-
extend Forwardable
|
6
|
-
include Enumerable
|
7
|
-
|
8
|
-
def_delegator :@list, :each, :each
|
9
|
-
def_delegator :@list, :length, :length
|
10
|
-
|
11
|
-
attr_reader :next_offset
|
12
|
-
|
13
|
-
def initialize(response, next_offset=nil)
|
14
|
-
@response = response
|
15
|
-
@list = Array.new
|
16
|
-
@next_offset = JSON.parse(next_offset).to_s if next_offset
|
17
|
-
initItems()
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
def initItems()
|
22
|
-
@response.each do |item|
|
23
|
-
@list.push(Result.new(item))
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
1
|
+
require 'forwardable'
|
2
|
+
|
3
|
+
module ChargeBee
|
4
|
+
class ListResult
|
5
|
+
extend Forwardable
|
6
|
+
include Enumerable
|
7
|
+
|
8
|
+
def_delegator :@list, :each, :each
|
9
|
+
def_delegator :@list, :length, :length
|
10
|
+
|
11
|
+
attr_reader :next_offset
|
12
|
+
|
13
|
+
def initialize(response, next_offset=nil)
|
14
|
+
@response = response
|
15
|
+
@list = Array.new
|
16
|
+
@next_offset = JSON.parse(next_offset).to_s if next_offset
|
17
|
+
initItems()
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def initItems()
|
22
|
+
@response.each do |item|
|
23
|
+
@list.push(Result.new(item))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|