chargebee 2.6.2 → 2.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1483 -1473
  3. data/LICENSE +24 -24
  4. data/README.rdoc +41 -41
  5. data/Rakefile +150 -150
  6. data/chargebee.gemspec +2 -2
  7. data/lib/.DS_Store +0 -0
  8. data/lib/chargebee.rb +85 -85
  9. data/lib/chargebee/environment.rb +28 -28
  10. data/lib/chargebee/errors.rb +43 -43
  11. data/lib/chargebee/list_result.rb +28 -28
  12. data/lib/chargebee/models/addon.rb +45 -45
  13. data/lib/chargebee/models/address.rb +18 -18
  14. data/lib/chargebee/models/card.rb +32 -32
  15. data/lib/chargebee/models/comment.rb +25 -25
  16. data/lib/chargebee/models/contact.rb +10 -10
  17. data/lib/chargebee/models/coupon.rb +40 -40
  18. data/lib/chargebee/models/coupon_code.rb +25 -25
  19. data/lib/chargebee/models/coupon_set.rb +37 -37
  20. data/lib/chargebee/models/credit_note.rb +77 -77
  21. data/lib/chargebee/models/credit_note_estimate.rb +35 -35
  22. data/lib/chargebee/models/customer.rb +120 -120
  23. data/lib/chargebee/models/download.rb +9 -9
  24. data/lib/chargebee/models/estimate.rb +46 -46
  25. data/lib/chargebee/models/event.rb +45 -45
  26. data/lib/chargebee/models/export.rb +86 -82
  27. data/lib/chargebee/models/gift.rb +42 -42
  28. data/lib/chargebee/models/hosted_page.rb +77 -73
  29. data/lib/chargebee/models/invoice.rb +172 -172
  30. data/lib/chargebee/models/invoice_estimate.rb +35 -35
  31. data/lib/chargebee/models/model.rb +101 -101
  32. data/lib/chargebee/models/order.rb +76 -76
  33. data/lib/chargebee/models/payment_source.rb +71 -70
  34. data/lib/chargebee/models/plan.rb +59 -59
  35. data/lib/chargebee/models/portal_session.rb +30 -30
  36. data/lib/chargebee/models/promotional_credit.rb +30 -30
  37. data/lib/chargebee/models/quote.rb +72 -72
  38. data/lib/chargebee/models/resource_migration.rb +13 -13
  39. data/lib/chargebee/models/site_migration_detail.rb +14 -14
  40. data/lib/chargebee/models/subscription.rb +137 -137
  41. data/lib/chargebee/models/subscription_estimate.rb +13 -13
  42. data/lib/chargebee/models/third_party_payment_method.rb +9 -9
  43. data/lib/chargebee/models/time_machine.rb +46 -46
  44. data/lib/chargebee/models/transaction.rb +62 -58
  45. data/lib/chargebee/models/unbilled_charge.rb +31 -31
  46. data/lib/chargebee/models/virtual_bank_account.rb +26 -26
  47. data/lib/chargebee/request.rb +27 -27
  48. data/lib/chargebee/rest.rb +92 -90
  49. data/lib/chargebee/result.rb +240 -240
  50. data/lib/chargebee/util.rb +56 -56
  51. data/lib/ssl/ca-certs.crt +3385 -3385
  52. data/spec/chargebee/list_result_spec.rb +53 -53
  53. data/spec/chargebee_spec.rb +99 -99
  54. data/spec/errors_spec.rb +23 -23
  55. data/spec/sample_response.rb +73 -73
  56. data/spec/spec_helper.rb +24 -24
  57. metadata +2 -2
