chartmogul-ruby 1.6.8 → 2.0.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.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +44 -0
  3. data/2.0-Upgrade.md +9 -0
  4. data/README.md +8 -2
  5. data/changelog.md +15 -1
  6. data/chartmogul-ruby.gemspec +1 -1
  7. data/fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_in_a_threaded_environment.yml +3 -3
  8. data/fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_when_credentials_are_updated.yml +2 -2
  9. data/fixtures/vcr_cassettes/ChartMogul_Account/returns_details_of_current_account.yml +64 -0
  10. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/adds_custom_attributes.yml +2 -2
  11. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/adds_required_tags.yml +2 -2
  12. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/can_page_through_search_endpoint.yml +1 -1
  13. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/correctly_handles_a_422_response.yml +1 -1
  14. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/correctly_interracts_with_the_API.yml +72 -124
  15. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/merges_customers.yml +5 -5
  16. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/raises_401_if_invalid_credentials.yml +1 -1
  17. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/raises_404_if_no_customers_found.yml +1 -1
  18. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/raises_422_for_update_with_invalid_data.yml +2 -2
  19. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/removes_custom_attributes.yml +2 -2
  20. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/removes_tags.yml +2 -2
  21. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/respects_camel_case_for_all_customers_endpoint.yml +45 -0
  22. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_all_customers_through_list_all_endpoint.yml +1 -1
  23. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_customer_through_retrieve_endpoint.yml +1 -1
  24. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_right_customers_through_search_endpoint.yml +1 -1
  25. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_custom_attributes.yml +2 -2
  26. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_customer.yml +3 -3
  27. data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_customer_using_class_method.yml +1 -1
  28. data/fixtures/vcr_cassettes/ChartMogul_Customer/_find_by_external_id/when_external_id_is_provided/returns_matching_user_if_exists.yml +2 -2
  29. data/fixtures/vcr_cassettes/ChartMogul_Customer/_find_by_external_id/when_external_id_is_provided/returns_nil_if_customer_does_not_exist.yml +2 -2
  30. data/fixtures/vcr_cassettes/ChartMogul_CustomerInvoices/API_Interactions/correctly_interracts_with_the_API.yml +7 -7
  31. data/fixtures/vcr_cassettes/ChartMogul_DataSource/API_Interactions/correctly_interracts_with_the_API.yml +4 -4
  32. data/fixtures/vcr_cassettes/ChartMogul_DataSource/API_Interactions/correctly_raises_errors_on_404.yml +1 -1
  33. data/fixtures/vcr_cassettes/ChartMogul_DataSource/API_Interactions/correctly_raises_errors_on_422.yml +1 -1
  34. data/fixtures/vcr_cassettes/ChartMogul_DataSource/API_Interactions/retrieves_existing_data_source_matching_uuid.yml +2 -2
  35. data/fixtures/vcr_cassettes/ChartMogul_Invoice/API_Interactions/deletes_an_invoice.yml +1 -1
  36. data/fixtures/vcr_cassettes/ChartMogul_Invoice/API_Interactions/deletes_an_invoice_with_class_method.yml +1 -1
  37. data/fixtures/vcr_cassettes/ChartMogul_Invoice/API_Interactions/raises_error_on_deleting_non-existing_invoice.yml +1 -1
  38. data/fixtures/vcr_cassettes/ChartMogul_Invoice/API_Interactions/retrieves_existing_invoice_by_uuid.yml +1 -1
  39. data/fixtures/vcr_cassettes/ChartMogul_Invoice/API_Interactions/returns_all_invoices_through_list_all_endpoint.yml +1 -1
  40. data/fixtures/vcr_cassettes/ChartMogul_Metrics_ARPA/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
  41. data/fixtures/vcr_cassettes/ChartMogul_Metrics_ARPA/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  42. data/fixtures/vcr_cassettes/ChartMogul_Metrics_ARR/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
  43. data/fixtures/vcr_cassettes/ChartMogul_Metrics_ARR/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  44. data/fixtures/vcr_cassettes/ChartMogul_Metrics_ASP/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
  45. data/fixtures/vcr_cassettes/ChartMogul_Metrics_ASP/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  46. data/fixtures/vcr_cassettes/ChartMogul_Metrics_Activity.yml +37 -0
  47. data/fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/behaves_like_PageableWithAnchor/should_be_pageable.yml +44 -0
  48. data/fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/should_have_Activity_entries.yml +18 -15
  49. data/fixtures/vcr_cassettes/ChartMogul_Metrics_AllKeyMetric/should_have_entries.yml +1 -1
  50. data/fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerChurnRate/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
  51. data/fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  52. data/fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerCount/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
  53. data/fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerCount/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  54. data/fixtures/vcr_cassettes/{ChartMogul_Metrics_Activity → ChartMogul_Metrics_Customers_Activity}/behaves_like_Pageable/should_be_pageable.yml +1 -1
  55. data/fixtures/vcr_cassettes/ChartMogul_Metrics_Customers_Activity/should_have_Activity_entries.yml +41 -0
  56. data/fixtures/vcr_cassettes/{ChartMogul_Metrics_Subscription → ChartMogul_Metrics_Customers_Subscription}/behaves_like_Pageable/should_be_pageable.yml +1 -1
  57. data/fixtures/vcr_cassettes/{ChartMogul_Metrics_Subscription → ChartMogul_Metrics_Customers_Subscription}/should_have_Subscription_entries.yml +1 -1
  58. data/fixtures/vcr_cassettes/ChartMogul_Metrics_LTV/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
  59. data/fixtures/vcr_cassettes/ChartMogul_Metrics_LTV/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  60. data/fixtures/vcr_cassettes/ChartMogul_Metrics_MRR/behaves_like_Summary/should_have_summary.yml +1 -1
  61. data/fixtures/vcr_cassettes/ChartMogul_Metrics_MRR/should_have_entries.yml +1 -1
  62. data/fixtures/vcr_cassettes/ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
  63. data/fixtures/vcr_cassettes/ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  64. data/fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_on_incorrect_credentials.yml +1 -1
  65. data/fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_with_500_internal_server_error.yml +1 -1
  66. data/fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_with_504_gateway_timeout_error.yml +1 -1
  67. data/fixtures/vcr_cassettes/ChartMogul_Ping/pings/when_credentials_correct.yml +1 -1
  68. data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/correctly_handles_a_422_error.yml +1 -1
  69. data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/correctly_interacts_with_the_API.yml +3 -3
  70. data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/deletes_existing_plan.yml +4 -4
  71. data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/retrieves_existing_plan_by_uuid.yml +3 -3
  72. data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/updates_existing_plan.yml +4 -4
  73. data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/updates_existing_plan_using_class_method.yml +3 -3
  74. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/correctly_handles_a_422_error.yml +1 -1
  75. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/deletes_a_plan_group.yml +6 -6
  76. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/retrieves_existing_plan_group_by_uuid.yml +5 -5
  77. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/returns_an_array_of_plan_groups.yml +7 -7
  78. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_name.yml +6 -6
  79. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_name_via_class_method.yml +5 -5
  80. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_plans.yml +8 -8
  81. data/fixtures/vcr_cassettes/ChartMogul_PlanGroups_Plans/API_interactions/given_a_plan_group_uuid_returns_an_array_of_plans_in_the_plan_group.yml +5 -5
  82. data/fixtures/vcr_cassettes/ChartMogul_Subscription/API_Interactions/connects_subscriptions.yml +10 -10
  83. data/fixtures/vcr_cassettes/ChartMogul_Subscription/API_Interactions/correctly_interracts_with_the_API.yml +7 -7
  84. data/fixtures/vcr_cassettes/ChartMogul_Subscription/API_Interactions/has_multiple_aliases.yml +2 -2
  85. data/fixtures/vcr_cassettes/ChartMogul_Subscription/_update_cancellation_dates/when_array_has_time_objects/is_setting_the_cancellation_dates_of_the_subscription.yml +3 -3
  86. data/fixtures/vcr_cassettes/ChartMogul_Subscription/_update_cancellation_dates/when_array_includes_invalid_entries/raises_an_exception.yml +2 -2
  87. data/fixtures/vcr_cassettes/ChartMogul_Subscription/_update_cancellation_dates/when_array_includes_valid_entries/is_setting_the_cancellation_dates_of_the_subscription.yml +3 -3
  88. data/fixtures/vcr_cassettes/ChartMogul_Subscription/_update_cancellation_dates/when_array_is_empty/makes_an_API_call_and_removes_the_cancellation_dates.yml +3 -3
  89. data/fixtures/vcr_cassettes/ChartMogul_Transactions_Payment/API_Interactions/correctly_interracts_with_the_API.yml +5 -5
  90. data/lib/chartmogul.rb +10 -3
  91. data/lib/chartmogul/account.rb +19 -0
  92. data/lib/chartmogul/api/actions/all.rb +2 -1
  93. data/lib/chartmogul/api/actions/create.rb +2 -2
  94. data/lib/chartmogul/api/actions/custom.rb +1 -1
  95. data/lib/chartmogul/api/actions/retrieve.rb +2 -1
  96. data/lib/chartmogul/api/actions/update.rb +2 -2
  97. data/lib/chartmogul/api_resource.rb +8 -4
  98. data/lib/chartmogul/concerns/pageable_with_anchor.rb +14 -0
  99. data/lib/chartmogul/config_attributes.rb +17 -1
  100. data/lib/chartmogul/customer.rb +2 -1
  101. data/lib/chartmogul/metrics/activity.rb +12 -8
  102. data/lib/chartmogul/metrics/customers/activity.rb +38 -0
  103. data/lib/chartmogul/metrics/customers/subscription.rb +41 -0
  104. data/lib/chartmogul/transactions/payment.rb +1 -1
  105. data/lib/chartmogul/transactions/refund.rb +1 -1
  106. data/lib/chartmogul/utils/hash_snake_caser.rb +9 -2
  107. data/lib/chartmogul/utils/json_parser.rb +2 -4
  108. data/lib/chartmogul/version.rb +1 -1
  109. metadata +18 -10
  110. data/.DS_Store +0 -0
  111. data/.travis.yml +0 -25
  112. data/lib/chartmogul/metrics/subscription.rb +0 -39
