chartmogul-ruby 2.1.0 → 3.0.2

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -1
  3. data/.rspec +0 -0
  4. data/README.md +4 -6
  5. data/changelog.md +13 -0
  6. data/chartmogul-ruby.gemspec +6 -0
  7. data/fixtures/vcr_cassettes/ChartMogul_Metrics_ARPA/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  8. data/fixtures/vcr_cassettes/ChartMogul_Metrics_ARR/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  9. data/fixtures/vcr_cassettes/ChartMogul_Metrics_ASP/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  10. data/fixtures/vcr_cassettes/ChartMogul_Metrics_AllKeyMetric/should_have_entries.yml +1 -1
  11. data/fixtures/vcr_cassettes/ChartMogul_Metrics_AllKeyMetric/should_have_summary.yml +42 -0
  12. data/fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  13. data/fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerCount/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  14. data/fixtures/vcr_cassettes/ChartMogul_Metrics_LTV/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  15. data/fixtures/vcr_cassettes/ChartMogul_Metrics_MRR/should_have_entries.yml +1 -1
  16. data/fixtures/vcr_cassettes/ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml +1 -1
  17. data/fixtures/vcr_cassettes/ChartMogul_SubscriptionEvent/API_interactions/creates_a_new_subscription_event.yml +320 -0
  18. data/fixtures/vcr_cassettes/ChartMogul_SubscriptionEvent/API_interactions/deletes_the_subscription_event.yml +377 -0
  19. data/fixtures/vcr_cassettes/ChartMogul_SubscriptionEvent/API_interactions/lists_all_subscription_events.yml +320 -0
  20. data/fixtures/vcr_cassettes/ChartMogul_SubscriptionEvent/API_interactions/updates_the_subscription_event.yml +377 -0
  21. data/lib/chartmogul/api/actions/destroy_with_params.rb +29 -0
  22. data/lib/chartmogul/api_resource.rb +2 -2
  23. data/lib/chartmogul/concerns/summary_all.rb +21 -0
  24. data/lib/chartmogul/configuration.rb +1 -2
  25. data/lib/chartmogul/line_items/one_time.rb +4 -1
  26. data/lib/chartmogul/line_items/subscription.rb +3 -0
  27. data/lib/chartmogul/metrics/all_key_metrics.rb +9 -0
  28. data/lib/chartmogul/metrics/arpa.rb +1 -0
  29. data/lib/chartmogul/metrics/arr.rb +1 -0
  30. data/lib/chartmogul/metrics/asp.rb +1 -0
  31. data/lib/chartmogul/metrics/customer_churn_rate.rb +1 -0
  32. data/lib/chartmogul/metrics/customer_count.rb +1 -0
  33. data/lib/chartmogul/metrics/ltv.rb +1 -0
  34. data/lib/chartmogul/metrics/mrr.rb +1 -0
  35. data/lib/chartmogul/metrics/mrr_churn_rate.rb +1 -0
  36. data/lib/chartmogul/subscription_event.rb +62 -0
  37. data/lib/chartmogul/summary_all.rb +30 -0
  38. data/lib/chartmogul/version.rb +1 -1
  39. data/lib/chartmogul.rb +5 -2
  40. data/pre-commit.example +0 -0
  41. metadata +19 -5
