chargebee 2.6.4 → 2.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1524 -1488
- data/LICENSE +24 -24
- data/README.rdoc +41 -41
- data/chargebee.gemspec +4 -3
- data/lib/chargebee.rb +85 -85
- data/lib/chargebee/environment.rb +28 -28
- data/lib/chargebee/errors.rb +43 -43
- data/lib/chargebee/models/addon.rb +45 -45
- data/lib/chargebee/models/address.rb +18 -18
- data/lib/chargebee/models/card.rb +32 -32
- data/lib/chargebee/models/comment.rb +25 -25
- data/lib/chargebee/models/contact.rb +10 -10
- data/lib/chargebee/models/coupon.rb +40 -40
- data/lib/chargebee/models/coupon_code.rb +25 -25
- data/lib/chargebee/models/coupon_set.rb +37 -37
- data/lib/chargebee/models/credit_note.rb +77 -77
- data/lib/chargebee/models/credit_note_estimate.rb +35 -35
- data/lib/chargebee/models/customer.rb +137 -120
- data/lib/chargebee/models/download.rb +9 -9
- data/lib/chargebee/models/estimate.rb +46 -46
- data/lib/chargebee/models/event.rb +45 -45
- data/lib/chargebee/models/export.rb +86 -86
- data/lib/chargebee/models/gift.rb +42 -42
- data/lib/chargebee/models/hierarchy.rb +10 -0
- data/lib/chargebee/models/hosted_page.rb +77 -77
- data/lib/chargebee/models/invoice.rb +172 -172
- data/lib/chargebee/models/invoice_estimate.rb +35 -35
- data/lib/chargebee/models/model.rb +101 -101
- data/lib/chargebee/models/order.rb +76 -76
- data/lib/chargebee/models/payment_source.rb +79 -71
- data/lib/chargebee/models/plan.rb +60 -59
- data/lib/chargebee/models/portal_session.rb +30 -30
- data/lib/chargebee/models/promotional_credit.rb +30 -30
- data/lib/chargebee/models/quote.rb +72 -72
- data/lib/chargebee/models/resource_migration.rb +13 -13
- data/lib/chargebee/models/site_migration_detail.rb +14 -14
- data/lib/chargebee/models/subscription.rb +137 -137
- data/lib/chargebee/models/subscription_estimate.rb +13 -13
- data/lib/chargebee/models/third_party_payment_method.rb +9 -9
- data/lib/chargebee/models/time_machine.rb +46 -46
- data/lib/chargebee/models/token.rb +11 -0
- data/lib/chargebee/models/transaction.rb +62 -62
- data/lib/chargebee/models/unbilled_charge.rb +31 -31
- data/lib/chargebee/models/virtual_bank_account.rb +30 -26
- data/lib/chargebee/request.rb +27 -27
- data/lib/chargebee/rest.rb +92 -92
- data/lib/chargebee/result.rb +255 -240
- data/spec/errors_spec.rb +23 -23
- data/spec/sample_response.rb +73 -73
- metadata +5 -4
- data/lib/chargebee/.DS_Store +0 -0
data/LICENSE
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
The MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2011-2019 ChargeBee, Inc.
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person
|
6
|
-
obtaining a copy of this software and associated documentation
|
7
|
-
files (the "Software"), to deal in the Software without
|
8
|
-
restriction, including without limitation the rights to use,
|
9
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
-
copies of the Software, and to permit persons to whom the
|
11
|
-
Software is furnished to do so, subject to the following
|
12
|
-
conditions:
|
13
|
-
|
14
|
-
The above copyright notice and this permission notice shall be
|
15
|
-
included in all copies or substantial portions of the Software.
|
16
|
-
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
19
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
21
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
22
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
23
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
24
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2011-2019 ChargeBee, Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
6
|
+
obtaining a copy of this software and associated documentation
|
7
|
+
files (the "Software"), to deal in the Software without
|
8
|
+
restriction, including without limitation the rights to use,
|
9
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the
|
11
|
+
Software is furnished to do so, subject to the following
|
12
|
+
conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
19
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
21
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
22
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
23
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
24
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
= Chargebee Ruby Client Library - API V2
|
2
|
-
|
3
|
-
{<img src="https://img.shields.io/gem/v/chargebee.svg?maxAge=2592000"/>}[https://rubygems.org/gems/chargebee]
|
4
|
-
{<img src="https://img.shields.io/gem/dtv/chargebee.svg?maxAge=2592000"/>}[https://rubygems.org/gems/chargebee]
|
5
|
-
|
6
|
-
This is the Ruby Library for integrating with Chargebee. Sign up for a Chargebee account {here}[https://www.chargebee.com].
|
7
|
-
|
8
|
-
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. This library is for <b>API version V2</b>. If you’re looking for V1, head to {chargebee-v1 branch}[https://github.com/chargebee/chargebee-ruby/tree/chargebee-v1].
|
9
|
-
|
10
|
-
== Installation
|
11
|
-
|
12
|
-
Install the latest version of the gem with the following command...
|
13
|
-
|
14
|
-
$ sudo gem install chargebee -v '~>2'
|
15
|
-
|
16
|
-
|
17
|
-
== Requirements
|
18
|
-
|
19
|
-
* Ruby 1.9.3 or above.
|
20
|
-
* rest-client
|
21
|
-
|
22
|
-
== Documentation
|
23
|
-
|
24
|
-
For API reference see {here}[https://apidocs.chargebee.com/docs/api?lang=ruby]
|
25
|
-
|
26
|
-
== Usage
|
27
|
-
|
28
|
-
To create a new subscription:
|
29
|
-
|
30
|
-
ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
|
31
|
-
result = ChargeBee::Subscription.create({
|
32
|
-
:id => "sub_KyVqDh__dev__NTn4VZZ1",
|
33
|
-
:plan_id => "basic",
|
34
|
-
})
|
35
|
-
subscription = result.subscription
|
36
|
-
puts "created subscription is #{subscription}"
|
37
|
-
|
38
|
-
== License
|
39
|
-
|
40
|
-
See the LICENSE file.
|
41
|
-
|
1
|
+
= Chargebee Ruby Client Library - API V2
|
2
|
+
|
3
|
+
{<img src="https://img.shields.io/gem/v/chargebee.svg?maxAge=2592000"/>}[https://rubygems.org/gems/chargebee]
|
4
|
+
{<img src="https://img.shields.io/gem/dtv/chargebee.svg?maxAge=2592000"/>}[https://rubygems.org/gems/chargebee]
|
5
|
+
|
6
|
+
This is the Ruby Library for integrating with Chargebee. Sign up for a Chargebee account {here}[https://www.chargebee.com].
|
7
|
+
|
8
|
+
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. This library is for <b>API version V2</b>. If you’re looking for V1, head to {chargebee-v1 branch}[https://github.com/chargebee/chargebee-ruby/tree/chargebee-v1].
|
9
|
+
|
10
|
+
== Installation
|
11
|
+
|
12
|
+
Install the latest version of the gem with the following command...
|
13
|
+
|
14
|
+
$ sudo gem install chargebee -v '~>2'
|
15
|
+
|
16
|
+
|
17
|
+
== Requirements
|
18
|
+
|
19
|
+
* Ruby 1.9.3 or above.
|
20
|
+
* rest-client
|
21
|
+
|
22
|
+
== Documentation
|
23
|
+
|
24
|
+
For API reference see {here}[https://apidocs.chargebee.com/docs/api?lang=ruby]
|
25
|
+
|
26
|
+
== Usage
|
27
|
+
|
28
|
+
To create a new subscription:
|
29
|
+
|
30
|
+
ChargeBee.configure({:api_key => "your_api_key" , :site => "your_site"})
|
31
|
+
result = ChargeBee::Subscription.create({
|
32
|
+
:id => "sub_KyVqDh__dev__NTn4VZZ1",
|
33
|
+
:plan_id => "basic",
|
34
|
+
})
|
35
|
+
subscription = result.subscription
|
36
|
+
puts "created subscription is #{subscription}"
|
37
|
+
|
38
|
+
== License
|
39
|
+
|
40
|
+
See the LICENSE file.
|
41
|
+
|
data/chargebee.gemspec
CHANGED
@@ -4,8 +4,8 @@ Gem::Specification.new do |s|
|
|
4
4
|
s.rubygems_version = '1.3.5'
|
5
5
|
s.required_ruby_version = '>= 1.9.3'
|
6
6
|
s.name = 'chargebee'
|
7
|
-
s.version = '2.6.
|
8
|
-
s.date = '2019-
|
7
|
+
s.version = '2.6.6'
|
8
|
+
s.date = '2019-07-08'
|
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."
|
@@ -35,7 +35,6 @@ Gem::Specification.new do |s|
|
|
35
35
|
chargebee.gemspec
|
36
36
|
lib/.DS_Store
|
37
37
|
lib/chargebee.rb
|
38
|
-
lib/chargebee/.DS_Store
|
39
38
|
lib/chargebee/environment.rb
|
40
39
|
lib/chargebee/errors.rb
|
41
40
|
lib/chargebee/list_result.rb
|
@@ -55,6 +54,7 @@ Gem::Specification.new do |s|
|
|
55
54
|
lib/chargebee/models/event.rb
|
56
55
|
lib/chargebee/models/export.rb
|
57
56
|
lib/chargebee/models/gift.rb
|
57
|
+
lib/chargebee/models/hierarchy.rb
|
58
58
|
lib/chargebee/models/hosted_page.rb
|
59
59
|
lib/chargebee/models/invoice.rb
|
60
60
|
lib/chargebee/models/invoice_estimate.rb
|
@@ -71,6 +71,7 @@ Gem::Specification.new do |s|
|
|
71
71
|
lib/chargebee/models/subscription_estimate.rb
|
72
72
|
lib/chargebee/models/third_party_payment_method.rb
|
73
73
|
lib/chargebee/models/time_machine.rb
|
74
|
+
lib/chargebee/models/token.rb
|
74
75
|
lib/chargebee/models/transaction.rb
|
75
76
|
lib/chargebee/models/unbilled_charge.rb
|
76
77
|
lib/chargebee/models/virtual_bank_account.rb
|
data/lib/chargebee.rb
CHANGED
@@ -1,85 +1,85 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/chargebee/environment'
|
2
|
-
require File.dirname(__FILE__) + '/chargebee/rest'
|
3
|
-
require File.dirname(__FILE__) + '/chargebee/util'
|
4
|
-
require File.dirname(__FILE__) + '/chargebee/request'
|
5
|
-
require File.dirname(__FILE__) + '/chargebee/result'
|
6
|
-
require File.dirname(__FILE__) + '/chargebee/list_result'
|
7
|
-
|
8
|
-
require File.dirname(__FILE__) + '/chargebee/errors'
|
9
|
-
|
10
|
-
require File.dirname(__FILE__) + '/chargebee/models/model'
|
11
|
-
require File.dirname(__FILE__) + '/chargebee/models/subscription'
|
12
|
-
require File.dirname(__FILE__) + '/chargebee/models/customer'
|
13
|
-
require File.dirname(__FILE__) + '/chargebee/models/card'
|
14
|
-
require File.dirname(__FILE__) + '/chargebee/models/third_party_payment_method'
|
15
|
-
require File.dirname(__FILE__) + '/chargebee/models/address'
|
16
|
-
require File.dirname(__FILE__) + '/chargebee/models/transaction'
|
17
|
-
require File.dirname(__FILE__) + '/chargebee/models/invoice'
|
18
|
-
require File.dirname(__FILE__) + '/chargebee/models/order'
|
19
|
-
require File.dirname(__FILE__) + '/chargebee/models/credit_note'
|
20
|
-
require File.dirname(__FILE__) + '/chargebee/models/estimate'
|
21
|
-
require File.dirname(__FILE__) + '/chargebee/models/subscription_estimate'
|
22
|
-
require File.dirname(__FILE__) + '/chargebee/models/invoice_estimate'
|
23
|
-
require File.dirname(__FILE__) + '/chargebee/models/credit_note_estimate'
|
24
|
-
require File.dirname(__FILE__) + '/chargebee/models/hosted_page'
|
25
|
-
require File.dirname(__FILE__) + '/chargebee/models/event'
|
26
|
-
require File.dirname(__FILE__) + '/chargebee/models/plan'
|
27
|
-
require File.dirname(__FILE__) + '/chargebee/models/addon'
|
28
|
-
require File.dirname(__FILE__) + '/chargebee/models/coupon'
|
29
|
-
require File.dirname(__FILE__) + '/chargebee/models/coupon_code'
|
30
|
-
require File.dirname(__FILE__) + '/chargebee/models/coupon_set'
|
31
|
-
require File.dirname(__FILE__) + '/chargebee/models/comment'
|
32
|
-
require File.dirname(__FILE__) + '/chargebee/models/portal_session'
|
33
|
-
require File.dirname(__FILE__) + '/chargebee/models/download'
|
34
|
-
require File.dirname(__FILE__) + '/chargebee/models/site_migration_detail'
|
35
|
-
require File.dirname(__FILE__) + '/chargebee/models/resource_migration'
|
36
|
-
require File.dirname(__FILE__) + '/chargebee/models/payment_source'
|
37
|
-
require File.dirname(__FILE__) + '/chargebee/models/unbilled_charge'
|
38
|
-
require File.dirname(__FILE__) + '/chargebee/models/time_machine'
|
39
|
-
require File.dirname(__FILE__) + '/chargebee/models/promotional_credit.rb'
|
40
|
-
require File.dirname(__FILE__) + '/chargebee/models/virtual_bank_account.rb'
|
41
|
-
require File.dirname(__FILE__) + '/chargebee/models/export'
|
42
|
-
require File.dirname(__FILE__) + '/chargebee/models/gift'
|
43
|
-
require File.dirname(__FILE__) + '/chargebee/models/quote'
|
44
|
-
require File.dirname(__FILE__) + '/chargebee/models/contact.rb'
|
45
|
-
|
46
|
-
module ChargeBee
|
47
|
-
|
48
|
-
VERSION = '2.6.
|
49
|
-
|
50
|
-
@@default_env = nil
|
51
|
-
@@verify_ca_certs = true
|
52
|
-
@@ca_cert_path = File.join(File.dirname(__FILE__), '/ssl/ca-certs.crt')
|
53
|
-
@@user_agent = "Chargebee-Ruby-Client v#{self::VERSION}"
|
54
|
-
|
55
|
-
def self.configure(options)
|
56
|
-
@@default_env = Environment.new(options)
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.default_env
|
60
|
-
@@default_env
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.verify_ca_certs=(verify)
|
64
|
-
@@verify_ca_certs = verify
|
65
|
-
end
|
66
|
-
|
67
|
-
def self.verify_ca_certs?
|
68
|
-
@@verify_ca_certs
|
69
|
-
end
|
70
|
-
|
71
|
-
def self.ca_cert_path
|
72
|
-
@@ca_cert_path
|
73
|
-
end
|
74
|
-
|
75
|
-
|
76
|
-
def self.source(source)
|
77
|
-
@@user_agent = @@user_agent + ' ' + source unless source.nil?
|
78
|
-
end
|
79
|
-
|
80
|
-
def self.user_agent
|
81
|
-
@@user_agent
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
1
|
+
require File.dirname(__FILE__) + '/chargebee/environment'
|
2
|
+
require File.dirname(__FILE__) + '/chargebee/rest'
|
3
|
+
require File.dirname(__FILE__) + '/chargebee/util'
|
4
|
+
require File.dirname(__FILE__) + '/chargebee/request'
|
5
|
+
require File.dirname(__FILE__) + '/chargebee/result'
|
6
|
+
require File.dirname(__FILE__) + '/chargebee/list_result'
|
7
|
+
|
8
|
+
require File.dirname(__FILE__) + '/chargebee/errors'
|
9
|
+
|
10
|
+
require File.dirname(__FILE__) + '/chargebee/models/model'
|
11
|
+
require File.dirname(__FILE__) + '/chargebee/models/subscription'
|
12
|
+
require File.dirname(__FILE__) + '/chargebee/models/customer'
|
13
|
+
require File.dirname(__FILE__) + '/chargebee/models/card'
|
14
|
+
require File.dirname(__FILE__) + '/chargebee/models/third_party_payment_method'
|
15
|
+
require File.dirname(__FILE__) + '/chargebee/models/address'
|
16
|
+
require File.dirname(__FILE__) + '/chargebee/models/transaction'
|
17
|
+
require File.dirname(__FILE__) + '/chargebee/models/invoice'
|
18
|
+
require File.dirname(__FILE__) + '/chargebee/models/order'
|
19
|
+
require File.dirname(__FILE__) + '/chargebee/models/credit_note'
|
20
|
+
require File.dirname(__FILE__) + '/chargebee/models/estimate'
|
21
|
+
require File.dirname(__FILE__) + '/chargebee/models/subscription_estimate'
|
22
|
+
require File.dirname(__FILE__) + '/chargebee/models/invoice_estimate'
|
23
|
+
require File.dirname(__FILE__) + '/chargebee/models/credit_note_estimate'
|
24
|
+
require File.dirname(__FILE__) + '/chargebee/models/hosted_page'
|
25
|
+
require File.dirname(__FILE__) + '/chargebee/models/event'
|
26
|
+
require File.dirname(__FILE__) + '/chargebee/models/plan'
|
27
|
+
require File.dirname(__FILE__) + '/chargebee/models/addon'
|
28
|
+
require File.dirname(__FILE__) + '/chargebee/models/coupon'
|
29
|
+
require File.dirname(__FILE__) + '/chargebee/models/coupon_code'
|
30
|
+
require File.dirname(__FILE__) + '/chargebee/models/coupon_set'
|
31
|
+
require File.dirname(__FILE__) + '/chargebee/models/comment'
|
32
|
+
require File.dirname(__FILE__) + '/chargebee/models/portal_session'
|
33
|
+
require File.dirname(__FILE__) + '/chargebee/models/download'
|
34
|
+
require File.dirname(__FILE__) + '/chargebee/models/site_migration_detail'
|
35
|
+
require File.dirname(__FILE__) + '/chargebee/models/resource_migration'
|
36
|
+
require File.dirname(__FILE__) + '/chargebee/models/payment_source'
|
37
|
+
require File.dirname(__FILE__) + '/chargebee/models/unbilled_charge'
|
38
|
+
require File.dirname(__FILE__) + '/chargebee/models/time_machine'
|
39
|
+
require File.dirname(__FILE__) + '/chargebee/models/promotional_credit.rb'
|
40
|
+
require File.dirname(__FILE__) + '/chargebee/models/virtual_bank_account.rb'
|
41
|
+
require File.dirname(__FILE__) + '/chargebee/models/export'
|
42
|
+
require File.dirname(__FILE__) + '/chargebee/models/gift'
|
43
|
+
require File.dirname(__FILE__) + '/chargebee/models/quote'
|
44
|
+
require File.dirname(__FILE__) + '/chargebee/models/contact.rb'
|
45
|
+
|
46
|
+
module ChargeBee
|
47
|
+
|
48
|
+
VERSION = '2.6.6'
|
49
|
+
|
50
|
+
@@default_env = nil
|
51
|
+
@@verify_ca_certs = true
|
52
|
+
@@ca_cert_path = File.join(File.dirname(__FILE__), '/ssl/ca-certs.crt')
|
53
|
+
@@user_agent = "Chargebee-Ruby-Client v#{self::VERSION}"
|
54
|
+
|
55
|
+
def self.configure(options)
|
56
|
+
@@default_env = Environment.new(options)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.default_env
|
60
|
+
@@default_env
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.verify_ca_certs=(verify)
|
64
|
+
@@verify_ca_certs = verify
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.verify_ca_certs?
|
68
|
+
@@verify_ca_certs
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.ca_cert_path
|
72
|
+
@@ca_cert_path
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
def self.source(source)
|
77
|
+
@@user_agent = @@user_agent + ' ' + source unless source.nil?
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.user_agent
|
81
|
+
@@user_agent
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
@@ -1,28 +1,28 @@
|
|
1
|
-
module ChargeBee
|
2
|
-
class Environment
|
3
|
-
API_VERSION = "v2"
|
4
|
-
# in seconds
|
5
|
-
TIME_MACHINE_TIMEOUT = 3
|
6
|
-
EXPORT_TIMEOUT = 10
|
7
|
-
|
8
|
-
attr_accessor :api_key, :site, :time_machine_sleeptime, :export_sleeptime
|
9
|
-
attr_reader :api_endpoint
|
10
|
-
|
11
|
-
def initialize(options)
|
12
|
-
options[:time_machine_sleeptime] ||= TIME_MACHINE_TIMEOUT
|
13
|
-
options[:export_sleeptime] ||= EXPORT_TIMEOUT
|
14
|
-
[:api_key, :site, :time_machine_sleeptime, :export_sleeptime].each do |attr|
|
15
|
-
instance_variable_set "@#{attr}", options[attr]
|
16
|
-
end
|
17
|
-
if($CHARGEBEE_DOMAIN == nil)
|
18
|
-
@api_endpoint = "https://#{@site}.chargebee.com/api/#{API_VERSION}"
|
19
|
-
else
|
20
|
-
@api_endpoint = "#{$ENV_PROTOCOL == nil ? "http": "https"}://#{@site}.#{$CHARGEBEE_DOMAIN}/api/#{API_VERSION}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def api_url(url)
|
25
|
-
url = @api_endpoint + url
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
1
|
+
module ChargeBee
|
2
|
+
class Environment
|
3
|
+
API_VERSION = "v2"
|
4
|
+
# in seconds
|
5
|
+
TIME_MACHINE_TIMEOUT = 3
|
6
|
+
EXPORT_TIMEOUT = 10
|
7
|
+
|
8
|
+
attr_accessor :api_key, :site, :time_machine_sleeptime, :export_sleeptime
|
9
|
+
attr_reader :api_endpoint
|
10
|
+
|
11
|
+
def initialize(options)
|
12
|
+
options[:time_machine_sleeptime] ||= TIME_MACHINE_TIMEOUT
|
13
|
+
options[:export_sleeptime] ||= EXPORT_TIMEOUT
|
14
|
+
[:api_key, :site, :time_machine_sleeptime, :export_sleeptime].each do |attr|
|
15
|
+
instance_variable_set "@#{attr}", options[attr]
|
16
|
+
end
|
17
|
+
if($CHARGEBEE_DOMAIN == nil)
|
18
|
+
@api_endpoint = "https://#{@site}.chargebee.com/api/#{API_VERSION}"
|
19
|
+
else
|
20
|
+
@api_endpoint = "#{$ENV_PROTOCOL == nil ? "http": "https"}://#{@site}.#{$CHARGEBEE_DOMAIN}/api/#{API_VERSION}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def api_url(url)
|
25
|
+
url = @api_endpoint + url
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/chargebee/errors.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
module ChargeBee
|
2
|
-
|
3
|
-
class Error < StandardError
|
4
|
-
attr_reader :original_error
|
5
|
-
|
6
|
-
def initialize(message=nil,original_error = nil)
|
7
|
-
super message
|
8
|
-
@original_error = original_error
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class IOError < Error; end
|
13
|
-
|
14
|
-
class APIError < Error
|
15
|
-
|
16
|
-
attr_reader :http_status_code, :type, :api_error_code, :param, :json_obj,
|
17
|
-
#Deprecated attributes
|
18
|
-
:http_code, :http_body, :error_code
|
19
|
-
|
20
|
-
def initialize(http_code=nil, json_obj = nil)
|
21
|
-
super json_obj[:message]
|
22
|
-
@json_obj = json_obj
|
23
|
-
@http_status_code = http_code
|
24
|
-
@type = json_obj[:type]
|
25
|
-
@api_error_code = json_obj[:api_error_code]
|
26
|
-
@param = json_obj[:param]
|
27
|
-
|
28
|
-
#Deprecated attributes
|
29
|
-
@error_code = json_obj[:error_code]
|
30
|
-
@http_code = http_code
|
31
|
-
@http_body = json_obj.to_s
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
class OperationFailedError < APIError; end
|
38
|
-
|
39
|
-
class InvalidRequestError < APIError; end
|
40
|
-
|
41
|
-
class PaymentError < APIError; end
|
42
|
-
|
43
|
-
end
|
1
|
+
module ChargeBee
|
2
|
+
|
3
|
+
class Error < StandardError
|
4
|
+
attr_reader :original_error
|
5
|
+
|
6
|
+
def initialize(message=nil,original_error = nil)
|
7
|
+
super message
|
8
|
+
@original_error = original_error
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class IOError < Error; end
|
13
|
+
|
14
|
+
class APIError < Error
|
15
|
+
|
16
|
+
attr_reader :http_status_code, :type, :api_error_code, :param, :json_obj,
|
17
|
+
#Deprecated attributes
|
18
|
+
:http_code, :http_body, :error_code
|
19
|
+
|
20
|
+
def initialize(http_code=nil, json_obj = nil)
|
21
|
+
super json_obj[:message]
|
22
|
+
@json_obj = json_obj
|
23
|
+
@http_status_code = http_code
|
24
|
+
@type = json_obj[:type]
|
25
|
+
@api_error_code = json_obj[:api_error_code]
|
26
|
+
@param = json_obj[:param]
|
27
|
+
|
28
|
+
#Deprecated attributes
|
29
|
+
@error_code = json_obj[:error_code]
|
30
|
+
@http_code = http_code
|
31
|
+
@http_body = json_obj.to_s
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
class OperationFailedError < APIError; end
|
38
|
+
|
39
|
+
class InvalidRequestError < APIError; end
|
40
|
+
|
41
|
+
class PaymentError < APIError; end
|
42
|
+
|
43
|
+
end
|