@@ -25,7 +25,7 @@ module ChartMogul
25
25
  req.body = JSON.dump(body_data)
26
26
  end
27
27
  end
28
- ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: skip_case_conversion)
28
+ ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: immutable_keys)
29
29
  end
30
30
 
31
31
  def custom!(http_method, http_path, body_data = {})
@@ -15,7 +15,8 @@ module ChartMogul
15
15
  req.headers['Content-Type'] = 'application/json'
16
16
  end
17
17
  end
18
- json = ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: skip_case_conversion)
18
+
19
+ json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: immutable_keys)
19
20
  new_from_json(json)
20
21
  end
21
22
  end
@@ -16,7 +16,7 @@ module ChartMogul
16
16
  end
17
17
  end
18
18
 
19
- json = ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: self.class.skip_case_conversion)
19
+ json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: self.class.immutable_keys)
20
20
 
21
21
  assign_all_attributes(json)
22
22
  end
@@ -31,7 +31,7 @@ module ChartMogul
31
31
  req.body = JSON.dump(resource.serialize_for_write)
32
32
  end
33
33
  end
34
- json = ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: skip_case_conversion)
34
+ json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: immutable_keys)
35
35
 
36
36
  new_from_json(json)
37
37
  end
@@ -17,7 +17,7 @@ module ChartMogul
17
17
  MAX_INTERVAL = 60