@@ -0,0 +1,377 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.chartmogul.com/v1/data_sources
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"name":"Subscription Events Test ds_update"}'
9
+ headers:
10
+ User-Agent:
11
+ - chartmogul-ruby/3.0.0
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic hidden
16
+ response:
17
+ status:
18
+ code: 201
19
+ message: Created
20
+ headers:
21
+ access-control-allow-credentials:
22
+ - 'true'
23
+ content-type:
24
+ - application/json
25
+ date:
26
+ - Fri, 27 May 2022 21:54:17 GMT
27
+ status:
28
+ - 201 Created
29
+ content-length:
30
+ - '172'
31
+ connection:
32
+ - keep-alive
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"uuid":"ds_8e206f5e-de07-11ec-8815-7b519b46d260","name":"Subscription
36
+ Events Test ds_update","system":"Import API","created_at":"2022-05-27T21:54:17.215Z","status":"idle"}'
37
+ http_version:
38
+ recorded_at: Fri, 27 May 2022 21:54:17 GMT
39
+ - request:
40
+ method: post
41
+ uri: https://api.chartmogul.com/v1/customers
42
+ body:
43
+ encoding: UTF-8
44
+ string: '{"external_id":"test_cus_ext_id","name":"Test Customer","data_source_uuid":"ds_8e206f5e-de07-11ec-8815-7b519b46d260"}'
45
+ headers:
46
+ User-Agent:
47
+ - chartmogul-ruby/3.0.0
48
+ Content-Type:
49
+ - application/json
50
+ Authorization:
51
+ - Basic hidden
52
+ response:
53
+ status:
54
+ code: 201
55
+ message: Created
56
+ headers:
57
+ access-control-allow-credentials:
58
+ - 'true'
59
+ content-type:
60
+ - application/json
61
+ date:
62
+ - Fri, 27 May 2022 21:54:17 GMT
63
+ status:
64
+ - 201 Created
65
+ content-length:
66
+ - '772'
67
+ connection:
68
+ - keep-alive
69
+ body:
70
+ encoding: UTF-8
71
+ string: '{"id":131944260,"uuid":"cus_8e5f5b06-de07-11ec-bf8c-e3f6cf4804ac","external_id":"test_cus_ext_id","name":"Test
72
+ Customer","email":"","status":"Lead","customer-since":null,"attributes":{"custom":{},"clearbit":{},"stripe":{},"tags":[]},"data_source_uuid":"ds_8e206f5e-de07-11ec-8815-7b519b46d260","data_source_uuids":["ds_8e206f5e-de07-11ec-8815-7b519b46d260"],"external_ids":["test_cus_ext_id"],"company":"","country":null,"state":null,"city":"","zip":null,"lead_created_at":null,"free_trial_started_at":null,"address":{"country":null,"state":null,"city":"","address_zip":null},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#/customers/131944260-Test_Customer","billing-system-type":"Import
73
+ API","currency":"USD","currency-sign":"$"}'
74
+ http_version:
75
+ recorded_at: Fri, 27 May 2022 21:54:17 GMT
76
+ - request:
77
+ method: post
78
+ uri: https://api.chartmogul.com/v1/plans
79
+ body:
80
+ encoding: UTF-8
81
+ string: '{"name":"Test Plan1","interval_count":7,"interval_unit":"day","data_source_uuid":"ds_8e206f5e-de07-11ec-8815-7b519b46d260"}'
82
+ headers:
83
+ User-Agent:
84
+ - chartmogul-ruby/3.0.0
85
+ Content-Type:
86
+ - application/json
87
+ Authorization:
88
+ - Basic hidden
89
+ response:
90
+ status:
91
+ code: 201
92
+ message: Created
93
+ headers:
94
+ access-control-allow-credentials:
95
+ - 'true'
96
+ cache-control:
97
+ - max-age=0, private, must-revalidate
98
+ content-type:
99
+ - application/json; charset=utf-8
100
+ date:
101
+ - Fri, 27 May 2022 21:54:18 GMT
102
+ etag:
103
+ - W/"48a3a10d72b78dec8060fa5517045a31"
104
+ referrer-policy:
105
+ - strict-origin-when-cross-origin
106
+ status:
107
+ - 201 Created
108
+ x-content-type-options:
109
+ - nosniff
110
+ x-download-options:
111
+ - noopen
112
+ x-frame-options:
113
+ - DENY
114
+ x-permitted-cross-domain-policies:
115
+ - none
116
+ x-request-id:
117
+ - daa8ab3a17de0a3a3b9d5285e57964c6
118
+ x-runtime:
119
+ - '0.043259'
120
+ x-xss-protection:
121
+ - 1; mode=block
122
+ content-length:
123
+ - '225'
124
+ connection:
125
+ - keep-alive
126
+ body:
127
+ encoding: UTF-8
128
+ string: '{"external_id":"7b1fc3a0-c035-013a-2b32-2ae6b33040d8","name":"Test
129
+ Plan1","interval_count":7,"interval_unit":"day","data_source_uuid":"ds_8e206f5e-de07-11ec-8815-7b519b46d260","uuid":"pl_7b1fc3a0-c035-013a-2b32-2ae6b33040d8"}'
130
+ http_version:
131
+ recorded_at: Fri, 27 May 2022 21:54:18 GMT
132
+ - request:
133
+ method: post
134
+ uri: https://api.chartmogul.com/v1/subscription_events
135
+ body:
136
+ encoding: UTF-8
137
+ string: '{"subscription_event":{"id":null,"data_source_uuid":"ds_8e206f5e-de07-11ec-8815-7b519b46d260","customer_external_id":"test_cus_ext_id","subscription_set_external_id":"","subscription_external_id":"test_cus_sub_ext_id1","plan_external_id":"","event_date":"2022-05-18T09:48:34Z","effective_date":"2021-12-30T00:01:00Z","event_type":"subscription_cancelled","external_id":"test_ev_id_update_1","errors":null,"created_at":null,"updated_at":null,"quantity":"","currency":"","amount_in_cents":"","tax_amount_in_cents":null,"retracted_event_id":null}}'
138
+ headers:
139
+ User-Agent:
140
+ - chartmogul-ruby/3.0.0
141
+ Content-Type:
142
+ - application/json
143
+ Authorization:
144
+ - Basic hidden
145
+ response:
146
+ status:
147
+ code: 201
148
+ message: Created
149
+ headers:
150
+ access-control-allow-credentials:
151
+ - 'true'
152
+ cache-control:
153
+ - max-age=0, private, must-revalidate
154
+ content-type:
155
+ - application/json; charset=utf-8
156
+ date:
157
+ - Fri, 27 May 2022 21:54:18 GMT
158
+ etag:
159
+ - W/"a0199d2ce12eef4fc0a5abfe03e28a41"
160
+ referrer-policy:
161
+ - strict-origin-when-cross-origin
162
+ status:
163
+ - 201 Created
164
+ x-content-type-options:
165
+ - nosniff
166
+ x-download-options:
167
+ - noopen
168
+ x-frame-options:
169
+ - DENY
170
+ x-permitted-cross-domain-policies:
171
+ - none
172
+ x-request-id:
173
+ - a3c959e856dd2c84a3c160428ef97a31
174
+ x-runtime:
175
+ - '0.039881'
176
+ x-xss-protection:
177
+ - 1; mode=block
178
+ content-length:
179
+ - '560'
180
+ connection:
181
+ - keep-alive
182
+ body:
183
+ encoding: UTF-8
184
+ string: '{"id":138979498,"data_source_uuid":"ds_8e206f5e-de07-11ec-8815-7b519b46d260","customer_external_id":"test_cus_ext_id","subscription_set_external_id":"","subscription_external_id":"test_cus_sub_ext_id1","plan_external_id":"","event_date":"2022-05-18T09:48:34Z","effective_date":"2021-12-30T00:01:00Z","event_type":"subscription_cancelled","external_id":"test_ev_id_update_1","errors":{},"created_at":"2022-05-27T21:54:18Z","updated_at":"2022-05-27T21:54:18Z","quantity":"","currency":"","amount_in_cents":"","tax_amount_in_cents":null,"retracted_event_id":null}'
185
+ http_version:
186
+ recorded_at: Fri, 27 May 2022 21:54:18 GMT
187
+ - request:
188
+ method: patch
189
+ uri: https://api.chartmogul.com/v1/subscription_events
190
+ body:
191
+ encoding: UTF-8
192
+ string: '{"subscription_event":{"external_id":"test_ev_id_update_2","id":138979498}}'
193
+ headers:
194
+ User-Agent:
195
+ - chartmogul-ruby/3.0.0
196
+ Content-Type:
197
+ - application/json
198
+ Authorization:
199
+ - Basic hidden
200
+ response:
201
+ status:
202
+ code: 200
203
+ message: OK
204
+ headers:
205
+ access-control-allow-credentials:
206
+ - 'true'
207
+ cache-control:
208
+ - max-age=0, private, must-revalidate
209
+ content-type:
210
+ - application/json; charset=utf-8
211
+ date:
212
+ - Fri, 27 May 2022 21:54:18 GMT
213
+ etag:
214
+ - W/"63531fd647f063a29d241a2ed4e9287a"
215
+ referrer-policy:
216
+ - strict-origin-when-cross-origin
217
+ status:
218
+ - 200 OK
219
+ vary:
220
+ - Accept-Encoding, Accept-Encoding
221
+ x-content-type-options:
222
+ - nosniff
223
+ x-download-options:
224
+ - noopen
225
+ x-frame-options:
226
+ - DENY
227
+ x-permitted-cross-domain-policies:
228
+ - none
229
+ x-request-id:
230
+ - 9e95374a6e8b5c5843fb3a2b9cbd9d5c
231
+ x-runtime:
232
+ - '0.049703'
233
+ x-xss-protection:
234
+ - 1; mode=block
235
+ content-length:
236
+ - '305'
237
+ connection:
238
+ - keep-alive
239
+ body:
240
+ encoding: ASCII-8BIT
241
+ string: '{"id":138979498,"data_source_uuid":"ds_8e206f5e-de07-11ec-8815-7b519b46d260","customer_external_id":"test_cus_ext_id","subscription_set_external_id":"","subscription_external_id":"test_cus_sub_ext_id1","plan_external_id":"","event_date":"2022-05-18T09:48:34Z","effective_date":"2021-12-30T00:01:00Z","event_type":"subscription_cancelled","external_id":"test_ev_id_update_2","errors":{},"created_at":"2022-05-27T21:54:18Z","updated_at":"2022-05-27T21:54:18Z","quantity":"","currency":"","amount_in_cents":"","tax_amount_in_cents":null,"retracted_event_id":null}'
242
+ http_version:
243
+ recorded_at: Fri, 27 May 2022 21:54:18 GMT
244
+ - request:
245
+ method: get
246
+ uri: https://api.chartmogul.com/v1/subscription_events?data_source_uuid=ds_8e206f5e-de07-11ec-8815-7b519b46d260
247
+ body:
248
+ encoding: US-ASCII
249
+ string: ''
250
+ headers:
251
+ User-Agent:
252
+ - chartmogul-ruby/3.0.0
253
+ Content-Type:
254
+ - application/json
255
+ Authorization:
256
+ - Basic hidden
257
+ response:
258
+ status:
259
+ code: 200
260
+ message: OK
261
+ headers:
262
+ access-control-allow-credentials:
263
+ - 'true'
264
+ cache-control:
265
+ - max-age=0, private, must-revalidate
266
+ content-type:
267
+ - application/json; charset=utf-8
268
+ date:
269
+ - Fri, 27 May 2022 21:54:19 GMT
270
+ etag:
271
+ - W/"993c2837a0d8cc9bf8c71ace5d08133d"
272
+ referrer-policy:
273
+ - strict-origin-when-cross-origin
274
+ status:
275
+ - 200 OK
276
+ vary:
277
+ - Accept-Encoding, Accept-Encoding
278
+ x-content-type-options:
279
+ - nosniff
280
+ x-download-options:
281
+ - noopen
282
+ x-frame-options:
283
+ - DENY
284
+ x-permitted-cross-domain-policies:
285
+ - none
286
+ x-request-id:
287
+ - 5a970a6116d23f9a5862192529f8fe70
288
+ x-runtime:
289
+ - '0.025956'
290
+ x-xss-protection:
291
+ - 1; mode=block
292
+ content-length:
293
+ - '370'
294
+ connection:
295
+ - keep-alive
296
+ body:
297
+ encoding: ASCII-8BIT
298
+ string: '{"subscription_events":[{"id":138979498,"data_source_uuid":"ds_8e206f5e-de07-11ec-8815-7b519b46d260","customer_external_id":"test_cus_ext_id","subscription_set_external_id":"","subscription_external_id":"test_cus_sub_ext_id1","plan_external_id":"","event_date":"2022-05-18T09:48:34Z","effective_date":"2021-12-30T00:01:00Z","event_type":"subscription_cancelled","external_id":"test_ev_id_update_2","errors":{},"created_at":"2022-05-27T21:54:18Z","updated_at":"2022-05-27T21:54:18Z","quantity":"","currency":"","amount_in_cents":"","tax_amount_in_cents":null,"retracted_event_id":null}],"meta":{"next_key":null,"prev_key":null,"before_key":"2022-05-27T21:54:19.186Z","page":1,"total_pages":1}}'
299
+ http_version:
300
+ recorded_at: Fri, 27 May 2022 21:54:19 GMT
301
+ - request:
302
+ method: delete
303
+ uri: https://api.chartmogul.com/v1/subscription_events?subscription_event%5Bid%5D=138979498
304
+ body:
305
+ encoding: US-ASCII
306
+ string: ''
307
+ headers:
308
+ User-Agent:
309
+ - chartmogul-ruby/3.0.0
310
+ Authorization:
311
+ - Basic hidden
312
+ response:
313
+ status:
314
+ code: 204
315
+ message: No Content
316
+ headers:
317
+ access-control-allow-credentials:
318
+ - 'true'
319
+ cache-control:
320
+ - no-cache
321
+ date:
322
+ - Fri, 27 May 2022 21:54:19 GMT
323
+ referrer-policy:
324
+ - strict-origin-when-cross-origin
325
+ status:
326
+ - 204 No Content
327
+ x-content-type-options:
328
+ - nosniff
329
+ x-download-options:
330
+ - noopen
331
+ x-frame-options:
332
+ - DENY
333
+ x-permitted-cross-domain-policies:
334
+ - none
335
+ x-request-id:
336
+ - 466c85b83831cd5366f4dba5697e605b
337
+ x-runtime:
338
+ - '0.034773'
339
+ x-xss-protection:
340
+ - 1; mode=block
341
+ connection:
342
+ - keep-alive
343
+ body:
344
+ encoding: UTF-8
345
+ string: ''
346
+ http_version:
347
+ recorded_at: Fri, 27 May 2022 21:54:19 GMT
348
+ - request:
349
+ method: delete
350
+ uri: https://api.chartmogul.com/v1/data_sources/ds_8e206f5e-de07-11ec-8815-7b519b46d260
351
+ body:
352
+ encoding: US-ASCII
353
+ string: ''
354
+ headers:
355
+ User-Agent:
356
+ - chartmogul-ruby/3.0.0
357
+ Authorization:
358
+ - Basic hidden
359
+ response:
360
+ status:
361
+ code: 204
362
+ message: No Content
363
+ headers:
364
+ access-control-allow-credentials:
365
+ - 'true'
366
+ date:
367
+ - Fri, 27 May 2022 21:54:20 GMT
368
+ status:
369
+ - 204 No Content
370
+ connection:
371
+ - keep-alive
372
+ body:
373
+ encoding: UTF-8
374
+ string: ''
375
+ http_version:
376
+ recorded_at: Fri, 27 May 2022 21:54:19 GMT
377
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChartMogul
4
+ module API
5
+ module Actions
6
+ module DestroyWithParams
7
+ def self.included(base)
8
+ base.extend ClassMethods
9
+ end
10
+
11
+ def destroy_with_params!
12
+ handling_errors do
13
+ connection.delete(resource_path.path, instance_attributes)
14
+ end
15
+ true
16
+ end
17
+
18
+ module ClassMethods
19
+ def destroy_with_params!(options = {})
20
+ handling_errors do
21
+ connection.delete(resource_path.path, options)
22
+ end
23
+ true
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -89,8 +89,8 @@ module ChartMogul
89
89
  private
