chargebee 2.11.1 → 2.13.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 +5 -5
- data/CHANGELOG.md +82 -0
- data/LICENSE +1 -1
- data/Rakefile +150 -150
- data/chargebee.gemspec +2 -2
- data/lib/chargebee/list_result.rb +28 -28
- data/lib/chargebee/models/credit_note.rb +11 -3
- data/lib/chargebee/models/customer.rb +9 -5
- data/lib/chargebee/models/download.rb +1 -1
- data/lib/chargebee/models/export.rb +1 -1
- data/lib/chargebee/models/invoice.rb +10 -1
- data/lib/chargebee/models/model.rb +2 -2
- data/lib/chargebee/models/payment_source.rb +9 -1
- data/lib/chargebee/models/tax_withheld.rb +2 -1
- data/lib/chargebee/rest.rb +7 -1
- data/lib/chargebee/result.rb +12 -6
- data/lib/chargebee/util.rb +69 -56
- data/lib/chargebee.rb +1 -1
- 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/errors_spec.rb +1 -1
- data/spec/spec_helper.rb +24 -24
- metadata +21 -20
data/lib/chargebee/result.rb
CHANGED
@@ -24,7 +24,7 @@ module ChargeBee
|
|
24
24
|
|
25
25
|
def customer()
|
26
26
|
customer = get(:customer, Customer,
|
27
|
-
{:billing_address => Customer::BillingAddress, :referral_urls => Customer::ReferralUrl, :contacts => Customer::Contact, :payment_method => Customer::PaymentMethod, :balances => Customer::Balance, :relationship => Customer::Relationship, :parent_account_access => Customer::ParentAccountAccess, :child_account_access => Customer::ChildAccountAccess});
|
27
|
+
{:billing_address => Customer::BillingAddress, :referral_urls => Customer::ReferralUrl, :contacts => Customer::Contact, :payment_method => Customer::PaymentMethod, :balances => Customer::Balance, :entity_identifiers => Customer::EntityIdentifier, :relationship => Customer::Relationship, :parent_account_access => Customer::ParentAccountAccess, :child_account_access => Customer::ChildAccountAccess});
|
28
28
|
return customer;
|
29
29
|
end
|
30
30
|
|
@@ -45,7 +45,7 @@ module ChargeBee
|
|
45
45
|
|
46
46
|
def payment_source()
|
47
47
|
payment_source = get(:payment_source, PaymentSource,
|
48
|
-
{:card => PaymentSource::Card, :bank_account => PaymentSource::BankAccount, :amazon_payment => PaymentSource::AmazonPayment, :paypal => PaymentSource::Paypal});
|
48
|
+
{:card => PaymentSource::Card, :bank_account => PaymentSource::BankAccount, :amazon_payment => PaymentSource::AmazonPayment, :upi => PaymentSource::Upi, :paypal => PaymentSource::Paypal, :mandates => PaymentSource::Mandate});
|
49
49
|
return payment_source;
|
50
50
|
end
|
51
51
|
|
@@ -71,7 +71,7 @@ module ChargeBee
|
|
71
71
|
|
72
72
|
def invoice()
|
73
73
|
invoice = get(:invoice, Invoice,
|
74
|
-
{:line_items => Invoice::LineItem, :discounts => Invoice::Discount, :line_item_discounts => Invoice::LineItemDiscount, :taxes => Invoice::Tax, :line_item_taxes => Invoice::LineItemTax, :line_item_tiers => Invoice::LineItemTier, :linked_payments => Invoice::LinkedPayment, :dunning_attempts => Invoice::DunningAttempt, :applied_credits => Invoice::AppliedCredit, :adjustment_credit_notes => Invoice::AdjustmentCreditNote, :issued_credit_notes => Invoice::IssuedCreditNote, :linked_orders => Invoice::LinkedOrder, :notes => Invoice::Note, :shipping_address => Invoice::ShippingAddress, :billing_address => Invoice::BillingAddress});
|
74
|
+
{:line_items => Invoice::LineItem, :discounts => Invoice::Discount, :line_item_discounts => Invoice::LineItemDiscount, :taxes => Invoice::Tax, :line_item_taxes => Invoice::LineItemTax, :line_item_tiers => Invoice::LineItemTier, :linked_payments => Invoice::LinkedPayment, :dunning_attempts => Invoice::DunningAttempt, :applied_credits => Invoice::AppliedCredit, :adjustment_credit_notes => Invoice::AdjustmentCreditNote, :issued_credit_notes => Invoice::IssuedCreditNote, :linked_orders => Invoice::LinkedOrder, :notes => Invoice::Note, :shipping_address => Invoice::ShippingAddress, :billing_address => Invoice::BillingAddress, :einvoice => Invoice::Einvoice});
|
75
75
|
return invoice;
|
76
76
|
end
|
77
77
|
|
@@ -82,7 +82,7 @@ module ChargeBee
|
|
82
82
|
|
83
83
|
def credit_note()
|
84
84
|
credit_note = get(:credit_note, CreditNote,
|
85
|
-
{:line_items => CreditNote::LineItem, :discounts => CreditNote::Discount, :line_item_discounts => CreditNote::LineItemDiscount, :line_item_tiers => CreditNote::LineItemTier, :taxes => CreditNote::Tax, :line_item_taxes => CreditNote::LineItemTax, :linked_refunds => CreditNote::LinkedRefund, :allocations => CreditNote::Allocation});
|
85
|
+
{:einvoice => CreditNote::Einvoice, :line_items => CreditNote::LineItem, :discounts => CreditNote::Discount, :line_item_discounts => CreditNote::LineItemDiscount, :line_item_tiers => CreditNote::LineItemTier, :taxes => CreditNote::Tax, :line_item_taxes => CreditNote::LineItemTax, :linked_refunds => CreditNote::LinkedRefund, :allocations => CreditNote::Allocation});
|
86
86
|
return credit_note;
|
87
87
|
end
|
88
88
|
|
@@ -281,7 +281,7 @@ module ChargeBee
|
|
281
281
|
|
282
282
|
def credit_notes()
|
283
283
|
credit_notes = get_list(:credit_notes, CreditNote,
|
284
|
-
{:line_items => CreditNote::LineItem, :discounts => CreditNote::Discount, :line_item_discounts => CreditNote::LineItemDiscount, :line_item_tiers => CreditNote::LineItemTier, :taxes => CreditNote::Tax, :line_item_taxes => CreditNote::LineItemTax, :linked_refunds => CreditNote::LinkedRefund, :allocations => CreditNote::Allocation});
|
284
|
+
{:einvoice => CreditNote::Einvoice, :line_items => CreditNote::LineItem, :discounts => CreditNote::Discount, :line_item_discounts => CreditNote::LineItemDiscount, :line_item_tiers => CreditNote::LineItemTier, :taxes => CreditNote::Tax, :line_item_taxes => CreditNote::LineItemTax, :linked_refunds => CreditNote::LinkedRefund, :allocations => CreditNote::Allocation});
|
285
285
|
return credit_notes;
|
286
286
|
end
|
287
287
|
|
@@ -297,9 +297,15 @@ module ChargeBee
|
|
297
297
|
return hierarchies;
|
298
298
|
end
|
299
299
|
|
300
|
+
def downloads()
|
301
|
+
downloads = get_list(:downloads, Download,
|
302
|
+
{});
|
303
|
+
return downloads;
|
304
|
+
end
|
305
|
+
|
300
306
|
def invoices()
|
301
307
|
invoices = get_list(:invoices, Invoice,
|
302
|
-
{:line_items => Invoice::LineItem, :discounts => Invoice::Discount, :line_item_discounts => Invoice::LineItemDiscount, :taxes => Invoice::Tax, :line_item_taxes => Invoice::LineItemTax, :line_item_tiers => Invoice::LineItemTier, :linked_payments => Invoice::LinkedPayment, :dunning_attempts => Invoice::DunningAttempt, :applied_credits => Invoice::AppliedCredit, :adjustment_credit_notes => Invoice::AdjustmentCreditNote, :issued_credit_notes => Invoice::IssuedCreditNote, :linked_orders => Invoice::LinkedOrder, :notes => Invoice::Note, :shipping_address => Invoice::ShippingAddress, :billing_address => Invoice::BillingAddress});
|
308
|
+
{:line_items => Invoice::LineItem, :discounts => Invoice::Discount, :line_item_discounts => Invoice::LineItemDiscount, :taxes => Invoice::Tax, :line_item_taxes => Invoice::LineItemTax, :line_item_tiers => Invoice::LineItemTier, :linked_payments => Invoice::LinkedPayment, :dunning_attempts => Invoice::DunningAttempt, :applied_credits => Invoice::AppliedCredit, :adjustment_credit_notes => Invoice::AdjustmentCreditNote, :issued_credit_notes => Invoice::IssuedCreditNote, :linked_orders => Invoice::LinkedOrder, :notes => Invoice::Note, :shipping_address => Invoice::ShippingAddress, :billing_address => Invoice::BillingAddress, :einvoice => Invoice::Einvoice});
|
303
309
|
return invoices;
|
304
310
|
end
|
305
311
|
|
data/lib/chargebee/util.rb
CHANGED
@@ -1,56 +1,69 @@
|
|
1
|
-
module ChargeBee
|
2
|
-
module Util
|
3
|
-
|
4
|
-
def self.serialize(value, prefix = nil, idx = nil)
|
5
|
-
serialized = {}
|
6
|
-
case value
|
7
|
-
when Hash
|
8
|
-
value.each do |k, v|
|
9
|
-
if(v.kind_of? Hash
|
10
|
-
serialized.merge!(serialize(v, k))
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
1
|
+
module ChargeBee
|
2
|
+
module Util
|
3
|
+
|
4
|
+
def self.serialize(value, prefix = nil, idx = nil)
|
5
|
+
serialized = {}
|
6
|
+
case value
|
7
|
+
when Hash
|
8
|
+
value.each do |k, v|
|
9
|
+
if(v.kind_of? Hash)
|
10
|
+
serialized.merge!(serialize(v, k))
|
11
|
+
elsif(v.kind_of? Array)
|
12
|
+
arrayContainsValue = false
|
13
|
+
v.each_with_index do |v1, i1|
|
14
|
+
if(v1.kind_of? Hash)
|
15
|
+
serialized.merge!(serialize(v1, k, i1))
|
16
|
+
else
|
17
|
+
arrayContainsValue = true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
if(arrayContainsValue == true)
|
21
|
+
key = "#{(prefix!=nil) ? prefix:''}#{(prefix!=nil) ? '['+k.to_s+']' : k}#{(idx != nil) ? '['+idx.to_s+']':''}"
|
22
|
+
serialized.merge!({key => as_str(v)})
|
23
|
+
end
|
24
|
+
else
|
25
|
+
key = "#{(prefix!=nil) ? prefix:''}#{(prefix!=nil) ? '['+k.to_s+']' : k}#{(idx != nil) ? '['+idx.to_s+']':''}"
|
26
|
+
serialized.merge!({key => as_str(v)})
|
27
|
+
end
|
28
|
+
end
|
29
|
+
when Array
|
30
|
+
value.each_with_index do |v, i|
|
31
|
+
serialized.merge!(serialize(v, prefix, i))
|
32
|
+
end
|
33
|
+
else
|
34
|
+
if(idx != nil and prefix != nil)
|
35
|
+
key = "#{prefix}[#{idx.to_s}]"
|
36
|
+
serialized.merge!({key => as_str(value)})
|
37
|
+
else
|
38
|
+
raise ArgumentError.new("only hash or arrays are allowed as value")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
serialized
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.symbolize_keys(object)
|
45
|
+
case object
|
46
|
+
when Hash
|
47
|
+
new = {}
|
48
|
+
object.each do |key, value|
|
49
|
+
key = (key.to_sym rescue key) || key
|
50
|
+
new[key] = symbolize_keys(value)
|
51
|
+
end
|
52
|
+
new
|
53
|
+
when Array
|
54
|
+
object.map { |value| symbolize_keys(value) }
|
55
|
+
else
|
56
|
+
object
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.as_str(value)
|
61
|
+
if(value == nil)
|
62
|
+
return ''
|
63
|
+
else
|
64
|
+
return value.to_s
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|