chartmogul-ruby 1.5.1 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -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/chartmogul-ruby.gemspec +9 -6
  9. data/fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_in_a_threaded_environment.yml +112 -0
  10. data/fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_when_credentials_are_updated.yml +77 -0
  11. data/lib/chartmogul.rb +7 -2
  12. data/lib/chartmogul/api/actions/all.rb +2 -0
  13. data/lib/chartmogul/api/actions/create.rb +2 -0
  14. data/lib/chartmogul/api/actions/custom.rb +2 -0
  15. data/lib/chartmogul/api/actions/destroy.rb +2 -0
  16. data/lib/chartmogul/api/actions/retrieve.rb +2 -0
  17. data/lib/chartmogul/api/actions/update.rb +2 -0
  18. data/lib/chartmogul/api_resource.rb +21 -12
  19. data/lib/chartmogul/concerns/entries.rb +2 -0
  20. data/lib/chartmogul/concerns/pageable.rb +2 -0
  21. data/lib/chartmogul/concerns/pageable2.rb +2 -0
  22. data/lib/chartmogul/concerns/summary.rb +2 -0
  23. data/lib/chartmogul/config_attributes.rb +7 -1
  24. data/lib/chartmogul/configuration.rb +2 -0
  25. data/lib/chartmogul/customer.rb +2 -0
  26. data/lib/chartmogul/customer_invoices.rb +2 -0
  27. data/lib/chartmogul/data_source.rb +2 -0
  28. data/lib/chartmogul/enrichment/customer.rb +2 -0
  29. data/lib/chartmogul/errors/chartmogul_error.rb +2 -0
  30. data/lib/chartmogul/errors/configuration_error.rb +2 -0
  31. data/lib/chartmogul/errors/forbidden_error.rb +2 -0
  32. data/lib/chartmogul/errors/not_found_error.rb +2 -0
  33. data/lib/chartmogul/errors/resource_invalid_error.rb +2 -0
  34. data/lib/chartmogul/errors/schema_invalid_error.rb +2 -0
  35. data/lib/chartmogul/errors/server_error.rb +2 -0
  36. data/lib/chartmogul/errors/unauthorized_error.rb +2 -0
  37. data/lib/chartmogul/invoice.rb +2 -0
  38. data/lib/chartmogul/line_items/one_time.rb +2 -0
  39. data/lib/chartmogul/line_items/subscription.rb +2 -0
  40. data/lib/chartmogul/metrics/activity.rb +2 -0
  41. data/lib/chartmogul/metrics/all_key_metrics.rb +2 -0
  42. data/lib/chartmogul/metrics/arpa.rb +2 -0
  43. data/lib/chartmogul/metrics/arr.rb +2 -0
  44. data/lib/chartmogul/metrics/asp.rb +2 -0
  45. data/lib/chartmogul/metrics/base.rb +6 -2
  46. data/lib/chartmogul/metrics/customer_churn_rate.rb +2 -0
  47. data/lib/chartmogul/metrics/customer_count.rb +2 -0
  48. data/lib/chartmogul/metrics/ltv.rb +2 -0
  49. data/lib/chartmogul/metrics/mrr.rb +2 -0
  50. data/lib/chartmogul/metrics/mrr_churn_rate.rb +2 -0
  51. data/lib/chartmogul/metrics/subscription.rb +2 -0
  52. data/lib/chartmogul/object.rb +2 -0
  53. data/lib/chartmogul/ping.rb +2 -0
  54. data/lib/chartmogul/plan.rb +2 -0
  55. data/lib/chartmogul/plan_group.rb +2 -0
  56. data/lib/chartmogul/plan_groups/plans.rb +2 -0
  57. data/lib/chartmogul/resource_path.rb +6 -1
  58. data/lib/chartmogul/subscription.rb +2 -0
  59. data/lib/chartmogul/summary.rb +2 -0
  60. data/lib/chartmogul/transactions/payment.rb +2 -0
  61. data/lib/chartmogul/transactions/refund.rb +2 -0
  62. data/lib/chartmogul/utils/hash_snake_caser.rb +2 -0
  63. data/lib/chartmogul/utils/json_parser.rb +2 -0
  64. data/lib/chartmogul/version.rb +3 -1
  65. metadata +58 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca7ae56bc58d152fa47c9af3e07b2f42f10b3cb357c08a68412675d1dc2565c3