90
90
 
91
91
  def self.build_connection
92
- Faraday.new(url: ChartMogul.api_base) do |faraday|
93
- faraday.use Faraday::Request::BasicAuthentication, ChartMogul.account_token, ChartMogul.secret_key
92
+ Faraday.new(url: ChartMogul.api_base, headers: { 'User-Agent' => "chartmogul-ruby/#{ChartMogul::VERSION}" }) do |faraday|
93
+ faraday.use Faraday::Request::BasicAuthentication, ChartMogul.api_key, ''
94
94
  faraday.use Faraday::Response::RaiseError
95
95
  faraday.request :retry, max: ChartMogul.max_retries, retry_statuses: RETRY_STATUSES,
96
96
  max_interval: MAX_INTERVAL, backoff_factor: BACKOFF_FACTOR,
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChartMogul
4
+ module Concerns
5
+ module SummaryAll
6
+ def self.included(base)
7
+ base.send :prepend, InstanceMethods
8
+
9
+ base.instance_eval do
10
+ readonly_attr :summary
11
+ end
12
+ end
13
+
14
+ module InstanceMethods
15
+ def set_summary(summary_attributes)
16
+ @summary = ChartMogul::SummaryAll.new_from_json(summary_attributes)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -2,8 +2,7 @@
2
2
 
