chargebee 1.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +528 -0
  3. data/LICENSE +24 -0
  4. data/README.rdoc +34 -0
  5. data/Rakefile +150 -0
  6. data/chargebee.gemspec +72 -0
  7. data/lib/chargebee.rb +59 -0
  8. data/lib/chargebee/environment.rb +23 -0
  9. data/lib/chargebee/errors.rb +43 -0
  10. data/lib/chargebee/list_result.rb +28 -0
  11. data/lib/chargebee/models/addon.rb +31 -0
  12. data/lib/chargebee/models/address.rb +19 -0
  13. data/lib/chargebee/models/card.rb +32 -0
  14. data/lib/chargebee/models/comment.rb +26 -0
  15. data/lib/chargebee/models/coupon.rb +25 -0
  16. data/lib/chargebee/models/coupon_code.rb +18 -0
  17. data/lib/chargebee/models/customer.rb +77 -0
  18. data/lib/chargebee/models/download.rb +10 -0
  19. data/lib/chargebee/models/estimate.rb +36 -0
  20. data/lib/chargebee/models/event.rb +46 -0
  21. data/lib/chargebee/models/hosted_page.rb +50 -0
  22. data/lib/chargebee/models/invoice.rb +114 -0
  23. data/lib/chargebee/models/model.rb +70 -0
  24. data/lib/chargebee/models/order.rb +31 -0
  25. data/lib/chargebee/models/payment_intent.rb +27 -0
  26. data/lib/chargebee/models/plan.rb +33 -0
  27. data/lib/chargebee/models/portal_session.rb +31 -0
  28. data/lib/chargebee/models/subscription.rb +86 -0
  29. data/lib/chargebee/models/transaction.rb +45 -0
  30. data/lib/chargebee/request.rb +16 -0
  31. data/lib/chargebee/rest.rb +90 -0
  32. data/lib/chargebee/result.rb +100 -0
  33. data/lib/chargebee/util.rb +56 -0
  34. data/lib/ssl/ca-certs.crt +3385 -0
  35. data/spec/chargebee/list_result_spec.rb +53 -0
  36. data/spec/chargebee_spec.rb +99 -0
  37. data/spec/sample_response.rb +73 -0
  38. data/spec/spec_helper.rb +24 -0
  39. metadata +145 -0