4
- data.tar.gz: 06db704ffdc4ee93eec4732d8aae1e3065afefa57415284409d8df734b967a66
3
+ metadata.gz: '0490c891de1f7d0e0caa23a8aa9b3bb14494814cea0c77b9b20b05e534bf1e14'
4
+ data.tar.gz: c141ac58cdde6ed3f2ac3f2f58bc2e3fd7961e5c903e26f836a6d7dfdf1dea90
5
5
  SHA512:
6
- metadata.gz: e8a1e1c07dc26c5cc1e4b09245688184a9ee1e73822c34c2f6d320040a6a88322be7c5374cd3e9c91a3594d8499282aaf30d30bc33344dfd7521176e6c9fbd71
7
- data.tar.gz: 8f638c5ec2168f0b5633a6e5f14af3fcc5603b144d9977f9db0c3a1c551a8ddfcd3e6c60b611d848c21ab5b6a6e0a8a681a19edf9bd3dc68b7f17848e19213bb
6
+ metadata.gz: 5877292fa2eb2c1b5ba3d8d2de80d5eb7b9188458e028330b8037651b4919aab6d915968fc449665bab16dbba4134938e423c43d23842ed1ce0851be6f23e5e7
7
+ data.tar.gz: 1f97329b49d5077e1366826c001d02df03e14fc7cdb52f082c889d1d07258904b00b7ff4121808cc4ca477e9e1ebd7181c59f60693819f2eb12890a988eb996a
data/.travis.yml CHANGED
@@ -1,4 +1,8 @@
1
+ os: linux
2
+ dist: bionic
3
+
1
4
  language: ruby
5
+
2
6
  rvm:
3
7
  - 2.3
4
8
  - 2.4
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
data/LICENSE.txt CHANGED
@@ -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 = '<Account key goes here>'
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
 
data/bin/console CHANGED
@@ -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,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'
@@ -23,10 +23,13 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'faraday', '~> 0.17.3'
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 2'
26
+ spec.add_development_dependency 'pry', '~> 0.12.2'
26
27
  spec.add_development_dependency 'rake', '~> 13.0'
27
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'
28
33
  spec.add_development_dependency 'vcr', '~> 5.1'
29
34
  spec.add_development_dependency 'webmock', '~> 3.8'
30
- spec.add_development_dependency 'simplecov', '~> 0.17.1'
31
- spec.add_development_dependency 'pry', '~> 0.12.2'
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
data/lib/chartmogul.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'time'
2
4
  require 'json'
3
5
  require 'faraday'
@@ -69,14 +71,17 @@ require 'chartmogul/metrics/subscription'
69
71
  require 'chartmogul/enrichment/customer'
70
72
 
71
73
  module ChartMogul
72
- API_BASE = 'https://api.chartmogul.com'.freeze
74
+ API_BASE = 'https://api.chartmogul.com'
73
75
  MAX_RETRIES = 20
74
76
 
75
77
  class << self
76
78
  extend ConfigAttributes
77
79
 
80
+ CONFIG_THREAD_KEY = 'chartmogul_ruby.config'
81
+
78
82
  def config
79
- @config ||= ChartMogul::Configuration.new
83
+ Thread.current[CONFIG_THREAD_KEY] = ChartMogul::Configuration.new if Thread.current[CONFIG_THREAD_KEY].nil?
84
+ Thread.current[CONFIG_THREAD_KEY]
80
85
  end
81
86
 
82
87
  config_accessor :account_token
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module API
3
5
  module Actions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module API
3
5
  module Actions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module API
3
5
  module Actions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module API
3
5
  module Actions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module API
3
5
  module Actions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module API
3
5
  module Actions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'forwardable'
2
4
 
3
5
  module ChartMogul
@@ -13,6 +15,7 @@ module ChartMogul
13
15
  INTERVAL_RANDOMNESS = 0.5
14
16
  INTERVAL = 1
15
17
  MAX_INTERVAL = 60
18
+ THREAD_CONNECTION_KEY = 'chartmogul_ruby.api_resource.connection'
16
19
 
17
20
  class << self; attr_reader :resource_path, :resource_name, :resource_root_key end
18
21
 
@@ -29,22 +32,15 @@ module ChartMogul
29
32
  end
30
33
 
31
34
  def self.connection
32
- @connection ||= Faraday.new(url: ChartMogul::API_BASE) do |faraday|
33
- faraday.use Faraday::Request::BasicAuthentication, ChartMogul.account_token, ChartMogul.secret_key
34
- faraday.use Faraday::Response::RaiseError
35
- faraday.request :retry, max: ChartMogul.max_retries, retry_statuses: RETRY_STATUSES,
36
- max_interval: MAX_INTERVAL, backoff_factor: BACKOFF_FACTOR,
37
- interval_randomness: INTERVAL_RANDOMNESS, interval: INTERVAL, exceptions: RETRY_EXCEPTIONS
38
- faraday.use Faraday::Adapter::NetHttp
39
- end
35
+ Thread.current[THREAD_CONNECTION_KEY] ||= build_connection
40
36
  end
