chargebee 2.47.0.beta.1 → 2.47.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 +25 -0
- data/Gemfile.lock +6 -2
- data/Rakefile +0 -13
- data/chargebee.gemspec +5 -3
- data/lib/chargebee/models/omnichannel_subscription.rb +2 -5
- data/lib/chargebee/models/omnichannel_subscription_item.rb +11 -0
- data/lib/chargebee/models/omnichannel_transaction.rb +1 -1
- data/lib/chargebee/models/recorded_purchase.rb +1 -1
- data/lib/chargebee/models/subscription.rb +6 -2
- data/lib/chargebee/request.rb +1 -1
- data/lib/chargebee/rest.rb +99 -0
- data/lib/chargebee/result.rb +9 -2
- data/lib/chargebee.rb +3 -3
- data/spec/chargebee/list_result_spec.rb +1 -1
- data/spec/chargebee_spec.rb +6 -5
- metadata +42 -20
- data/lib/chargebee/nativeRequest.rb +0 -136
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6faa46d51fb6ea60406a763027cc3b76c7478ce4
|
4
|
+
data.tar.gz: 72dc97688118a2b2563c6e1de9a4e41d6ce80986
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e54108ac52fb4bbd9463959f602d5fdbd5655a3e3b38665b7f420a027ed5c90bf30c4bd340ff270caddaa53666148e2b184ddc8e5a9758cf33f2b40cd92206f7
|
7
|
+
data.tar.gz: be4ad479e9ea815ea9f803065dcbb3822a352381fc38b8f553006a86f1ca9a76521170b1d2dbfe985864ee9e6ed8a58a3d2d7990e8ce92afb1194c1786969886
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
### v2.47.0 (2024-11-27)
|
2
|
+
|
3
|
+
#### New Resource:
|
4
|
+
* OmnichannelSubscriptionItem has been added.
|
5
|
+
|
6
|
+
#### New Attribute:
|
7
|
+
* resource_version has been added to OmnichannelSubscription.
|
8
|
+
* resource_version has been added to OmnichannelTransaction.
|
9
|
+
* resource_version has been added to RecordedPurchase.
|
10
|
+
|
11
|
+
#### New Input Parameters:
|
12
|
+
* limit has been added to OmnichannelSubscription#ListRequest.
|
13
|
+
* offset has been added to OmnichannelSubscription#ListRequest.
|
14
|
+
* customer_id has been added to OmnichannelSubscription#ListRequest.
|
15
|
+
* replace_coupon_list has been added to HostedPage#CheckoutExistingRequest.
|
16
|
+
* replace_coupon_list has been added to HostedPage#CheckoutExistingForItemsRequest.
|
17
|
+
* subscription[po_number] has been added to HostedPage#CheckoutNewForItemsRequest.
|
18
|
+
|
19
|
+
#### Removed Subresource:
|
20
|
+
* OmnichannelSubscriptionItem subresource has been removed from OmnichannelSubscription and is now a standalone resource.
|
21
|
+
|
22
|
+
#### Deprecated Attribute:
|
23
|
+
* metadata has been deprecated from subscription.
|
24
|
+
|
25
|
+
|
1
26
|
### v2.46.0 (2024-11-14)
|
2
27
|
* * *
|
3
28
|
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
chargebee (2.
|
4
|
+
chargebee (2.47.0)
|
5
5
|
cgi (>= 0.1.0, < 1.0.0)
|
6
6
|
json_pure (~> 2.1)
|
7
|
+
rest-client (>= 1.8, <= 2.0.2)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
@@ -20,6 +21,10 @@ GEM
|
|
20
21
|
mime-types-data (3.2022.0105)
|
21
22
|
mocha (1.13.0)
|
22
23
|
netrc (0.11.0)
|
24
|
+
rest-client (2.0.2)
|
25
|
+
http-cookie (>= 1.0.2, < 2.0)
|
26
|
+
mime-types (>= 1.16, < 4.0)
|
27
|
+
netrc (~> 0.8)
|
23
28
|
rspec (3.0.0)
|
24
29
|
rspec-core (~> 3.0.0)
|
25
30
|
rspec-expectations (~> 3.0.0)
|
@@ -38,7 +43,6 @@ GEM
|
|
38
43
|
|
39
44
|
PLATFORMS
|
40
45
|
arm64-darwin-21
|
41
|
-
arm64-darwin-23
|
42
46
|
x86_64-darwin-20
|
43
47
|
x86_64-linux
|
44
48
|
|
data/Rakefile
CHANGED
@@ -148,16 +148,3 @@ task :validate do
|
|
148
148
|
exit!
|
149
149
|
end
|
150
150
|
end
|
151
|
-
|
152
|
-
desc "Create tag v#{version} and build and push #{gem_file} to Rubygems for Beta version."
|
153
|
-
task :release_beta => :build do
|
154
|
-
unless `git branch` =~ /^\* next$/
|
155
|
-
puts "You must be on the next branch to release beta!"
|
156
|
-
exit!
|
157
|
-
end
|
158
|
-
sh "git commit --allow-empty -a -m 'Release #{version}'"
|
159
|
-
sh "git tag v#{version}"
|
160
|
-
sh "git push origin next"
|
161
|
-
sh "git push origin v#{version}"
|
162
|
-
sh "gem push pkg/#{name}-#{version}.gem"
|
163
|
-
end
|
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.47.0
|
8
|
-
s.date = '2024-11-
|
7
|
+
s.version = '2.47.0'
|
8
|
+
s.date = '2024-11-27'
|
9
9
|
s.summary = "Ruby client for Chargebee API."
|
10
10
|
s.description = "Subscription Billing - Simple. Secure. Affordable. More details at www.chargebee.com."
|
11
11
|
s.metadata = {
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.extra_rdoc_files = %w[README.md LICENSE]
|
24
24
|
|
25
25
|
s.add_dependency('json_pure', '~> 2.1')
|
26
|
+
s.add_dependency('rest-client', '>=1.8', '<=2.0.2')
|
26
27
|
s.add_dependency('cgi', '>=0.1.0', '<1.0.0')
|
27
28
|
s.add_development_dependency('rspec', '~> 3.0.0')
|
28
29
|
s.add_development_dependency('mocha')
|
@@ -88,6 +89,7 @@ Gem::Specification.new do |s|
|
|
88
89
|
lib/chargebee/models/model.rb
|
89
90
|
lib/chargebee/models/non_subscription.rb
|
90
91
|
lib/chargebee/models/omnichannel_subscription.rb
|
92
|
+
lib/chargebee/models/omnichannel_subscription_item.rb
|
91
93
|
lib/chargebee/models/omnichannel_transaction.rb
|
92
94
|
lib/chargebee/models/order.rb
|
93
95
|
lib/chargebee/models/payment_intent.rb
|
@@ -122,8 +124,8 @@ Gem::Specification.new do |s|
|
|
122
124
|
lib/chargebee/models/unbilled_charge.rb
|
123
125
|
lib/chargebee/models/usage.rb
|
124
126
|
lib/chargebee/models/virtual_bank_account.rb
|
125
|
-
lib/chargebee/nativeRequest.rb
|
126
127
|
lib/chargebee/request.rb
|
128
|
+
lib/chargebee/rest.rb
|
127
129
|
lib/chargebee/result.rb
|
128
130
|
lib/chargebee/util.rb
|
129
131
|
lib/ssl/ca-certs.crt
|
@@ -1,11 +1,8 @@
|
|
1
1
|
module ChargeBee
|
2
2
|
class OmnichannelSubscription < Model
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
end
|
7
|
-
|
8
|
-
attr_accessor :id, :id_at_source, :app_id, :source, :customer_id, :created_at, :omnichannel_subscription_items
|
4
|
+
attr_accessor :id, :id_at_source, :app_id, :source, :customer_id, :created_at, :resource_version,
|
5
|
+
:omnichannel_subscription_items
|
9
6
|
|
10
7
|
# OPERATIONS
|
11
8
|
#-----------
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ChargeBee
|
2
|
+
class OmnichannelSubscriptionItem < Model
|
3
|
+
|
4
|
+
attr_accessor :id, :item_id_at_source, :status, :current_term_start, :current_term_end, :expired_at,
|
5
|
+
:expiration_reason, :cancelled_at, :cancellation_reason, :resource_version
|
6
|
+
|
7
|
+
# OPERATIONS
|
8
|
+
#-----------
|
9
|
+
|
10
|
+
end # ~OmnichannelSubscriptionItem
|
11
|
+
end # ~ChargeBee
|
@@ -10,7 +10,7 @@ module ChargeBee
|
|
10
10
|
end
|
11
11
|
|
12
12
|
attr_accessor :id, :customer_id, :app_id, :source, :status, :omnichannel_transaction_id, :created_at,
|
13
|
-
:linked_omnichannel_subscriptions, :error_detail
|
13
|
+
:resource_version, :linked_omnichannel_subscriptions, :error_detail
|
14
14
|
|
15
15
|
# OPERATIONS
|
16
16
|
#-----------
|
@@ -56,9 +56,13 @@ module ChargeBee
|
|
56
56
|
:offline_payment_method, :channel, :net_term_days, :active_id, :subscription_items, :item_tiers,
|
57
57
|
:charged_items, :due_invoices_count, :due_since, :total_dues, :mrr, :arr, :exchange_rate, :base_currency_code,
|
58
58
|
:addons, :event_based_addons, :charged_event_based_addons, :coupon, :coupons, :shipping_address,
|
59
|
-
:referral_info, :invoice_notes, :meta_data, :
|
59
|
+
:referral_info, :invoice_notes, :meta_data, :deleted, :changes_scheduled_at, :contract_term,
|
60
60
|
:cancel_reason_code, :free_period, :free_period_unit, :create_pending_invoices, :auto_close_invoices,
|
61
|
-
:discounts, :business_entity_id
|
61
|
+
:discounts, :business_entity_id, :metadata
|
62
|
+
def metadata
|
63
|
+
warn "[DEPRECATION] `metadata` is deprecated please use meta_data instead."
|
64
|
+
@metadata
|
65
|
+
end
|
62
66
|
|
63
67
|
# OPERATIONS
|
64
68
|
#-----------
|
data/lib/chargebee/request.rb
CHANGED
@@ -15,7 +15,7 @@ module ChargeBee
|
|
15
15
|
def self.send(method, url, params={}, env=nil, headers={})
|
16
16
|
env ||= ChargeBee.default_env
|
17
17
|
ser_params = Util.serialize(params)
|
18
|
-
resp, rheaders =
|
18
|
+
resp, rheaders = Rest.request(method, url, env, ser_params||={}, headers)
|
19
19
|
if resp.has_key?(:list)
|
20
20
|
ListResult.new(resp[:list], resp[:next_offset], rheaders)
|
21
21
|
else
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module ChargeBee
|
5
|
+
module Rest
|
6
|
+
|
7
|
+
def self.request(method, url, env, params=nil, headers={})
|
8
|
+
raise Error.new('No environment configured.') unless env
|
9
|
+
api_key = env.api_key
|
10
|
+
|
11
|
+
if(ChargeBee.verify_ca_certs?)
|
12
|
+
ssl_opts = {
|
13
|
+
:verify_ssl => OpenSSL::SSL::VERIFY_PEER,
|
14
|
+
:ssl_ca_file => ChargeBee.ca_cert_path
|
15
|
+
}
|
16
|
+
else
|
17
|
+
ssl_opts = {
|
18
|
+
:verify_ssl => false
|
19
|
+
}
|
20
|
+
end
|
21
|
+
case method.to_s.downcase.to_sym
|
22
|
+
when :get, :head, :delete
|
23
|
+
headers = { :params => params }.merge(headers)
|
24
|
+
payload = nil
|
25
|
+
else
|
26
|
+
payload = params
|
27
|
+
end
|
28
|
+
|
29
|
+
user_agent = ChargeBee.user_agent
|
30
|
+
headers = {
|
31
|
+
"User-Agent" => user_agent,
|
32
|
+
:accept => :json,
|
33
|
+
"Lang-Version" => RUBY_VERSION,
|
34
|
+
"OS-Version" => RUBY_PLATFORM
|
35
|
+
}.merge(headers)
|
36
|
+
opts = {
|
37
|
+
:method => method,
|
38
|
+
:url => env.api_url(url),
|
39
|
+
:user => api_key,
|
40
|
+
:headers => headers,
|
41
|
+
:payload => payload,
|
42
|
+
:open_timeout => env.connect_timeout,
|
43
|
+
:timeout => env.read_timeout
|
44
|
+
}.merge(ssl_opts)
|
45
|
+
|
46
|
+
begin
|
47
|
+
response = RestClient::Request.execute(opts)
|
48
|
+
rescue RestClient::ExceptionWithResponse => e
|
49
|
+
if rcode = e.http_code and rbody = e.http_body
|
50
|
+
raise handle_for_error(e, rcode, rbody)
|
51
|
+
else
|
52
|
+
raise IOError.new("IO Exception when trying to connect to chargebee with url #{opts[:url]} . Reason #{e}",e)
|
53
|
+
end
|
54
|
+
rescue Exception => e
|
55
|
+
raise IOError.new("IO Exception when trying to connect to chargebee with url #{opts[:url]} . Reason #{e}",e)
|
56
|
+
end
|
57
|
+
rheaders = response.headers
|
58
|
+
rbody = response.body
|
59
|
+
rcode = response.code
|
60
|
+
begin
|
61
|
+
resp = JSON.parse(rbody)
|
62
|
+
rescue Exception => e
|
63
|
+
if rbody.include? "503"
|
64
|
+
raise Error.new("Sorry, the server is currently unable to handle the request due to a temporary overload or scheduled maintenance. Please retry after sometime. \n type: internal_temporary_error, \n http_status_code: 503, \n error_code: internal_temporary_error,\n content: #{rbody.inspect}",e)
|
65
|
+
elsif rbody.include? "504"
|
66
|
+
raise Error.new("The server did not receive a timely response from an upstream server, request aborted. If this problem persists, contact us at support@chargebee.com. \n type: gateway_timeout, \n http_status_code: 504, \n error_code: gateway_timeout,\n content: #{rbody.inspect}",e)
|
67
|
+
else
|
68
|
+
raise Error.new("Sorry, something went wrong when trying to process the request. If this problem persists, contact us at support@chargebee.com. \n type: internal_error, \n http_status_code: 500, \n error_code: internal_error,\n content: #{rbody.inspect}",e)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
resp = Util.symbolize_keys(resp)
|
72
|
+
return resp, rheaders
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.handle_for_error(e, rcode=nil, rbody=nil)
|
76
|
+
if(rcode == 204)
|
77
|
+
raise Error.new("No response returned by the chargebee api. The http status code is #{rcode}")
|
78
|
+
end
|
79
|
+
begin
|
80
|
+
error_obj = JSON.parse(rbody)
|
81
|
+
error_obj = Util.symbolize_keys(error_obj)
|
82
|
+
rescue Exception => e
|
83
|
+
raise Error.new("Error response not in JSON format. The http status code is #{rcode} \n #{rbody.inspect}",e)
|
84
|
+
end
|
85
|
+
type = error_obj[:type]
|
86
|
+
if("payment" == type)
|
87
|
+
raise PaymentError.new(rcode, error_obj)
|
88
|
+
elsif("operation_failed" == type)
|
89
|
+
raise OperationFailedError.new(rcode, error_obj)
|
90
|
+
elsif("invalid_request" == type)
|
91
|
+
raise InvalidRequestError.new(rcode, error_obj)
|
92
|
+
else
|
93
|
+
raise APIError.new(rcode, error_obj)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
data/lib/chargebee/result.rb
CHANGED
@@ -433,8 +433,10 @@ module ChargeBee
|
|
433
433
|
end
|
434
434
|
|
435
435
|
def omnichannel_subscription()
|
436
|
-
omnichannel_subscription = get(:omnichannel_subscription, OmnichannelSubscription,
|
437
|
-
{:omnichannel_subscription_items =>
|
436
|
+
omnichannel_subscription = get(:omnichannel_subscription, OmnichannelSubscription, {},
|
437
|
+
{:omnichannel_subscription_items => OmnichannelSubscriptionItem});
|
438
|
+
omnichannel_subscription.init_dependant_list(@response[:omnichannel_subscription], :omnichannel_subscription_items,
|
439
|
+
{});
|
438
440
|
return omnichannel_subscription;
|
439
441
|
end
|
440
442
|
|
@@ -443,6 +445,11 @@ module ChargeBee
|
|
443
445
|
return omnichannel_transaction;
|
444
446
|
end
|
445
447
|
|
448
|
+
def omnichannel_subscription_item()
|
449
|
+
omnichannel_subscription_item = get(:omnichannel_subscription_item, OmnichannelSubscriptionItem);
|
450
|
+
return omnichannel_subscription_item;
|
451
|
+
end
|
452
|
+
|
446
453
|
def recorded_purchase()
|
447
454
|
recorded_purchase = get(:recorded_purchase, RecordedPurchase,
|
448
455
|
{:linked_omnichannel_subscriptions => RecordedPurchase::LinkedOmnichannelSubscription, :error_detail => RecordedPurchase::ErrorDetail});
|
data/lib/chargebee.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/chargebee/environment'
|
2
|
-
require File.dirname(__FILE__) + '/chargebee/
|
2
|
+
require File.dirname(__FILE__) + '/chargebee/rest'
|
3
3
|
require File.dirname(__FILE__) + '/chargebee/util'
|
4
4
|
require File.dirname(__FILE__) + '/chargebee/request'
|
5
5
|
require File.dirname(__FILE__) + '/chargebee/result'
|
@@ -81,12 +81,12 @@ require File.dirname(__FILE__) + '/chargebee/models/payment_schedule_estimate'
|
|
81
81
|
require File.dirname(__FILE__) + '/chargebee/models/omnichannel_subscription'
|
82
82
|
require File.dirname(__FILE__) + '/chargebee/models/omnichannel_transaction'
|
83
83
|
require File.dirname(__FILE__) + '/chargebee/models/recorded_purchase'
|
84
|
-
|
84
|
+
require File.dirname(__FILE__) + '/chargebee/models/omnichannel_subscription_item'
|
85
85
|
|
86
86
|
|
87
87
|
module ChargeBee
|
88
88
|
|
89
|
-
VERSION = '2.47.0
|
89
|
+
VERSION = '2.47.0'
|
90
90
|
|
91
91
|
@@default_env = nil
|
92
92
|
@@verify_ca_certs = true
|
data/spec/chargebee_spec.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'rest_client'
|
2
3
|
require 'sample_response'
|
3
4
|
|
4
5
|
describe "chargebee" do
|
5
6
|
|
6
7
|
before(:all) do
|
7
|
-
@request =
|
8
|
+
@request = RestClient::Request
|
8
9
|
end
|
9
10
|
|
10
11
|
it "serialize should convert the hash to acceptable format" do
|
@@ -54,7 +55,7 @@ describe "chargebee" do
|
|
54
55
|
end
|
55
56
|
|
56
57
|
it "should properly convert the response json into proper object" do
|
57
|
-
@request.expects(:
|
58
|
+
@request.expects(:execute).once.returns(mock_response(simple_subscription, headers))
|
58
59
|
result = ChargeBee::Subscription.retrieve("simple_subscription")
|
59
60
|
h = result.get_response_headers
|
60
61
|
expect(h).to eq(headers)
|
@@ -67,7 +68,7 @@ describe "chargebee" do
|
|
67
68
|
end
|
68
69
|
|
69
70
|
it "should properly convert the nested response json into proper object with sub types" do
|
70
|
-
@request.expects(:
|
71
|
+
@request.expects(:execute).once.returns(mock_response(nested_subscription, headers))
|
71
72
|
result = ChargeBee::Subscription.retrieve("nested_subscription")
|
72
73
|
s = result.subscription
|
73
74
|
expect(s.id).to eq("nested_subscription")
|
@@ -79,7 +80,7 @@ describe "chargebee" do
|
|
79
80
|
end
|
80
81
|
|
81
82
|
it "should properly convert the list response json into proper result object" do
|
82
|
-
@request.expects(:
|
83
|
+
@request.expects(:execute).once.returns(mock_response(list_subscriptions, headers))
|
83
84
|
result = ChargeBee::Subscription.list({:limit => 2})
|
84
85
|
expect(result.length).to eq(2)
|
85
86
|
result.each do |i|
|
@@ -88,7 +89,7 @@ describe "chargebee" do
|
|
88
89
|
end
|
89
90
|
|
90
91
|
it "should parse event api response and provide the content properly" do
|
91
|
-
@request.expects(:
|
92
|
+
@request.expects(:execute).once.returns(mock_response(sample_event, headers))
|
92
93
|
result = ChargeBee::Event.retrieve("sample_event")
|
93
94
|
event = result.event
|
94
95
|
s = event.content.subscription
|
metadata
CHANGED
@@ -1,76 +1,96 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chargebee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.47.0
|
4
|
+
version: 2.47.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rajaraman S
|
8
8
|
- Thiyagarajan T
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-11-
|
12
|
+
date: 2024-11-27 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
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rest-client
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.8'
|
35
|
+
- - <=
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.0.2
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '1.8'
|
45
|
+
- - <=
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.0.2
|
28
48
|
- !ruby/object:Gem::Dependency
|
29
49
|
name: cgi
|
30
50
|
requirement: !ruby/object:Gem::Requirement
|
31
51
|
requirements:
|
32
|
-
- -
|
52
|
+
- - '>='
|
33
53
|
- !ruby/object:Gem::Version
|
34
54
|
version: 0.1.0
|
35
|
-
- -
|
55
|
+
- - <
|
36
56
|
- !ruby/object:Gem::Version
|
37
57
|
version: 1.0.0
|
38
58
|
type: :runtime
|
39
59
|
prerelease: false
|
40
60
|
version_requirements: !ruby/object:Gem::Requirement
|
41
61
|
requirements:
|
42
|
-
- -
|
62
|
+
- - '>='
|
43
63
|
- !ruby/object:Gem::Version
|
44
64
|
version: 0.1.0
|
45
|
-
- -
|
65
|
+
- - <
|
46
66
|
- !ruby/object:Gem::Version
|
47
67
|
version: 1.0.0
|
48
68
|
- !ruby/object:Gem::Dependency
|
49
69
|
name: rspec
|
50
70
|
requirement: !ruby/object:Gem::Requirement
|
51
71
|
requirements:
|
52
|
-
- -
|
72
|
+
- - ~>
|
53
73
|
- !ruby/object:Gem::Version
|
54
74
|
version: 3.0.0
|
55
75
|
type: :development
|
56
76
|
prerelease: false
|
57
77
|
version_requirements: !ruby/object:Gem::Requirement
|
58
78
|
requirements:
|
59
|
-
- -
|
79
|
+
- - ~>
|
60
80
|
- !ruby/object:Gem::Version
|
61
81
|
version: 3.0.0
|
62
82
|
- !ruby/object:Gem::Dependency
|
63
83
|
name: mocha
|
64
84
|
requirement: !ruby/object:Gem::Requirement
|
65
85
|
requirements:
|
66
|
-
- -
|
86
|
+
- - '>='
|
67
87
|
- !ruby/object:Gem::Version
|
68
88
|
version: '0'
|
69
89
|
type: :development
|
70
90
|
prerelease: false
|
71
91
|
version_requirements: !ruby/object:Gem::Requirement
|
72
92
|
requirements:
|
73
|
-
- -
|
93
|
+
- - '>='
|
74
94
|
- !ruby/object:Gem::Version
|
75
95
|
version: '0'
|
76
96
|
description: Subscription Billing - Simple. Secure. Affordable. More details at www.chargebee.com.
|
@@ -142,6 +162,7 @@ files:
|
|
142
162
|
- lib/chargebee/models/model.rb
|
143
163
|
- lib/chargebee/models/non_subscription.rb
|
144
164
|
- lib/chargebee/models/omnichannel_subscription.rb
|
165
|
+
- lib/chargebee/models/omnichannel_subscription_item.rb
|
145
166
|
- lib/chargebee/models/omnichannel_transaction.rb
|
146
167
|
- lib/chargebee/models/order.rb
|
147
168
|
- lib/chargebee/models/payment_intent.rb
|
@@ -176,8 +197,8 @@ files:
|
|
176
197
|
- lib/chargebee/models/unbilled_charge.rb
|
177
198
|
- lib/chargebee/models/usage.rb
|
178
199
|
- lib/chargebee/models/virtual_bank_account.rb
|
179
|
-
- lib/chargebee/nativeRequest.rb
|
180
200
|
- lib/chargebee/request.rb
|
201
|
+
- lib/chargebee/rest.rb
|
181
202
|
- lib/chargebee/result.rb
|
182
203
|
- lib/chargebee/util.rb
|
183
204
|
- lib/ssl/ca-certs.crt
|
@@ -191,24 +212,25 @@ licenses:
|
|
191
212
|
- MIT
|
192
213
|
metadata:
|
193
214
|
changelog_uri: https://github.com/chargebee/chargebee-ruby/blob/master/CHANGELOG.md
|
194
|
-
post_install_message:
|
215
|
+
post_install_message:
|
195
216
|
rdoc_options:
|
196
|
-
-
|
217
|
+
- --charset=UTF-8
|
197
218
|
require_paths:
|
198
219
|
- lib
|
199
220
|
required_ruby_version: !ruby/object:Gem::Requirement
|
200
221
|
requirements:
|
201
|
-
- -
|
222
|
+
- - '>='
|
202
223
|
- !ruby/object:Gem::Version
|
203
224
|
version: 1.9.3
|
204
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
205
226
|
requirements:
|
206
|
-
- -
|
227
|
+
- - '>='
|
207
228
|
- !ruby/object:Gem::Version
|
208
229
|
version: '0'
|
209
230
|
requirements: []
|
210
|
-
|
211
|
-
|
231
|
+
rubyforge_project:
|
232
|
+
rubygems_version: 2.4.5
|
233
|
+
signing_key:
|
212
234
|
specification_version: 2
|
213
235
|
summary: Ruby client for Chargebee API.
|
214
236
|
test_files:
|
@@ -1,136 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'net/http'
|
3
|
-
require 'uri'
|
4
|
-
require 'stringio'
|
5
|
-
|
6
|
-
module ChargeBee
|
7
|
-
module NativeRequest
|
8
|
-
|
9
|
-
def self.request(method, url, env, params = nil, headers = {})
|
10
|
-
raise Error.new('No environment configured.') unless env
|
11
|
-
api_key = env.api_key
|
12
|
-
|
13
|
-
uri = URI(env.api_url(url))
|
14
|
-
|
15
|
-
case method.to_s.downcase.to_sym
|
16
|
-
when :get, :head, :delete
|
17
|
-
uri.query = URI.encode_www_form(params) if params
|
18
|
-
payload = nil
|
19
|
-
else
|
20
|
-
payload = URI.encode_www_form(params || {})
|
21
|
-
end
|
22
|
-
user_agent = ChargeBee.user_agent
|
23
|
-
headers = {
|
24
|
-
"User-Agent" => user_agent,
|
25
|
-
"Accept" => "application/json",
|
26
|
-
"Lang-Version" => RUBY_VERSION,
|
27
|
-
"OS-Version" => RUBY_PLATFORM,
|
28
|
-
"Content-Type" => "application/x-www-form-urlencoded"
|
29
|
-
}.merge(headers)
|
30
|
-
|
31
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
32
|
-
http.use_ssl = true
|
33
|
-
http.open_timeout=env.connect_timeout
|
34
|
-
http.read_timeout=env.read_timeout
|
35
|
-
if ChargeBee.verify_ca_certs?
|
36
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
37
|
-
http.ca_file = ChargeBee.ca_cert_path
|
38
|
-
else
|
39
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
40
|
-
end
|
41
|
-
|
42
|
-
request_class = case method.to_s.downcase.to_sym
|
43
|
-
when :get then Net::HTTP::Get
|
44
|
-
when :post then Net::HTTP::Post
|
45
|
-
when :put then Net::HTTP::Put
|
46
|
-
when :delete then Net::HTTP::Delete
|
47
|
-
else raise Error.new("Unsupported HTTP method: #{method}")
|
48
|
-
end
|
49
|
-
|
50
|
-
request = request_class.new(uri, headers)
|
51
|
-
request.body = payload if payload
|
52
|
-
|
53
|
-
request.basic_auth(api_key, nil)
|
54
|
-
begin
|
55
|
-
response = http.request(request)
|
56
|
-
rescue => e
|
57
|
-
raise IOError.new("IO Exception when trying to connect to ChargeBee with URL #{uri} . Reason: #{e}", e)
|
58
|
-
end
|
59
|
-
handle_response(response, headers)
|
60
|
-
end
|
61
|
-
|
62
|
-
def self.handle_response(response, headers)
|
63
|
-
rcode = response.code.to_i
|
64
|
-
rbody = response.body
|
65
|
-
|
66
|
-
# converting headers to rest-client format previously we were using rest-client,
|
67
|
-
# and mapping headers to that format to support backward compatability
|
68
|
-
rheaders = beautify_headers(response.to_hash)
|
69
|
-
|
70
|
-
# When a custom 'Accept-Encoding' header is set to gzip, Net::HTTP will not automatically
|
71
|
-
# decompress the response. Therefore, we need to manually handle decompression
|
72
|
-
# based on the 'Content-Encoding' header in the response.
|
73
|
-
# https://github.com/ruby/ruby/blob/19c1f0233eb5202403c52b196f1d573893eacab7/lib/net/http/generic_request.rb#L82
|
74
|
-
if headers.keys.any? { |k| k.downcase == 'accept-encoding' } && rheaders[:content_encoding] == 'gzip' && rbody && !rbody.empty?
|
75
|
-
rbody = Zlib::GzipReader.new(StringIO.new(rbody)).read
|
76
|
-
end
|
77
|
-
|
78
|
-
if rcode >= 200 && rcode < 300
|
79
|
-
begin
|
80
|
-
resp = JSON.parse(rbody)
|
81
|
-
rescue JSON::ParserError => e
|
82
|
-
raise handle_json_error(rbody, e)
|
83
|
-
end
|
84
|
-
return Util.symbolize_keys(resp), rheaders
|
85
|
-
else
|
86
|
-
raise handle_for_error(rcode, rbody)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.handle_json_error(rbody, e)
|
91
|
-
if rbody.include?("503")
|
92
|
-
raise Error.new("Sorry, the server is currently unable to handle the request due to a temporary overload or scheduled maintenance. Please retry after sometime. \n type: internal_temporary_error, \n http_status_code: 503, \n error_code: internal_temporary_error,\n content: #{rbody.inspect}",e)
|
93
|
-
elsif rbody.include?("504")
|
94
|
-
raise Error.new("The server did not receive a timely response from an upstream server, request aborted. If this problem persists, contact us at support@chargebee.com. \n type: gateway_timeout, \n http_status_code: 504, \n error_code: gateway_timeout,\n content: #{rbody.inspect}",e)
|
95
|
-
else
|
96
|
-
raise Error.new("Sorry, something went wrong when trying to process the request. If this problem persists, contact us at support@chargebee.com. \n type: internal_error, \n http_status_code: 500, \n error_code: internal_error,\n content: #{rbody.inspect}",e)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def self.handle_for_error(rcode, rbody)
|
101
|
-
return Error.new("No response returned by ChargeBee API. HTTP status code: #{rcode}") if rcode == 204
|
102
|
-
begin
|
103
|
-
error_obj = JSON.parse(rbody)
|
104
|
-
error_obj = Util.symbolize_keys(error_obj)
|
105
|
-
rescue Exception => e
|
106
|
-
raise Error.new("Error response not in JSON format. The http status code is #{rcode} \n #{rbody.inspect}",e)
|
107
|
-
end
|
108
|
-
type = error_obj[:type]
|
109
|
-
case type
|
110
|
-
when "payment"
|
111
|
-
raise PaymentError.new(rcode, error_obj)
|
112
|
-
when "operation_failed"
|
113
|
-
raise OperationFailedError.new(rcode, error_obj)
|
114
|
-
when "invalid_request"
|
115
|
-
raise InvalidRequestError.new(rcode, error_obj)
|
116
|
-
else
|
117
|
-
raise APIError.new(rcode, error_obj)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
# directly copying headers formatting from rest-client to support backward compatability for rest-client
|
121
|
-
def self.beautify_headers(headers)
|
122
|
-
headers.inject({}) do |out, (key, value)|
|
123
|
-
key_sym = key.tr('-', '_').downcase.to_sym
|
124
|
-
|
125
|
-
# Handle Set-Cookie specially since it cannot be joined by comma.
|
126
|
-
if key.downcase == 'set-cookie'
|
127
|
-
out[key_sym] = value
|
128
|
-
else
|
129
|
-
out[key_sym] = value.join(', ')
|
130
|
-
end
|
131
|
-
|
132
|
-
out
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|