3
3
  module ChartMogul
4
4
  class Configuration
5
- attr_accessor :account_token
6
- attr_accessor :secret_key
5
+ attr_accessor :api_key
7
6
  attr_accessor :max_retries
8
7
  attr_accessor :api_base
9
8
  end
@@ -14,8 +14,11 @@ module ChartMogul
14
14
  writeable_attr :tax_amount_in_cents
15
15
  writeable_attr :transaction_fees_in_cents
16
16
  writeable_attr :external_id
17
- writeable_attr :plan_uuid
17
+ writeable_attr :transaction_fees_currency
18
+ writeable_attr :discount_description
19
+ writeable_attr :event_order
18
20
 
21
+ writeable_attr :plan_uuid
19
22
  writeable_attr :invoice_uuid
20
23
 
21
24
  def initialize(attributes = {})
@@ -19,6 +19,9 @@ module ChartMogul
19
19
  writeable_attr :transaction_fees_in_cents
20
20
  writeable_attr :external_id
21
21
  writeable_attr :subscription_set_external_id
22
+ writeable_attr :transaction_fees_currency
23
+ writeable_attr :discount_description
24
+ writeable_attr :event_order
22
25
 
23
26
  readonly_attr :subscription_uuid
24
27
  writeable_attr :invoice_uuid
