chartmogul-ruby 1.4.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +7 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE.txt +1 -1
  5. data/README.md +4 -2
  6. data/Rakefile +2 -0
  7. data/bin/console +1 -0
  8. data/changelog.md +3 -0
  9. data/chartmogul-ruby.gemspec +14 -11
  10. data/fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_in_a_threaded_environment.yml +112 -0
  11. data/fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_when_credentials_are_updated.yml +77 -0
  12. data/fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_with_500_internal_server_error.yml +40 -0
  13. data/fixtures/vcr_cassettes/ChartMogul_Ping/pings/and_fails_with_504_gateway_timeout_error.yml +40 -0
  14. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/correctly_handles_a_422_error.yml +50 -0
  15. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/deletes_a_plan_group.yml +293 -0
  16. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/retrieves_existing_plan_group_by_uuid.yml +251 -0
  17. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/returns_an_array_of_plan_groups.yml +357 -0
  18. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_name.yml +304 -0
  19. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_plans.yml +411 -0
  20. data/fixtures/vcr_cassettes/ChartMogul_PlanGroups_Plans/API_interactions/given_a_plan_group_uuid_returns_an_array_of_plans_in_the_plan_group.yml +252 -0
  21. data/lib/chartmogul.rb +10 -2
  22. data/lib/chartmogul/api/actions/all.rb +2 -0
  23. data/lib/chartmogul/api/actions/create.rb +2 -0
  24. data/lib/chartmogul/api/actions/custom.rb +2 -0
  25. data/lib/chartmogul/api/actions/destroy.rb +2 -0
  26. data/lib/chartmogul/api/actions/retrieve.rb +2 -0
  27. data/lib/chartmogul/api/actions/update.rb +2 -0
  28. data/lib/chartmogul/api_resource.rb +24 -12
  29. data/lib/chartmogul/concerns/entries.rb +2 -0
  30. data/lib/chartmogul/concerns/pageable.rb +2 -0
  31. data/lib/chartmogul/concerns/pageable2.rb +2 -0
  32. data/lib/chartmogul/concerns/summary.rb +2 -0
  33. data/lib/chartmogul/config_attributes.rb +7 -1
  34. data/lib/chartmogul/configuration.rb +2 -0
  35. data/lib/chartmogul/customer.rb +2 -0
  36. data/lib/chartmogul/customer_invoices.rb +2 -0
  37. data/lib/chartmogul/data_source.rb +2 -0
  38. data/lib/chartmogul/enrichment/customer.rb +2 -0
  39. data/lib/chartmogul/errors/chartmogul_error.rb +2 -0
  40. data/lib/chartmogul/errors/configuration_error.rb +2 -0
  41. data/lib/chartmogul/errors/forbidden_error.rb +2 -0
  42. data/lib/chartmogul/errors/not_found_error.rb +2 -0
  43. data/lib/chartmogul/errors/resource_invalid_error.rb +2 -0
  44. data/lib/chartmogul/errors/schema_invalid_error.rb +2 -0
  45. data/lib/chartmogul/errors/server_error.rb +6 -0
  46. data/lib/chartmogul/errors/unauthorized_error.rb +2 -0
  47. data/lib/chartmogul/invoice.rb +2 -0
  48. data/lib/chartmogul/line_items/one_time.rb +2 -0
  49. data/lib/chartmogul/line_items/subscription.rb +2 -0
  50. data/lib/chartmogul/metrics/activity.rb +2 -0
  51. data/lib/chartmogul/metrics/all_key_metrics.rb +2 -0
  52. data/lib/chartmogul/metrics/arpa.rb +2 -0
  53. data/lib/chartmogul/metrics/arr.rb +2 -0
  54. data/lib/chartmogul/metrics/asp.rb +2 -0
  55. data/lib/chartmogul/metrics/base.rb +6 -2
  56. data/lib/chartmogul/metrics/customer_churn_rate.rb +2 -0
  57. data/lib/chartmogul/metrics/customer_count.rb +2 -0
  58. data/lib/chartmogul/metrics/ltv.rb +2 -0
  59. data/lib/chartmogul/metrics/mrr.rb +2 -0
  60. data/lib/chartmogul/metrics/mrr_churn_rate.rb +2 -0
  61. data/lib/chartmogul/metrics/subscription.rb +2 -0
  62. data/lib/chartmogul/object.rb +2 -0
  63. data/lib/chartmogul/ping.rb +2 -0
  64. data/lib/chartmogul/plan.rb +2 -0
  65. data/lib/chartmogul/plan_group.rb +39 -0
  66. data/lib/chartmogul/plan_groups/plans.rb +17 -0
  67. data/lib/chartmogul/resource_path.rb +6 -1
  68. data/lib/chartmogul/subscription.rb +2 -0
  69. data/lib/chartmogul/summary.rb +2 -0
  70. data/lib/chartmogul/transactions/payment.rb +2 -0
  71. data/lib/chartmogul/transactions/refund.rb +2 -0
  72. data/lib/chartmogul/utils/hash_snake_caser.rb +2 -0
  73. data/lib/chartmogul/utils/json_parser.rb +2 -0
  74. data/lib/chartmogul/version.rb +3 -1
  75. metadata +78 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9374c3e5f0335ea291d6273b51ff0c3e213c6aef
