chartmogul-ruby 1.6.7 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -1
- data/changelog.md +13 -0
- data/chartmogul-ruby.gemspec +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_in_a_threaded_environment.yml +3 -3
- data/fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_when_credentials_are_updated.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_Account/returns_details_of_current_account.yml +64 -0
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/adds_custom_attributes.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/adds_required_tags.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/can_page_through_search_endpoint.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/correctly_handles_a_422_response.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/correctly_interracts_with_the_API.yml +72 -124
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/merges_customers.yml +5 -5
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/raises_401_if_invalid_credentials.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/raises_404_if_no_customers_found.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/raises_422_for_update_with_invalid_data.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/removes_custom_attributes.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/removes_tags.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/respects_camel_case_for_all_customers_endpoint.yml +45 -0
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_all_customers_through_list_all_endpoint.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_customer_through_retrieve_endpoint.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_right_customers_through_search_endpoint.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_custom_attributes.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_customer.yml +3 -3
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_customer_using_class_method.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Customer/_find_by_external_id/when_external_id_is_provided/returns_matching_user_if_exists.yml +2 -2
- 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
- data/fixtures/vcr_cassettes/ChartMogul_CustomerInvoices/API_Interactions/correctly_interracts_with_the_API.yml +7 -7
- data/fixtures/vcr_cassettes/ChartMogul_DataSource/API_Interactions/correctly_interracts_with_the_API.yml +4 -4
- data/fixtures/vcr_cassettes/ChartMogul_DataSource/API_Interactions/correctly_raises_errors_on_404.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_DataSource/API_Interactions/correctly_raises_errors_on_422.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_DataSource/API_Interactions/retrieves_existing_data_source_matching_uuid.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_Invoice/API_Interactions/deletes_an_invoice.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Invoice/API_Interactions/deletes_an_invoice_with_class_method.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Invoice/API_Interactions/raises_error_on_deleting_non-existing_invoice.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Invoice/API_Interactions/retrieves_existing_invoice_by_uuid.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Invoice/API_Interactions/returns_all_invoices_through_list_all_endpoint.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_ARPA/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_ARPA/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_ARR/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_ARR/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_ASP/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_ASP/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/behaves_like_Pageable/should_be_pageable.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/should_have_Activity_entries.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_AllKeyMetric/should_have_entries.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerChurnRate/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerCount/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerCount/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_LTV/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_LTV/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_MRR/behaves_like_Summary/should_have_summary.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_MRR/should_have_entries.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_Subscription/behaves_like_Pageable/should_be_pageable.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_Subscription/should_have_Subscription_entries.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_on_incorrect_credentials.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_with_500_internal_server_error.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_with_504_gateway_timeout_error.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Ping/pings/when_credentials_correct.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/correctly_handles_a_422_error.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/correctly_interacts_with_the_API.yml +3 -3
- data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/deletes_existing_plan.yml +4 -4
- data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/retrieves_existing_plan_by_uuid.yml +3 -3
- data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/updates_existing_plan.yml +4 -4
- data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/updates_existing_plan_using_class_method.yml +3 -3
- data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/correctly_handles_a_422_error.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/deletes_a_plan_group.yml +6 -6
- data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/retrieves_existing_plan_group_by_uuid.yml +5 -5
- data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/returns_an_array_of_plan_groups.yml +7 -7
- data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_name.yml +6 -6
- data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_name_via_class_method.yml +5 -5
- data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_plans.yml +8 -8
- 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
- data/fixtures/vcr_cassettes/ChartMogul_Subscription/API_Interactions/connects_subscriptions.yml +10 -10
- data/fixtures/vcr_cassettes/ChartMogul_Subscription/API_Interactions/correctly_interracts_with_the_API.yml +7 -7
- data/fixtures/vcr_cassettes/ChartMogul_Subscription/API_Interactions/has_multiple_aliases.yml +2 -2
- 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
- data/fixtures/vcr_cassettes/ChartMogul_Subscription/_update_cancellation_dates/when_array_includes_invalid_entries/raises_an_exception.yml +2 -2
- 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
- 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
- data/fixtures/vcr_cassettes/ChartMogul_Transactions_Payment/API_Interactions/correctly_interracts_with_the_API.yml +5 -5
- data/lib/chartmogul.rb +7 -2
- data/lib/chartmogul/account.rb +19 -0
- data/lib/chartmogul/api/actions/all.rb +2 -1
- data/lib/chartmogul/api/actions/create.rb +2 -2
- data/lib/chartmogul/api/actions/custom.rb +1 -1
- data/lib/chartmogul/api/actions/retrieve.rb +2 -1
- data/lib/chartmogul/api/actions/update.rb +2 -2
- data/lib/chartmogul/api_resource.rb +8 -4
- data/lib/chartmogul/config_attributes.rb +17 -1
- data/lib/chartmogul/customer.rb +2 -1
- data/lib/chartmogul/metrics/activity.rb +1 -0
- data/lib/chartmogul/transactions/payment.rb +1 -1
- data/lib/chartmogul/transactions/refund.rb +1 -1
- data/lib/chartmogul/utils/hash_snake_caser.rb +9 -2
- data/lib/chartmogul/utils/json_parser.rb +2 -4
- data/lib/chartmogul/version.rb +1 -1
- metadata +7 -4
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
Authorization:
|
15
|
-
- Basic
|
15
|
+
- Basic hidden
|
16
16
|
response:
|
17
17
|
status:
|
18
18
|
code: 201
|
@@ -63,7 +63,7 @@ http_interactions:
|
|
63
63
|
Content-Type:
|
64
64
|
- application/json
|
65
65
|
Authorization:
|
66
|
-
- Basic
|
66
|
+
- Basic hidden
|
67
67
|
response:
|
68
68
|
status:
|
69
69
|
code: 201
|
@@ -114,7 +114,7 @@ http_interactions:
|
|
114
114
|
Content-Type:
|
115
115
|
- application/json
|
116
116
|
Authorization:
|
117
|
-
- Basic
|
117
|
+
- Basic hidden
|
118
118
|
response:
|
119
119
|
status:
|
120
120
|
code: 201
|
@@ -165,7 +165,7 @@ http_interactions:
|
|
165
165
|
Content-Type:
|
166
166
|
- application/json
|
167
167
|
Authorization:
|
168
|
-
- Basic
|
168
|
+
- Basic hidden
|
169
169
|
response:
|
170
170
|
status:
|
171
171
|
code: 201
|
@@ -214,7 +214,7 @@ http_interactions:
|
|
214
214
|
Content-Type:
|
215
215
|
- application/json
|
216
216
|
Authorization:
|
217
|
-
- Basic
|
217
|
+
- Basic hidden
|
218
218
|
response:
|
219
219
|
status:
|
220
220
|
code: 200
|
@@ -263,7 +263,7 @@ http_interactions:
|
|
263
263
|
Content-Type:
|
264
264
|
- application/json
|
265
265
|
Authorization:
|
266
|
-
- Basic
|
266
|
+
- Basic hidden
|
267
267
|
response:
|
268
268
|
status:
|
269
269
|
code: 202
|
@@ -306,7 +306,7 @@ http_interactions:
|
|
306
306
|
User-Agent:
|
307
307
|
- Faraday v0.9.2
|
308
308
|
Authorization:
|
309
|
-
- Basic
|
309
|
+
- Basic hidden
|
310
310
|
response:
|
311
311
|
status:
|
312
312
|
code: 204
|
data/fixtures/vcr_cassettes/ChartMogul_Subscription/API_Interactions/has_multiple_aliases.yml
CHANGED
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
Authorization:
|
15
|
-
- Basic
|
15
|
+
- Basic hidden
|
16
16
|
response:
|
17
17
|
status:
|
18
18
|
code: 200
|
@@ -61,7 +61,7 @@ http_interactions:
|
|
61
61
|
Content-Type:
|
62
62
|
- application/json
|
63
63
|
Authorization:
|
64
|
-
- Basic
|
64
|
+
- Basic hidden
|
65
65
|
response:
|
66
66
|
status:
|
67
67
|
code: 200
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
Authorization:
|
15
|
-
- Basic
|
15
|
+
- Basic hidden
|
16
16
|
response:
|
17
17
|
status:
|
18
18
|
code: 200
|
@@ -51,7 +51,7 @@ http_interactions:
|
|
51
51
|
Content-Type:
|
52
52
|
- application/json
|
53
53
|
Authorization:
|
54
|
-
- Basic
|
54
|
+
- Basic hidden
|
55
55
|
response:
|
56
56
|
status:
|
57
57
|
code: 200
|
@@ -102,7 +102,7 @@ http_interactions:
|
|
102
102
|
Content-Type:
|
103
103
|
- application/json
|
104
104
|
Authorization:
|
105
|
-
- Basic
|
105
|
+
- Basic hidden
|
106
106
|
response:
|
107
107
|
status:
|
108
108
|
code: 202
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
Authorization:
|
15
|
-
- Basic
|
15
|
+
- Basic hidden
|
16
16
|
response:
|
17
17
|
status:
|
18
18
|
code: 200
|
@@ -51,7 +51,7 @@ http_interactions:
|
|
51
51
|
Content-Type:
|
52
52
|
- application/json
|
53
53
|
Authorization:
|
54
|
-
- Basic
|
54
|
+
- Basic hidden
|
55
55
|
response:
|
56
56
|
status:
|
57
57
|
code: 200
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
Authorization:
|
15
|
-
- Basic
|
15
|
+
- Basic hidden
|
16
16
|
response:
|
17
17
|
status:
|
18
18
|
code: 200
|
@@ -51,7 +51,7 @@ http_interactions:
|
|
51
51
|
Content-Type:
|
52
52
|
- application/json
|
53
53
|
Authorization:
|
54
|
-
- Basic
|
54
|
+
- Basic hidden
|
55
55
|
response:
|
56
56
|
status:
|
57
57
|
code: 200
|
@@ -102,7 +102,7 @@ http_interactions:
|
|
102
102
|
Content-Type:
|
103
103
|
- application/json
|
104
104
|
Authorization:
|
105
|
-
- Basic
|
105
|
+
- Basic hidden
|
106
106
|
response:
|
107
107
|
status:
|
108
108
|
code: 202
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
Authorization:
|
15
|
-
- Basic
|
15
|
+
- Basic hidden
|
16
16
|
response:
|
17
17
|
status:
|
18
18
|
code: 200
|
@@ -51,7 +51,7 @@ http_interactions:
|
|
51
51
|
Content-Type:
|
52
52
|
- application/json
|
53
53
|
Authorization:
|
54
|
-
- Basic
|
54
|
+
- Basic hidden
|
55
55
|
response:
|
56
56
|
status:
|
57
57
|
code: 200
|
@@ -102,7 +102,7 @@ http_interactions:
|
|
102
102
|
Content-Type:
|
103
103
|
- application/json
|
104
104
|
Authorization:
|
105
|
-
- Basic
|
105
|
+
- Basic hidden
|
106
106
|
response:
|
107
107
|
status:
|
108
108
|
code: 202
|
@@ -12,7 +12,7 @@ http_interactions:
|
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
Authorization:
|
15
|
-
- Basic
|
15
|
+
- Basic hidden
|
16
16
|
response:
|
17
17
|
status:
|
18
18
|
code: 201
|
@@ -63,7 +63,7 @@ http_interactions:
|
|
63
63
|
Content-Type:
|
64
64
|
- application/json
|
65
65
|
Authorization:
|
66
|
-
- Basic
|
66
|
+
- Basic hidden
|
67
67
|
response:
|
68
68
|
status:
|
69
69
|
code: 201
|
@@ -113,7 +113,7 @@ http_interactions:
|
|
113
113
|
Content-Type:
|
114
114
|
- application/json
|
115
115
|
Authorization:
|
116
|
-
- Basic
|
116
|
+
- Basic hidden
|
117
117
|
response:
|
118
118
|
status:
|
119
119
|
code: 201
|
@@ -162,7 +162,7 @@ http_interactions:
|
|
162
162
|
Content-Type:
|
163
163
|
- application/json
|
164
164
|
Authorization:
|
165
|
-
- Basic
|
165
|
+
- Basic hidden
|
166
166
|
response:
|
167
167
|
status:
|
168
168
|
code: 201
|
@@ -209,7 +209,7 @@ http_interactions:
|
|
209
209
|
User-Agent:
|
210
210
|
- Faraday v0.9.2
|
211
211
|
Authorization:
|
212
|
-
- Basic
|
212
|
+
- Basic hidden
|
213
213
|
response:
|
214
214
|
status:
|
215
215
|
code: 204
|
data/lib/chartmogul.rb
CHANGED
@@ -53,6 +53,7 @@ require 'chartmogul/ping'
|
|
53
53
|
require 'chartmogul/plan'
|
54
54
|
require 'chartmogul/plan_group'
|
55
55
|
require 'chartmogul/plan_groups/plans'
|
56
|
+
require 'chartmogul/account'
|
56
57
|
|
57
58
|
require 'chartmogul/metrics/arpa'
|
58
59
|
require 'chartmogul/metrics/arr'
|
@@ -78,10 +79,14 @@ module ChartMogul
|
|
78
79
|
class << self
|
79
80
|
extend ConfigAttributes
|
80
81
|
|
82
|
+
def global_config
|
83
|
+
@global_config ||= ChartMogul::Configuration.new
|
84
|
+
end
|
81
85
|
|
86
|
+
# This configuration is thread-safe and fits multi-account async
|
87
|
+
# jobs processing use case.
|
82
88
|
def config
|
83
|
-
Thread.current[CONFIG_THREAD_KEY]
|
84
|
-
Thread.current[CONFIG_THREAD_KEY]
|
89
|
+
Thread.current[CONFIG_THREAD_KEY] ||= ChartMogul::Configuration.new
|
85
90
|
end
|
86
91
|
|
87
92
|
config_accessor :account_token
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ChartMogul
|
4
|
+
class Account < APIResource
|
5
|
+
set_resource_name 'Account'
|
6
|
+
set_resource_path '/v1/account'
|
7
|
+
|
8
|
+
readonly_attr :name
|
9
|
+
readonly_attr :currency
|
10
|
+
readonly_attr :time_zone
|
11
|
+
readonly_attr :week_start_on
|
12
|
+
|
13
|
+
include API::Actions::Custom
|
14
|
+
|
15
|
+
def self.retrieve
|
16
|
+
custom!(:get, '/v1/account')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -15,7 +15,8 @@ module ChartMogul
|
|
15
15
|
req.headers['Content-Type'] = 'application/json'
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
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
|
@@ -15,7 +15,7 @@ module ChartMogul
|
|
15
15
|
req.body = JSON.dump(serialize_for_write)
|
16
16
|
end
|
17
17
|
end
|
18
|
-
json = ChartMogul::Utils::JSONParser.parse(resp.body,
|
18
|
+
json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: self.class.immutable_keys)
|
19
19
|
|
20
20
|
assign_all_attributes(json)
|
21
21
|
end
|
@@ -30,7 +30,7 @@ module ChartMogul
|
|
30
30
|
req.body = JSON.dump(resource.serialize_for_write)
|
31
31
|
end
|
32
32
|
end
|
33
|
-
json = ChartMogul::Utils::JSONParser.parse(resp.body,
|
33
|
+
json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: immutable_keys)
|
34
34
|
|
35
35
|
new_from_json(json)
|
36
36
|
end
|
@@ -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,
|
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
|
-
|
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,
|
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,
|
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
|
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
|
-
|
35
|
-
|
36
|
-
|
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
|
@@ -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
|
data/lib/chartmogul/customer.rb
CHANGED
@@ -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
|
-
|
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
|
@@ -12,6 +12,7 @@ module ChartMogul
|
|
12
12
|
readonly_attr :activity_mrr_movement
|
13
13
|
readonly_attr :currency
|
14
14
|
readonly_attr :currency_sign
|
15
|
+
readonly_attr :subscription_external_id
|
15
16
|
|
16
17
|
def self.all(customer_uuid, options = {})
|
17
18
|
ChartMogul::Metrics::Activities.all(customer_uuid, options)
|