41
37
 
42
38
  def self.handling_errors
43
39
  yield
44
- rescue Faraday::ClientError => exception
45
- exception.response ? handle_request_error(exception) : handle_other_error(exception)
46
- rescue => exception
47
- handle_other_error(exception)
40
+ rescue Faraday::ClientError => e
41
+ e.response ? handle_request_error(e) : handle_other_error(e)
42
+ rescue StandardError => e
43
+ handle_other_error(e)
48
44
  end
49
45
 
50
46
  def self.handle_request_error(exception)
@@ -80,5 +76,18 @@ module ChartMogul
80
76
  end
81
77
 
82
78
  def_delegators 'self.class', :resource_path, :resource_name, :resource_root_key, :connection, :handling_errors
79
+
80
+ private
81
+
82
+ def self.build_connection
83
+ Faraday.new(url: ChartMogul::API_BASE) do |faraday|
84
+ faraday.use Faraday::Request::BasicAuthentication, ChartMogul.account_token, ChartMogul.secret_key
85
+ faraday.use Faraday::Response::RaiseError
86
+ faraday.request :retry, max: ChartMogul.max_retries, retry_statuses: RETRY_STATUSES,
87
+ max_interval: MAX_INTERVAL, backoff_factor: BACKOFF_FACTOR,
88
+ interval_randomness: INTERVAL_RANDOMNESS, interval: INTERVAL, exceptions: RETRY_EXCEPTIONS
89
+ faraday.use Faraday::Adapter::NetHttp
90
+ end
91
+ end
83
92
  end
84
93
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Concerns
3
5
  module Entries
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Concerns
3
5
  module Pageable
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Concerns
3
5
  module Pageable2
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Concerns
3
5
  module Summary
@@ -1,14 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module ConfigAttributes
3
5
  def config_accessor(attribute, default_value = nil)
4
6
  define_method(attribute) do
5
7
  attr = config.send(attribute) || default_value
6
- raise ConfigurationError, "Configuration for #{attribute} not set" if attr.nil?
8
+ if attr.nil?
9
+ raise ConfigurationError, "Configuration for #{attribute} not set"
10
+ end
11
+
7
12
  attr
8
13
  end
9
14
 
10
15
  define_method("#{attribute}=") do |val|
11
16
  config.send("#{attribute}=", val)
17
+ Thread.current[ChartMogul::APIResource::THREAD_CONNECTION_KEY] = nil
12
18
  end
13
19
  end
14
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class Configuration
3
5
  attr_accessor :account_token
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class Customer < APIResource
3
5
  set_resource_name 'Customer'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'forwardable'
2
4
 
3
5
  module ChartMogul
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class DataSource < APIResource
3
5
  set_resource_name 'Data Source'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Enrichment
3
5
  # <b>DEPRECATED:</b> Please use <tt>ChartMogul/Customer</tt> instead.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class ChartMogulError < StandardError
3
5
  attr_reader :error_message, :response, :http_status
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class ConfigurationError < ChartMogulError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class ForbiddenError < ChartMogulError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class NotFoundError < ChartMogulError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class ResourceInvalidError < ChartMogulError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class SchemaInvalidError < ChartMogulError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class ServerError < ChartMogulError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class UnauthorizedError < ChartMogulError
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class Invoice < APIResource
3
5
  set_resource_name 'Invoice'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module LineItems
3
5
  class OneTime < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module LineItems
3
5
  class Subscription < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  class Activity < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  class AllKeyMetric < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  class ARPA < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  class ARR < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  class ASP < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  def self.all(options = {})
@@ -40,11 +42,13 @@ module ChartMogul
40
42
 
41
43
  def self.preprocess_params(options)
42
44
  %i[start_date end_date].each do |param_name|
43
- options[param_name.to_s.tr('_', '-')] = options.delete(param_name) if options[param_name]
45
+ if options[param_name]
46
+ options[param_name.to_s.tr('_', '-')] = options.delete(param_name)
47
+ end
44
48
  end
45
49
 
46
50
  %i[geo plans].each do |param_name|
47
- if options[param_name] && options[param_name].is_a?(Array)
51
+ if options[param_name]&.is_a?(Array)
48
52
  options[param_name] = options[param_name].join(',')
49
53
  end