4
- data.tar.gz: ddb280e6a5a98688d8a1d1febc9510427fbeed5d
2
+ SHA256:
3
+ metadata.gz: '0490c891de1f7d0e0caa23a8aa9b3bb14494814cea0c77b9b20b05e534bf1e14'
4
+ data.tar.gz: c141ac58cdde6ed3f2ac3f2f58bc2e3fd7961e5c903e26f836a6d7dfdf1dea90
5
5
  SHA512:
6
- metadata.gz: 3336095bfc0a8b4d3ad142f17609b9cef8882ecc7f5c727963f60e7d4757d0575e99953cfb418e5c9f10d807e88526797b4a93a2a5034235674c776801abc046
7
- data.tar.gz: ebf5566dcaa6f476de2dcc68fe994a731cd7a18d1a04f62d2192aa540ec6deb7d44dcfa0cd0b7f0af9247e64dc8bc22a7f649246057bd55d30f7179e2138ca5e
6
+ metadata.gz: 5877292fa2eb2c1b5ba3d8d2de80d5eb7b9188458e028330b8037651b4919aab6d915968fc449665bab16dbba4134938e423c43d23842ed1ce0851be6f23e5e7
7
+ data.tar.gz: 1f97329b49d5077e1366826c001d02df03e14fc7cdb52f082c889d1d07258904b00b7ff4121808cc4ca477e9e1ebd7181c59f60693819f2eb12890a988eb996a
@@ -1,7 +1,14 @@
1
+ os: linux
2
+ dist: bionic
3
+
1
4
  language: ruby
5
+
2
6
  rvm:
3
7
  - 2.3
4
8
  - 2.4
9
+ - 2.5
10
+ - 2.6
11
+ - 2.7
5
12
 
6
13
  before_install: gem install bundler
7
14
 
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in chartmogul-ruby.gemspec
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 ChartMogul Ltd
3
+ Copyright (c) 2020 ChartMogul Ltd
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -48,7 +48,7 @@ Or install it yourself as:
48
48
  $ gem install chartmogul-ruby
49
49
 
50
50
  ### Supported Ruby Versions
51
- This gem supports Ruby 2.3 and 2.4.
51
+ This gem supports Ruby 2.3 and above.
52
52
 
53
53
  ## Configuration
54
54
 
@@ -59,6 +59,8 @@ ChartMogul.account_token = ''
59
59
  ChartMogul.secret_key = '<Secret key goes here>'
60
60
  ```
61
61
 
62
+ Configuration is threadsafe and applied only to the current thread.
63
+
62
64
  Test your authentication:
63
65
  ```ruby
64
66
  ChartMogul::Ping.ping