18
18
  THREAD_CONNECTION_KEY = 'chartmogul_ruby.api_resource.connection'
19
19
 
20
- class << self; attr_reader :resource_path, :resource_name, :resource_root_key, :skip_case_conversion end
20
+ class << self; attr_reader :resource_path, :resource_name, :resource_root_key end
21
21
 
22
22
  def self.set_resource_path(path)
23
23
  @resource_path = ChartMogul::ResourcePath.new(path)
@@ -31,9 +31,13 @@ module ChartMogul
31
31
  @resource_root_key = root_key
32
32
  end
33
33
 
34
- # When true, response hash keys won't be converted to snake case
35
- def self.set_skip_case_conversion(value)
36
- @skip_case_conversion = value
34
+ def self.immutable_keys
35
+ @immutable_keys ||= []
36
+ end
37
+
38
+ # When set with keys, nested hash keys of these immutable keys won't be converted to snake case
39
+ def self.set_immutable_keys(array)
40
+ @immutable_keys = array
37
41
  end
38
42
 
39
43
  def self.connection
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChartMogul
4
+ module Concerns
5
+ module PageableWithAnchor
6
+ def self.included(base)
7
+ base.instance_eval do
8
+ readonly_attr :has_more
9
+ readonly_attr :per_page
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -4,7 +4,7 @@ module ChartMogul
4
4
  module ConfigAttributes
