chartmogul-ruby 3.3.1 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/4.0-Upgrade.md +43 -0
- data/README.md +5 -1
- data/changelog.md +10 -0
- data/chartmogul-ruby.gemspec +1 -1
- data/lib/chartmogul/customer.rb +8 -0
- data/lib/chartmogul/errors/deprecated_parameter_error.rb +6 -0
- data/lib/chartmogul/note.rb +40 -0
- data/lib/chartmogul/resource_path.rb +6 -1
- data/lib/chartmogul/version.rb +1 -1
- data/lib/chartmogul.rb +2 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f528ebe8e70838100b70e1b0b303f7032bb406cb982840de597fcef929e5f1f
|
4
|
+
data.tar.gz: 21150268340facfa3466b2a31d3d0eac3c1aed868608f0de265b2a6d619cb000
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c822a95c9fa65a4c13ad4d0bc35c370714fdfac2dd375bbca1b494ce19d2e8e6482639136a67d43278d25ae53c0e53694e02e08e7fd89b5a8c1faf077c4d559e
|
7
|
+
data.tar.gz: 2313f6a228d0d0cbfd17550a41ae7fbe31be01187779217bff7a7ece3505df310bdef483eb308c784cb8dd238184955f383a0236bcb6c2b0df42e2253d14c496
|
data/.github/workflows/test.yml
CHANGED
data/4.0-Upgrade.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Upgrading to chartmogul-ruby 4.0.0
|
2
|
+
|
3
|
+
This new version replaces the existing pagination for the `.all()` endpoints that used a combination
|
4
|
+
of `page` and `per_page` parameters, and instead uses a `cursor` based pagination. So to list
|
5
|
+
(as an example) Plans you now can:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
ChartMogul.api_key = '<API key goes here>'
|
9
|
+
|
10
|
+
# Getting the first page
|
11
|
+
plans = ChartMogul::Plan.all(per_page: 12)
|
12
|
+
```
|
13
|
+
|
14
|
+
This will return an array of plans (if available), and a cursor + has_more fields:
|
15
|
+
|
16
|
+
```json
|
17
|
+
{
|
18
|
+
"plans": [
|
19
|
+
{
|
20
|
+
"uuid": "some_uuid",
|
21
|
+
"data_source_uuid": "some_uuid",
|
22
|
+
"name": "Master Plan"
|
23
|
+
}
|
24
|
+
],
|
25
|
+
"has_more": true,
|
26
|
+
"cursor": "MjAyMy0wNy0yOFQwODowOToyMi4xNTQyMDMwMDBaJjk0NDQ0Mg=="
|
27
|
+
}
|
28
|
+
```
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
# You can get the following pages by passing a cursor to .all
|
32
|
+
if plans.has_more
|
33
|
+
more_plans = ChartMogul::Plan.all(per_page: 12, cursor: plans.cursor)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Or by calling .next on the result
|
37
|
+
if plans.has_more
|
38
|
+
more_plans = plans.next(per_page: 3)
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
If you have existing code that relies on the `page` parameter, those requests will now throw an error
|
43
|
+
alerting you of their deprecation.
|
data/README.md
CHANGED
@@ -47,7 +47,8 @@ Or install it yourself as:
|
|
47
47
|
$ gem install chartmogul-ruby
|
48
48
|
|
49
49
|
### Supported Ruby Versions
|
50
|
-
|
50
|
+
|
51
|
+
This gem supports Ruby 2.7 and above.
|
51
52
|
|
52
53
|
## Configuration
|
53
54
|
|
@@ -66,6 +67,7 @@ ChartMogul.api_key = '<API key goes here>'
|
|
66
67
|
Thread-safe configuration is used if available, otherwise global is used.
|
67
68
|
|
68
69
|
Test your authentication:
|
70
|
+
|
69
71
|
```ruby
|
70
72
|
ChartMogul::Ping.ping
|
71
73
|
```
|
@@ -100,9 +102,11 @@ You can find examples for each endpoint in the ChartMogul [API documentation](ht
|
|
100
102
|
The library will keep retrying if the request exceeds the rate limit or if there's any network related error. By default, the request will be retried for 20 times (approximated 15 minutes) before finally giving up.
|
101
103
|
|
102
104
|
You can change the retry count with:
|
105
|
+
|
103
106
|
```ruby
|
104
107
|
ChartMogul.max_retries = 15
|
105
108
|
```
|
109
|
+
|
106
110
|
Set it to 0 to disable it.
|
107
111
|
|
108
112
|
## Development
|
data/changelog.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# chartmogul-ruby Change Log
|
2
2
|
|
3
|
+
## Version 4.1.0 - December 20, 2023
|
4
|
+
- Adds support for Customer Notes
|
5
|
+
|
6
|
+
## Version 4.0.1 - November 7 2023
|
7
|
+
- Add upgrade guide from v3.x to v4.x
|
8
|
+
|
9
|
+
## Version 4.0.0 - November 1 2023
|
10
|
+
- Remove support for old pagination using `page` parameter.
|
11
|
+
- Drop support for Ruby versions below 2.7.
|
12
|
+
|
3
13
|
## Version 3.3.1 - October 27 2023
|
4
14
|
- Add support for cursor based pagination to `.all` endpoints.
|
5
15
|
- Add `.next` pagination method for all supported cursor based endpoints.
|
data/chartmogul-ruby.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = 'Official Ruby client for ChartMogul\'s API'
|
15
15
|
spec.homepage = 'https://github.com/chartmogul/chartmogul-ruby'
|
16
16
|
spec.license = 'MIT'
|
17
|
-
spec.required_ruby_version = '>= 2.
|
17
|
+
spec.required_ruby_version = '>= 2.7'
|
18
18
|
|
19
19
|
spec.post_install_message = %q{
|
20
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.
|
data/lib/chartmogul/customer.rb
CHANGED
@@ -84,6 +84,14 @@ module ChartMogul
|
|
84
84
|
Contact.create!(options.merge(customer_uuid: uuid))
|
85
85
|
end
|
86
86
|
|
87
|
+
def notes(options = {})
|
88
|
+
Notes.all(options.merge(customer_uuid: uuid))
|
89
|
+
end
|
90
|
+
|
91
|
+
def create_note(options = {})
|
92
|
+
Note.create!(options.merge(customer_uuid: uuid))
|
93
|
+
end
|
94
|
+
|
87
95
|
# Enrichment
|
88
96
|
def tags
|
89
97
|
@attributes[:tags]
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
module ChartMogul
|
6
|
+
class Note < APIResource
|
7
|
+
set_resource_name 'CustomerNote'
|
8
|
+
set_resource_path '/v1/customer_notes'
|
9
|
+
|
10
|
+
readonly_attr :uuid
|
11
|
+
|
12
|
+
writeable_attr :customer_uuid
|
13
|
+
writeable_attr :type
|
14
|
+
writeable_attr :text
|
15
|
+
writeable_attr :author
|
16
|
+
writeable_attr :text
|
17
|
+
writeable_attr :call_duration
|
18
|
+
writeable_attr :created_at
|
19
|
+
writeable_attr :updated_at
|
20
|
+
|
21
|
+
include API::Actions::Create
|
22
|
+
include API::Actions::Destroy
|
23
|
+
include API::Actions::Retrieve
|
24
|
+
include API::Actions::Update
|
25
|
+
|
26
|
+
def self.all(options = {})
|
27
|
+
Notes.all(options)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Notes < APIResource
|
32
|
+
set_resource_name 'CustomerNotes'
|
33
|
+
set_resource_path '/v1/customer_notes'
|
34
|
+
|
35
|
+
include Concerns::Entries
|
36
|
+
include Concerns::PageableWithCursor
|
37
|
+
|
38
|
+
set_entry_class Note
|
39
|
+
end
|
40
|
+
end
|
@@ -9,6 +9,8 @@ module ChartMogul
|
|
9
9
|
|
10
10
|
class RequiredParameterMissing < StandardError; end
|
11
11
|
|
12
|
+
DEPRECATED_PARAMETER = 'page'
|
13
|
+
|
12
14
|
def initialize(path)
|
13
15
|
@path = path
|
14
16
|
@named_params = path.scan(/:\w+/).each_with_object({}) do |named_param, hash|
|
@@ -22,7 +24,6 @@ module ChartMogul
|
|
22
24
|
|
23
25
|
# For path = '/hello/:hello_id/say' & params = { hello_id: 1, search: 'cat' }
|
24
26
|
# it will return '/hello/1/say?search=cat'
|
25
|
-
|
26
27
|
def apply_with_get_params(params = {})
|
27
28
|
base_path = apply_named_params(params)
|
28
29
|
get_params = params.reject { |param_name| named_params.values.include?(param_name) }
|
@@ -33,6 +34,10 @@ module ChartMogul
|
|
33
34
|
private
|
34
35
|
|
35
36
|
def apply_named_params(params)
|
37
|
+
if params.keys.map(&:to_s).include?(DEPRECATED_PARAMETER)
|
38
|
+
raise(ChartMogul::DeprecatedParameterError, "#{DEPRECATED_PARAMETER} is deprecated.")
|
39
|
+
end
|
40
|
+
|
36
41
|
path.dup.tap do |path|
|
37
42
|
named_params.each do |named_param, param_key|
|
38
43
|
unless params.key?(param_key)
|
data/lib/chartmogul/version.rb
CHANGED
data/lib/chartmogul.rb
CHANGED
@@ -18,6 +18,7 @@ require 'chartmogul/errors/resource_invalid_error'
|
|
18
18
|
require 'chartmogul/errors/schema_invalid_error'
|
19
19
|
require 'chartmogul/errors/server_error'
|
20
20
|
require 'chartmogul/errors/unauthorized_error'
|
21
|
+
require 'chartmogul/errors/deprecated_parameter_error'
|
21
22
|
|
22
23
|
require 'chartmogul/config_attributes'
|
23
24
|
require 'chartmogul/configuration'
|
@@ -54,6 +55,7 @@ require 'chartmogul/subscription'
|
|
54
55
|
require 'chartmogul/invoice'
|
55
56
|
require 'chartmogul/customer_invoices'
|
56
57
|
require 'chartmogul/customer'
|
58
|
+
require 'chartmogul/note'
|
57
59
|
require 'chartmogul/contact'
|
58
60
|
require 'chartmogul/data_source'
|
59
61
|
require 'chartmogul/ping'
|
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:
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petr Kopac
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- ".gitignore"
|
190
190
|
- ".rspec"
|
191
191
|
- 2.0-Upgrade.md
|
192
|
+
- 4.0-Upgrade.md
|
192
193
|
- Gemfile
|
193
194
|
- LICENSE.txt
|
194
195
|
- README.md
|
@@ -223,6 +224,7 @@ files:
|
|
223
224
|
- lib/chartmogul/enrichment/customer.rb
|
224
225
|
- lib/chartmogul/errors/chartmogul_error.rb
|
225
226
|
- lib/chartmogul/errors/configuration_error.rb
|
227
|
+
- lib/chartmogul/errors/deprecated_parameter_error.rb
|
226
228
|
- lib/chartmogul/errors/forbidden_error.rb
|
227
229
|
- lib/chartmogul/errors/not_found_error.rb
|
228
230
|
- lib/chartmogul/errors/resource_invalid_error.rb
|
@@ -246,6 +248,7 @@ files:
|
|
246
248
|
- lib/chartmogul/metrics/ltv.rb
|
247
249
|
- lib/chartmogul/metrics/mrr.rb
|
248
250
|
- lib/chartmogul/metrics/mrr_churn_rate.rb
|
251
|
+
- lib/chartmogul/note.rb
|
249
252
|
- lib/chartmogul/object.rb
|
250
253
|
- lib/chartmogul/ping.rb
|
251
254
|
- lib/chartmogul/plan.rb
|
@@ -279,14 +282,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
279
282
|
requirements:
|
280
283
|
- - ">="
|
281
284
|
- !ruby/object:Gem::Version
|
282
|
-
version: '2.
|
285
|
+
version: '2.7'
|
283
286
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
284
287
|
requirements:
|
285
288
|
- - ">="
|
286
289
|
- !ruby/object:Gem::Version
|
287
290
|
version: '0'
|
288
291
|
requirements: []
|
289
|
-
rubygems_version: 3.4.
|
292
|
+
rubygems_version: 3.4.21
|
290
293
|
signing_key:
|
291
294
|
specification_version: 4
|
292
295
|
summary: Chartmogul API Ruby Client
|