@@ -115,7 +117,7 @@ The gem is available as open source under the terms of the [MIT License](http://
115
117
 
116
118
  ### The MIT License (MIT)
117
119
 
118
- *Copyright (c) 2016 ChartMogul Ltd.*
120
+ *Copyright (c) 2020 ChartMogul Ltd.*
119
121
 
120
122
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
121
123
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'chartmogul'
@@ -1,5 +1,8 @@
1
1
  # chartmogul-ruby Change Log
2
2
 
3
+ ## Version 1.5.0 - 20 February 2020
4
+ - Add support for plan groups API
5
+
3
6
  ## Version 1.4.0 - 20 September 2019
4
7
  - Add support for subscription sets
5
8
 
@@ -1,14 +1,14 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'chartmogul/version'
6
6
 
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'chartmogul-ruby'
9
9
  spec.version = ChartMogul::VERSION
10
- spec.authors = ['Jason Langenauer']
11
- spec.email = ['jason@chartmogul.com']
10
+ spec.authors = ['Petr Kopac']
11
+ spec.email = ['petr@chartmogul.com']
12
12
 
13
13
  spec.summary = 'Chartmogul API Ruby Client'
14
14
  spec.description = 'Official Ruby client for ChartMogul\'s API'
@@ -20,13 +20,16 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ['lib']
22
22
 
23
- spec.add_dependency 'faraday', '~> 0.15.0'
23
+ spec.add_dependency 'faraday', '~> 0.17.3'
24
24
 
25
- spec.add_development_dependency 'bundler', '~> 2.0.1'
26
- spec.add_development_dependency 'rake', '~> 10.0'
27
- spec.add_development_dependency 'rspec', '~> 3.0'
28
- spec.add_development_dependency 'vcr', '~> 3.0'
29
- spec.add_development_dependency 'webmock', '~> 3.4', '>= 3.4.2'
30
- spec.add_development_dependency 'simplecov', '~> 0.16.0'
25
+ spec.add_development_dependency 'bundler', '~> 2'
31
26
  spec.add_development_dependency 'pry', '~> 0.12.2'
27
+ spec.add_development_dependency 'rake', '~> 13.0'
28
+ spec.add_development_dependency 'rspec', '~> 3.0'
29
+ spec.add_development_dependency 'rubocop', '0.79'
30
+ spec.add_development_dependency 'rubocop-rspec', '~> 1.38'
31
+ spec.add_development_dependency 'rubocop-thread_safety', '~> 0.3.4'
32
+ spec.add_development_dependency 'simplecov', '~> 0.17.1'
33
+ spec.add_development_dependency 'vcr', '~> 5.1'
34
+ spec.add_development_dependency 'webmock', '~> 3.8'
32
35
  end
@@ -0,0 +1,112 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.chartmogul.com/v1/ping
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.17.3
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic aW52YWxpZDppbnZhbGlk
16
+ response:
17
+ status:
18
+ code: 401
19
+ message: Unauthorized
20
+ headers:
21
+ server:
22
+ - nginx/1.10.1
23
+ date:
24
+ - Fri, 17 Jul 2020 08:25:06 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
+ http_version:
37
+ recorded_at: Fri, 17 Jul 2020 08:25:06 GMT
38
+ - request:
39
+ method: get
40
+ uri: https://api.chartmogul.com/v1/ping
41
+ body:
42
+ encoding: UTF-8
43
+ string: "{}"
44
+ headers:
45
+ User-Agent:
46
+ - Faraday v0.17.3
47
+ Content-Type:
48
+ - application/json
49
+ Authorization:
50
+ - Basic ZHVtbXktdG9rZW46ZHVtbXktdG9rZW4=
51
+ response:
52
+ status:
53
+ code: 200
54
+ message: OK
55
+ headers:
56
+ server:
57
+ - nginx/1.10.1
58
+ date:
59
+ - Fri, 17 Jul 2020 08:25:11 GMT
60
+ content-type:
61
+ - application/json
62
+ transfer-encoding:
63
+ - chunked
64
+ connection:
65
+ - keep-alive
66
+ vary:
67
+ - Accept-Encoding, Accept-Encoding
68
+ status:
69
+ - 200 OK
70
+ access-control-allow-credentials:
71
+ - 'true'
72
+ body:
73
+ encoding: ASCII-8BIT
74
+ string: '{"data":"pong!"}'
75
+ http_version:
76
+ recorded_at: Fri, 17 Jul 2020 08:25:11 GMT
77
+ - request:
78
+ method: get
79
+ uri: https://api.chartmogul.com/v1/ping
80
+ body:
81
+ encoding: UTF-8
82
+ string: "{}"
83
+ headers:
84
+ User-Agent:
85
+ - Faraday v0.17.3
86
+ Content-Type:
87
+ - application/json
88
+ Authorization:
89
+ - Basic aW52YWxpZDppbnZhbGlk
90
+ response:
91
+ status:
92
+ code: 401
93
+ message: Unauthorized
94
+ headers:
95
+ server:
96
+ - nginx/1.10.1
97
+ date:
98
+ - Fri, 17 Jul 2020 08:25:11 GMT
99
+ content-type:
100
+ - application/json
101
+ transfer-encoding:
102
+ - chunked
103
+ connection:
104
+ - keep-alive
105
+ status:
106
+ - 401 Unauthorized
107
+ body:
108
+ encoding: UTF-8
109
+ string: '{"code":401,"message":"No valid API key provided","param":null}'
110
+ http_version:
111
+ recorded_at: Fri, 17 Jul 2020 08:25:11 GMT
112
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,77 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.chartmogul.com/v1/ping
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.17.3
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic aW52YWxpZDppbnZhbGlk
16
+ response:
17
+ status:
18
+ code: 401
19
+ message: Unauthorized
20
+ headers:
21
+ server:
22
+ - nginx/1.10.1
23
+ date:
24
+ - Fri, 17 Jul 2020 08:25:25 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
+ http_version:
37
+ recorded_at: Fri, 17 Jul 2020 08:25:25 GMT
38
+ - request:
39
+ method: get
40
+ uri: https://api.chartmogul.com/v1/ping
41
+ body:
42
+ encoding: UTF-8
43
+ string: "{}"
44
+ headers:
45
+ User-Agent:
46
+ - Faraday v0.17.3
47
+ Content-Type:
48
+ - application/json
49
+ Authorization:
50
+ - Basic ZHVtbXktdG9rZW46ZHVtbXktdG9rZW4=
51
+ response:
52
+ status:
53
+ code: 200
54
+ message: OK
55
+ headers:
56
+ server:
57
+ - nginx/1.10.1
58
+ date:
59
+ - Fri, 17 Jul 2020 08:25:26 GMT
60
+ content-type:
61
+ - application/json
62
+ transfer-encoding:
63
+ - chunked
64
+ connection:
65
+ - keep-alive
66
+ vary:
67
+ - Accept-Encoding, Accept-Encoding
68
+ status:
69
+ - 200 OK
70
+ access-control-allow-credentials:
71
+ - 'true'
72
+ body:
73
+ encoding: ASCII-8BIT
74
+ string: '{"data":"pong!"}'
75
+ http_version:
76
+ recorded_at: Fri, 17 Jul 2020 08:25:26 GMT
77
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.chartmogul.com/v1/ping
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic ZHVtbXktdG9rZW46ZHVtbXktdG9rZW4=
16
+ response:
17
+ status:
18
+ code: 500
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx/1.10.1
23
+ cache-control:
24
+ - private
25
+ content-length:
26
+ - '25'
27
+ content-type:
28
+ - text/plain; charset=utf-8
29
+ access-control-allow-origin:
30
+ - "*"
31
+ date:
32
+ - Tue, 10 Dec 2019 07:43:50 GMT
33
+ connection:
34
+ - close
35
+ body:
36
+ encoding: UTF-8
37
+ string: 500 Internal Server Error
38
+ http_version:
39
+ recorded_at: Tue, 10 Dec 2019 07:43:51 GMT
40
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,40 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.chartmogul.com/v1/ping
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic ZHVtbXktdG9rZW46ZHVtbXktdG9rZW4=
16
+ response:
17
+ status:
18
+ code: 504
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx/1.10.1
23
+ cache-control:
24
+ - private
25
+ content-length:
26
+ - '25'
27
+ content-type:
28
+ - text/plain; charset=utf-8
29
+ access-control-allow-origin:
30
+ - "*"
31
+ date:
32
+ - Tue, 10 Dec 2019 07:43:50 GMT
33
+ connection:
34
+ - close
35
+ body:
36
+ encoding: UTF-8
37
+ string: 504 Gateway Timeout Error
38
+ http_version:
39
+ recorded_at: Tue, 10 Dec 2019 07:43:51 GMT
40
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.chartmogul.com/v1/plan_groups
6
+ body:
7
+ encoding: UTF-8
8
+ string: "{}"
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.15.4
12
+ Content-Type:
13
+ - application/json
14
+ Authorization:
15
+ - Basic secret
16
+ response:
17
+ status:
18
+ code: 422
19
+ message:
20
+ headers:
21
+ server:
22
+ - nginx/1.10.1
23
+ date:
24
+ - Wed, 12 Feb 2020 17:06:03 GMT
25
+ content-type:
26
+ - application/json; charset=utf-8
27
+ transfer-encoding:
28
+ - chunked
29
+ connection:
30
+ - close
31
+ status:
32
+ - 422 Unprocessable Entity
33
+ x-frame-options:
34
+ - SAMEORIGIN
35
+ x-xss-protection:
36
+ - 1; mode=block
37
+ x-content-type-options:
38
+ - nosniff
39
+ cache-control:
40
+ - no-cache
41
+ x-request-id:
42
+ - 829dd1b4-e36e-49ec-8647-187294a7cb00
43
+ x-runtime:
44
+ - '0.654937'
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"plans":["Please provide uuids of the plans in the plan group"]}'
48
+ http_version:
49
+ recorded_at: Wed, 12 Feb 2020 17:06:03 GMT
50
+ recorded_with: VCR 3.0.3