5
5
  def config_accessor(attribute, default_value = nil)
6
6
  define_method(attribute) do
7
- attr = config.send(attribute) || default_value
7
+ attr = config.send(attribute) || global_config.send(attribute) || default_value
8
8
  if attr.nil?
9
9
  raise ConfigurationError, "Configuration for #{attribute} not set"
10
10
  end
@@ -12,9 +12,25 @@ module ChartMogul
12
12
  attr
13
13
  end
14
14
 
15
+ define_method("global_#{attribute}") do
16
+ attr = global_config.send(attribute) || default_value
17
+ if attr.nil?
18
+ raise ConfigurationError, "Global configuration for #{attribute} not set"
19
+ end
20
+
21
+ attr
22
+ end
23
+
15
24
  define_method("#{attribute}=") do |val|
16
25
  config.send("#{attribute}=", val)
17
26
  Thread.current[ChartMogul::APIResource::THREAD_CONNECTION_KEY] = nil
27
+ val
28
+ end
29
+
30
+ define_method("global_#{attribute}=") do |val|
31
+ global_config.send("#{attribute}=", val)
32
+ Thread.current[ChartMogul::APIResource::THREAD_CONNECTION_KEY] = nil
33
+ val
18
34
  end
19
35
  end
20
36
  end
@@ -4,7 +4,7 @@ module ChartMogul
4
4
  class Customer < APIResource
5
5
  set_resource_name 'Customer'
6
6
  set_resource_path '/v1/customers'
7
- set_skip_case_conversion true
7
+ set_immutable_keys([:attributes, :custom])
8
8
 
9
9
  readonly_attr :uuid
10
10
  readonly_attr :id
@@ -132,6 +132,7 @@ module ChartMogul
132
132
  class Customers < APIResource
133
133
  set_resource_name 'Customers'
134
134
  set_resource_path '/v1/customers'
135
+ set_immutable_keys([:attributes, :custom])
135
136
 
136
137
  include Concerns::Entries
137
138
  include API::Actions::Custom
@@ -3,7 +3,6 @@
3
3
  module ChartMogul
4
4
  module Metrics
5
5
  class Activity < ChartMogul::Object
6
- readonly_attr :id
7
6
  readonly_attr :description
8
7
  readonly_attr :type
9
8
  readonly_attr :date, type: :time
@@ -11,25 +10,30 @@ module ChartMogul
11
10
  readonly_attr :activity_mrr
12
11
  readonly_attr :activity_mrr_movement
13
12
  readonly_attr :currency
14
- readonly_attr :currency_sign
15
13
  readonly_attr :subscription_external_id