50
54
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  class CustomerChurnRate < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  class CustomerCount < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  class LTV < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  class MRR < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  class MRRChurnRate < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Metrics
3
5
  class Subscription < ChartMogul::Object
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'set'
2
4
 
3
5
  module ChartMogul
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class Ping < APIResource
3
5
  set_resource_name 'Ping'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class Plan < APIResource
3
5
  set_resource_name 'Plan'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class PlanGroup < APIResource
3
5
  set_resource_name 'PlanGroup'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module PlanGroups
3
5
  class Plans < APIResource
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'uri'
2
4
 
3
5
  module ChartMogul
@@ -33,7 +35,10 @@ module ChartMogul
33
35
  def apply_named_params(params)
34
36
  path.dup.tap do |path|
35
37
  named_params.each do |named_param, param_key|
36
- raise(RequiredParameterMissing, "#{named_param} is required") unless params.key?(param_key)
38
+ unless params.key?(param_key)
39
+ raise(RequiredParameterMissing, "#{named_param} is required")
40
+ end
41
+
37
42
  path.gsub!(named_param, params[param_key].to_s)
38
43
  end
39
44
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class Subscription < APIResource
3
5
  set_resource_name 'Subscription'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  class Summary < ChartMogul::Object
3
5
  readonly_attr :current
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Transactions
3
5
  class Payment < APIResource
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Transactions
3
5
  class Refund < APIResource
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Utils
3
5
  class HashSnakeCaser
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
4
  module Utils
3
5
  class JSONParser
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
- VERSION = '1.5.1'.freeze
4
+ VERSION = '1.6.1'
3
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chartmogul-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
- - Jason Langenauer
7
+ - Petr Kopac
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-10 00:00:00.000000000 Z
11
+ date: 2020-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.12.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.12.2
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -67,33 +81,47 @@ dependencies:
67
81
  - !ruby/object:Gem::Version
68
82
  version: '3.0'
69
83
  - !ruby/object:Gem::Dependency
70
- name: vcr
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: '0.79'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: '0.79'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop-rspec
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: '5.1'
103
+ version: '1.38'
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: '5.1'
110
+ version: '1.38'
83
111
  - !ruby/object:Gem::Dependency
84
- name: webmock
112
+ name: rubocop-thread_safety
85
113
  requirement: !ruby/object:Gem::Requirement
86
114
  requirements:
87
115
  - - "~>"
88
116
  - !ruby/object:Gem::Version
89
- version: '3.8'
117
+ version: 0.3.4
90
118
  type: :development
91
119
  prerelease: false
92
120
  version_requirements: !ruby/object:Gem::Requirement
93
121
  requirements:
94
122
  - - "~>"
95
123
  - !ruby/object:Gem::Version
96
- version: '3.8'
124
+ version: 0.3.4
97
125
  - !ruby/object:Gem::Dependency
98
126
  name: simplecov
99
127
  requirement: !ruby/object:Gem::Requirement
@@ -109,22 +137,36 @@ dependencies:
109
137
  - !ruby/object:Gem::Version
110
138
  version: 0.17.1
111
139
  - !ruby/object:Gem::Dependency
112
- name: pry
140
+ name: vcr
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - "~>"
116
144
  - !ruby/object:Gem::Version
117
- version: 0.12.2
145
+ version: '5.1'
118
146
  type: :development
119
147
  prerelease: false
120
148
  version_requirements: !ruby/object:Gem::Requirement
121
149
  requirements:
122
150
  - - "~>"
123
151
  - !ruby/object:Gem::Version
124
- version: 0.12.2
152
+ version: '5.1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.8'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '3.8'
125
167
  description: Official Ruby client for ChartMogul's API
126
168
  email:
127
- - jason@chartmogul.com
169
+ - petr@chartmogul.com
128
170
  executables: []
129
171
  extensions: []
130
172
  extra_rdoc_files: []
@@ -140,6 +182,8 @@ files:
140
182
  - bin/setup
141
183
  - changelog.md
142
184
  - chartmogul-ruby.gemspec
185
+ - fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_in_a_threaded_environment.yml
186
+ - fixtures/vcr_cassettes/ChartMogul_APIResource/connection/works_when_credentials_are_updated.yml
143
187
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/adds_custom_attributes.yml
144
188
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/adds_required_tags.yml
145
189
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/can_page_through_search_endpoint.yml
@@ -287,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
331
  - !ruby/object:Gem::Version
288
332
  version: '0'
289
333
  requirements: []
290
- rubygems_version: 3.0.6
334
+ rubygems_version: 3.0.8
291
335
  signing_key:
292
336
  specification_version: 4
293
337
  summary: Chartmogul API Ruby Client