@@ -12,6 +12,14 @@ module ChartMogul
12
12
  readonly_attr :ltv
13
13
  readonly_attr :mrr
14
14
  readonly_attr :mrr_churn_rate
15
+ readonly_attr :arpa_percentage_change
16
+ readonly_attr :arr_percentage_change
17
+ readonly_attr :asp_percentage_change
18
+ readonly_attr :customer_churn_rate_percentage_change
19
+ readonly_attr :customers_percentage_change
20
+ readonly_attr :ltv_percentage_change
21
+ readonly_attr :mrr_percentage_change
22
+ readonly_attr :mrr_churn_rate_percentage_change
15
23
  end
16
24
 
17
25
  class AllKeyMetrics < APIResource
@@ -19,6 +27,7 @@ module ChartMogul
19
27
  set_resource_path '/v1/metrics/all'
20
28
 
21
29
  include Concerns::Entries
30
+ include Concerns::SummaryAll
22
31
 
23
32
  set_entry_class AllKeyMetric
24
33
  end
@@ -5,6 +5,7 @@ module ChartMogul
5
5
  class ARPA < ChartMogul::Object
6
6
  readonly_attr :date, type: :date
7
7
  readonly_attr :arpa
8
+ readonly_attr :percentage_change
8
9
  end
9
10
 
