chartmogul-ruby 1.7.2 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) 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 +10 -0
  6. data/chartmogul-ruby.gemspec +7 -1
  7. data/fixtures/vcr_cassettes/ChartMogul_Metrics_ActivitiesExport/get_activities_export.yml +43 -0
  8. data/fixtures/vcr_cassettes/ChartMogul_Metrics_ActivitiesExport/post_activities_export.yml +83 -0
  9. data/fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/behaves_like_PageableWithAnchor/should_be_pageable.yml +44 -0
  10. data/fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/should_have_Activity_entries.yml +17 -14
  11. data/fixtures/vcr_cassettes/ChartMogul_Metrics_Activity.yml +37 -0
  12. data/fixtures/vcr_cassettes/{ChartMogul_Metrics_Activity → ChartMogul_Metrics_Customers_Activity}/behaves_like_Pageable/should_be_pageable.yml +0 -0
  13. data/fixtures/vcr_cassettes/ChartMogul_Metrics_Customers_Activity/should_have_Activity_entries.yml +41 -0
  14. data/fixtures/vcr_cassettes/{ChartMogul_Metrics_Subscription → ChartMogul_Metrics_Customers_Subscription}/behaves_like_Pageable/should_be_pageable.yml +0 -0
  15. data/fixtures/vcr_cassettes/{ChartMogul_Metrics_Subscription → ChartMogul_Metrics_Customers_Subscription}/should_have_Subscription_entries.yml +0 -0
  16. data/lib/chartmogul/concerns/pageable_with_anchor.rb +14 -0
  17. data/lib/chartmogul/config_attributes.rb +17 -1
  18. data/lib/chartmogul/line_items/one_time.rb +4 -1
  19. data/lib/chartmogul/line_items/subscription.rb +3 -0
  20. data/lib/chartmogul/metrics/activities_export.rb +38 -0
  21. data/lib/chartmogul/metrics/activity.rb +12 -8
  22. data/lib/chartmogul/metrics/customers/activity.rb +38 -0
  23. data/lib/chartmogul/metrics/customers/subscription.rb +41 -0
  24. data/lib/chartmogul/version.rb +1 -1
  25. data/lib/chartmogul.rb +10 -3
  26. metadata +27 -13
  27. data/.travis.yml +0 -25
  28. data/lib/chartmogul/metrics/subscription.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5381b67c739d176db4a06bb7bda534885bd370253fcbae18c090196183cd37c4
4
- data.tar.gz: 3b64a66d45d6a890b826d8eb7fd7baa8d9bb9fa942c42eda07dab1496a8e3f49
3
+ metadata.gz: 40f19685adcb71589c00b1fb49b10d174dc75918beaf90b8b57663820d77ea58
4
+ data.tar.gz: 2cca1ff4273f7ae537837260b683f25873bb72dc23beb260cef88fe6be2fa922
5
5
  SHA512:
6
- metadata.gz: 2f97167bbf6aaa21ae83003c073ed3a5fc69fcb8a81eebc105f7b16c6cf85dd2e775a97842a6fa050ca4311c316617c8a74af3b06feb67f60b043e2fb5a6f0eb
7
- data.tar.gz: 7d82814b322e62b04baa2b4b4b44b7b516cebbca04e3540c7eb6b68d05c2267db0fdf8f483238efe10230de6790397d7af1a3a0fa22fe1e87f01aa57a23f0c4d
6
+ metadata.gz: b0f481312ddcc98a3db16e3ce30e763b82d81ca8a0d8bc82cf9567f0a5bb69f0f0149c4938277c8d8ae59440b4d58f346cc5c53c15718131e332fdcca214f52a
7
+ data.tar.gz: a865cae002eac8073ef58ff40937c32fa4f489e4f1f6fdde8c336dc016f0a80214d27c76ab5ada9dd3fc8fb51d1ded199c092d04f72e66e4ed5546f74875edb4
@@ -0,0 +1,44 @@
1
+ name: Run specs and generate Code Climate report
2
+ on:
3
+ push:
4
+ branches: [ main ]
5
+ pull_request:
6
+ branches: [ main ]
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ ruby-version: [2.3, 2.4, 2.5, 2.6, 2.7]
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Set up Ruby ${{ matrix.ruby-version }}
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: ${{ matrix.ruby-version }}
19
+ bundler-cache: true
20
+ - name: Install dependencies
21
+ run: bundle install
22
+ - name: Set ENV for codeclimate (pull_request)
23
+ run: |
24
+ git fetch --no-tags --prune --depth=1 origin +refs/heads/$GITHUB_HEAD_REF:refs/remotes/origin/$GITHUB_HEAD_REF
25
+ echo "GIT_BRANCH=$GITHUB_HEAD_REF" >> $GITHUB_ENV
26
+ echo "GIT_COMMIT_SHA=$(git rev-parse origin/$GITHUB_HEAD_REF)" >> $GITHUB_ENV
27
+ if: github.event_name == 'pull_request'
28
+ - name: Set ENV for codeclimate (push)
29
+ run: |
30
+ echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
31
+ echo "GIT_COMMIT_SHA=$GITHUB_SHA" >> $GITHUB_ENV
32
+ if: github.event_name == 'push'
33
+ - name: Install Code Climate test report
34
+ run: |
35
+ curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
36
+ chmod +x ./cc-test-reporter
37
+ ./cc-test-reporter before-build
38
+ - name: Run tests
39
+ run: bundle exec rake
40
+ - name: Send Report to Code Climate
41
+ env:
42
+ CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
43
+ if: ${{ success() }}
44
+ run: ./cc-test-reporter after-build
data/2.0-Upgrade.md ADDED
@@ -0,0 +1,9 @@
1
+ # Upgrading to chartmogul-ruby 2.0.0
2
+
3
+ The gem upgrade brings breaking changes to the Metrics API. All other APIs remain unaffected. Please note the following changes:
4
+
5
+ * If you used the Metrics API to get a customer's activities or subscriptions, make the following changes in the namespace
6
+ - `ChartMogul::Metrics::Activity.all('cus_58c7d166-3bd1-4c10-948e-e68bb0fa2478')` should be replaced with `ChartMogul::Metrics::Customers::Activity.all('cus_58c7d166-3bd1-4c10-948e-e68bb0fa2478')`
7
+ - `ChartMogul::Metrics::Subscription.all('cus_3f6f53d3-bca7-4fcd-ad47-345180ef329b')` should be replace with `ChartMogul::Metrics::Customers::Subscription.all('cus_3f6f53d3-bca7-4fcd-ad47-345180ef329b')`
8
+
9
+
data/README.md CHANGED
@@ -8,7 +8,6 @@
8
8
 
9
9
  <p align="center">
10
10
  <a href="https://badge.fury.io/rb/chartmogul-ruby"><img src="https://badge.fury.io/rb/chartmogul-ruby.svg" alt="Gem Version"></a>
11
- <a href="https://travis-ci.org/chartmogul/chartmogul-ruby"><img src="https://travis-ci.org/chartmogul/chartmogul-ruby.svg?branch=main" alt="Travis project"></a>
12
11
  <a href="https://codeclimate.com/github/chartmogul/chartmogul-ruby/test_coverage"><img src="https://api.codeclimate.com/v1/badges/40e8bdff4d1dbf2451de/test_coverage" /></a>
13
12
  </p>
14
13
 
@@ -53,13 +52,20 @@ This gem supports Ruby 2.3 and above.
53
52
  ## Configuration
54
53
 
55
54
  Configure `chartmogul-ruby` with your Account Token and Secret Key, available from the administration section of your ChartMogul account.
55
+ You can either do this in the global scope for the whole runtime (eg. in initializer):
56
56
 
57
+ ```ruby
58
+ ChartMogul.global_account_token = '<Account key goes here>'
59
+ ChartMogul.global_secret_key = '<Secret key goes here>'
60
+ ```
61
+
62
+ Or in a thread-safe scope for the current thread only (eg. different accounts in different async jobs):
57
63
  ```ruby
58
64
  ChartMogul.account_token = '<Account key goes here>'
59
65
  ChartMogul.secret_key = '<Secret key goes here>'
60
66
  ```
61
67
 
62
- Configuration is threadsafe and applied only to the current thread.
68
+ Thread-safe configuration is used if available, otherwise global is used.
63
69
 
64
70
  Test your authentication:
65
71
  ```ruby
data/changelog.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # chartmogul-ruby Change Log
2
2
 
3
+ ## Version 2.9.0 - 3 Nov 2021
4
+ - Adds post install message informing about authentication changes *& deprecation warning.
5
+
6
+ ## Version 2.1.0 - 9 July 2021
7
+ - Adds ChartMogul::Metrics::ActivitiesExport class to support async activities export endpoint
8
+
9
+ ## Version 2.0.0 - 25 June 2021
10
+ - Moves customer scoped Metrics::Activities and Metrics::Subscriptions under Metrics::Customers namespace
11
+ - Adds unscoped activities API endpoint
12
+
3
13
  ## Version 1.7.2 - 16 March 2021
4
14
  - Fix bug preventing instantiating attributes on ChartMogul::Customers objects
5
15
 
@@ -16,12 +16,18 @@ Gem::Specification.new do |spec|
16
16
  spec.license = 'MIT'
17
17
  spec.required_ruby_version = '>= 2.3'
18
18
 
19
+ spec.post_install_message = %q{
20
+ Starting October 29 2021, we are updating our developer libraries to support the enhanced API Access Management. Please use the same API Key for both API Token and Secret Key.
21
+ [Deprecation] - account_token/secret_key combo is deprecated. Please use API key for both fields.
22
+ Version 3.x will introduce a breaking change in authentication configuration. For more details, please visit: https://dev.chartmogul.com/docs/authentication
23
+ }
24
+
19
25
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
26
  spec.bindir = 'exe'
21
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
28
  spec.require_paths = ['lib']
23
29
 
24
- spec.add_dependency 'faraday', '~> 1.0.0'
30
+ spec.add_dependency 'faraday', '~> 1.0'
25
31
 
26
32
  spec.add_development_dependency 'bundler', '~> 2'
27
33
  spec.add_development_dependency 'pry', '~> 0.12.2'
@@ -0,0 +1,43 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.chartmogul.com/v1/activities_export/44037b8f-4a89-4fc6-8114-2288c71a9518
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v1.0.1
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic hidden
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ server:
22
+ - nginx/1.10.1
23
+ date:
24
+ - Fri, 09 Jul 2021 14:06:07 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - keep-alive
31
+ vary:
32
+ - Accept-Encoding, Accept-Encoding
33
+ status:
34
+ - 200 OK
35
+ access-control-allow-credentials:
36
+ - 'true'
37
+ body:
38
+ encoding: ASCII-8BIT
39
+ string: '{"id":"44037b8f-4a89-4fc6-8114-2288c71a9518","status":"succeeded","file_url":"https://chartmogul-customer-export.s3.eu-west-1.amazonaws.com/activities-acme-corp-062ea48c-5d74-46dd-bd60-23206cdc241a.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=123%2Feu-west-1%2Fs3%2Faws4_request\u0026X-Amz-Date=20210709T135547Z\u0026X-Amz-Expires=604800\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=abc","params":{"kind":"activities","params":{"end_date":"2020-12-31
40
+ 00:00:00 +0000","start_date":"2020-01-01 00:00:00 +0000","activity_type":"new_biz"}},"expires_at":"2021-07-16T13:55:47+00:00","created_at":"2021-07-09T13:55:44+00:00"}'
41
+ http_version:
42
+ recorded_at: Fri, 09 Jul 2021 14:06:07 GMT
43
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,83 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.chartmogul.com/v1/activities_export
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"start-date":"2020-01-01T00:00:00Z","end-date":"2020-12-31T00:00:00Z","type":"new_biz"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v1.0.1
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic hidden
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ server:
22
+ - nginx/1.10.1
23
+ date:
24
+ - Fri, 09 Jul 2021 14:37:32 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - keep-alive
31
+ vary:
32
+ - Accept-Encoding, Accept-Encoding
33
+ status:
34
+ - 200 OK
35
+ access-control-allow-credentials:
36
+ - 'true'
37
+ body:
38
+ encoding: ASCII-8BIT
39
+ string: '{"id":"17042239-3674-4a61-b838-b6b307f28506","status":"pending","file_url":null,"params":{"kind":"activities","params":{"activity_type":"new_biz","start_date":"2020-01-01
40
+ 00:00:00 +0000","end_date":"2020-12-31 00:00:00 +0000"}},"expires_at":null,"created_at":"2021-07-09T14:37:32+00:00"}'
41
+ http_version:
42
+ recorded_at: Fri, 09 Jul 2021 14:37:32 GMT
43
+ - request:
44
+ method: get
45
+ uri: https://api.chartmogul.com/v1/activities_export/17042239-3674-4a61-b838-b6b307f28506
46
+ body:
47
+ encoding: US-ASCII
48
+ string: ''
49
+ headers:
50
+ User-Agent:
51
+ - Faraday v1.0.1
52
+ Content-Type:
53
+ - application/json
54
+ Authorization:
55
+ - Basic hidden
56
+ response:
57
+ status:
58
+ code: 200
59
+ message: OK
60
+ headers:
61
+ server:
62
+ - nginx/1.10.1
63
+ date:
64
+ - Fri, 09 Jul 2021 14:38:10 GMT
65
+ content-type:
66
+ - application/json
67
+ transfer-encoding:
68
+ - chunked
69
+ connection:
70
+ - keep-alive
71
+ vary:
72
+ - Accept-Encoding, Accept-Encoding
73
+ status:
74
+ - 200 OK
75
+ access-control-allow-credentials:
76
+ - 'true'
77
+ body:
78
+ encoding: ASCII-8BIT
79
+ string: '{"id":"17042239-3674-4a61-b838-b6b307f28506","status":"succeeded","file_url":"https://chartmogul-customer-export.s3.eu-west-1.amazonaws.com/activities-acme-corp-062ea48c-5d74-46dd-bd60-23206cdc241a.zip?X-Amz-Algorithm=AWS4-HMAC-SHA256\u0026X-Amz-Credential=123%2Feu-west-1%2Fs3%2Faws4_request\u0026X-Amz-Date=20210709T135547Z\u0026X-Amz-Expires=604800\u0026X-Amz-SignedHeaders=host\u0026X-Amz-Signature=abc","params":{"kind":"activities","params":{"end_date":"2020-12-31
80
+ 00:00:00 +0000","start_date":"2020-01-01 00:00:00 +0000","activity_type":"new_biz"}},"expires_at":"2021-07-16T14:37:43+00:00","created_at":"2021-07-09T14:37:32+00:00"}'
81
+ http_version:
82
+ recorded_at: Fri, 09 Jul 2021 14:38:10 GMT
83
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.chartmogul.com/v1/activities?per_page=2
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v1.0.1
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic hidden
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ server:
22
+ - nginx/1.10.1
23
+ date:
24
+ - Fri, 18 Jun 2021 11:59:07 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - keep-alive
31
+ vary:
32
+ - Accept-Encoding, Accept-Encoding
33
+ status:
34
+ - 200 OK
35
+ access-control-allow-credentials:
36
+ - 'true'
37
+ body:
38
+ encoding: ASCII-8BIT
39
+ string: '{"entries":[{"description":"purchased the Basic1 plan","activity-mrr-movement":4478,"activity-mrr":4478,"activity-arr":53736,"date":"2016-08-01T06:28:25+00:00","type":"new_biz","currency":"EUR","subscription-external-id":"si_18dZuXAN0YShtow4jjqxxNnW","plan-external-id":"a3e832e1-1bd1-4889-8466-8efdbfbdd94b","customer-name":"Customer
40
+ for test@example.com","customer-uuid":"6456e930-8c8e-11eb-a506-0ff43d2cc026","customer-external-id":"cus_8vQm8XjeEOw75p","billing-connector-uuid":"decdeb4c-8c8d-11eb-a506-b3974867f58c","uuid":"2f545d5f-f241-458c-8e99-38c0e5a6e6ff"},{"description":"purchased
41
+ the Basic1 plan","activity-mrr-movement":4425,"activity-mrr":4425,"activity-arr":53100,"date":"2016-08-17T09:28:10+00:00","type":"new_biz","currency":"EUR","subscription-external-id":"si_18jQLGAN0YShtow4kFWpOMVX","plan-external-id":"a3e832e1-1bd1-4889-8466-8efdbfbdd94b","customer-name":"Customer
42
+ for test@example.com","customer-uuid":"63ad1285-8c8e-11eb-a506-47d6b1cc7553","customer-external-id":"cus_91TH9rjhhYCpai","billing-connector-uuid":"decdeb4c-8c8d-11eb-a506-b3974867f58c","uuid":"9d5ba7fd-e06d-4750-a8f6-2983f3a30fb2"}],"has_more":true,"per_page":2}'
43
+ recorded_at: Fri, 18 Jun 2021 11:59:07 GMT
44
+ recorded_with: VCR 6.0.0
@@ -2,13 +2,13 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.chartmogul.com/v1/customers/cus_91af761e-9d0a-11e5-b514-1feab446feac/activities
5
+ uri: https://api.chartmogul.com/v1/activities?per_page=2
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
9
9
  headers:
10
10
  User-Agent:
11
- - Faraday v0.9.2
11
+ - Faraday v1.0.1
12
12
  Content-Type:
13
13
  - application/json
14
14
  Authorization:
@@ -16,26 +16,29 @@ http_interactions:
16
16
  response:
17
17
  status:
18
18
  code: 200
19
- message:
19
+ message: OK
20
20
  headers:
21
21
  server:
22
- - nginx/1.9.10
22
+ - nginx/1.10.1
23
23
  date:
24
- - Fri, 01 Jul 2016 14:47:49 GMT
24
+ - Fri, 18 Jun 2021 11:59:07 GMT
25
25
  content-type:
26
26
  - application/json
27
- content-length:
28
- - '278'
27
+ transfer-encoding:
28
+ - chunked
29
29
  connection:
30
- - close
30
+ - keep-alive
31
+ vary:
32
+ - Accept-Encoding, Accept-Encoding
31
33
  status:
32
34
  - 200 OK
33
35
  access-control-allow-credentials:
34
36
  - 'true'
35
37
  body:
36
- encoding: UTF-8
37
- string: '{"entries":[{"id":16664702,"description":"purchased the Yael Cohen
38
- plan","activity-mrr-movement":10871,"activity-mrr":10871,"activity-arr":130452,"date":"2015-04-16T13:38:29+00:00","type":"new_biz","currency":"USD","currency-sign":"$","subscription_external_id":"si_IJxVS1c1TjSB0s"}],"has_more":false,"per_page":200,"page":1}'
39
- http_version:
40
- recorded_at: Fri, 01 Jul 2016 14:47:49 GMT
41
- recorded_with: VCR 3.0.3
38
+ encoding: ASCII-8BIT
39
+ string: '{"entries":[{"description":"purchased the Basic1 plan","activity-mrr-movement":4478,"activity-mrr":4478,"activity-arr":53736,"date":"2016-08-01T06:28:25+00:00","type":"new_biz","currency":"EUR","subscription-external-id":"si_18dZuXAN0YShtow4jjqxxNnW","plan-external-id":"a3e832e1-1bd1-4889-8466-8efdbfbdd94b","customer-name":"Customer
40
+ for test@example.com","customer-uuid":"6456e930-8c8e-11eb-a506-0ff43d2cc026","customer-external-id":"cus_8vQm8XjeEOw75p","billing-connector-uuid":"decdeb4c-8c8d-11eb-a506-b3974867f58c","uuid":"2f545d5f-f241-458c-8e99-38c0e5a6e6ff"},{"description":"purchased
41
+ the Basic1 plan","activity-mrr-movement":4425,"activity-mrr":4425,"activity-arr":53100,"date":"2016-08-17T09:28:10+00:00","type":"new_biz","currency":"EUR","subscription-external-id":"si_18jQLGAN0YShtow4kFWpOMVX","plan-external-id":"a3e832e1-1bd1-4889-8466-8efdbfbdd94b","customer-name":"Customer
42
+ for test@example.com","customer-uuid":"63ad1285-8c8e-11eb-a506-47d6b1cc7553","customer-external-id":"cus_91TH9rjhhYCpai","billing-connector-uuid":"decdeb4c-8c8d-11eb-a506-b3974867f58c","uuid":"9d5ba7fd-e06d-4750-a8f6-2983f3a30fb2"}],"has_more":true,"per_page":2}'
43
+ recorded_at: Fri, 18 Jun 2021 11:59:07 GMT
44
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,37 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.chartmogul.com/v1/activities
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v1.0.1
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic hidden
16
+ response:
17
+ status:
18
+ code: 401
19
+ message: Unauthorized
20
+ headers:
21
+ server:
22
+ - nginx/1.10.1
23
+ date:
24
+ - Fri, 18 Jun 2021 10:37:37 GMT
25
+ content-type:
26
+ - application/json
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - keep-alive
31
+ status:
32
+ - 401 Unauthorized
33
+ body:
34
+ encoding: UTF-8
35
+ string: '{"code":401,"message":"No valid API key provided","param":null}'
36
+ recorded_at: Fri, 18 Jun 2021 10:37:37 GMT
37
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.chartmogul.com/v1/customers/cus_91af761e-9d0a-11e5-b514-1feab446feac/activities
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.2
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic hidden
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx/1.9.10
23
+ date:
24
+ - Fri, 01 Jul 2016 14:47:49 GMT
25
+ content-type:
26
+ - application/json
27
+ content-length:
28
+ - '278'
29
+ connection:
30
+ - close
31
+ status:
32
+ - 200 OK
33
+ access-control-allow-credentials:
34
+ - 'true'
35
+ body:
36
+ encoding: UTF-8
37
+ string: '{"entries":[{"id":16664702,"description":"purchased the Yael Cohen
38
+ plan","activity-mrr-movement":10871,"activity-mrr":10871,"activity-arr":130452,"date":"2015-04-16T13:38:29+00:00","type":"new_biz","currency":"USD","currency-sign":"$","subscription_external_id":"si_IJxVS1c1TjSB0s"}],"has_more":false,"per_page":200,"page":1}'
39
+ http_version:
40
+ recorded_at: Fri, 01 Jul 2016 14:47:49 GMT
41
+ recorded_with: VCR 3.0.3
@@ -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
@@ -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
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ChartMogul
4
+ module Metrics
5
+ class ActivitiesExport < APIResource
6
+ set_resource_name 'ActivitiesExport'
7
+ set_resource_path '/v1/activities_export'
8
+
9
+ readonly_attr :id
10
+ readonly_attr :status
11
+ readonly_attr :file_url
12
+ readonly_attr :params
13
+ readonly_attr :expires_at
14
+ readonly_attr :created_at
15
+
16
+ writeable_attr :start_date
17
+ writeable_attr :end_date
18
+ writeable_attr :type
19
+
20
+ include API::Actions::Retrieve
21
+ include API::Actions::Create
22
+
23
+ def serialize_for_write
24
+ super.tap do |attributes|
25
+ attributes.clone.each do |k, v|
26
+ attributes[preprocess_attributes(k)] = attributes.delete(k)
27
+ end
28
+ end
29
+ end
30
+
31
+ def preprocess_attributes(attribute)
32
+ return attribute unless %i[start_date end_date].include?(attribute)
33
+
34
+ attribute.to_s.tr('_', '-')
35
+ end
36
+ end
37
+ end
38
+ end
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ChartMogul
4
- VERSION = '1.7.2'
4
+ VERSION = '2.9.0'
5
5
  end
data/lib/chartmogul.rb CHANGED
@@ -43,6 +43,7 @@ require 'chartmogul/concerns/entries'
43
43
  require 'chartmogul/concerns/summary'
44
44
  require 'chartmogul/concerns/pageable'
45
45
  require 'chartmogul/concerns/pageable2'
46
+ require 'chartmogul/concerns/pageable_with_anchor'
46
47
 
47
48
  require 'chartmogul/subscription'
48
49
  require 'chartmogul/invoice'
@@ -66,8 +67,10 @@ require 'chartmogul/metrics/mrr_churn_rate'
66
67
  require 'chartmogul/metrics/all_key_metrics'
67
68
  require 'chartmogul/metrics/base'
68
69
 
70
+ require 'chartmogul/metrics/customers/activity'
71
+ require 'chartmogul/metrics/customers/subscription'
69
72
  require 'chartmogul/metrics/activity'
70
- require 'chartmogul/metrics/subscription'
73
+ require 'chartmogul/metrics/activities_export'
71
74
 
72
75
  require 'chartmogul/enrichment/customer'
73
76
 
@@ -79,10 +82,14 @@ module ChartMogul
79
82
  class << self
80
83
  extend ConfigAttributes
81
84
 
85
+ def global_config
86
+ @global_config ||= ChartMogul::Configuration.new
87
+ end
82
88
 
89
+ # This configuration is thread-safe and fits multi-account async
90
+ # jobs processing use case.
83
91
  def config
84
- Thread.current[CONFIG_THREAD_KEY] = ChartMogul::Configuration.new if Thread.current[CONFIG_THREAD_KEY].nil?
85
- Thread.current[CONFIG_THREAD_KEY]
92
+ Thread.current[CONFIG_THREAD_KEY] ||= ChartMogul::Configuration.new
86
93
  end
87
94
 
88
95
  config_accessor :account_token
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.7.2
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Petr Kopac
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-03-18 00:00:00.000000000 Z
11
+ date: 2021-11-19 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,9 +171,10 @@ executables: []
171
171
  extensions: []
172
172
  extra_rdoc_files: []
173
173
  files:
174
+ - ".github/workflows/test.yml"
174
175
  - ".gitignore"
175
176
  - ".rspec"
176
- - ".travis.yml"
177
+ - 2.0-Upgrade.md
177
178
  - Gemfile
178
179
  - LICENSE.txt
179
180
  - README.md
@@ -221,21 +222,26 @@ files:
221
222
  - fixtures/vcr_cassettes/ChartMogul_Metrics_ARR/behaves_like_Metrics_API_resource/should_have_entries.yml
222
223
  - fixtures/vcr_cassettes/ChartMogul_Metrics_ASP/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
223
224
  - fixtures/vcr_cassettes/ChartMogul_Metrics_ASP/behaves_like_Metrics_API_resource/should_have_entries.yml
224
- - fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/behaves_like_Pageable/should_be_pageable.yml
225
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_ActivitiesExport/get_activities_export.yml
226
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_ActivitiesExport/post_activities_export.yml
227
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Activity.yml
228
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/behaves_like_PageableWithAnchor/should_be_pageable.yml
225
229
  - fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/should_have_Activity_entries.yml
226
230
  - fixtures/vcr_cassettes/ChartMogul_Metrics_AllKeyMetric/should_have_entries.yml
227
231
  - fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerChurnRate/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
228
232
  - fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml
229
233
  - fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerCount/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
230
234
  - fixtures/vcr_cassettes/ChartMogul_Metrics_CustomerCount/behaves_like_Metrics_API_resource/should_have_entries.yml
235
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Customers_Activity/behaves_like_Pageable/should_be_pageable.yml
236
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Customers_Activity/should_have_Activity_entries.yml
237
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Customers_Subscription/behaves_like_Pageable/should_be_pageable.yml
238
+ - fixtures/vcr_cassettes/ChartMogul_Metrics_Customers_Subscription/should_have_Subscription_entries.yml
231
239
  - fixtures/vcr_cassettes/ChartMogul_Metrics_LTV/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
232
240
  - fixtures/vcr_cassettes/ChartMogul_Metrics_LTV/behaves_like_Metrics_API_resource/should_have_entries.yml
233
241
  - fixtures/vcr_cassettes/ChartMogul_Metrics_MRR/behaves_like_Summary/should_have_summary.yml
234
242
  - fixtures/vcr_cassettes/ChartMogul_Metrics_MRR/should_have_entries.yml
235
243
  - fixtures/vcr_cassettes/ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/behaves_like_Summary/should_have_summary.yml
236
244
  - fixtures/vcr_cassettes/ChartMogul_Metrics_MRRChurnRate/behaves_like_Metrics_API_resource/should_have_entries.yml
237
- - fixtures/vcr_cassettes/ChartMogul_Metrics_Subscription/behaves_like_Pageable/should_be_pageable.yml
238
- - fixtures/vcr_cassettes/ChartMogul_Metrics_Subscription/should_have_Subscription_entries.yml
239
245
  - fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_on_incorrect_credentials.yml
240
246
  - fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_with_500_internal_server_error.yml
241
247
  - fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_with_504_gateway_timeout_error.yml
@@ -274,6 +280,7 @@ files:
274
280
  - lib/chartmogul/concerns/entries.rb
275
281
  - lib/chartmogul/concerns/pageable.rb
276
282
  - lib/chartmogul/concerns/pageable2.rb
283
+ - lib/chartmogul/concerns/pageable_with_anchor.rb
277
284
  - lib/chartmogul/concerns/summary.rb
278
285
  - lib/chartmogul/config_attributes.rb
279
286
  - lib/chartmogul/configuration.rb
@@ -292,6 +299,7 @@ files:
292
299
  - lib/chartmogul/invoice.rb
293
300
  - lib/chartmogul/line_items/one_time.rb
294
301
  - lib/chartmogul/line_items/subscription.rb
302
+ - lib/chartmogul/metrics/activities_export.rb
295
303
  - lib/chartmogul/metrics/activity.rb
296
304
  - lib/chartmogul/metrics/all_key_metrics.rb
297
305
  - lib/chartmogul/metrics/arpa.rb
@@ -300,10 +308,11 @@ files:
300
308
  - lib/chartmogul/metrics/base.rb
301
309
  - lib/chartmogul/metrics/customer_churn_rate.rb
302
310
  - lib/chartmogul/metrics/customer_count.rb
311
+ - lib/chartmogul/metrics/customers/activity.rb
312
+ - lib/chartmogul/metrics/customers/subscription.rb
303
313
  - lib/chartmogul/metrics/ltv.rb
304
314
  - lib/chartmogul/metrics/mrr.rb
305
315
  - lib/chartmogul/metrics/mrr_churn_rate.rb
306
- - lib/chartmogul/metrics/subscription.rb
307
316
  - lib/chartmogul/object.rb
308
317
  - lib/chartmogul/ping.rb
309
318
  - lib/chartmogul/plan.rb
@@ -322,7 +331,12 @@ homepage: https://github.com/chartmogul/chartmogul-ruby
322
331
  licenses:
323
332
  - MIT
324
333
  metadata: {}
325
- post_install_message:
334
+ post_install_message: "\n Starting October 29 2021, we are updating our developer
335
+ libraries to support the enhanced API Access Management. Please use the same API
336
+ Key for both API Token and Secret Key.\n [Deprecation] - account_token/secret_key
337
+ combo is deprecated. Please use API key for both fields.\n Version 3.x will introduce
338
+ a breaking change in authentication configuration. For more details, please visit:
339
+ https://dev.chartmogul.com/docs/authentication\n "
326
340
  rdoc_options: []
327
341
  require_paths:
328
342
  - lib
@@ -337,8 +351,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
337
351
  - !ruby/object:Gem::Version
338
352
  version: '0'
339
353
  requirements: []
340
- rubygems_version: 3.1.4
341
- signing_key:
354
+ rubygems_version: 3.1.6
355
+ signing_key:
342
356
  specification_version: 4
343
357
  summary: Chartmogul API Ruby Client
344
358
  test_files: []
data/.travis.yml DELETED
@@ -1,25 +0,0 @@
1
- os: linux
2
- dist: bionic
3
-
4
- language: ruby
5
-
6
- rvm:
7
- - 2.3
8
- - 2.4
9
- - 2.5
10
- - 2.6
11
- - 2.7
12
-
13
- before_install: gem install bundler
14
-
15
- before_script:
16
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
17
- - chmod +x ./cc-test-reporter
18
- - ./cc-test-reporter before-build
19
-
20
- branches:
21
- only:
22
- - main
23
-
24
- after_script:
25
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ChartMogul
4
- module Metrics
5
- class Subscription < ChartMogul::Object
6
- readonly_attr :id
7
- readonly_attr :external_id
8
- readonly_attr :plan
9
- readonly_attr :quantity
10
- readonly_attr :mrr
11
- readonly_attr :arr
12
- readonly_attr :status
13
- readonly_attr :billing_cycle
14
- readonly_attr :billing_cycle_count
15
- readonly_attr :start_date, type: :time
16
- readonly_attr :end_date, type: :time
17
- readonly_attr :currency
18
- readonly_attr :currency_sign
19
-
20
- def self.all(customer_uuid, options = {})
21
- ChartMogul::Metrics::Subscriptions.all(customer_uuid, options)
22
- end
23
- end
24
-
25
- class Subscriptions < APIResource
26
- set_resource_name 'Subscriptions'
27
- set_resource_path '/v1/customers/:customer_uuid/subscriptions'
28
-
29
- include Concerns::Entries
30
- include Concerns::Pageable
31
-
32
- set_entry_class Subscription
33
-
34
- def self.all(customer_uuid, options = {})
35
- super(options.merge(customer_uuid: customer_uuid))
36
- end
37
- end
38
- end
39
- end