@@ -0,0 +1,19 @@
1
+ module ChargeBee
2
+ class Address < Model
3
+
4
+ attr_accessor :label, :first_name, :last_name, :email, :company, :phone, :addr, :extended_addr,
5
+ :extended_addr2, :city, :state_code, :state, :country, :zip, :subscription_id
6
+
7
+ # OPERATIONS
8
+ #-----------
9
+
10
+ def self.retrieve(params, env=nil, headers={})
11
+ Request.send('get', uri_path("addresses"), params, env, headers)
12
+ end
13
+
14
+ def self.update(params, env=nil, headers={})
15
+ Request.send('post', uri_path("addresses"), params, env, headers)
16
+ end
17
+
18
+ end # ~Address
19
+ end # ~ChargeBee
@@ -0,0 +1,32 @@
1
+ module ChargeBee
2
+ class Card < Model
3
+
4
+ attr_accessor :status, :gateway, :reference_id, :first_name, :last_name, :iin, :last4, :card_type,
5
+ :expiry_month, :expiry_year, :billing_addr1, :billing_addr2, :billing_city, :billing_state_code,
6
+ :billing_state, :billing_country, :billing_zip, :ip_address, :customer_id, :masked_number
7
+
8
+ # OPERATIONS
9
+ #-----------
10
+
11
+ def self.retrieve(id, env=nil, headers={})
12
+ Request.send('get', uri_path("cards",id.to_s), {}, env, headers)
13
+ end
14
+
15
+ def self.update_card_for_customer(id, params, env=nil, headers={})
16
+ Request.send('post', uri_path("customers",id.to_s,"credit_card"), params, env, headers)
17
+ end
18
+
19
+ def self.update_card_for_customer_using_payment_intent(id, params={}, env=nil, headers={})
20
+ Request.send('post', uri_path("customers",id.to_s,"credit_card_using_payment_intent"), params, env, headers)
21
+ end
22
+
23
+ def self.switch_gateway_for_customer(id, params, env=nil, headers={})
24
+ Request.send('post', uri_path("customers",id.to_s,"switch_gateway"), params, env, headers)
25
+ end
26
+
27
+ def self.delete_card_for_customer(id, env=nil, headers={})
28
+ Request.send('post', uri_path("customers",id.to_s,"delete_card"), {}, env, headers)
29
+ end
30
+
31
+ end # ~Card
32
+ end # ~ChargeBee
@@ -0,0 +1,26 @@
1
+ module ChargeBee
2
+ class Comment < Model
3
+
4
+ attr_accessor :id, :entity_type, :added_by, :notes, :created_at, :type, :entity_id
5
+
6
+ # OPERATIONS
7
+ #-----------
8
+
9
+ def self.create(params, env=nil, headers={})
10
+ Request.send('post', uri_path("comments"), params, env, headers)
11
+ end
12
+
13
+ def self.retrieve(id, env=nil, headers={})
14
+ Request.send('get', uri_path("comments",id.to_s), {}, env, headers)
15
+ end
16
+
17
+ def self.list(params={}, env=nil, headers={})
18
+ Request.send('get', uri_path("comments"), params, env, headers)
19
+ end
20
+
21
+ def self.delete(id, env=nil, headers={})
22
+ Request.send('post', uri_path("comments",id.to_s,"delete"), {}, env, headers)
23
+ end
24
+
25
+ end # ~Comment
26
+ end # ~ChargeBee
@@ -0,0 +1,25 @@
1
+ module ChargeBee
2
+ class Coupon < Model
3
+
4
+ attr_accessor :id, :name, :invoice_name, :discount_type, :discount_percentage, :discount_amount,
5
+ :discount_quantity, :duration_type, :duration_month, :valid_till, :max_redemptions, :status,
6
+ :apply_discount_on, :apply_on, :plan_constraint, :addon_constraint, :created_at, :archived_at,
7
+ :plan_ids, :addon_ids, :redemptions, :invoice_notes, :meta_data
8
+
9
+ # OPERATIONS
10
+ #-----------
11
+
12
+ def self.create(params, env=nil, headers={})
13
+ Request.send('post', uri_path("coupons"), params, env, headers)
14
+ end
15
+
16
+ def self.list(params={}, env=nil, headers={})
17
+ Request.send('get', uri_path("coupons"), params, env, headers)
18
+ end
19
+
20
+ def self.retrieve(id, env=nil, headers={})
21
+ Request.send('get', uri_path("coupons",id.to_s), {}, env, headers)
22
+ end
23
+
24
+ end # ~Coupon
25
+ end # ~ChargeBee
@@ -0,0 +1,18 @@
1
+ module ChargeBee
2
+ class CouponCode < Model
3
+
4
+ attr_accessor :code, :coupon_id, :coupon_set_name
5
+
6
+ # OPERATIONS
7
+ #-----------
8
+
9
+ def self.create(params, env=nil, headers={})
10
+ Request.send('post', uri_path("coupon_codes"), params, env, headers)
11
+ end
12
+
13
+ def self.retrieve(id, env=nil, headers={})
14
+ Request.send('get', uri_path("coupon_codes",id.to_s), {}, env, headers)
15
+ end
16
+
17
+ end # ~CouponCode
18
+ end # ~ChargeBee
@@ -0,0 +1,77 @@
1
+ module ChargeBee
2
+ class Customer < Model
3
+
4
+ class BillingAddress < Model
5
+ attr_accessor :first_name, :last_name, :email, :company, :phone, :line1, :line2, :line3, :city, :state_code, :state, :country, :zip
6
+ end
7
+
8
+ class Contact < Model
9
+ attr_accessor :id, :first_name, :last_name, :email, :phone, :label, :enabled, :send_account_email, :send_billing_email
10
+ end
11
+
12
+ class PaymentMethod < Model
13
+ attr_accessor :type, :gateway, :status, :reference_id
14
+ end
15
+
16
+ attr_accessor :id, :first_name, :last_name, :email, :phone, :company, :vat_number, :auto_collection,
17
+ :allow_direct_debit, :created_at, :created_from_ip, :taxability, :card_status, :billing_address,
18
+ :contacts, :payment_method, :invoice_notes, :account_credits, :refundable_credits, :excess_payments,
19
+ :meta_data
20
+
21
+ # OPERATIONS
22
+ #-----------
23
+
24
+ def self.create(params={}, env=nil, headers={})
25
+ Request.send('post', uri_path("customers"), params, env, headers)
26
+ end
27
+
28
+ def self.list(params={}, env=nil, headers={})
29
+ Request.send('get', uri_path("customers"), params, env, headers)
30
+ end
31
+
32
+ def self.retrieve(id, env=nil, headers={})
33
+ Request.send('get', uri_path("customers",id.to_s), {}, env, headers)
34
+ end
35
+
36
+ def self.update(id, params={}, env=nil, headers={})
37
+ Request.send('post', uri_path("customers",id.to_s), params, env, headers)
38
+ end
39
+
40
+ def self.update_payment_method(id, params, env=nil, headers={})
41
+ Request.send('post', uri_path("customers",id.to_s,"update_payment_method"), params, env, headers)
42
+ end
43
+
44
+ def self.update_billing_info(id, params={}, env=nil, headers={})
45
+ Request.send('post', uri_path("customers",id.to_s,"update_billing_info"), params, env, headers)
46
+ end
47
+
48
+ def self.add_contact(id, params, env=nil, headers={})
49
+ Request.send('post', uri_path("customers",id.to_s,"add_contact"), params, env, headers)
50
+ end
51
+
52
+ def self.update_contact(id, params, env=nil, headers={})
53
+ Request.send('post', uri_path("customers",id.to_s,"update_contact"), params, env, headers)
54
+ end
55
+
56
+ def self.delete_contact(id, params, env=nil, headers={})
57
+ Request.send('post', uri_path("customers",id.to_s,"delete_contact"), params, env, headers)
58
+ end
59
+
60
+ def self.add_account_credits(id, params, env=nil, headers={})
61
+ Request.send('post', uri_path("customers",id.to_s,"add_account_credits"), params, env, headers)
62
+ end
63
+
64
+ def self.deduct_account_credits(id, params, env=nil, headers={})
65
+ Request.send('post', uri_path("customers",id.to_s,"deduct_account_credits"), params, env, headers)
66
+ end
67
+
68
+ def self.set_account_credits(id, params, env=nil, headers={})
69
+ Request.send('post', uri_path("customers",id.to_s,"set_account_credits"), params, env, headers)
70
+ end
71
+
72
+ def self.delete(id, params={}, env=nil, headers={})
73
+ Request.send('post', uri_path("customers",id.to_s,"delete"), params, env, headers)
74
+ end
75
+
76
+ end # ~Customer
77
+ end # ~ChargeBee
@@ -0,0 +1,10 @@
1
+ module ChargeBee
2
+ class Download < Model
3
+
4
+ attr_accessor :download_url, :valid_till
5
+
6
+ # OPERATIONS
7
+ #-----------
8
+
9
+ end # ~Download
10
+ end # ~ChargeBee
@@ -0,0 +1,36 @@
1
+ module ChargeBee
2
+ class Estimate < Model
3
+
4
+ class LineItem < Model
5
+ attr_accessor :date_from, :date_to, :unit_amount, :quantity, :is_taxed, :tax, :tax_rate, :amount, :description, :type, :entity_type, :entity_id
6
+ end
7
+
8
+ class Discount < Model
9
+ attr_accessor :amount, :description, :type, :entity_id
10
+ end
11
+
12
+ class Tax < Model
13
+ attr_accessor :amount, :description
14
+ end
15
+
16
+ attr_accessor :created_at, :recurring, :subscription_id, :subscription_status, :term_ends_at,
17
+ :collect_now, :price_type, :amount, :credits_applied, :amount_due, :sub_total, :line_items,
18
+ :discounts, :taxes
19
+
20
+ # OPERATIONS
21
+ #-----------
22
+
23
+ def self.create_subscription(params, env=nil, headers={})
24
+ Request.send('post', uri_path("estimates","create_subscription"), params, env, headers)
25
+ end
26
+
27
+ def self.update_subscription(params, env=nil, headers={})
28
+ Request.send('post', uri_path("estimates","update_subscription"), params, env, headers)
29
+ end
30
+
31
+ def self.renewal_estimate(id, params={}, env=nil, headers={})
32
+ Request.send('get', uri_path("subscriptions",id.to_s,"renewal_estimate"), params, env, headers)
33
+ end
34
+
35
+ end # ~Estimate
36
+ end # ~ChargeBee
@@ -0,0 +1,46 @@
1
+ module ChargeBee
2
+ class Event < Model
3
+
4
+ class Webhook < Model
5
+ attr_accessor :id, :webhook_status
6
+ end
7
+
8
+ attr_accessor :id, :occurred_at, :source, :user, :webhook_status, :webhook_failure_reason, :webhooks,
9
+ :event_type, :api_version
10
+
11
+ class Content < Result
12
+ end
13
+
14
+ def content
15
+ Content.new(@values[:content])
16
+ end
17
+
18
+ def self.deserialize(json)
19
+ begin
20
+ webhook_data = JSON.parse(json)
21
+ rescue JSON::ParserError => e
22
+ raise Error.new("Invalid webhook object to deserialize. #{e}",e)
23
+ end
24
+
25
+ api_version = webhook_data["api_version"]
26
+ if api_version != nil && api_version.casecmp(Environment::API_VERSION) != 0
27
+ raise Error.new("API version [#{api_version.upcase}] in response does not match with client library API version [#{Environment::API_VERSION.upcase}]")
28
+ end
29
+
30
+ webhook_data = Util.symbolize_keys(webhook_data)
31
+ Event.construct(webhook_data)
32
+ end
33
+
34
+ # OPERATIONS
35
+ #-----------
36
+
37
+ def self.list(params={}, env=nil, headers={})
38
+ Request.send('get', uri_path("events"), params, env, headers)
39
+ end
40
+
41
+ def self.retrieve(id, env=nil, headers={})
42
+ Request.send('get', uri_path("events",id.to_s), {}, env, headers)
43
+ end
44
+
45
+ end # ~Event
46
+ end # ~ChargeBee
@@ -0,0 +1,50 @@
1
+ module ChargeBee
2
+ class HostedPage < Model
3
+
4
+ attr_accessor :id, :type, :url, :state, :failure_reason, :pass_thru_content, :embed, :created_at,
5
+ :expires_at
6
+
7
+ class Content < Result
8
+ end
9
+
10
+ def content
11
+ if @values[:content].nil?
12
+ nil
13
+ else
14
+ Content.new(@values[:content])
15
+ end
16
+ end
17
+
18
+ # OPERATIONS
19
+ #-----------
20
+
21
+ def self.checkout_new(params, env=nil, headers={})
22
+ Request.send('post', uri_path("hosted_pages","checkout_new"), params, env, headers)
23
+ end
24
+
25
+ def self.checkout_existing(params, env=nil, headers={})
26
+ Request.send('post', uri_path("hosted_pages","checkout_existing"), params, env, headers)
27
+ end
28
+
29
+ def self.update_card(params, env=nil, headers={})
30
+ Request.send('post', uri_path("hosted_pages","update_card"), params, env, headers)
31
+ end
32
+
33
+ def self.update_payment_method(params, env=nil, headers={})
34
+ Request.send('post', uri_path("hosted_pages","update_payment_method"), params, env, headers)
35
+ end
36
+
37
+ def self.checkout_onetime_charge(params, env=nil, headers={})
38
+ Request.send('post', uri_path("hosted_pages","checkout_onetime_charge"), params, env, headers)
39
+ end
40
+
41
+ def self.checkout_onetime_addons(params, env=nil, headers={})
42
+ Request.send('post', uri_path("hosted_pages","checkout_onetime_addons"), params, env, headers)
43
+ end
44
+
45
+ def self.retrieve(id, env=nil, headers={})
46
+ Request.send('get', uri_path("hosted_pages",id.to_s), {}, env, headers)
47
+ end
48
+
49
+ end # ~HostedPage
50
+ end # ~ChargeBee
@@ -0,0 +1,114 @@
1
+ module ChargeBee
2
+ class Invoice < Model
3
+
4
+ class LineItem < Model
5
+ attr_accessor :date_from, :date_to, :unit_amount, :quantity, :is_taxed, :tax, :tax_rate, :amount, :description, :type, :entity_type, :entity_id
6
+ end
7
+
8
+ class Discount < Model
9
+ attr_accessor :amount, :description, :type, :entity_id
10
+ end
11
+
12
+ class Tax < Model
13
+ attr_accessor :amount, :description
14
+ end
15
+
16
+ class LinkedTransaction < Model
17
+ attr_accessor :txn_id, :applied_amount, :applied_at, :txn_type, :txn_status, :txn_date, :txn_amount
18
+ end
19
+
20
+ class LinkedOrder < Model
21
+ attr_accessor :id, :status, :reference_id, :fulfillment_status, :batch_id, :created_at
22
+ end
23
+
24
+ class Note < Model
25
+ attr_accessor :entity_type, :note, :entity_id
26
+ end
27
+
28
+ class ShippingAddress < Model
29
+ attr_accessor :first_name, :last_name, :email, :company, :phone, :line1, :line2, :line3, :city, :state_code, :state, :country, :zip
30
+ end
31
+
32
+ class BillingAddress < Model
33
+ attr_accessor :first_name, :last_name, :email, :company, :phone, :line1, :line2, :line3, :city, :state_code, :state, :country, :zip
34
+ end
35
+
36
+ attr_accessor :id, :po_number, :customer_id, :subscription_id, :recurring, :status, :vat_number,
37
+ :price_type, :start_date, :end_date, :amount, :amount_paid, :amount_adjusted, :credits_applied,
38
+ :amount_due, :paid_on, :dunning_status, :next_retry, :sub_total, :tax, :first_invoice, :currency_code,
39
+ :line_items, :discounts, :taxes, :linked_transactions, :linked_orders, :notes, :shipping_address,
40
+ :billing_address
41
+
42
+ # OPERATIONS
43
+ #-----------
44
+
45
+ def self.create(params, env=nil, headers={})
46
+ Request.send('post', uri_path("invoices"), params, env, headers)
47
+ end
48
+
49
+ def self.charge(params, env=nil, headers={})
50
+ Request.send('post', uri_path("invoices","charge"), params, env, headers)
51
+ end
52
+
53
+ def self.charge_addon(params, env=nil, headers={})
54
+ Request.send('post', uri_path("invoices","charge_addon"), params, env, headers)
55
+ end
56
+
57
+ def self.stop_dunning(id, env=nil, headers={})
58
+ Request.send('post', uri_path("invoices",id.to_s,"stop_dunning"), {}, env, headers)
59
+ end
60
+
61
+ def self.list(params={}, env=nil, headers={})
62
+ Request.send('get', uri_path("invoices"), params, env, headers)
63
+ end
64
+
65
+ def self.invoices_for_customer(id, params={}, env=nil, headers={})
66
+ Request.send('get', uri_path("customers",id.to_s,"invoices"), params, env, headers)
67
+ end
68
+
69
+ def self.invoices_for_subscription(id, params={}, env=nil, headers={})
70
+ Request.send('get', uri_path("subscriptions",id.to_s,"invoices"), params, env, headers)
71
+ end
72
+
73
+ def self.retrieve(id, env=nil, headers={})
74
+ Request.send('get', uri_path("invoices",id.to_s), {}, env, headers)
75
+ end
76
+
77
+ def self.pdf(id, env=nil, headers={})
78
+ Request.send('post', uri_path("invoices",id.to_s,"pdf"), {}, env, headers)
79
+ end
80
+
81
+ def self.add_charge(id, params, env=nil, headers={})
82
+ Request.send('post', uri_path("invoices",id.to_s,"add_charge"), params, env, headers)
83
+ end
84
+
85
+ def self.add_addon_charge(id, params, env=nil, headers={})
86
+ Request.send('post', uri_path("invoices",id.to_s,"add_addon_charge"), params, env, headers)
87
+ end
88
+
89
+ def self.collect(id, env=nil, headers={})
90
+ Request.send('post', uri_path("invoices",id.to_s,"collect"), {}, env, headers)
91
+ end
92
+
93
+ def self.collect_payment(id, params={}, env=nil, headers={})
94
+ Request.send('post', uri_path("invoices",id.to_s,"collect_payment"), params, env, headers)
95
+ end
96
+
97
+ def self.refund(id, params={}, env=nil, headers={})
98
+ Request.send('post', uri_path("invoices",id.to_s,"refund"), params, env, headers)
99
+ end
100
+
101
+ def self.record_refund(id, params, env=nil, headers={})
102
+ Request.send('post', uri_path("invoices",id.to_s,"record_refund"), params, env, headers)
103
+ end
104
+
105
+ def self.void_invoice(id, params={}, env=nil, headers={})
106
+ Request.send('post', uri_path("invoices",id.to_s,"void"), params, env, headers)
107
+ end
108
+
109
+ def self.delete(id, params={}, env=nil, headers={})
110
+ Request.send('post', uri_path("invoices",id.to_s,"delete"), params, env, headers)
111
+ end
112
+
113
+ end # ~Invoice
114
+ end # ~ChargeBee