10
11
  class ARPAs < APIResource
@@ -5,6 +5,7 @@ module ChartMogul
5
5
  class ARR < ChartMogul::Object
6
6
  readonly_attr :date, type: :date
7
7
  readonly_attr :arr
8
+ readonly_attr :percentage_change
8
9
  end
9
10
 
10
11
  class ARRs < APIResource
@@ -5,6 +5,7 @@ module ChartMogul
5
5
  class ASP < ChartMogul::Object
6
6
  readonly_attr :date, type: :date
7
7
  readonly_attr :asp
8
+ readonly_attr :percentage_change
8
9
  end
9
10
 
10
11
  class ASPs < APIResource
@@ -5,6 +5,7 @@ module ChartMogul
5
5
  class CustomerChurnRate < ChartMogul::Object
6
6
  readonly_attr :date, type: :date
7
7
  readonly_attr :customer_churn_rate
8
+ readonly_attr :percentage_change
8
9
  end
9
10
 
10
11
  class CustomerChurnRates < APIResource
@@ -5,6 +5,7 @@ module ChartMogul
5
5
  class CustomerCount < ChartMogul::Object
6
6
  readonly_attr :date, type: :date
7
7
  readonly_attr :customers
8
+ readonly_attr :percentage_change
8
9
  end
9
10
 
10
11
  class CustomerCounts < APIResource
@@ -5,6 +5,7 @@ module ChartMogul
5
5
  class LTV < ChartMogul::Object
6
6
  readonly_attr :date, type: :date
7
7
  readonly_attr :ltv