14
+ readonly_attr :plan_external_id
15
+ readonly_attr :customer_name
16
+ readonly_attr :customer_uuid
17
+ readonly_attr :customer_external_id
18
+ readonly_attr :billing_connector_uuid
19
+ readonly_attr :uuid
16
20
 
17
- def self.all(customer_uuid, options = {})
18
- ChartMogul::Metrics::Activities.all(customer_uuid, options)
21
+ def self.all(options = {})
22
+ ChartMogul::Metrics::Activities.all(options)
19
23
  end
20
24
  end
21
25
 
22
26
  class Activities < APIResource
23
27
  set_resource_name 'Activities'
24
- set_resource_path '/v1/customers/:customer_uuid/activities'
28
+ set_resource_path '/v1/activities'
25
29
 
26
30
  include Concerns::Entries
27
- include Concerns::Pageable
31
+ include Concerns::PageableWithAnchor
28
32
 
29
33
  set_entry_class Activity
30
34
 
31
- def self.all(customer_uuid, options = {})
32
- super(options.merge(customer_uuid: customer_uuid))
35
+ def self.all(options = {})
36
+ super(options)
33
37
  end
34
38
  end
35
39
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChartMogul
4
+ module Metrics
5
+ module Customers
6
+ class Activity < ChartMogul::Object
7
+ readonly_attr :id
8
+ readonly_attr :description
9
+ readonly_attr :type
10
+ readonly_attr :date, type: :time
11
+ readonly_attr :activity_arr
12
+ readonly_attr :activity_mrr
13
+ readonly_attr :activity_mrr_movement
14
+ readonly_attr :currency
15
+ readonly_attr :currency_sign
16
+ readonly_attr :subscription_external_id
17
+
18
+ def self.all(customer_uuid, options = {})
19
+ ChartMogul::Metrics::Customers::Activities.all(customer_uuid, options)
20
+ end
21
+ end
22
+
23
+ class Activities < APIResource
24
+ set_resource_name 'Activities'
25
+ set_resource_path '/v1/customers/:customer_uuid/activities'
26
+
27
+ include Concerns::Entries
28
+ include Concerns::Pageable
29
+
30
+ set_entry_class Activity
31
+
32
+ def self.all(customer_uuid, options = {})
33
+ super(options.merge(customer_uuid: customer_uuid))
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChartMogul
4
+ module Metrics
5
+ module Customers
6
+ class Subscription < ChartMogul::Object
7
+ readonly_attr :id
8
+ readonly_attr :external_id
9
+ readonly_attr :plan
10
+ readonly_attr :quantity
11
+ readonly_attr :mrr
12
+ readonly_attr :arr
13
+ readonly_attr :status
14
+ readonly_attr :billing_cycle
15
+ readonly_attr :billing_cycle_count
16
+ readonly_attr :start_date, type: :time
17
+ readonly_attr :end_date, type: :time
18
+ readonly_attr :currency
19
+ readonly_attr :currency_sign
20
+
21
+ def self.all(customer_uuid, options = {})
22
+ ChartMogul::Metrics::Customers::Subscriptions.all(customer_uuid, options)
23
+ end
24
+ end
25
+
26
+ class Subscriptions < APIResource
27
+ set_resource_name 'Subscriptions'
28
+ set_resource_path '/v1/customers/:customer_uuid/subscriptions'
29
+
30
+ include Concerns::Entries
31
+ include Concerns::Pageable
32
+
33
+ set_entry_class Subscription
34
+
35
+ def self.all(customer_uuid, options = {})
36
+ super(options.merge(customer_uuid: customer_uuid))
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -12,7 +12,7 @@ module ChartMogul
12
12
  writeable_attr :date, type: :time
13
13
  writeable_attr :result
14
14
  writeable_attr :external_id
15
-
15
+ writeable_attr :amount_in_cents
16
16
  writeable_attr :invoice_uuid
17
17
 
18
18
  def initialize(attributes = {})
