chartmogul-ruby 1.5.1 → 1.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +5 -1
  4. data/Gemfile +2 -0
  5. data/LICENSE.txt +1 -1
  6. data/README.md +5 -3
  7. data/Rakefile +2 -0
  8. data/bin/console +1 -0
  9. data/chartmogul-ruby.gemspec +21 -17
  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_Customer/API_Interactions/updates_customer_using_class_method.yml +53 -0
  13. data/fixtures/vcr_cassettes/ChartMogul_CustomerInvoices/API_Interactions/correctly_interracts_with_the_API.yml +148 -109
  14. data/fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/updates_existing_plan_using_class_method.yml +164 -0
  15. data/fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_name_via_class_method.yml +297 -0
  16. data/lib/chartmogul.rb +8 -2
  17. data/lib/chartmogul/api/actions/all.rb +2 -0
  18. data/lib/chartmogul/api/actions/create.rb +2 -0
  19. data/lib/chartmogul/api/actions/custom.rb +2 -0
  20. data/lib/chartmogul/api/actions/destroy.rb +2 -0
  21. data/lib/chartmogul/api/actions/retrieve.rb +2 -0
  22. data/lib/chartmogul/api/actions/update.rb +22 -0
  23. data/lib/chartmogul/api_resource.rb +21 -12
  24. data/lib/chartmogul/concerns/entries.rb +2 -0
  25. data/lib/chartmogul/concerns/pageable.rb +2 -0
  26. data/lib/chartmogul/concerns/pageable2.rb +2 -0
  27. data/lib/chartmogul/concerns/summary.rb +2 -0
  28. data/lib/chartmogul/config_attributes.rb +7 -1
  29. data/lib/chartmogul/configuration.rb +3 -0
  30. data/lib/chartmogul/customer.rb +2 -0
  31. data/lib/chartmogul/customer_invoices.rb +11 -0
  32. data/lib/chartmogul/data_source.rb +2 -0
  33. data/lib/chartmogul/enrichment/customer.rb +2 -0
  34. data/lib/chartmogul/errors/chartmogul_error.rb +2 -0
  35. data/lib/chartmogul/errors/configuration_error.rb +2 -0
  36. data/lib/chartmogul/errors/forbidden_error.rb +2 -0
  37. data/lib/chartmogul/errors/not_found_error.rb +2 -0
  38. data/lib/chartmogul/errors/resource_invalid_error.rb +2 -0
  39. data/lib/chartmogul/errors/schema_invalid_error.rb +2 -0
  40. data/lib/chartmogul/errors/server_error.rb +2 -0
  41. data/lib/chartmogul/errors/unauthorized_error.rb +2 -0
  42. data/lib/chartmogul/invoice.rb +2 -0
  43. data/lib/chartmogul/line_items/one_time.rb +2 -0
  44. data/lib/chartmogul/line_items/subscription.rb +2 -0
  45. data/lib/chartmogul/metrics/activity.rb +2 -0
  46. data/lib/chartmogul/metrics/all_key_metrics.rb +2 -0
  47. data/lib/chartmogul/metrics/arpa.rb +2 -0
  48. data/lib/chartmogul/metrics/arr.rb +2 -0
  49. data/lib/chartmogul/metrics/asp.rb +2 -0
  50. data/lib/chartmogul/metrics/base.rb +6 -2
  51. data/lib/chartmogul/metrics/customer_churn_rate.rb +2 -0
  52. data/lib/chartmogul/metrics/customer_count.rb +2 -0
  53. data/lib/chartmogul/metrics/ltv.rb +2 -0
  54. data/lib/chartmogul/metrics/mrr.rb +2 -0
  55. data/lib/chartmogul/metrics/mrr_churn_rate.rb +2 -0
  56. data/lib/chartmogul/metrics/subscription.rb +2 -0
  57. data/lib/chartmogul/object.rb +2 -0
  58. data/lib/chartmogul/ping.rb +2 -0
  59. data/lib/chartmogul/plan.rb +2 -0
  60. data/lib/chartmogul/plan_group.rb +2 -0
  61. data/lib/chartmogul/plan_groups/plans.rb +2 -0
  62. data/lib/chartmogul/resource_path.rb +6 -1
  63. data/lib/chartmogul/subscription.rb +2 -0
  64. data/lib/chartmogul/summary.rb +2 -0
  65. data/lib/chartmogul/transactions/payment.rb +2 -0
  66. data/lib/chartmogul/transactions/refund.rb +2 -0
  67. data/lib/chartmogul/utils/hash_snake_caser.rb +2 -0
  68. data/lib/chartmogul/utils/json_parser.rb +11 -1
  69. data/lib/chartmogul/version.rb +3 -1
  70. metadata +64 -17