@@ -1,28 +1,28 @@
1
- module ChargeBee
2
- class Environment
3
- API_VERSION = "v2"
4
- # in seconds
5
- TIME_MACHINE_TIMEOUT = 3
6
- EXPORT_TIMEOUT = 10
7
-
8
- attr_accessor :api_key, :site, :time_machine_sleeptime, :export_sleeptime
9
- attr_reader :api_endpoint
10
-
11
- def initialize(options)
12
- options[:time_machine_sleeptime] ||= TIME_MACHINE_TIMEOUT
13
- options[:export_sleeptime] ||= EXPORT_TIMEOUT
14
- [:api_key, :site, :time_machine_sleeptime, :export_sleeptime].each do |attr|
15
- instance_variable_set "@#{attr}", options[attr]
16
- end
17
- if($CHARGEBEE_DOMAIN == nil)
18
- @api_endpoint = "https://#{@site}.chargebee.com/api/#{API_VERSION}"
19
- else
20
- @api_endpoint = "#{$ENV_PROTOCOL == nil ? "http": "https"}://#{@site}.#{$CHARGEBEE_DOMAIN}/api/#{API_VERSION}"
21
- end
22
- end
23
-
24
- def api_url(url)
25
- url = @api_endpoint + url
26
- end
27
- end
28
- end
1
+ module ChargeBee
2
+ class Environment
3
+ API_VERSION = "v2"
4
+ # in seconds
5
+ TIME_MACHINE_TIMEOUT = 3
6
+ EXPORT_TIMEOUT = 10
7
+
8
+ attr_accessor :api_key, :site, :time_machine_sleeptime, :export_sleeptime
9
+ attr_reader :api_endpoint
10
+
11
+ def initialize(options)
12
+ options[:time_machine_sleeptime] ||= TIME_MACHINE_TIMEOUT
13
+ options[:export_sleeptime] ||= EXPORT_TIMEOUT
14
+ [:api_key, :site, :time_machine_sleeptime, :export_sleeptime].each do |attr|
15
+ instance_variable_set "@#{attr}", options[attr]
16
+ end
17
+ if($CHARGEBEE_DOMAIN == nil)
18
+ @api_endpoint = "https://#{@site}.chargebee.com/api/#{API_VERSION}"
19
+ else
20
+ @api_endpoint = "#{$ENV_PROTOCOL == nil ? "http": "https"}://#{@site}.#{$CHARGEBEE_DOMAIN}/api/#{API_VERSION}"
21
+ end
22
+ end
23
+
24
+ def api_url(url)
25
+ url = @api_endpoint + url
26
+ end
27
+ end
28
+ end
@@ -1,43 +1,43 @@
1
- module ChargeBee
2
-
3
- class Error < StandardError
4
- attr_reader :original_error
5
-
6
- def initialize(message=nil,original_error = nil)
7
- super message
8
- @original_error = original_error
9
- end
10
- end
11
-
12
- class IOError < Error; end
13
-
14
- class APIError < Error
15
-
16
- attr_reader :http_status_code, :type, :api_error_code, :param, :json_obj,
17
- #Deprecated attributes
18
- :http_code, :http_body, :error_code
19
-
20
- def initialize(http_code=nil, json_obj = nil)
21
- super json_obj[:message]
22
- @json_obj = json_obj
23
- @http_status_code = http_code
24
- @type = json_obj[:type]
25
- @api_error_code = json_obj[:api_error_code]
26
- @param = json_obj[:param]
27
-
28
- #Deprecated attributes
29
- @error_code = json_obj[:error_code]
30
- @http_code = http_code
31
- @http_body = json_obj.to_s
32
- end
33
-
34
- end
35
-
36
-
37
- class OperationFailedError < APIError; end
38
-
39
- class InvalidRequestError < APIError; end
40
-
41
- class PaymentError < APIError; end
42
-
43
- end
1
+ module ChargeBee
2
+
3
+ class Error < StandardError
4
+ attr_reader :original_error
5
+
6
+ def initialize(message=nil,original_error = nil)
7
+ super message
8
+ @original_error = original_error
9
+ end
10
+ end
11
+
12
+ class IOError < Error; end
13
+
14
+ class APIError < Error
15
+
16
+ attr_reader :http_status_code, :type, :api_error_code, :param, :json_obj,
17
+ #Deprecated attributes
18
+ :http_code, :http_body, :error_code
19
+
20
+ def initialize(http_code=nil, json_obj = nil)
21
+ super json_obj[:message]
22
+ @json_obj = json_obj
23
+ @http_status_code = http_code
24
+ @type = json_obj[:type]
25
+ @api_error_code = json_obj[:api_error_code]
26
+ @param = json_obj[:param]
27
+
28
+ #Deprecated attributes
29
+ @error_code = json_obj[:error_code]
30
+ @http_code = http_code
31
+ @http_body = json_obj.to_s
32
+ end
33
+
34
+ end
35
+
36
+
37
+ class OperationFailedError < APIError; end
38
+
39
+ class InvalidRequestError < APIError; end
40
+
41
+ class PaymentError < APIError; end
42
+
43
+ end
@@ -1,28 +1,28 @@
1
- require 'forwardable'
2
-
3
- module ChargeBee
4
- class ListResult
5
- extend Forwardable
6
- include Enumerable
7
-
8
- def_delegator :@list, :each, :each
9
- def_delegator :@list, :length, :length
10
-
11
- attr_reader :next_offset
12
-
13
- def initialize(response, next_offset=nil)
14
- @response = response
15
- @list = Array.new
16
- @next_offset = JSON.parse(next_offset).to_s if next_offset
17
- initItems()
18
- end
19
-
20
- private
21
- def initItems()
22
- @response.each do |item|
23
- @list.push(Result.new(item))
24
- end
25
- end
26
-
27
- end
28
- end
1
+ require 'forwardable'
2
+
3
+ module ChargeBee
4
+ class ListResult
5
+ extend Forwardable
6
+ include Enumerable
7
+
8
+ def_delegator :@list, :each, :each
9
+ def_delegator :@list, :length, :length
10
+
11
+ attr_reader :next_offset
12
+
13
+ def initialize(response, next_offset=nil)
14
+ @response = response
15
+ @list = Array.new
16
+ @next_offset = JSON.parse(next_offset).to_s if next_offset
17
+ initItems()
18
+ end
19
+
20
+ private
21
+ def initItems()
22
+ @response.each do |item|
23
+ @list.push(Result.new(item))
24
+ end
25
+ end
26
+
27
+ end
28
+ end
@@ -1,46 +1,46 @@
1
- module ChargeBee
2
- class Addon < Model
3
-
4
- class Tier < Model
5
- attr_accessor :starting_unit, :ending_unit, :price
6
- end
7
-
8
- attr_accessor :id, :name, :invoice_name, :description, :pricing_model, :type, :charge_type,
9
- :price, :currency_code, :period, :period_unit, :unit, :status, :archived_at, :enabled_in_portal,
10
- :tax_code, :sku, :accounting_code, :accounting_category1, :accounting_category2, :is_shippable,
11
- :shipping_frequency_period, :shipping_frequency_period_unit, :resource_version, :updated_at,
12
- :invoice_notes, :taxable, :tax_profile_id, :meta_data, :tiers
13
-
14
- # OPERATIONS
15
- #-----------
16
-
17
- def self.create(params, env=nil, headers={})
18
- Request.send('post', uri_path("addons"), params, env, headers)
19
- end
20
-
21
- def self.update(id, params={}, env=nil, headers={})
22
- Request.send('post', uri_path("addons",id.to_s), params, env, headers)
23
- end
24
-
25
- def self.list(params={}, env=nil, headers={})
26
- Request.send_list_request('get', uri_path("addons"), params, env, headers)
27
- end
28
-
29
- def self.retrieve(id, env=nil, headers={})
30
- Request.send('get', uri_path("addons",id.to_s), {}, env, headers)
31
- end
32
-
33
- def self.delete(id, env=nil, headers={})
34
- Request.send('post', uri_path("addons",id.to_s,"delete"), {}, env, headers)
35
- end
36
-
37
- def self.copy(params, env=nil, headers={})
38
- Request.send('post', uri_path("addons","copy"), params, env, headers)
39
- end
40
-
41
- def self.unarchive(id, env=nil, headers={})
42
- Request.send('post', uri_path("addons",id.to_s,"unarchive"), {}, env, headers)
43
- end
44
-
45
- end # ~Addon
1
+ module ChargeBee
2
+ class Addon < Model
3
+
4
+ class Tier < Model
5
+ attr_accessor :starting_unit, :ending_unit, :price
6
+ end
7
+
8
+ attr_accessor :id, :name, :invoice_name, :description, :pricing_model, :type, :charge_type,
9
+ :price, :currency_code, :period, :period_unit, :unit, :status, :archived_at, :enabled_in_portal,
10
+ :tax_code, :sku, :accounting_code, :accounting_category1, :accounting_category2, :is_shippable,
11
+ :shipping_frequency_period, :shipping_frequency_period_unit, :resource_version, :updated_at,
12
+ :invoice_notes, :taxable, :tax_profile_id, :meta_data, :tiers
13
+
14
+ # OPERATIONS
15
+ #-----------
16
+
17
+ def self.create(params, env=nil, headers={})
18
+ Request.send('post', uri_path("addons"), params, env, headers)
19
+ end
20
+
21
+ def self.update(id, params={}, env=nil, headers={})
22
+ Request.send('post', uri_path("addons",id.to_s), params, env, headers)
23
+ end
24
+
25
+ def self.list(params={}, env=nil, headers={})
26
+ Request.send_list_request('get', uri_path("addons"), params, env, headers)
27
+ end
28
+
29
+ def self.retrieve(id, env=nil, headers={})
30
+ Request.send('get', uri_path("addons",id.to_s), {}, env, headers)
31
+ end
32
+
33
+ def self.delete(id, env=nil, headers={})
34
+ Request.send('post', uri_path("addons",id.to_s,"delete"), {}, env, headers)
35
+ end
36
+
37
+ def self.copy(params, env=nil, headers={})
38
+ Request.send('post', uri_path("addons","copy"), params, env, headers)
39
+ end
40
+
41
+ def self.unarchive(id, env=nil, headers={})
42
+ Request.send('post', uri_path("addons",id.to_s,"unarchive"), {}, env, headers)
43
+ end
44
+
45
+ end # ~Addon
46
46
  end # ~ChargeBee