@@ -12,7 +12,7 @@ module ChartMogul
12
12
  writeable_attr :date, type: :time
13
13
  writeable_attr :result
14
14
  writeable_attr :external_id
15
-
15
+ writeable_attr :amount_in_cents
16
16
  writeable_attr :invoice_uuid
17
17
 
18
18
  def initialize(attributes = {})
@@ -8,8 +8,9 @@ module ChartMogul
8
8
  # Rubyish snake_case, suitable for use during instantiation of Ruby
9
9
  # model attributes.
10
10
  #
11
- def initialize(hash)
11
+ def initialize(hash, immutable_keys: [])
12
12
  @hash = hash
13
+ @immutable_keys = immutable_keys
13
14
  end
14
15
 
15
16
  def to_snake_keys(value = @hash)
@@ -26,7 +27,13 @@ module ChartMogul
26
27
  private
27
28
 
28
29
  def snake_hash(value)
29
- Hash[value.map { |k, v| [underscore_key(k), to_snake_keys(v)] }]
30
+ Hash[value.map { |k, v| [underscore_key(k), immutable_check(k, v)] }]
31
+ end
32
+
33
+ def immutable_check(k,v)
34
+ return v if @immutable_keys.include?(k)
35
+
36
+ to_snake_keys(v)
30
37
  end
31
38
 
32
39
  def underscore_key(k)
@@ -4,11 +4,9 @@ module ChartMogul
4
4
  module Utils
5
5
  class JSONParser
6
6
  class << self
7
- def parse(json_string, skip_case_conversion: false)
7
+ def parse(json_string, immutable_keys: [])
8
8
  hash = JSON.parse(json_string, symbolize_names: true)
9
- return hash if skip_case_conversion
10
-
11
- HashSnakeCaser.new(hash).to_snake_keys
9
+ HashSnakeCaser.new(hash, immutable_keys: immutable_keys).to_snake_keys
12
10
  end
13
11
 
14
12
  def typecast_custom_attributes(custom_attributes)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChartMogul
4
- VERSION = '1.6.8'
4
+ VERSION = '2.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chartmogul-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.8
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Kopac
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-12 00:00:00.000000000 Z
11
+ date: 2021-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0
26
+ version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -171,10 +171,10 @@ executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
- - ".DS_Store"
174
+ - ".github/workflows/test.yml"
175
175
  - ".gitignore"
176
176
  - ".rspec"
177
- - ".travis.yml"
177
+ - 2.0-Upgrade.md
178
178
  - Gemfile
179
179
  - LICENSE.txt
180
180
  - README.md
@@ -185,6 +185,7 @@ files:
185
185
  - chartmogul-ruby.gemspec
186
186
  - fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_in_a_threaded_environment.yml
187
187
  - fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_when_credentials_are_updated.yml
188
+ - fixtures/vcr_cassettes/ChartMogul_Account/returns_details_of_current_account.yml
188
189
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/adds_custom_attributes.yml
189
190
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/adds_required_tags.yml
190
191
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/can_page_through_search_endpoint.yml
@@ -196,6 +197,7 @@ files:
196
197
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/raises_422_for_update_with_invalid_data.yml
197
198
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/removes_custom_attributes.yml
198
199
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/removes_tags.yml
200
+ - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/respects_camel_case_for_all_customers_endpoint.yml
199
201
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_all_customers_through_list_all_endpoint.yml
200
202
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_customer_through_retrieve_endpoint.yml
201
203
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_right_customers_through_search_endpoint.yml
@@ -220,21 +222,24 @@ files:
220
222
  - fixtures/vcr_cassettes/ChartMogul_Metrics_ARR/behaves_like_Metrics_API_resource/should_have_entries.yml
221
223
  - fixtures/vcr_cassettes/ChartMogul_Metrics_ASP/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
222
224
  - fixtures/vcr_cassettes/ChartMogul_Metrics_ASP/behaves_like_Metrics_API_resource/should_have_entries.yml
