chargebee 1.7.4 → 2.6.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1107 -94
- data/LICENSE +1 -1
- data/README.rdoc +22 -15
- data/chargebee.gemspec +27 -7
- data/lib/.DS_Store +0 -0
- data/lib/chargebee.rb +28 -2
- data/lib/chargebee/environment.rb +11 -6
- data/lib/chargebee/errors.rb +1 -1
- data/lib/chargebee/models/addon.rb +18 -3
- data/lib/chargebee/models/address.rb +1 -1
- data/lib/chargebee/models/card.rb +8 -7
- data/lib/chargebee/models/comment.rb +1 -1
- data/lib/chargebee/models/contact.rb +11 -0
- data/lib/chargebee/models/coupon.rb +20 -4
- data/lib/chargebee/models/coupon_code.rb +9 -1
- data/lib/chargebee/models/coupon_set.rb +38 -0
- data/lib/chargebee/models/credit_note.rb +78 -0
- data/lib/chargebee/models/credit_note_estimate.rb +36 -0
- data/lib/chargebee/models/customer.rb +73 -12
- data/lib/chargebee/models/estimate.rb +26 -15
- data/lib/chargebee/models/event.rb +1 -1
- data/lib/chargebee/models/export.rb +87 -0
- data/lib/chargebee/models/gift.rb +43 -0
- data/lib/chargebee/models/hierarchy.rb +10 -0
- data/lib/chargebee/models/hosted_page.rb +33 -5
- data/lib/chargebee/models/invoice.rb +82 -19
- data/lib/chargebee/models/invoice_estimate.rb +36 -0
- data/lib/chargebee/models/model.rb +34 -3
- data/lib/chargebee/models/order.rb +49 -3
- data/lib/chargebee/models/payment_source.rb +84 -0
- data/lib/chargebee/models/plan.rb +33 -5
- data/lib/chargebee/models/promotional_credit.rb +31 -0
- data/lib/chargebee/models/quote.rb +77 -0
- data/lib/chargebee/models/resource_migration.rb +14 -0
- data/lib/chargebee/models/site_migration_detail.rb +15 -0
- data/lib/chargebee/models/subscription.rb +60 -8
- data/lib/chargebee/models/subscription_estimate.rb +14 -0
- data/lib/chargebee/models/third_party_payment_method.rb +10 -0
- data/lib/chargebee/models/time_machine.rb +47 -0
- data/lib/chargebee/models/token.rb +11 -0
- data/lib/chargebee/models/transaction.rb +29 -10
- data/lib/chargebee/models/unbilled_charge.rb +32 -0
- data/lib/chargebee/models/virtual_bank_account.rb +32 -0
- data/lib/chargebee/request.rb +11 -0
- data/lib/chargebee/rest.rb +6 -4
- data/lib/chargebee/result.rb +183 -27
- data/spec/errors_spec.rb +23 -0
- data/spec/sample_response.rb +1 -1
- metadata +39 -11
- data/lib/chargebee/models/payment_intent.rb +0 -27
@@ -0,0 +1,32 @@
|
|
1
|
+
module ChargeBee
|
2
|
+
class UnbilledCharge < Model
|
3
|
+
|
4
|
+
class Tier < Model
|
5
|
+
attr_accessor :starting_unit, :ending_unit, :quantity_used, :unit_amount
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_accessor :id, :customer_id, :subscription_id, :date_from, :date_to, :unit_amount, :pricing_model,
|
9
|
+
:quantity, :amount, :currency_code, :discount_amount, :description, :entity_type, :entity_id,
|
10
|
+
:is_voided, :voided_at, :tiers, :deleted
|
11
|
+
|
12
|
+
# OPERATIONS
|
13
|
+
#-----------
|
14
|
+
|
15
|
+
def self.invoice_unbilled_charges(params={}, env=nil, headers={})
|
16
|
+
Request.send('post', uri_path("unbilled_charges","invoice_unbilled_charges"), params, env, headers)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.delete(id, env=nil, headers={})
|
20
|
+
Request.send('post', uri_path("unbilled_charges",id.to_s,"delete"), {}, env, headers)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.list(params={}, env=nil, headers={})
|
24
|
+
Request.send_list_request('get', uri_path("unbilled_charges"), params, env, headers)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.invoice_now_estimate(params={}, env=nil, headers={})
|
28
|
+
Request.send('post', uri_path("unbilled_charges","invoice_now_estimate"), params, env, headers)
|
29
|
+
end
|
30
|
+
|
31
|
+
end # ~UnbilledCharge
|
32
|
+
end # ~ChargeBee
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module ChargeBee
|
2
|
+
class VirtualBankAccount < Model
|
3
|
+
|
4
|
+
attr_accessor :id, :customer_id, :email, :scheme, :bank_name, :account_number, :routing_number,
|
5
|
+
:swift_code, :gateway, :gateway_account_id, :resource_version, :updated_at, :created_at, :reference_id,
|
6
|
+
:deleted
|
7
|
+
|
8
|
+
# OPERATIONS
|
9
|
+
#-----------
|
10
|
+
|
11
|
+
def self.create_using_permanent_token(params, env=nil, headers={})
|
12
|
+
Request.send('post', uri_path("virtual_bank_accounts","create_using_permanent_token"), params, env, headers)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.create(params, env=nil, headers={})
|
16
|
+
Request.send('post', uri_path("virtual_bank_accounts"), params, env, headers)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.retrieve(id, env=nil, headers={})
|
20
|
+
Request.send('get', uri_path("virtual_bank_accounts",id.to_s), {}, env, headers)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.list(params={}, env=nil, headers={})
|
24
|
+
Request.send_list_request('get', uri_path("virtual_bank_accounts"), params, env, headers)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.delete_local(id, env=nil, headers={})
|
28
|
+
Request.send('post', uri_path("virtual_bank_accounts",id.to_s,"delete_local"), {}, env, headers)
|
29
|
+
end
|
30
|
+
|
31
|
+
end # ~VirtualBankAccount
|
32
|
+
end # ~ChargeBee
|
data/lib/chargebee/request.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
module ChargeBee
|
2
2
|
class Request
|
3
3
|
|
4
|
+
def self.send_list_request(method, url, params={}, env=nil, headers={})
|
5
|
+
serialized = {}
|
6
|
+
params.each do |k, v|
|
7
|
+
if(v.kind_of? Array)
|
8
|
+
v = v.to_json
|
9
|
+
end
|
10
|
+
serialized["#{k}"] = v
|
11
|
+
end
|
12
|
+
self.send(method, url, serialized, env, headers)
|
13
|
+
end
|
14
|
+
|
4
15
|
def self.send(method, url, params={}, env=nil, headers={})
|
5
16
|
env ||= ChargeBee.default_env
|
6
17
|
ser_params = Util.serialize(params)
|
data/lib/chargebee/rest.rb
CHANGED
@@ -4,7 +4,7 @@ require 'json'
|
|
4
4
|
module ChargeBee
|
5
5
|
module Rest
|
6
6
|
|
7
|
-
def self.request(method, url, env, params=nil, headers)
|
7
|
+
def self.request(method, url, env, params=nil, headers={})
|
8
8
|
raise Error.new('No environment configured.') unless env
|
9
9
|
api_key = env.api_key
|
10
10
|
|
@@ -25,11 +25,13 @@ module ChargeBee
|
|
25
25
|
else
|
26
26
|
payload = params
|
27
27
|
end
|
28
|
-
|
29
|
-
user_agent =
|
28
|
+
|
29
|
+
user_agent = ChargeBee.user_agent
|
30
30
|
headers = {
|
31
31
|
"User-Agent" => user_agent,
|
32
|
-
:accept => :json
|
32
|
+
:accept => :json,
|
33
|
+
"Lang-Version" => RUBY_VERSION,
|
34
|
+
"OS-Version" => RUBY_PLATFORM
|
33
35
|
}.merge(headers)
|
34
36
|
opts = {
|
35
37
|
:method => method,
|
data/lib/chargebee/result.rb
CHANGED
@@ -6,90 +6,246 @@ module ChargeBee
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def subscription()
|
9
|
-
get(:subscription, Subscription,
|
10
|
-
{:addons => Subscription::Addon, :coupons => Subscription::Coupon, :shipping_address => Subscription::ShippingAddress});
|
9
|
+
subscription = get(:subscription, Subscription,
|
10
|
+
{: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});
|
11
|
+
return subscription;
|
11
12
|
end
|
12
13
|
|
13
14
|
def customer()
|
14
|
-
get(:customer, Customer,
|
15
|
-
{:billing_address => Customer::BillingAddress, :contacts => Customer::Contact, :payment_method => Customer::PaymentMethod});
|
15
|
+
customer = get(:customer, Customer,
|
16
|
+
{:billing_address => Customer::BillingAddress, :referral_urls => Customer::ReferralUrl, :contacts => Customer::Contact, :payment_method => Customer::PaymentMethod, :balances => Customer::Balance, :relationship => Customer::Relationship});
|
17
|
+
return customer;
|
18
|
+
end
|
19
|
+
|
20
|
+
def hierarchy()
|
21
|
+
hierarchy = get(:hierarchy, Hierarchy);
|
22
|
+
return hierarchy;
|
23
|
+
end
|
24
|
+
|
25
|
+
def contact()
|
26
|
+
contact = get(:contact, Contact);
|
27
|
+
return contact;
|
28
|
+
end
|
29
|
+
|
30
|
+
def token()
|
31
|
+
token = get(:token, Token);
|
32
|
+
return token;
|
33
|
+
end
|
34
|
+
|
35
|
+
def payment_source()
|
36
|
+
payment_source = get(:payment_source, PaymentSource,
|
37
|
+
{:card => PaymentSource::Card, :bank_account => PaymentSource::BankAccount, :amazon_payment => PaymentSource::AmazonPayment, :paypal => PaymentSource::Paypal});
|
38
|
+
return payment_source;
|
39
|
+
end
|
40
|
+
|
41
|
+
def third_party_payment_method()
|
42
|
+
third_party_payment_method = get(:third_party_payment_method, ThirdPartyPaymentMethod);
|
43
|
+
return third_party_payment_method;
|
44
|
+
end
|
45
|
+
|
46
|
+
def virtual_bank_account()
|
47
|
+
virtual_bank_account = get(:virtual_bank_account, VirtualBankAccount);
|
48
|
+
return virtual_bank_account;
|
16
49
|
end
|
17
50
|
|
18
51
|
def card()
|
19
|
-
get(:card, Card);
|
52
|
+
card = get(:card, Card);
|
53
|
+
return card;
|
54
|
+
end
|
55
|
+
|
56
|
+
def promotional_credit()
|
57
|
+
promotional_credit = get(:promotional_credit, PromotionalCredit);
|
58
|
+
return promotional_credit;
|
20
59
|
end
|
21
60
|
|
22
61
|
def invoice()
|
23
|
-
get(:invoice, Invoice,
|
24
|
-
{:line_items => Invoice::LineItem, :discounts => Invoice::Discount, :taxes => Invoice::Tax, :
|
62
|
+
invoice = get(:invoice, Invoice,
|
63
|
+
{: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});
|
64
|
+
return invoice;
|
65
|
+
end
|
66
|
+
|
67
|
+
def credit_note()
|
68
|
+
credit_note = get(:credit_note, CreditNote,
|
69
|
+
{: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});
|
70
|
+
return credit_note;
|
71
|
+
end
|
72
|
+
|
73
|
+
def unbilled_charge()
|
74
|
+
unbilled_charge = get(:unbilled_charge, UnbilledCharge,
|
75
|
+
{:tiers => UnbilledCharge::Tier});
|
76
|
+
return unbilled_charge;
|
25
77
|
end
|
26
78
|
|
27
79
|
def order()
|
28
|
-
get(:order, Order
|
80
|
+
order = get(:order, Order,
|
81
|
+
{:order_line_items => Order::OrderLineItem, :shipping_address => Order::ShippingAddress, :billing_address => Order::BillingAddress, :line_item_taxes => Order::LineItemTax, :line_item_discounts => Order::LineItemDiscount, :linked_credit_notes => Order::LinkedCreditNote});
|
82
|
+
return order;
|
83
|
+
end
|
84
|
+
|
85
|
+
def gift()
|
86
|
+
gift = get(:gift, Gift,
|
87
|
+
{:gifter => Gift::Gifter, :gift_receiver => Gift::GiftReceiver, :gift_timelines => Gift::GiftTimeline});
|
88
|
+
return gift;
|
29
89
|
end
|
30
90
|
|
31
91
|
def transaction()
|
32
|
-
get(:transaction, Transaction,
|
33
|
-
{:linked_invoices => Transaction::LinkedInvoice, :linked_refunds => Transaction::LinkedRefund});
|
92
|
+
transaction = get(:transaction, Transaction,
|
93
|
+
{:linked_invoices => Transaction::LinkedInvoice, :linked_credit_notes => Transaction::LinkedCreditNote, :linked_refunds => Transaction::LinkedRefund, :linked_payments => Transaction::LinkedPayment});
|
94
|
+
return transaction;
|
34
95
|
end
|
35
96
|
|
36
97
|
def hosted_page()
|
37
|
-
get(:hosted_page, HostedPage);
|
98
|
+
hosted_page = get(:hosted_page, HostedPage);
|
99
|
+
return hosted_page;
|
38
100
|
end
|
39
101
|
|
40
102
|
def estimate()
|
41
|
-
get(:estimate, Estimate,
|
42
|
-
{:
|
103
|
+
estimate = get(:estimate, Estimate, {},
|
104
|
+
{:subscription_estimate => SubscriptionEstimate, :invoice_estimate => InvoiceEstimate, :invoice_estimates => InvoiceEstimate, :next_invoice_estimate => InvoiceEstimate, :credit_note_estimates => CreditNoteEstimate, :unbilled_charge_estimates => UnbilledCharge});
|
105
|
+
estimate.init_dependant(@response[:estimate], :subscription_estimate,
|
106
|
+
{:shipping_address => SubscriptionEstimate::ShippingAddress});
|
107
|
+
estimate.init_dependant(@response[:estimate], :invoice_estimate,
|
108
|
+
{:line_items => InvoiceEstimate::LineItem, :discounts => InvoiceEstimate::Discount, :taxes => InvoiceEstimate::Tax, :line_item_taxes => InvoiceEstimate::LineItemTax, :line_item_tiers => InvoiceEstimate::LineItemTier, :line_item_discounts => InvoiceEstimate::LineItemDiscount});
|
109
|
+
estimate.init_dependant(@response[:estimate], :next_invoice_estimate,
|
110
|
+
{:line_items => InvoiceEstimate::LineItem, :discounts => InvoiceEstimate::Discount, :taxes => InvoiceEstimate::Tax, :line_item_taxes => InvoiceEstimate::LineItemTax, :line_item_tiers => InvoiceEstimate::LineItemTier, :line_item_discounts => InvoiceEstimate::LineItemDiscount});
|
111
|
+
estimate.init_dependant_list(@response[:estimate], :invoice_estimates,
|
112
|
+
{:line_items => InvoiceEstimate::LineItem, :discounts => InvoiceEstimate::Discount, :taxes => InvoiceEstimate::Tax, :line_item_taxes => InvoiceEstimate::LineItemTax, :line_item_tiers => InvoiceEstimate::LineItemTier, :line_item_discounts => InvoiceEstimate::LineItemDiscount});
|
113
|
+
estimate.init_dependant_list(@response[:estimate], :credit_note_estimates,
|
114
|
+
{:line_items => CreditNoteEstimate::LineItem, :discounts => CreditNoteEstimate::Discount, :taxes => CreditNoteEstimate::Tax, :line_item_taxes => CreditNoteEstimate::LineItemTax, :line_item_discounts => CreditNoteEstimate::LineItemDiscount, :line_item_tiers => CreditNoteEstimate::LineItemTier});
|
115
|
+
estimate.init_dependant_list(@response[:estimate], :unbilled_charge_estimates,
|
116
|
+
{:tiers => UnbilledCharge::Tier});
|
117
|
+
return estimate;
|
118
|
+
end
|
119
|
+
|
120
|
+
def quote()
|
121
|
+
quote = get(:quote, Quote,
|
122
|
+
{:line_items => Quote::LineItem, :discounts => Quote::Discount, :line_item_discounts => Quote::LineItemDiscount, :taxes => Quote::Tax, :line_item_taxes => Quote::LineItemTax, :shipping_address => Quote::ShippingAddress, :billing_address => Quote::BillingAddress});
|
123
|
+
return quote;
|
43
124
|
end
|
44
125
|
|
45
126
|
def plan()
|
46
|
-
get(:plan, Plan
|
127
|
+
plan = get(:plan, Plan,
|
128
|
+
{:tiers => Plan::Tier, :applicable_addons => Plan::ApplicableAddon, :attached_addons => Plan::AttachedAddon, :event_based_addons => Plan::EventBasedAddon});
|
129
|
+
return plan;
|
47
130
|
end
|
48
131
|
|
49
132
|
def addon()
|
50
|
-
get(:addon, Addon
|
133
|
+
addon = get(:addon, Addon,
|
134
|
+
{:tiers => Addon::Tier});
|
135
|
+
return addon;
|
51
136
|
end
|
52
137
|
|
53
138
|
def coupon()
|
54
|
-
get(:coupon, Coupon);
|
139
|
+
coupon = get(:coupon, Coupon);
|
140
|
+
return coupon;
|
141
|
+
end
|
142
|
+
|
143
|
+
def coupon_set()
|
144
|
+
coupon_set = get(:coupon_set, CouponSet);
|
145
|
+
return coupon_set;
|
55
146
|
end
|
56
147
|
|
57
148
|
def coupon_code()
|
58
|
-
get(:coupon_code, CouponCode);
|
149
|
+
coupon_code = get(:coupon_code, CouponCode);
|
150
|
+
return coupon_code;
|
59
151
|
end
|
60
152
|
|
61
153
|
def address()
|
62
|
-
get(:address, Address);
|
154
|
+
address = get(:address, Address);
|
155
|
+
return address;
|
63
156
|
end
|
64
157
|
|
65
158
|
def event()
|
66
|
-
get(:event, Event,
|
159
|
+
event = get(:event, Event,
|
67
160
|
{:webhooks => Event::Webhook});
|
161
|
+
return event;
|
68
162
|
end
|
69
163
|
|
70
164
|
def comment()
|
71
|
-
get(:comment, Comment);
|
165
|
+
comment = get(:comment, Comment);
|
166
|
+
return comment;
|
72
167
|
end
|
73
168
|
|
74
169
|
def download()
|
75
|
-
get(:download, Download);
|
170
|
+
download = get(:download, Download);
|
171
|
+
return download;
|
76
172
|
end
|
77
173
|
|
78
174
|
def portal_session()
|
79
|
-
get(:portal_session, PortalSession,
|
175
|
+
portal_session = get(:portal_session, PortalSession,
|
80
176
|
{:linked_customers => PortalSession::LinkedCustomer});
|
177
|
+
return portal_session;
|
178
|
+
end
|
179
|
+
|
180
|
+
def site_migration_detail()
|
181
|
+
site_migration_detail = get(:site_migration_detail, SiteMigrationDetail);
|
182
|
+
return site_migration_detail;
|
81
183
|
end
|
82
184
|
|
83
|
-
def
|
84
|
-
get(:
|
85
|
-
|
185
|
+
def resource_migration()
|
186
|
+
resource_migration = get(:resource_migration, ResourceMigration);
|
187
|
+
return resource_migration;
|
86
188
|
end
|
87
189
|
|
190
|
+
def time_machine()
|
191
|
+
time_machine = get(:time_machine, TimeMachine);
|
192
|
+
return time_machine;
|
193
|
+
end
|
194
|
+
|
195
|
+
def export()
|
196
|
+
export = get(:export, Export,
|
197
|
+
{:download => Export::Download});
|
198
|
+
return export;
|
199
|
+
end
|
200
|
+
|
201
|
+
|
202
|
+
def unbilled_charges()
|
203
|
+
unbilled_charges = get_list(:unbilled_charges, UnbilledCharge,
|
204
|
+
{:tiers => UnbilledCharge::Tier});
|
205
|
+
return unbilled_charges;
|
206
|
+
end
|
207
|
+
|
208
|
+
def credit_notes()
|
209
|
+
credit_notes = get_list(:credit_notes, CreditNote,
|
210
|
+
{: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});
|
211
|
+
return credit_notes;
|
212
|
+
end
|
213
|
+
|
214
|
+
def hierarchies()
|
215
|
+
hierarchies = get_list(:hierarchies, Hierarchy,
|
216
|
+
{});
|
217
|
+
return hierarchies;
|
218
|
+
end
|
219
|
+
|
220
|
+
def invoices()
|
221
|
+
invoices = get_list(:invoices, Invoice,
|
222
|
+
{: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});
|
223
|
+
return invoices;
|
224
|
+
end
|
225
|
+
|
88
226
|
|
227
|
+
private
|
228
|
+
def get_list(type, klass, sub_types = {}, dependant_types = {}, dependant_sub_types = {})
|
229
|
+
if(@response[type] == nil)
|
230
|
+
return nil
|
231
|
+
end
|
232
|
+
set_val = Array.new
|
233
|
+
@response[type].each do |obj|
|
234
|
+
case obj
|
235
|
+
when Hash
|
236
|
+
model = klass.construct(obj, sub_types, dependant_types)
|
237
|
+
dependant_sub_types.each do |k,v|
|
238
|
+
model.init_dependant(obj, k, v);
|
239
|
+
end
|
240
|
+
set_val.push(model)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
return instance_variable_set("@#{type}", set_val)
|
244
|
+
end
|
89
245
|
|
90
246
|
private
|
91
|
-
def get(type, klass, sub_types = {})
|
92
|
-
klass.construct(@response[type], sub_types)
|
247
|
+
def get(type, klass, sub_types = {}, dependant_types = {})
|
248
|
+
return klass.construct(@response[type], sub_types, dependant_types)
|
93
249
|
end
|
94
250
|
|
95
251
|
def to_s(*args)
|
data/spec/errors_spec.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'ChargeBee::InvalidRequestError' do
|
4
|
+
let(:invalid_request_json) do
|
5
|
+
{
|
6
|
+
message: 'id: The value chargebee_account is already present.',
|
7
|
+
type: 'invalid_request',
|
8
|
+
api_error_code: 'duplicate_entry',
|
9
|
+
param: 'id',
|
10
|
+
error_code: 'param_not_unique',
|
11
|
+
error_msg: 'The value chargebee_account is already present.',
|
12
|
+
error_param: 'id',
|
13
|
+
http_status_code: 400
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
it "provide message from error api response" do
|
18
|
+
error = ChargeBee::InvalidRequestError.new(400, invalid_request_json)
|
19
|
+
error.message.should eq 'id: The value chargebee_account is already present.'
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
data/spec/sample_response.rb
CHANGED
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:
|
4
|
+
version: 2.6.7
|
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: 2019-
|
12
|
+
date: 2019-07-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json_pure
|
@@ -17,28 +17,34 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1
|
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
|
-
version: '1
|
27
|
+
version: '2.1'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rest-client
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '1.
|
34
|
+
version: '1.8'
|
35
|
+
- - <
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.0'
|
35
38
|
type: :runtime
|
36
39
|
prerelease: false
|
37
40
|
version_requirements: !ruby/object:Gem::Requirement
|
38
41
|
requirements:
|
39
|
-
- -
|
42
|
+
- - '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '1.8'
|
45
|
+
- - <
|
40
46
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
47
|
+
version: '3.0'
|
42
48
|
- !ruby/object:Gem::Dependency
|
43
49
|
name: rspec
|
44
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,6 +88,7 @@ files:
|
|
82
88
|
- README.rdoc
|
83
89
|
- Rakefile
|
84
90
|
- chargebee.gemspec
|
91
|
+
- lib/.DS_Store
|
85
92
|
- lib/chargebee.rb
|
86
93
|
- lib/chargebee/environment.rb
|
87
94
|
- lib/chargebee/errors.rb
|
@@ -90,21 +97,39 @@ files:
|
|
90
97
|
- lib/chargebee/models/address.rb
|
91
98
|
- lib/chargebee/models/card.rb
|
92
99
|
- lib/chargebee/models/comment.rb
|
100
|
+
- lib/chargebee/models/contact.rb
|
93
101
|
- lib/chargebee/models/coupon.rb
|
94
102
|
- lib/chargebee/models/coupon_code.rb
|
103
|
+
- lib/chargebee/models/coupon_set.rb
|
104
|
+
- lib/chargebee/models/credit_note.rb
|
105
|
+
- lib/chargebee/models/credit_note_estimate.rb
|
95
106
|
- lib/chargebee/models/customer.rb
|
96
107
|
- lib/chargebee/models/download.rb
|
97
108
|
- lib/chargebee/models/estimate.rb
|
98
109
|
- lib/chargebee/models/event.rb
|
110
|
+
- lib/chargebee/models/export.rb
|
111
|
+
- lib/chargebee/models/gift.rb
|
112
|
+
- lib/chargebee/models/hierarchy.rb
|
99
113
|
- lib/chargebee/models/hosted_page.rb
|
100
114
|
- lib/chargebee/models/invoice.rb
|
115
|
+
- lib/chargebee/models/invoice_estimate.rb
|
101
116
|
- lib/chargebee/models/model.rb
|
102
117
|
- lib/chargebee/models/order.rb
|
103
|
-
- lib/chargebee/models/
|
118
|
+
- lib/chargebee/models/payment_source.rb
|
104
119
|
- lib/chargebee/models/plan.rb
|
105
120
|
- lib/chargebee/models/portal_session.rb
|
121
|
+
- lib/chargebee/models/promotional_credit.rb
|
122
|
+
- lib/chargebee/models/quote.rb
|
123
|
+
- lib/chargebee/models/resource_migration.rb
|
124
|
+
- lib/chargebee/models/site_migration_detail.rb
|
106
125
|
- lib/chargebee/models/subscription.rb
|
126
|
+
- lib/chargebee/models/subscription_estimate.rb
|
127
|
+
- lib/chargebee/models/third_party_payment_method.rb
|
128
|
+
- lib/chargebee/models/time_machine.rb
|
129
|
+
- lib/chargebee/models/token.rb
|
107
130
|
- lib/chargebee/models/transaction.rb
|
131
|
+
- lib/chargebee/models/unbilled_charge.rb
|
132
|
+
- lib/chargebee/models/virtual_bank_account.rb
|
108
133
|
- lib/chargebee/request.rb
|
109
134
|
- lib/chargebee/rest.rb
|
110
135
|
- lib/chargebee/result.rb
|
@@ -112,10 +137,12 @@ files:
|
|
112
137
|
- lib/ssl/ca-certs.crt
|
113
138
|
- spec/chargebee/list_result_spec.rb
|
114
139
|
- spec/chargebee_spec.rb
|
140
|
+
- spec/errors_spec.rb
|
115
141
|
- spec/sample_response.rb
|
116
142
|
- spec/spec_helper.rb
|
117
143
|
homepage: https://apidocs.chargebee.com/api/docs?lang=ruby
|
118
|
-
licenses:
|
144
|
+
licenses:
|
145
|
+
- MIT
|
119
146
|
metadata: {}
|
120
147
|
post_install_message:
|
121
148
|
rdoc_options:
|
@@ -126,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
153
|
requirements:
|
127
154
|
- - '>='
|
128
155
|
- !ruby/object:Gem::Version
|
129
|
-
version:
|
156
|
+
version: 1.9.3
|
130
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
158
|
requirements:
|
132
159
|
- - '>='
|
@@ -141,5 +168,6 @@ summary: Ruby client for Chargebee API.
|
|
141
168
|
test_files:
|
142
169
|
- spec/chargebee/list_result_spec.rb
|
143
170
|
- spec/chargebee_spec.rb
|
171
|
+
- spec/errors_spec.rb
|
144
172
|
- spec/sample_response.rb
|
145
173
|
- spec/spec_helper.rb
|