@@ -1,19 +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, :validation_status, :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
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, :validation_status, :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
19
  end # ~ChargeBee
@@ -1,33 +1,33 @@
1
- module ChargeBee
2
- class Card < Model
3
-
4
- attr_accessor :payment_source_id, :status, :gateway, :gateway_account_id, :first_name, :last_name,
5
- :iin, :last4, :card_type, :funding_type, :expiry_month, :expiry_year, :issuing_country, :billing_addr1,
6
- :billing_addr2, :billing_city, :billing_state_code, :billing_state, :billing_country, :billing_zip,
7
- :ip_address, :customer_id, :masked_number
8
-
9
- # OPERATIONS
10
- #-----------
11
-
12
- def self.retrieve(id, env=nil, headers={})
13
- Request.send('get', uri_path("cards",id.to_s), {}, env, headers)
14
- end
15
-
16
- def self.update_card_for_customer(id, params, env=nil, headers={})
17
- Request.send('post', uri_path("customers",id.to_s,"credit_card"), params, env, headers)
18
- end
19
-
20
- def self.switch_gateway_for_customer(id, params, env=nil, headers={})
21
- Request.send('post', uri_path("customers",id.to_s,"switch_gateway"), params, env, headers)
22
- end
23
-
24
- def self.copy_card_for_customer(id, params, env=nil, headers={})
25
- Request.send('post', uri_path("customers",id.to_s,"copy_card"), params, env, headers)
26
- end
27
-
28
- def self.delete_card_for_customer(id, env=nil, headers={})
29
- Request.send('post', uri_path("customers",id.to_s,"delete_card"), {}, env, headers)
30
- end
31
-
32
- end # ~Card
1
+ module ChargeBee
2
+ class Card < Model
3
+
4
+ attr_accessor :payment_source_id, :status, :gateway, :gateway_account_id, :first_name, :last_name,
5
+ :iin, :last4, :card_type, :funding_type, :expiry_month, :expiry_year, :issuing_country, :billing_addr1,
6
+ :billing_addr2, :billing_city, :billing_state_code, :billing_state, :billing_country, :billing_zip,
7
+ :created_at, :resource_version, :updated_at, :ip_address, :customer_id, :masked_number
8
+
9
+ # OPERATIONS
10
+ #-----------
11
+
12
+ def self.retrieve(id, env=nil, headers={})
13
+ Request.send('get', uri_path("cards",id.to_s), {}, env, headers)
14
+ end
15
+
16
+ def self.update_card_for_customer(id, params, env=nil, headers={})
17
+ Request.send('post', uri_path("customers",id.to_s,"credit_card"), params, env, headers)
18
+ end
19
+
20
+ def self.switch_gateway_for_customer(id, params, env=nil, headers={})
21
+ Request.send('post', uri_path("customers",id.to_s,"switch_gateway"), params, env, headers)
22
+ end
23
+
24
+ def self.copy_card_for_customer(id, params, env=nil, headers={})
25
+ Request.send('post', uri_path("customers",id.to_s,"copy_card"), params, env, headers)
26
+ end
27
+
28
+ def self.delete_card_for_customer(id, env=nil, headers={})
29
+ Request.send('post', uri_path("customers",id.to_s,"delete_card"), {}, env, headers)
30
+ end
31
+
32
+ end # ~Card
33
33
  end # ~ChargeBee
@@ -1,26 +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_list_request('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
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_list_request('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
26
  end # ~ChargeBee