223
- - fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/behaves_like_Pageable/should_be_pageable.yml
225
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Activity.yml
226
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/behaves_like_PageableWithAnchor/should_be_pageable.yml
224
227
  - fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/should_have_Activity_entries.yml
225
228
  - fixtures/vcr_cassettes/ChartMogul_Metrics_AllKeyMetric/should_have_entries.yml
226
229
  - fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerChurnRate/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
227
230
  - fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml
228
231
  - fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerCount/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
229
232
  - fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerCount/behaves_like_Metrics_API_resource/should_have_entries.yml
233
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Customers_Activity/behaves_like_Pageable/should_be_pageable.yml
234
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Customers_Activity/should_have_Activity_entries.yml
235
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Customers_Subscription/behaves_like_Pageable/should_be_pageable.yml
236
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Customers_Subscription/should_have_Subscription_entries.yml
230
237
  - fixtures/vcr_cassettes/ChartMogul_Metrics_LTV/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
231
238
  - fixtures/vcr_cassettes/ChartMogul_Metrics_LTV/behaves_like_Metrics_API_resource/should_have_entries.yml
232
239
  - fixtures/vcr_cassettes/ChartMogul_Metrics_MRR/behaves_like_Summary/should_have_summary.yml
233
240
  - fixtures/vcr_cassettes/ChartMogul_Metrics_MRR/should_have_entries.yml
234
241
  - fixtures/vcr_cassettes/ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
235
242
  - fixtures/vcr_cassettes/ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml
236
- - fixtures/vcr_cassettes/ChartMogul_Metrics_Subscription/behaves_like_Pageable/should_be_pageable.yml
237
- - fixtures/vcr_cassettes/ChartMogul_Metrics_Subscription/should_have_Subscription_entries.yml
238
243
  - fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_on_incorrect_credentials.yml
239
244
  - fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_with_500_internal_server_error.yml
240
245
  - fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_with_504_gateway_timeout_error.yml
@@ -262,6 +267,7 @@ files:
262
267
  - fixtures/vcr_cassettes/ChartMogul_Subscription/_update_cancellation_dates/when_array_is_empty/makes_an_API_call_and_removes_the_cancellation_dates.yml
263
268
  - fixtures/vcr_cassettes/ChartMogul_Transactions_Payment/API_Interactions/correctly_interracts_with_the_API.yml
264
269
  - lib/chartmogul.rb
270
+ - lib/chartmogul/account.rb
265
271
  - lib/chartmogul/api/actions/all.rb
266
272
  - lib/chartmogul/api/actions/create.rb
267
273
  - lib/chartmogul/api/actions/custom.rb
@@ -272,6 +278,7 @@ files:
272
278
  - lib/chartmogul/concerns/entries.rb
273
279
  - lib/chartmogul/concerns/pageable.rb
274
280
  - lib/chartmogul/concerns/pageable2.rb
281
+ - lib/chartmogul/concerns/pageable_with_anchor.rb
275
282
  - lib/chartmogul/concerns/summary.rb
276
283
  - lib/chartmogul/config_attributes.rb
277
284
  - lib/chartmogul/configuration.rb
@@ -298,10 +305,11 @@ files:
298
305
  - lib/chartmogul/metrics/base.rb
299
306
  - lib/chartmogul/metrics/customer_churn_rate.rb
300
307
  - lib/chartmogul/metrics/customer_count.rb
308
+ - lib/chartmogul/metrics/customers/activity.rb
309
+ - lib/chartmogul/metrics/customers/subscription.rb
301
310
  - lib/chartmogul/metrics/ltv.rb
302
311
  - lib/chartmogul/metrics/mrr.rb
303
312
  - lib/chartmogul/metrics/mrr_churn_rate.rb
304
- - lib/chartmogul/metrics/subscription.rb
305
313
  - lib/chartmogul/object.rb
306
314
  - lib/chartmogul/ping.rb
307
315
  - lib/chartmogul/plan.rb