8
+ readonly_attr :percentage_change
8
9
  end
9
10
 
10
11
  class LTVs < APIResource
@@ -13,6 +13,7 @@ module ChartMogul
13
13
 
14
14
  readonly_attr :mrr_churn
15
15
  readonly_attr :mrr_reactivation
16
+ readonly_attr :percentage_change
16
17
  end
17
18
 
18
19
  class MRRs < APIResource
@@ -5,6 +5,7 @@ module ChartMogul
5
5
  class MRRChurnRate < ChartMogul::Object
6
6
  readonly_attr :date, type: :date
7
7
  readonly_attr :mrr_churn_rate
8
+ readonly_attr :percentage_change
8
9
  end
9
10
 
10
11
  class MRRChurnRates < APIResource
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChartMogul
4
+ class SubscriptionEvent < APIResource
5
+ set_resource_name 'SubscriptionEvent'
6
+ set_resource_path '/v1/subscription_events'
7
+
8
+ readonly_attr :id
9
+ writeable_attr :data_source_uuid
10
+ writeable_attr :customer_external_id
11
+ writeable_attr :subscription_set_external_id
12
+ writeable_attr :subscription_external_id
13
+ writeable_attr :plan_external_id
14
+ writeable_attr :event_date
15
+ writeable_attr :effective_date
16
+ writeable_attr :event_type
17
+ writeable_attr :external_id
18
+ readonly_attr :errors
19
+ readonly_attr :created_at
20
+ readonly_attr :updated_at
21
+ writeable_attr :quantity
22
+ writeable_attr :currency
23
+ writeable_attr :amount_in_cents
24
+ writeable_attr :tax_amount_in_cents
25
+ writeable_attr :retracted_event_id
26
+
27
+ include API::Actions::Custom
28
+ include API::Actions::DestroyWithParams
29
+
30
+ def self.all(options = {})
31
+ SubscriptionEvents.all(options)
32
+ end
33
+
34
+ def create!
35
+ custom!(:post, resource_path.path, subscription_event: instance_attributes)
36
+ end
37
+
38
+ def update!(attrs)
39
+ custom!(:patch, resource_path.path, subscription_event: attrs.merge(id: instance_attributes[:id]))
40
+ end
41
+
42
+ def destroy!
43
+ handling_errors do
44
+ connection.delete(resource_path.path, subscription_event: { id: instance_attributes[:id] })
45
+ end
46
+ end
47
+ end
48
+
49
+ class SubscriptionEvents < APIResource
50
+ set_resource_name 'SubscriptionEvents'
51
+ set_resource_path '/v1/subscription_events'
52
+
53
+ set_resource_root_key :subscription_events
54
+
55
+ writeable_attr :meta
56
+
57
+ include API::Actions::All
58
+ include Concerns::Entries
59
+
60
+ set_entry_class SubscriptionEvent
61
+ end
62
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChartMogul
4
+ class SummaryAll < ChartMogul::Object
5
+ readonly_attr :current_arpa
6
+ readonly_attr :current_arr
7
+ readonly_attr :current_asp
8
+ readonly_attr :current_customer_churn_rate
9
+ readonly_attr :current_customers
10
+ readonly_attr :current_ltv
11
+ readonly_attr :current_mrr
12
+ readonly_attr :current_mrr_churn_rate
13
+ readonly_attr :previous_arpa
14
+ readonly_attr :previous_arr
15
+ readonly_attr :previous_asp
16
+ readonly_attr :previous_customer_churn_rate
17
+ readonly_attr :previous_customers
18
+ readonly_attr :previous_ltv
19
+ readonly_attr :previous_mrr
20
+ readonly_attr :previous_mrr_churn_rate
21
+ readonly_attr :arpa_percentage_change
22
+ readonly_attr :arr_percentage_change
23
+ readonly_attr :asp_percentage_change
24
+ readonly_attr :customer_churn_rate_percentage_change
25
+ readonly_attr :customers_percentage_change
26
+ readonly_attr :ltv_percentage_change
27
+ readonly_attr :mrr_percentage_change
28
+ readonly_attr :mrr_churn_rate_percentage_change
29
+ end
30
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChartMogul
4
- VERSION = '2.1.0'
4
+ VERSION = '3.0.2'
5
5
  end