chargebee 2.47.1 → 2.49.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 +49 -0
- data/Gemfile.lock +2 -6
- data/Rakefile +13 -0
- data/chargebee.gemspec +4 -3
- data/lib/chargebee/errors.rb +2 -1
- data/lib/chargebee/models/configuration.rb +14 -0
- data/lib/chargebee/models/credit_note.rb +1 -1
- data/lib/chargebee/models/credit_note_estimate.rb +1 -1
- data/lib/chargebee/models/gateway_error_detail.rb +1 -1
- data/lib/chargebee/models/invoice.rb +1 -1
- data/lib/chargebee/models/invoice_estimate.rb +1 -1
- data/lib/chargebee/models/omnichannel_subscription.rb +5 -1
- data/lib/chargebee/models/omnichannel_subscription_item.rb +1 -1
- data/lib/chargebee/models/quote.rb +3 -2
- data/lib/chargebee/models/quote_line_group.rb +1 -1
- data/lib/chargebee/models/quoted_subscription.rb +1 -1
- data/lib/chargebee/models/subscription.rb +8 -4
- data/lib/chargebee/models/transaction.rb +1 -1
- data/lib/chargebee/nativeRequest.rb +136 -0
- data/lib/chargebee/request.rb +1 -1
- data/lib/chargebee/result.rb +14 -3
- data/lib/chargebee.rb +3 -2
- data/spec/chargebee/list_result_spec.rb +1 -1
- data/spec/chargebee_spec.rb +5 -6
- metadata +4 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a52725486531b040a5d430e9889b0b33b3953ba8
|
4
|
+
data.tar.gz: a66b2838d48287dae8fe2fd6b7c3d874ac5cd84f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df1cd531937cc375146bdfc1b1d1e0432cfbe811c50a2c5204bd72ea5035053f1a058eedefaad9acafca5d7d469feeaa165b87517d88133178708ca3efa25ac
|
7
|
+
data.tar.gz: 75910fe9baf6ff616fd80f33f5c5ee561b65eac8bd2ab39ed3407d17af4b799c429a2f1a39db5c02001285ca4d773026d97e05e747560db07fface445e1e5277
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,52 @@
|
|
1
|
+
### v2.49.0 (2025-01-16)
|
2
|
+
|
3
|
+
#### New Feature
|
4
|
+
* Net::HTTP has been used as a dependency.
|
5
|
+
* All instances of rest-client have been replaced with Net::HTTP for making HTTP requests.
|
6
|
+
* Updated error handling and response parsing to match the behavior of rest-client.
|
7
|
+
* Adjusted headers and request options for compatibility with Net::HTTP.
|
8
|
+
|
9
|
+
### v2.48.0 (2024-12-19)
|
10
|
+
* * *
|
11
|
+
|
12
|
+
#### New Resource:
|
13
|
+
* Configuration has been added.
|
14
|
+
|
15
|
+
#### New Attribute:
|
16
|
+
* discount_type has been added to CreditNote#Discount.
|
17
|
+
* discount_type has been added to CreditNoteEstimate#Discount.
|
18
|
+
* discount_type has been added to Invoice#Discount.
|
19
|
+
* discount_type has been added to InvoiceEstimate#Discount.
|
20
|
+
* discount_type has been added to QuoteLineGroup#Discount.
|
21
|
+
* initial_purchase_transaction has been added to OmnichannelSubscription.
|
22
|
+
* error_cause_id has been added to GatewayErrorDetail.
|
23
|
+
* error_cause_id has been added to Transaction#GatewayErrorDetail.
|
24
|
+
* error_cause_id has been added to APIError.
|
25
|
+
* deleted has been added to Quote.
|
26
|
+
* current_term_start has been added to QuotedSubscripiton#SubscriptionItem.
|
27
|
+
* current_term_end has been added to QuotedSubscripiton#SubscriptionItem.
|
28
|
+
* next_billing_at has been added to QuotedSubscripiton#SubscriptionItem.
|
29
|
+
* current_term_start has been added to Subscription#SubscriptionItem.
|
30
|
+
* current_term_end has been added to Subscription#SubscriptionItem.
|
31
|
+
* next_billing_at has been added to Subscription#SubscriptionItem.
|
32
|
+
* billing_override has been added to Subscription.
|
33
|
+
* grace_period_expires_at has been added to OmnichannelSubscriptionItem.
|
34
|
+
|
35
|
+
#### New Input Params:
|
36
|
+
* billing_override has been added to Subscription#CreateWithItemsInputParam.
|
37
|
+
* billing_override has been added to Subscription#UpdateForItemsInputParam.
|
38
|
+
|
39
|
+
#### New Enum Values:
|
40
|
+
* OMNICHANNEL_SUBSCRIPTION_IMPORTED has been added to EventTypeEnum.
|
41
|
+
* DISABLED has been added to Event#WebhookStatus.
|
42
|
+
* OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_STARTED has been added to EventTypeEnum.
|
43
|
+
* OMNICHANNEL_SUBSCRIPTION_ITEM_GRACE_PERIOD_EXPIRED has been added to EventTypeEnum.
|
44
|
+
* OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_STARTED has been added to EventTypeEnum.
|
45
|
+
* OMNICHANNEL_SUBSCRIPTION_ITEM_DUNNING_EXPIRED has been added to EventTypeEnum.
|
46
|
+
* IGNORED has been added to RecordedPurchase#StatusEnum.
|
47
|
+
* IN_DUNNING & IN_GRACE_PERIOD have been added to OmnichannelSubscriptionItem#StatusEnum.
|
48
|
+
|
49
|
+
|
1
50
|
### v2.47.1 (2024-12-10)
|
2
51
|
|
3
52
|
#### New Feature:
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
chargebee (2.
|
4
|
+
chargebee (2.49.0)
|
5
5
|
cgi (>= 0.1.0, < 1.0.0)
|
6
6
|
json_pure (~> 2.1)
|
7
|
-
rest-client (>= 1.8, <= 2.0.2)
|
8
7
|
|
9
8
|
GEM
|
10
9
|
remote: https://rubygems.org/
|
@@ -21,10 +20,6 @@ GEM
|
|
21
20
|
mime-types-data (3.2022.0105)
|
22
21
|
mocha (1.13.0)
|
23
22
|
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)
|
28
23
|
rspec (3.0.0)
|
29
24
|
rspec-core (~> 3.0.0)
|
30
25
|
rspec-expectations (~> 3.0.0)
|
@@ -43,6 +38,7 @@ GEM
|
|
43
38
|
|
44
39
|
PLATFORMS
|
45
40
|
arm64-darwin-21
|
41
|
+
arm64-darwin-23
|
46
42
|
x86_64-darwin-20
|
47
43
|
x86_64-linux
|
48
44
|
|
data/Rakefile
CHANGED
@@ -148,3 +148,16 @@ 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.
|
8
|
-
s.date = '
|
7
|
+
s.version = '2.49.0'
|
8
|
+
s.date = '2025-01-16'
|
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,7 +23,6 @@ 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')
|
27
26
|
s.add_dependency('cgi', '>=0.1.0', '<1.0.0')
|
28
27
|
s.add_development_dependency('rspec', '~> 3.0.0')
|
29
28
|
s.add_development_dependency('mocha')
|
@@ -51,6 +50,7 @@ Gem::Specification.new do |s|
|
|
51
50
|
lib/chargebee/models/business_entity_transfer.rb
|
52
51
|
lib/chargebee/models/card.rb
|
53
52
|
lib/chargebee/models/comment.rb
|
53
|
+
lib/chargebee/models/configuration.rb
|
54
54
|
lib/chargebee/models/contact.rb
|
55
55
|
lib/chargebee/models/contract_term.rb
|
56
56
|
lib/chargebee/models/coupon.rb
|
@@ -124,6 +124,7 @@ Gem::Specification.new do |s|
|
|
124
124
|
lib/chargebee/models/unbilled_charge.rb
|
125
125
|
lib/chargebee/models/usage.rb
|
126
126
|
lib/chargebee/models/virtual_bank_account.rb
|
127
|
+
lib/chargebee/nativeRequest.rb
|
127
128
|
lib/chargebee/request.rb
|
128
129
|
lib/chargebee/rest.rb
|
129
130
|
lib/chargebee/result.rb
|
data/lib/chargebee/errors.rb
CHANGED
@@ -13,7 +13,7 @@ module ChargeBee
|
|
13
13
|
|
14
14
|
class APIError < Error
|
15
15
|
|
16
|
-
attr_reader :http_status_code, :type, :api_error_code, :param, :json_obj,
|
16
|
+
attr_reader :http_status_code, :type, :api_error_code, :param, :json_obj, :error_cause_id,
|
17
17
|
#Deprecated attributes
|
18
18
|
:http_code, :http_body, :error_code
|
19
19
|
|
@@ -24,6 +24,7 @@ module ChargeBee
|
|
24
24
|
@type = json_obj[:type]
|
25
25
|
@api_error_code = json_obj[:api_error_code]
|
26
26
|
@param = json_obj[:param]
|
27
|
+
@error_cause_id = json_obj[:error_cause_id]
|
27
28
|
|
28
29
|
#Deprecated attributes
|
29
30
|
@error_code = json_obj[:error_code]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ChargeBee
|
2
|
+
class Configuration < Model
|
3
|
+
|
4
|
+
attr_accessor :domain, :product_catalog_version
|
5
|
+
|
6
|
+
# OPERATIONS
|
7
|
+
#-----------
|
8
|
+
|
9
|
+
def self.list(env=nil, headers={})
|
10
|
+
Request.send_list_request('get', uri_path("configurations"), {}, env, headers)
|
11
|
+
end
|
12
|
+
|
13
|
+
end # ~Configuration
|
14
|
+
end # ~ChargeBee
|
@@ -10,7 +10,7 @@ module ChargeBee
|
|
10
10
|
end
|
11
11
|
|
12
12
|
class Discount < Model
|
13
|
-
attr_accessor :amount, :description, :entity_type, :entity_id, :coupon_set_code
|
13
|
+
attr_accessor :amount, :description, :entity_type, :discount_type, :entity_id, :coupon_set_code
|
14
14
|
end
|
15
15
|
|
16
16
|
class LineItemDiscount < Model
|
@@ -3,7 +3,7 @@ module ChargeBee
|
|
3
3
|
|
4
4
|
attr_accessor :request_id, :error_category, :error_code, :error_message, :decline_code, :decline_message,
|
5
5
|
:network_error_code, :network_error_message, :error_field, :recommendation_code, :recommendation_message,
|
6
|
-
:processor_error_code, :processor_error_message
|
6
|
+
:processor_error_code, :processor_error_message, :error_cause_id
|
7
7
|
|
8
8
|
# OPERATIONS
|
9
9
|
#-----------
|
@@ -6,7 +6,7 @@ module ChargeBee
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class Discount < Model
|
9
|
-
attr_accessor :amount, :description, :entity_type, :entity_id, :coupon_set_code
|
9
|
+
attr_accessor :amount, :description, :entity_type, :discount_type, :entity_id, :coupon_set_code
|
10
10
|
end
|
11
11
|
|
12
12
|
class LineItemDiscount < Model
|
@@ -1,8 +1,12 @@
|
|
1
1
|
module ChargeBee
|
2
2
|
class OmnichannelSubscription < Model
|
3
3
|
|
4
|
+
class OmnichannelTransaction < Model
|
5
|
+
attr_accessor :id, :id_at_source, :app_id, :price_currency, :price_units, :price_nanos, :type, :transacted_at, :created_at, :resource_version
|
6
|
+
end
|
7
|
+
|
4
8
|
attr_accessor :id, :id_at_source, :app_id, :source, :customer_id, :created_at, :resource_version,
|
5
|
-
:omnichannel_subscription_items
|
9
|
+
:omnichannel_subscription_items, :initial_purchase_transaction
|
6
10
|
|
7
11
|
# OPERATIONS
|
8
12
|
#-----------
|
@@ -2,7 +2,7 @@ module ChargeBee
|
|
2
2
|
class OmnichannelSubscriptionItem < Model
|
3
3
|
|
4
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
|
5
|
+
:expiration_reason, :cancelled_at, :cancellation_reason, :grace_period_expires_at, :resource_version
|
6
6
|
|
7
7
|
# OPERATIONS
|
8
8
|
#-----------
|
@@ -6,7 +6,7 @@ module ChargeBee
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class Discount < Model
|
9
|
-
attr_accessor :amount, :description, :entity_type, :entity_id, :coupon_set_code
|
9
|
+
attr_accessor :amount, :description, :entity_type, :discount_type, :entity_id, :coupon_set_code
|
10
10
|
end
|
11
11
|
|
12
12
|
class LineItemDiscount < Model
|
@@ -38,7 +38,8 @@ module ChargeBee
|
|
38
38
|
:sub_total, :total, :credits_applied, :amount_paid, :amount_due, :version, :resource_version,
|
39
39
|
:updated_at, :vat_number_prefix, :line_items, :discounts, :line_item_discounts, :taxes, :line_item_taxes,
|
40
40
|
:line_item_tiers, :tax_category, :currency_code, :notes, :shipping_address, :billing_address,
|
41
|
-
:contract_term_start, :contract_term_end, :contract_term_termination_fee, :business_entity_id
|
41
|
+
:contract_term_start, :contract_term_end, :contract_term_termination_fee, :business_entity_id,
|
42
|
+
:deleted
|
42
43
|
|
43
44
|
# OPERATIONS
|
44
45
|
#-----------
|
@@ -6,7 +6,7 @@ module ChargeBee
|
|
6
6
|
end
|
7
7
|
|
8
8
|
class Discount < Model
|
9
|
-
attr_accessor :amount, :description, :entity_type, :entity_id, :coupon_set_code
|
9
|
+
attr_accessor :amount, :description, :entity_type, :discount_type, :entity_id, :coupon_set_code
|
10
10
|
end
|
11
11
|
|
12
12
|
class LineItemDiscount < Model
|
@@ -14,7 +14,7 @@ module ChargeBee
|
|
14
14
|
end
|
15
15
|
|
16
16
|
class SubscriptionItem < Model
|
17
|
-
attr_accessor :item_price_id, :item_type, :quantity, :quantity_in_decimal, :metered_quantity, :last_calculated_at, :unit_price, :unit_price_in_decimal, :amount, :amount_in_decimal, :billing_period, :billing_period_unit, :free_quantity, :free_quantity_in_decimal, :trial_end, :billing_cycles, :service_period_days, :charge_on_event, :charge_once, :charge_on_option, :proration_type, :usage_accumulation_reset_frequency
|
17
|
+
attr_accessor :item_price_id, :item_type, :quantity, :quantity_in_decimal, :metered_quantity, :last_calculated_at, :unit_price, :unit_price_in_decimal, :amount, :current_term_start, :current_term_end, :next_billing_at, :amount_in_decimal, :billing_period, :billing_period_unit, :free_quantity, :free_quantity_in_decimal, :trial_end, :billing_cycles, :service_period_days, :charge_on_event, :charge_once, :charge_on_option, :proration_type, :usage_accumulation_reset_frequency
|
18
18
|
end
|
19
19
|
|
20
20
|
class ItemTier < Model
|
@@ -2,7 +2,7 @@ module ChargeBee
|
|
2
2
|
class Subscription < Model
|
3
3
|
|
4
4
|
class SubscriptionItem < Model
|
5
|
-
attr_accessor :item_price_id, :item_type, :quantity, :quantity_in_decimal, :metered_quantity, :last_calculated_at, :unit_price, :unit_price_in_decimal, :amount, :amount_in_decimal, :billing_period, :billing_period_unit, :free_quantity, :free_quantity_in_decimal, :trial_end, :billing_cycles, :service_period_days, :charge_on_event, :charge_once, :charge_on_option, :proration_type, :usage_accumulation_reset_frequency
|
5
|
+
attr_accessor :item_price_id, :item_type, :quantity, :quantity_in_decimal, :metered_quantity, :last_calculated_at, :unit_price, :unit_price_in_decimal, :amount, :current_term_start, :current_term_end, :next_billing_at, :amount_in_decimal, :billing_period, :billing_period_unit, :free_quantity, :free_quantity_in_decimal, :trial_end, :billing_cycles, :service_period_days, :charge_on_event, :charge_once, :charge_on_option, :proration_type, :usage_accumulation_reset_frequency
|
6
6
|
end
|
7
7
|
|
8
8
|
class ItemTier < Model
|
@@ -37,6 +37,10 @@ module ChargeBee
|
|
37
37
|
attr_accessor :referral_code, :coupon_code, :referrer_id, :external_reference_id, :reward_status, :referral_system, :account_id, :campaign_id, :external_campaign_id, :friend_offer_type, :referrer_reward_type, :notify_referral_system, :destination_url, :post_purchase_widget_enabled
|
38
38
|
end
|
39
39
|
|
40
|
+
class BillingOverride < Model
|
41
|
+
attr_accessor :max_excess_payment_usage, :max_refundable_credits_usage
|
42
|
+
end
|
43
|
+
|
40
44
|
class ContractTerm < Model
|
41
45
|
attr_accessor :id, :status, :contract_start, :contract_end, :billing_cycle, :action_at_term_end, :total_contract_value, :total_contract_value_before_tax, :cancellation_cutoff_period, :created_at, :subscription_id, :remaining_billing_cycles
|
42
46
|
end
|
@@ -56,9 +60,9 @@ module ChargeBee
|
|
56
60
|
:offline_payment_method, :channel, :net_term_days, :active_id, :subscription_items, :item_tiers,
|
57
61
|
:charged_items, :due_invoices_count, :due_since, :total_dues, :mrr, :arr, :exchange_rate, :base_currency_code,
|
58
62
|
:addons, :event_based_addons, :charged_event_based_addons, :coupon, :coupons, :shipping_address,
|
59
|
-
:referral_info, :invoice_notes, :meta_data, :deleted, :changes_scheduled_at,
|
60
|
-
:cancel_reason_code, :free_period, :free_period_unit, :create_pending_invoices,
|
61
|
-
:discounts, :business_entity_id, :metadata
|
63
|
+
:referral_info, :billing_override, :invoice_notes, :meta_data, :deleted, :changes_scheduled_at,
|
64
|
+
:contract_term, :cancel_reason_code, :free_period, :free_period_unit, :create_pending_invoices,
|
65
|
+
:auto_close_invoices, :discounts, :business_entity_id, :metadata
|
62
66
|
def metadata
|
63
67
|
warn "[DEPRECATION] `metadata` is deprecated please use meta_data instead."
|
64
68
|
@metadata
|
@@ -18,7 +18,7 @@ module ChargeBee
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class GatewayErrorDetail < Model
|
21
|
-
attr_accessor :request_id, :error_category, :error_code, :error_message, :decline_code, :decline_message, :network_error_code, :network_error_message, :error_field, :recommendation_code, :recommendation_message, :processor_error_code, :processor_error_message
|
21
|
+
attr_accessor :request_id, :error_category, :error_code, :error_message, :decline_code, :decline_message, :network_error_code, :network_error_message, :error_field, :recommendation_code, :recommendation_message, :processor_error_code, :processor_error_message, :error_cause_id
|
22
22
|
end
|
23
23
|
|
24
24
|
attr_accessor :id, :customer_id, :subscription_id, :gateway_account_id, :payment_source_id,
|
@@ -0,0 +1,136 @@
|
|
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
|
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 = NativeRequest.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
|
data/lib/chargebee/result.rb
CHANGED
@@ -23,7 +23,7 @@ module ChargeBee
|
|
23
23
|
|
24
24
|
def subscription()
|
25
25
|
subscription = get(:subscription, Subscription,
|
26
|
-
{:subscription_items => Subscription::SubscriptionItem, :item_tiers => Subscription::ItemTier, :charged_items => Subscription::ChargedItem, :addons => Subscription::Addon, :event_based_addons => Subscription::EventBasedAddon, :charged_event_based_addons => Subscription::ChargedEventBasedAddon, :coupons => Subscription::Coupon, :shipping_address => Subscription::ShippingAddress, :referral_info => Subscription::ReferralInfo, :contract_term => Subscription::ContractTerm, :discounts => Subscription::Discount});
|
26
|
+
{:subscription_items => Subscription::SubscriptionItem, :item_tiers => Subscription::ItemTier, :charged_items => Subscription::ChargedItem, :addons => Subscription::Addon, :event_based_addons => Subscription::EventBasedAddon, :charged_event_based_addons => Subscription::ChargedEventBasedAddon, :coupons => Subscription::Coupon, :shipping_address => Subscription::ShippingAddress, :referral_info => Subscription::ReferralInfo, :billing_override => Subscription::BillingOverride, :contract_term => Subscription::ContractTerm, :discounts => Subscription::Discount});
|
27
27
|
return subscription;
|
28
28
|
end
|
29
29
|
|
@@ -329,6 +329,11 @@ module ChargeBee
|
|
329
329
|
return differential_price;
|
330
330
|
end
|
331
331
|
|
332
|
+
def configuration()
|
333
|
+
configuration = get(:configuration, Configuration);
|
334
|
+
return configuration;
|
335
|
+
end
|
336
|
+
|
332
337
|
def feature()
|
333
338
|
feature = get(:feature, Feature,
|
334
339
|
{:levels => Feature::Level});
|
@@ -389,7 +394,7 @@ module ChargeBee
|
|
389
394
|
return non_subscription;
|
390
395
|
end
|
391
396
|
|
392
|
-
def entitlement_override()
|
397
|
+
def entitlement_override()
|
393
398
|
entitlement_override = get(:entitlement_override, EntitlementOverride);
|
394
399
|
return entitlement_override;
|
395
400
|
end
|
@@ -498,6 +503,12 @@ module ChargeBee
|
|
498
503
|
return downloads;
|
499
504
|
end
|
500
505
|
|
506
|
+
def configurations()
|
507
|
+
configurations = get_list(:configurations, Configuration,
|
508
|
+
{});
|
509
|
+
return configurations;
|
510
|
+
end
|
511
|
+
|
501
512
|
def in_app_subscriptions()
|
502
513
|
in_app_subscriptions = get_list(:in_app_subscriptions, InAppSubscription,
|
503
514
|
{});
|
@@ -510,7 +521,7 @@ module ChargeBee
|
|
510
521
|
end
|
511
522
|
|
512
523
|
def get_raw_response()
|
513
|
-
|
524
|
+
@response;
|
514
525
|
end
|
515
526
|
|
516
527
|
private
|
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/nativeRequest'
|
3
3
|
require File.dirname(__FILE__) + '/chargebee/util'
|
4
4
|
require File.dirname(__FILE__) + '/chargebee/request'
|
5
5
|
require File.dirname(__FILE__) + '/chargebee/result'
|
@@ -82,11 +82,12 @@ 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
|
+
require File.dirname(__FILE__) + '/chargebee/models/configuration'
|
85
86
|
|
86
87
|
|
87
88
|
module ChargeBee
|
88
89
|
|
89
|
-
VERSION = '2.
|
90
|
+
VERSION = '2.49.0'
|
90
91
|
|
91
92
|
@@default_env = nil
|
92
93
|
@@verify_ca_certs = true
|
data/spec/chargebee_spec.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'rest_client'
|
3
2
|
require 'sample_response'
|
4
3
|
|
5
4
|
describe "chargebee" do
|
6
5
|
|
7
6
|
before(:all) do
|
8
|
-
@request =
|
7
|
+
@request = ChargeBee::NativeRequest
|
9
8
|
end
|
10
9
|
|
11
10
|
it "serialize should convert the hash to acceptable format" do
|
@@ -55,7 +54,7 @@ describe "chargebee" do
|
|
55
54
|
end
|
56
55
|
|
57
56
|
it "should properly convert the response json into proper object" do
|
58
|
-
@request.expects(:
|
57
|
+
@request.expects(:request).once.returns([simple_subscription, headers])
|
59
58
|
result = ChargeBee::Subscription.retrieve("simple_subscription")
|
60
59
|
h = result.get_response_headers
|
61
60
|
expect(h).to eq(headers)
|
@@ -68,7 +67,7 @@ describe "chargebee" do
|
|
68
67
|
end
|
69
68
|
|
70
69
|
it "should properly convert the nested response json into proper object with sub types" do
|
71
|
-
@request.expects(:
|
70
|
+
@request.expects(:request).once.returns([nested_subscription, headers])
|
72
71
|
result = ChargeBee::Subscription.retrieve("nested_subscription")
|
73
72
|
s = result.subscription
|
74
73
|
expect(s.id).to eq("nested_subscription")
|
@@ -80,7 +79,7 @@ describe "chargebee" do
|
|
80
79
|
end
|
81
80
|
|
82
81
|
it "should properly convert the list response json into proper result object" do
|
83
|
-
@request.expects(:
|
82
|
+
@request.expects(:request).once.returns([list_subscriptions, headers])
|
84
83
|
result = ChargeBee::Subscription.list({:limit => 2})
|
85
84
|
expect(result.length).to eq(2)
|
86
85
|
result.each do |i|
|
@@ -89,7 +88,7 @@ describe "chargebee" do
|
|
89
88
|
end
|
90
89
|
|
91
90
|
it "should parse event api response and provide the content properly" do
|
92
|
-
@request.expects(:
|
91
|
+
@request.expects(:request).once.returns([sample_event, headers])
|
93
92
|
result = ChargeBee::Event.retrieve("sample_event")
|
94
93
|
event = result.event
|
95
94
|
s = event.content.subscription
|
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: 2.
|
4
|
+
version: 2.49.0
|
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: 2025-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_pure
|
@@ -25,26 +25,6 @@ dependencies:
|
|
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
|
48
28
|
- !ruby/object:Gem::Dependency
|
49
29
|
name: cgi
|
50
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,6 +104,7 @@ files:
|
|
124
104
|
- lib/chargebee/models/business_entity_transfer.rb
|
125
105
|
- lib/chargebee/models/card.rb
|
126
106
|
- lib/chargebee/models/comment.rb
|
107
|
+
- lib/chargebee/models/configuration.rb
|
127
108
|
- lib/chargebee/models/contact.rb
|
128
109
|
- lib/chargebee/models/contract_term.rb
|
129
110
|
- lib/chargebee/models/coupon.rb
|
@@ -197,6 +178,7 @@ files:
|
|
197
178
|
- lib/chargebee/models/unbilled_charge.rb
|
198
179
|
- lib/chargebee/models/usage.rb
|
199
180
|
- lib/chargebee/models/virtual_bank_account.rb
|
181
|
+
- lib/chargebee/nativeRequest.rb
|
200
182
|
- lib/chargebee/request.rb
|
201
183
|
- lib/chargebee/rest.rb
|
202
184
|
- lib/chargebee/result.rb
|