@@ -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
@@ -18,7 +20,15 @@ module ChartMogul
18
20
  def opt_string_to_time(value)
19
21
  return value unless value.instance_of?(String)
20
22
 
21
- Time.iso8601(value) rescue Time.rfc2822(value) rescue value
23
+ parse_timestamp(value)
24
+ rescue ArgumentError
25
+ value
26
+ end
27
+
28
+ def parse_timestamp(value)
29
+ Time.iso8601(value)
30
+ rescue ArgumentError
31
+ Time.rfc2822(value)
22
32
  end
23
33
  end
24
34
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChartMogul
2
- VERSION = '1.5.1'.freeze
4
+ VERSION = '1.6.6'
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.6
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-08-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: 0.17.3
19
+ version: 1.0.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: 0.17.3
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -156,6 +200,7 @@ files:
156
200
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/returns_right_customers_through_search_endpoint.yml
157
201
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_custom_attributes.yml
158
202
  - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_customer.yml
203
+ - fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_customer_using_class_method.yml
159
204
  - fixtures/vcr_cassettes/ChartMogul_Customer/_find_by_external_id/when_external_id_is_provided/returns_matching_user_if_exists.yml
160
205
  - fixtures/vcr_cassettes/ChartMogul_Customer/_find_by_external_id/when_external_id_is_provided/returns_nil_if_customer_does_not_exist.yml
161
206
  - fixtures/vcr_cassettes/ChartMogul_CustomerInvoices/API_Interactions/correctly_interracts_with_the_API.yml
@@ -198,11 +243,13 @@ files:
198
243
  - fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/deletes_existing_plan.yml
199
244
  - fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/retrieves_existing_plan_by_uuid.yml
200
245
  - fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/updates_existing_plan.yml
246
+ - fixtures/vcr_cassettes/ChartMogul_Plan/API_Interactions/updates_existing_plan_using_class_method.yml
201
247
  - fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/correctly_handles_a_422_error.yml
202
248
  - fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/deletes_a_plan_group.yml
203
249
  - fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/retrieves_existing_plan_group_by_uuid.yml
204
250
  - fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/returns_an_array_of_plan_groups.yml
205
251
  - fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_name.yml
252
+ - fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_name_via_class_method.yml
206
253
  - fixtures/vcr_cassettes/ChartMogul_PlanGroup/API_interactions/updates_existing_plan_group_plans.yml
207
254
  - fixtures/vcr_cassettes/ChartMogul_PlanGroups_Plans/API_interactions/given_a_plan_group_uuid_returns_an_array_of_plans_in_the_plan_group.yml
208
255
  - fixtures/vcr_cassettes/ChartMogul_Subscription/API_Interactions/connects_subscriptions.yml
@@ -280,14 +327,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
280
327
  requirements:
281
328
  - - ">="
282
329
  - !ruby/object:Gem::Version
283
- version: '0'
330
+ version: '2.3'
284
331
  required_rubygems_version: !ruby/object:Gem::Requirement
285
332
  requirements:
286
333
  - - ">="
287
334
  - !ruby/object:Gem::Version
288
335
  version: '0'
289
336
  requirements: []
290
- rubygems_version: 3.0.6
337
+ rubygems_version: 3.1.4
291
338
  signing_key:
292
339
  specification_version: 4
293
340
  summary: Chartmogul API Ruby Client