chartmogul-ruby 1.6.2 → 1.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.gitignore +1 -0
- data/changelog.md +6 -0
- data/chartmogul-ruby.gemspec +14 -13
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/adds_custom_attributes.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_custom_attributes.yml +2 -2
- data/fixtures/vcr_cassettes/ChartMogul_CustomerInvoices/API_Interactions/correctly_interracts_with_the_API.yml +148 -109
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/behaves_like_Pageable/should_be_pageable.yml +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/should_have_Activity_entries.yml +1 -1
- data/lib/chartmogul.rb +2 -1
- data/lib/chartmogul/api/actions/create.rb +2 -2
- data/lib/chartmogul/api/actions/custom.rb +1 -1
- data/lib/chartmogul/api/actions/retrieve.rb +1 -1
- data/lib/chartmogul/api/actions/update.rb +3 -2
- data/lib/chartmogul/api_resource.rb +9 -4
- data/lib/chartmogul/configuration.rb +1 -0
- data/lib/chartmogul/customer.rb +1 -0
- data/lib/chartmogul/customer_invoices.rb +9 -0
- data/lib/chartmogul/metrics/activity.rb +1 -0
- data/lib/chartmogul/utils/json_parser.rb +12 -2
- data/lib/chartmogul/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dda2af29a185fd3a055fbfa3eeed97099989826a85f356e90ca7d0878757df2
|
4
|
+
data.tar.gz: 62a743e3b125b484e2993c6d539a8ec7f1ce7da67b2d40bc19d6853cee85fdd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bda6fc0c8a5266d528b7cc41d71da5f1b5471c0b526d2a7008cc93cb92f6c07fa7029af93801db3f24b07c79e035be9841324c9e4a6212c0ff4f510ceea82ec
|
7
|
+
data.tar.gz: 2c666f0cb45b87c1d4ca453e966d935680ed836dd0e3178b8b35c2e89e4094827b7baa297fea5669e3560fc5d5b436b1a42b3fdcb5e786a00d5163ddfe40f7f6
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
CHANGED
data/changelog.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# chartmogul-ruby Change Log
|
2
2
|
|
3
|
+
## Version 1.6.8 -1 November 2020
|
4
|
+
- Add support for subscription_external_id when listing Activities
|
5
|
+
|
6
|
+
## Version 1.6.7 - 8 September 2020
|
7
|
+
- Allow adding Customer custom attributes in camel case
|
8
|
+
|
3
9
|
## Version 1.5.0 - 20 February 2020
|
4
10
|
- Add support for plan groups API
|
5
11
|
|
data/chartmogul-ruby.gemspec
CHANGED
@@ -5,22 +5,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'chartmogul/version'
|
6
6
|
|
7
7
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.authors
|
11
|
-
spec.email
|
8
|
+
spec.name = 'chartmogul-ruby'
|
9
|
+
spec.version = ChartMogul::VERSION
|
10
|
+
spec.authors = ['Petr Kopac']
|
11
|
+
spec.email = ['petr@chartmogul.com']
|
12
12
|
|
13
|
-
spec.summary
|
14
|
-
spec.description
|
15
|
-
spec.homepage
|
16
|
-
spec.license
|
13
|
+
spec.summary = 'Chartmogul API Ruby Client'
|
14
|
+
spec.description = 'Official Ruby client for ChartMogul\'s API'
|
15
|
+
spec.homepage = 'https://github.com/chartmogul/chartmogul-ruby'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
spec.required_ruby_version = '>= 2.3'
|
17
18
|
|
18
|
-
spec.files
|
19
|
-
spec.bindir
|
20
|
-
spec.executables
|
21
|
-
spec.require_paths
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
22
23
|
|
23
|
-
spec.add_dependency 'faraday', '~> 0.
|
24
|
+
spec.add_dependency 'faraday', '~> 1.0.0'
|
24
25
|
|
25
26
|
spec.add_development_dependency 'bundler', '~> 2'
|
26
27
|
spec.add_development_dependency 'pry', '~> 0.12.2'
|
@@ -44,7 +44,7 @@ http_interactions:
|
|
44
44
|
uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047/attributes/custom
|
45
45
|
body:
|
46
46
|
encoding: UTF-8
|
47
|
-
string: '{"custom":[{"type":"String","key":"
|
47
|
+
string: '{"custom":[{"type":"String","key":"StringKey","value":"String Value"},{"type":"Integer","key":"integer_key","value":1234},{"type":"Timestamp","key":"timestamp_key","value":"2016-01-31
|
48
48
|
00:00:00 UTC"},{"type":"Boolean","key":"boolean_key","value":true}]}'
|
49
49
|
headers:
|
50
50
|
User-Agent:
|
@@ -74,7 +74,7 @@ http_interactions:
|
|
74
74
|
- 'true'
|
75
75
|
body:
|
76
76
|
encoding: UTF-8
|
77
|
-
string: '{"custom":{"
|
77
|
+
string: '{"custom":{"StringKey":"String Value","integer_key":1234,"timestamp_key":"2016-01-31T00:00:00.000Z","boolean_key":true}}'
|
78
78
|
http_version:
|
79
79
|
recorded_at: Wed, 29 Jun 2016 12:47:09 GMT
|
80
80
|
recorded_with: VCR 3.0.3
|
data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_custom_attributes.yml
CHANGED
@@ -45,7 +45,7 @@ http_interactions:
|
|
45
45
|
uri: https://api.chartmogul.com/v1/customers/cus_07393ece-aab1-4255-8bcd-0ef11e24b047/attributes/custom
|
46
46
|
body:
|
47
47
|
encoding: UTF-8
|
48
|
-
string: '{"custom":{"
|
48
|
+
string: '{"custom":{"StringKey":"Another String Value","integer_key":5678,"timestamp_key":"2016-02-01
|
49
49
|
00:00:00 UTC","boolean_key":false}}'
|
50
50
|
headers:
|
51
51
|
User-Agent:
|
@@ -75,7 +75,7 @@ http_interactions:
|
|
75
75
|
- 'true'
|
76
76
|
body:
|
77
77
|
encoding: UTF-8
|
78
|
-
string: '{"custom":{"
|
78
|
+
string: '{"custom":{"StringKey":"Another String Value","integer_key":5678,"timestamp_key":"2016-02-01T00:00:00.000Z","boolean_key":false}}'
|
79
79
|
http_version:
|
80
80
|
recorded_at: Wed, 29 Jun 2016 12:47:09 GMT
|
81
81
|
recorded_with: VCR 3.0.3
|
@@ -8,291 +8,330 @@ http_interactions:
|
|
8
8
|
string: '{"name":"Customer Invoices Test Data Source"}'
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Faraday
|
11
|
+
- Faraday v1.0.1
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
Authorization:
|
15
|
-
- Basic
|
15
|
+
- Basic YjNjZTUxNTNkMDYyNmQwNjE3YWQ4OWQyMzQ2OTA1OTc6OGE0YTgyOTMwYTVhMjgzOTA3MDgwNGYzMTdmNTZjYjA=
|
16
16
|
response:
|
17
17
|
status:
|
18
18
|
code: 201
|
19
|
-
message:
|
19
|
+
message: Created
|
20
20
|
headers:
|
21
21
|
server:
|
22
|
-
- nginx/1.
|
22
|
+
- nginx/1.10.1
|
23
23
|
date:
|
24
|
-
-
|
24
|
+
- Fri, 14 Aug 2020 08:21:40 GMT
|
25
25
|
content-type:
|
26
|
-
- application/json
|
26
|
+
- application/json
|
27
27
|
transfer-encoding:
|
28
28
|
- chunked
|
29
29
|
connection:
|
30
|
-
-
|
31
|
-
|
32
|
-
-
|
33
|
-
|
34
|
-
-
|
35
|
-
x-content-type-options:
|
36
|
-
- nosniff
|
37
|
-
etag:
|
38
|
-
- W/"60451ca489b1142994522bdcd2a78022"
|
39
|
-
cache-control:
|
40
|
-
- max-age=0, private, must-revalidate
|
41
|
-
x-request-id:
|
42
|
-
- 14e68eba-6131-4b04-8210-d9901cadd7ef
|
43
|
-
x-runtime:
|
44
|
-
- '0.536866'
|
45
|
-
strict-transport-security:
|
46
|
-
- max-age=15768000
|
30
|
+
- keep-alive
|
31
|
+
status:
|
32
|
+
- 201 Created
|
33
|
+
access-control-allow-credentials:
|
34
|
+
- 'true'
|
47
35
|
body:
|
48
36
|
encoding: UTF-8
|
49
|
-
string: '{"uuid":"
|
50
|
-
Invoices Test Data Source","created_at":"
|
37
|
+
string: '{"uuid":"ds_2db7bab6-de07-11ea-a4dd-7f82d51c3d05","name":"Customer
|
38
|
+
Invoices Test Data Source","system":"Import API","created_at":"2020-08-14T08:21:40.103Z","status":"idle"}'
|
51
39
|
http_version:
|
52
|
-
recorded_at:
|
40
|
+
recorded_at: Fri, 14 Aug 2020 08:21:40 GMT
|
53
41
|
- request:
|
54
42
|
method: post
|
55
43
|
uri: https://api.chartmogul.com/v1/customers
|
56
44
|
body:
|
57
45
|
encoding: UTF-8
|
58
|
-
string: '{"
|
59
|
-
Customer","email":"test@customer.com","company":null,"country":"DE","state":null,"city":"Berlin","zip":null}'
|
46
|
+
string: '{"external_id":"test_cus_ext_id","name":"Test Customer","email":"test@customer.com","country":"DE","city":"Berlin","data_source_uuid":"ds_2db7bab6-de07-11ea-a4dd-7f82d51c3d05"}'
|
60
47
|
headers:
|
61
48
|
User-Agent:
|
62
|
-
- Faraday
|
49
|
+
- Faraday v1.0.1
|
63
50
|
Content-Type:
|
64
51
|
- application/json
|
65
52
|
Authorization:
|
66
|
-
- Basic
|
53
|
+
- Basic YjNjZTUxNTNkMDYyNmQwNjE3YWQ4OWQyMzQ2OTA1OTc6OGE0YTgyOTMwYTVhMjgzOTA3MDgwNGYzMTdmNTZjYjA=
|
67
54
|
response:
|
68
55
|
status:
|
69
56
|
code: 201
|
70
|
-
message:
|
57
|
+
message: Created
|
71
58
|
headers:
|
72
59
|
server:
|
73
|
-
- nginx/1.
|
60
|
+
- nginx/1.10.1
|
74
61
|
date:
|
75
|
-
-
|
62
|
+
- Fri, 14 Aug 2020 08:21:40 GMT
|
76
63
|
content-type:
|
77
|
-
- application/json
|
64
|
+
- application/json
|
78
65
|
transfer-encoding:
|
79
66
|
- chunked
|
80
67
|
connection:
|
81
|
-
-
|
82
|
-
|
83
|
-
-
|
84
|
-
|
85
|
-
-
|
86
|
-
x-content-type-options:
|
87
|
-
- nosniff
|
88
|
-
etag:
|
89
|
-
- W/"b207f005123ccc7fbe07e3cf8d4ef474"
|
90
|
-
cache-control:
|
91
|
-
- max-age=0, private, must-revalidate
|
92
|
-
x-request-id:
|
93
|
-
- 8b32a149-5c4a-4b14-a82f-666adaf3897a
|
94
|
-
x-runtime:
|
95
|
-
- '0.221606'
|
96
|
-
strict-transport-security:
|
97
|
-
- max-age=15768000
|
68
|
+
- keep-alive
|
69
|
+
status:
|
70
|
+
- 201 Created
|
71
|
+
access-control-allow-credentials:
|
72
|
+
- 'true'
|
98
73
|
body:
|
99
74
|
encoding: UTF-8
|
100
|
-
string: '{"uuid":"
|
101
|
-
Customer","
|
75
|
+
string: '{"id":58654367,"uuid":"cus_2e010ebe-de07-11ea-a4dd-ff06789b4dcf","external_id":"test_cus_ext_id","name":"Test
|
76
|
+
Customer","email":"test@customer.com","status":"Lead","customer-since":null,"attributes":{"custom":{},"clearbit":{},"stripe":{},"tags":[]},"data_source_uuid":"ds_2db7bab6-de07-11ea-a4dd-7f82d51c3d05","data_source_uuids":["ds_2db7bab6-de07-11ea-a4dd-7f82d51c3d05"],"external_ids":["test_cus_ext_id"],"company":"","country":"DE","state":null,"city":"Berlin","zip":null,"lead_created_at":null,"free_trial_started_at":null,"address":{"country":"Germany","state":null,"city":"Berlin","address_zip":null},"mrr":0,"arr":0,"billing-system-url":null,"chartmogul-url":"https://app.chartmogul.com/#customers/58654367-Test_Customer","billing-system-type":"Import
|
77
|
+
API","currency":"USD","currency-sign":"$"}'
|
102
78
|
http_version:
|
103
|
-
recorded_at:
|
79
|
+
recorded_at: Fri, 14 Aug 2020 08:21:40 GMT
|
104
80
|
- request:
|
105
81
|
method: post
|
106
82
|
uri: https://api.chartmogul.com/v1/plans
|
107
83
|
body:
|
108
84
|
encoding: UTF-8
|
109
|
-
string: '{"data_source_uuid":"
|
110
|
-
Plan","interval_count":7,"interval_unit":"day","external_id":"test_cus_pl_ext_id"}'
|
85
|
+
string: '{"name":"Test Plan","interval_count":7,"interval_unit":"day","external_id":"test_cus_pl_ext_id","data_source_uuid":"ds_2db7bab6-de07-11ea-a4dd-7f82d51c3d05"}'
|
111
86
|
headers:
|
112
87
|
User-Agent:
|
113
|
-
- Faraday
|
88
|
+
- Faraday v1.0.1
|
114
89
|
Content-Type:
|
115
90
|
- application/json
|
116
91
|
Authorization:
|
117
|
-
- Basic
|
92
|
+
- Basic YjNjZTUxNTNkMDYyNmQwNjE3YWQ4OWQyMzQ2OTA1OTc6OGE0YTgyOTMwYTVhMjgzOTA3MDgwNGYzMTdmNTZjYjA=
|
118
93
|
response:
|
119
94
|
status:
|
120
95
|
code: 201
|
121
|
-
message:
|
96
|
+
message: Created
|
122
97
|
headers:
|
123
98
|
server:
|
124
|
-
- nginx/1.
|
99
|
+
- nginx/1.10.1
|
125
100
|
date:
|
126
|
-
-
|
101
|
+
- Fri, 14 Aug 2020 08:21:41 GMT
|
127
102
|
content-type:
|
128
103
|
- application/json; charset=utf-8
|
129
104
|
transfer-encoding:
|
130
105
|
- chunked
|
131
106
|
connection:
|
132
|
-
-
|
107
|
+
- keep-alive
|
108
|
+
status:
|
109
|
+
- 201 Created
|
133
110
|
x-frame-options:
|
134
111
|
- SAMEORIGIN
|
135
112
|
x-xss-protection:
|
136
113
|
- 1; mode=block
|
137
114
|
x-content-type-options:
|
138
115
|
- nosniff
|
116
|
+
x-download-options:
|
117
|
+
- noopen
|
118
|
+
x-permitted-cross-domain-policies:
|
119
|
+
- none
|
120
|
+
referrer-policy:
|
121
|
+
- strict-origin-when-cross-origin
|
139
122
|
etag:
|
140
|
-
- W/"
|
123
|
+
- W/"1d19bf324f0b6bf397ba8851cb55543c"
|
141
124
|
cache-control:
|
142
125
|
- max-age=0, private, must-revalidate
|
143
126
|
x-request-id:
|
144
|
-
-
|
127
|
+
- cbb7d1e3-f3a4-4ba2-b85c-7d3eed91922d
|
145
128
|
x-runtime:
|
146
|
-
- '0.
|
129
|
+
- '0.350185'
|
147
130
|
strict-transport-security:
|
148
131
|
- max-age=15768000
|
149
132
|
body:
|
150
133
|
encoding: UTF-8
|
151
|
-
string: '{"
|
152
|
-
Plan","interval_count":7,"interval_unit":"day","data_source_uuid":"ds_9fb17361-f24c-4c13-a25d-4c08fbc7132e"}'
|
134
|
+
string: '{"external_id":"test_cus_pl_ext_id","name":"Test Plan","interval_count":7,"interval_unit":"day","data_source_uuid":"ds_2db7bab6-de07-11ea-a4dd-7f82d51c3d05","uuid":"pl_2e010ebf-de07-11ea-a4dd-8bf0a8234993"}'
|
153
135
|
http_version:
|
154
|
-
recorded_at:
|
136
|
+
recorded_at: Fri, 14 Aug 2020 08:21:41 GMT
|
155
137
|
- request:
|
156
138
|
method: get
|
157
|
-
uri: https://api.chartmogul.com/v1/import/customers/
|
139
|
+
uri: https://api.chartmogul.com/v1/import/customers/cus_2e010ebe-de07-11ea-a4dd-ff06789b4dcf/invoices
|
158
140
|
body:
|
159
141
|
encoding: US-ASCII
|
160
142
|
string: ''
|
161
143
|
headers:
|
162
144
|
User-Agent:
|
163
|
-
- Faraday
|
145
|
+
- Faraday v1.0.1
|
164
146
|
Content-Type:
|
165
147
|
- application/json
|
166
148
|
Authorization:
|
167
|
-
- Basic
|
149
|
+
- Basic YjNjZTUxNTNkMDYyNmQwNjE3YWQ4OWQyMzQ2OTA1OTc6OGE0YTgyOTMwYTVhMjgzOTA3MDgwNGYzMTdmNTZjYjA=
|
168
150
|
response:
|
169
151
|
status:
|
170
152
|
code: 200
|
171
|
-
message:
|
153
|
+
message: OK
|
172
154
|
headers:
|
173
155
|
server:
|
174
|
-
- nginx/1.
|
156
|
+
- nginx/1.10.1
|
175
157
|
date:
|
176
|
-
-
|
158
|
+
- Fri, 14 Aug 2020 08:21:41 GMT
|
177
159
|
content-type:
|
178
160
|
- application/json; charset=utf-8
|
179
161
|
transfer-encoding:
|
180
162
|
- chunked
|
181
163
|
connection:
|
182
|
-
-
|
164
|
+
- keep-alive
|
165
|
+
vary:
|
166
|
+
- Accept-Encoding, Accept-Encoding
|
167
|
+
status:
|
168
|
+
- 200 OK
|
183
169
|
x-frame-options:
|
184
170
|
- SAMEORIGIN
|
185
171
|
x-xss-protection:
|
186
172
|
- 1; mode=block
|
187
173
|
x-content-type-options:
|
188
174
|
- nosniff
|
175
|
+
x-download-options:
|
176
|
+
- noopen
|
177
|
+
x-permitted-cross-domain-policies:
|
178
|
+
- none
|
179
|
+
referrer-policy:
|
180
|
+
- strict-origin-when-cross-origin
|
189
181
|
etag:
|
190
|
-
- W/"
|
182
|
+
- W/"aeef59b540af9e5982db384f237518a2"
|
191
183
|
cache-control:
|
192
184
|
- max-age=0, private, must-revalidate
|
193
185
|
x-request-id:
|
194
|
-
-
|
186
|
+
- 47e6129d-8195-4273-9c31-170905e27755
|
195
187
|
x-runtime:
|
196
|
-
- '0.
|
188
|
+
- '0.179805'
|
197
189
|
strict-transport-security:
|
198
190
|
- max-age=15768000
|
199
191
|
body:
|
200
|
-
encoding:
|
201
|
-
string: '{"customer_uuid":"
|
192
|
+
encoding: ASCII-8BIT
|
193
|
+
string: '{"customer_uuid":"cus_2e010ebe-de07-11ea-a4dd-ff06789b4dcf","invoices":[],"current_page":1,"total_pages":0}'
|
202
194
|
http_version:
|
203
|
-
recorded_at:
|
195
|
+
recorded_at: Fri, 14 Aug 2020 08:21:42 GMT
|
204
196
|
- request:
|
205
197
|
method: post
|
206
|
-
uri: https://api.chartmogul.com/v1/import/customers/
|
198
|
+
uri: https://api.chartmogul.com/v1/import/customers/cus_2e010ebe-de07-11ea-a4dd-ff06789b4dcf/invoices
|
207
199
|
body:
|
208
200
|
encoding: UTF-8
|
209
|
-
string: '{"invoices":[{"date":"2016-01-01 12:00:00
|
210
|
-
12:00:00
|
211
|
-
12:00:00
|
212
|
-
12:00:00
|
213
|
-
12:00:00
|
201
|
+
string: '{"invoices":[{"date":"2016-01-01 12:00:00 UTC","currency":"USD","line_items":[{"type":"subscription","subscription_external_id":"test_cus_sub_ext_id","service_period_start":"2016-01-01
|
202
|
+
12:00:00 UTC","service_period_end":"2016-02-01 12:00:00 UTC","amount_in_cents":1000,"cancelled_at":"2016-01-15
|
203
|
+
12:00:00 UTC","prorated":false,"quantity":5,"discount_amount_in_cents":1200,"discount_code":"DISCCODE","tax_amount_in_cents":200,"external_id":"test_cus_li_ext_id","plan_uuid":"pl_2e010ebf-de07-11ea-a4dd-8bf0a8234993"}],"transactions":[{"type":"payment","date":"2016-01-01
|
204
|
+
12:00:00 UTC","result":"successful","external_id":"test_cus_tr_ext_id"}],"external_id":"test_cus_inv_ext_id","customer_external_id":"test_cus_ext_id","due_date":"2016-01-07
|
205
|
+
12:00:00 UTC"}],"customer_uuid":"cus_2e010ebe-de07-11ea-a4dd-ff06789b4dcf"}'
|
214
206
|
headers:
|
215
207
|
User-Agent:
|
216
|
-
- Faraday
|
208
|
+
- Faraday v1.0.1
|
217
209
|
Content-Type:
|
218
210
|
- application/json
|
219
211
|
Authorization:
|
220
|
-
- Basic
|
212
|
+
- Basic YjNjZTUxNTNkMDYyNmQwNjE3YWQ4OWQyMzQ2OTA1OTc6OGE0YTgyOTMwYTVhMjgzOTA3MDgwNGYzMTdmNTZjYjA=
|
221
213
|
response:
|
222
214
|
status:
|
223
215
|
code: 201
|
224
|
-
message:
|
216
|
+
message: Created
|
225
217
|
headers:
|
226
218
|
server:
|
227
|
-
- nginx/1.
|
219
|
+
- nginx/1.10.1
|
228
220
|
date:
|
229
|
-
-
|
221
|
+
- Fri, 14 Aug 2020 08:21:43 GMT
|
230
222
|
content-type:
|
231
223
|
- application/json; charset=utf-8
|
232
224
|
transfer-encoding:
|
233
225
|
- chunked
|
234
226
|
connection:
|
235
|
-
-
|
227
|
+
- keep-alive
|
228
|
+
status:
|
229
|
+
- 201 Created
|
236
230
|
x-frame-options:
|
237
231
|
- SAMEORIGIN
|
238
232
|
x-xss-protection:
|
239
233
|
- 1; mode=block
|
240
234
|
x-content-type-options:
|
241
235
|
- nosniff
|
236
|
+
x-download-options:
|
237
|
+
- noopen
|
238
|
+
x-permitted-cross-domain-policies:
|
239
|
+
- none
|
240
|
+
referrer-policy:
|
241
|
+
- strict-origin-when-cross-origin
|
242
242
|
etag:
|
243
|
-
- W/"
|
243
|
+
- W/"2f2be4d16bccef7180e8df0515ebfd2f"
|
244
244
|
cache-control:
|
245
245
|
- max-age=0, private, must-revalidate
|
246
246
|
x-request-id:
|
247
|
-
-
|
247
|
+
- ccdcc2fb-0a04-4307-94c8-f8482ec6bd09
|
248
248
|
x-runtime:
|
249
|
-
- '
|
249
|
+
- '1.437992'
|
250
250
|
strict-transport-security:
|
251
251
|
- max-age=15768000
|
252
252
|
body:
|
253
253
|
encoding: UTF-8
|
254
|
-
string: '{"invoices":[{"uuid":"
|
254
|
+
string: '{"invoices":[{"uuid":"inv_deb98a20-3e71-49df-a49a-ac9d29c004be","date":"2016-01-01T12:00:00.000Z","due_date":"2016-01-07T12:00:00.000Z","external_id":"test_cus_inv_ext_id","currency":"USD","line_items":[{"uuid":"li_ffa7fad8-c393-45d2-aec4-2a869ece67c5","external_id":"test_cus_li_ext_id","type":"subscription","subscription_uuid":"sub_f3fa6a4e-8fc8-4843-95f2-062bc17826c6","subscription_external_id":"test_cus_sub_ext_id","prorated":false,"service_period_start":"2016-01-01T12:00:00.000Z","service_period_end":"2016-02-01T12:00:00.000Z","plan_uuid":"pl_2e010ebf-de07-11ea-a4dd-8bf0a8234993","amount_in_cents":1000,"quantity":5,"discount_code":"DISCCODE","discount_amount_in_cents":1200,"tax_amount_in_cents":200,"transaction_fees_in_cents":0,"account_code":""}],"transactions":[{"uuid":"tr_ff121f19-ef39-4bc8-824e-225d1b33e5da","external_id":"test_cus_tr_ext_id","type":"payment","date":"2016-01-01T12:00:00.000Z","result":"successful"}]}]}'
|
255
255
|
http_version:
|
256
|
-
recorded_at:
|
256
|
+
recorded_at: Fri, 14 Aug 2020 08:21:43 GMT
|
257
257
|
- request:
|
258
258
|
method: delete
|
259
|
-
uri: https://api.chartmogul.com/v1/data_sources/
|
259
|
+
uri: https://api.chartmogul.com/v1/data_sources/ds_2db7bab6-de07-11ea-a4dd-7f82d51c3d05/customers/cus_2e010ebe-de07-11ea-a4dd-ff06789b4dcf/invoices
|
260
260
|
body:
|
261
261
|
encoding: US-ASCII
|
262
262
|
string: ''
|
263
263
|
headers:
|
264
264
|
User-Agent:
|
265
|
-
- Faraday
|
265
|
+
- Faraday v1.0.1
|
266
266
|
Authorization:
|
267
|
-
- Basic
|
267
|
+
- Basic YjNjZTUxNTNkMDYyNmQwNjE3YWQ4OWQyMzQ2OTA1OTc6OGE0YTgyOTMwYTVhMjgzOTA3MDgwNGYzMTdmNTZjYjA=
|
268
268
|
response:
|
269
269
|
status:
|
270
270
|
code: 204
|
271
|
-
message:
|
271
|
+
message: No Content
|
272
272
|
headers:
|
273
273
|
server:
|
274
|
-
- nginx/1.
|
274
|
+
- nginx/1.10.1
|
275
275
|
date:
|
276
|
-
-
|
276
|
+
- Fri, 14 Aug 2020 08:21:44 GMT
|
277
277
|
connection:
|
278
|
-
-
|
278
|
+
- keep-alive
|
279
|
+
status:
|
280
|
+
- 204 No Content
|
279
281
|
x-frame-options:
|
280
282
|
- SAMEORIGIN
|
281
283
|
x-xss-protection:
|
282
284
|
- 1; mode=block
|
283
285
|
x-content-type-options:
|
284
286
|
- nosniff
|
287
|
+
x-download-options:
|
288
|
+
- noopen
|
289
|
+
x-permitted-cross-domain-policies:
|
290
|
+
- none
|
291
|
+
referrer-policy:
|
292
|
+
- strict-origin-when-cross-origin
|
285
293
|
cache-control:
|
286
294
|
- no-cache
|
287
295
|
x-request-id:
|
288
|
-
-
|
296
|
+
- c03bcf86-5a42-4655-b015-76ffc653ec91
|
289
297
|
x-runtime:
|
290
|
-
- '0.
|
298
|
+
- '0.353793'
|
291
299
|
strict-transport-security:
|
292
300
|
- max-age=15768000
|
293
301
|
body:
|
294
302
|
encoding: UTF-8
|
295
303
|
string: ''
|
296
304
|
http_version:
|
297
|
-
recorded_at:
|
298
|
-
|
305
|
+
recorded_at: Fri, 14 Aug 2020 08:21:44 GMT
|
306
|
+
- request:
|
307
|
+
method: delete
|
308
|
+
uri: https://api.chartmogul.com/v1/data_sources/ds_2db7bab6-de07-11ea-a4dd-7f82d51c3d05
|
309
|
+
body:
|
310
|
+
encoding: US-ASCII
|
311
|
+
string: ''
|
312
|
+
headers:
|
313
|
+
User-Agent:
|
314
|
+
- Faraday v1.0.1
|
315
|
+
Authorization:
|
316
|
+
- Basic YjNjZTUxNTNkMDYyNmQwNjE3YWQ4OWQyMzQ2OTA1OTc6OGE0YTgyOTMwYTVhMjgzOTA3MDgwNGYzMTdmNTZjYjA=
|
317
|
+
response:
|
318
|
+
status:
|
319
|
+
code: 204
|
320
|
+
message: No Content
|
321
|
+
headers:
|
322
|
+
server:
|
323
|
+
- nginx/1.10.1
|
324
|
+
date:
|
325
|
+
- Fri, 14 Aug 2020 08:21:44 GMT
|
326
|
+
connection:
|
327
|
+
- keep-alive
|
328
|
+
status:
|
329
|
+
- 204 No Content
|
330
|
+
access-control-allow-credentials:
|
331
|
+
- 'true'
|
332
|
+
body:
|
333
|
+
encoding: UTF-8
|
334
|
+
string: ''
|
335
|
+
http_version:
|
336
|
+
recorded_at: Fri, 14 Aug 2020 08:21:44 GMT
|
337
|
+
recorded_with: VCR 5.1.0
|
data/fixtures/vcr_cassettes/ChartMogul_Metrics_Activity/behaves_like_Pageable/should_be_pageable.yml
CHANGED
@@ -35,7 +35,7 @@ http_interactions:
|
|
35
35
|
body:
|
36
36
|
encoding: UTF-8
|
37
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":"$"}],"has_more":false,"per_page":200,"page":1}'
|
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
39
|
http_version:
|
40
40
|
recorded_at: Fri, 01 Jul 2016 14:47:49 GMT
|
41
41
|
recorded_with: VCR 3.0.3
|
@@ -35,7 +35,7 @@ http_interactions:
|
|
35
35
|
body:
|
36
36
|
encoding: UTF-8
|
37
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":"$"}],"has_more":false,"per_page":200,"page":1}'
|
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
39
|
http_version:
|
40
40
|
recorded_at: Fri, 01 Jul 2016 14:47:49 GMT
|
41
41
|
recorded_with: VCR 3.0.3
|
data/lib/chartmogul.rb
CHANGED
@@ -73,11 +73,11 @@ require 'chartmogul/enrichment/customer'
|
|
73
73
|
module ChartMogul
|
74
74
|
API_BASE = 'https://api.chartmogul.com'
|
75
75
|
MAX_RETRIES = 20
|
76
|
+
CONFIG_THREAD_KEY = 'chartmogul_ruby.config'
|
76
77
|
|
77
78
|
class << self
|
78
79
|
extend ConfigAttributes
|
79
80
|
|
80
|
-
CONFIG_THREAD_KEY = 'chartmogul_ruby.config'
|
81
81
|
|
82
82
|
def config
|
83
83
|
Thread.current[CONFIG_THREAD_KEY] = ChartMogul::Configuration.new if Thread.current[CONFIG_THREAD_KEY].nil?
|
@@ -87,5 +87,6 @@ module ChartMogul
|
|
87
87
|
config_accessor :account_token
|
88
88
|
config_accessor :secret_key
|
89
89
|
config_accessor :max_retries, MAX_RETRIES
|
90
|
+
config_accessor :api_base, API_BASE
|
90
91
|
end
|
91
92
|
end
|
@@ -15,7 +15,7 @@ module ChartMogul
|
|
15
15
|
req.body = JSON.dump(serialize_for_write)
|
16
16
|
end
|
17
17
|
end
|
18
|
-
json = ChartMogul::Utils::JSONParser.parse(resp.body)
|
18
|
+
json = ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: self.class.skip_case_conversion)
|
19
19
|
|
20
20
|
assign_all_attributes(json)
|
21
21
|
end
|
@@ -30,7 +30,7 @@ module ChartMogul
|
|
30
30
|
req.body = JSON.dump(resource.serialize_for_write)
|
31
31
|
end
|
32
32
|
end
|
33
|
-
json = ChartMogul::Utils::JSONParser.parse(resp.body)
|
33
|
+
json = ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: skip_case_conversion)
|
34
34
|
|
35
35
|
new_from_json(json)
|
36
36
|
end
|
@@ -25,7 +25,7 @@ module ChartMogul
|
|
25
25
|
req.body = JSON.dump(body_data)
|
26
26
|
end
|
27
27
|
end
|
28
|
-
ChartMogul::Utils::JSONParser.parse(resp.body)
|
28
|
+
ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: skip_case_conversion)
|
29
29
|
end
|
30
30
|
|
31
31
|
def custom!(http_method, http_path, body_data = {})
|
@@ -15,7 +15,7 @@ module ChartMogul
|
|
15
15
|
req.headers['Content-Type'] = 'application/json'
|
16
16
|
end
|
17
17
|
end
|
18
|
-
json = ChartMogul::Utils::JSONParser.parse(resp.body)
|
18
|
+
json = ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: skip_case_conversion)
|
19
19
|
new_from_json(json)
|
20
20
|
end
|
21
21
|
end
|
@@ -15,7 +15,8 @@ module ChartMogul
|
|
15
15
|
req.body = JSON.dump(serialize_for_write)
|
16
16
|
end
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
|
+
json = ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: self.class.skip_case_conversion)
|
19
20
|
|
20
21
|
assign_all_attributes(json)
|
21
22
|
end
|
@@ -30,7 +31,7 @@ module ChartMogul
|
|
30
31
|
req.body = JSON.dump(resource.serialize_for_write)
|
31
32
|
end
|
32
33
|
end
|
33
|
-
json = ChartMogul::Utils::JSONParser.parse(resp.body)
|
34
|
+
json = ChartMogul::Utils::JSONParser.parse(resp.body, skip_case_conversion: skip_case_conversion)
|
34
35
|
|
35
36
|
new_from_json(json)
|
36
37
|
end
|
@@ -17,7 +17,7 @@ module ChartMogul
|
|
17
17
|
MAX_INTERVAL = 60
|
18
18
|
THREAD_CONNECTION_KEY = 'chartmogul_ruby.api_resource.connection'
|
19
19
|
|
20
|
-
class << self; attr_reader :resource_path, :resource_name, :resource_root_key end
|
20
|
+
class << self; attr_reader :resource_path, :resource_name, :resource_root_key, :skip_case_conversion end
|
21
21
|
|
22
22
|
def self.set_resource_path(path)
|
23
23
|
@resource_path = ChartMogul::ResourcePath.new(path)
|
@@ -31,13 +31,18 @@ module ChartMogul
|
|
31
31
|
@resource_root_key = root_key
|
32
32
|
end
|
33
33
|
|
34
|
+
# When true, response hash keys won't be converted to snake case
|
35
|
+
def self.set_skip_case_conversion(value)
|
36
|
+
@skip_case_conversion = value
|
37
|
+
end
|
38
|
+
|
34
39
|
def self.connection
|
35
40
|
Thread.current[THREAD_CONNECTION_KEY] ||= build_connection
|
36
41
|
end
|
37
42
|
|
38
43
|
def self.handling_errors
|
39
44
|
yield
|
40
|
-
rescue Faraday::ClientError => e
|
45
|
+
rescue Faraday::ClientError, Faraday::ServerError => e
|
41
46
|
e.response ? handle_request_error(e) : handle_other_error(e)
|
42
47
|
rescue StandardError => e
|
43
48
|
handle_other_error(e)
|
@@ -80,13 +85,13 @@ module ChartMogul
|
|
80
85
|
private
|
81
86
|
|
82
87
|
def self.build_connection
|
83
|
-
Faraday.new(url: ChartMogul
|
88
|
+
Faraday.new(url: ChartMogul.api_base) do |faraday|
|
84
89
|
faraday.use Faraday::Request::BasicAuthentication, ChartMogul.account_token, ChartMogul.secret_key
|
85
90
|
faraday.use Faraday::Response::RaiseError
|
86
91
|
faraday.request :retry, max: ChartMogul.max_retries, retry_statuses: RETRY_STATUSES,
|
87
92
|
max_interval: MAX_INTERVAL, backoff_factor: BACKOFF_FACTOR,
|
88
93
|
interval_randomness: INTERVAL_RANDOMNESS, interval: INTERVAL, exceptions: RETRY_EXCEPTIONS
|
89
|
-
faraday.
|
94
|
+
faraday.adapter Faraday::Adapter::NetHttp
|
90
95
|
end
|
91
96
|
end
|
92
97
|
end
|
data/lib/chartmogul/customer.rb
CHANGED
@@ -26,6 +26,15 @@ module ChartMogul
|
|
26
26
|
super(options.merge(customer_uuid: customer_uuid))
|
27
27
|
end
|
28
28
|
|
29
|
+
def self.destroy_all!(data_source_uuid, customer_uuid)
|
30
|
+
path = ChartMogul::ResourcePath.new('v1/data_sources/:data_source_uuid/customers/:customer_uuid/invoices')
|
31
|
+
handling_errors do
|
32
|
+
connection.delete(path.apply(data_source_uuid: data_source_uuid, customer_uuid: customer_uuid))
|
33
|
+
end
|
34
|
+
true
|
35
|
+
end
|
36
|
+
|
37
|
+
|
29
38
|
def_delegators :invoices, :each, :[], :<<, :size, :length, :empty?, :first
|
30
39
|
|
31
40
|
private
|
@@ -12,6 +12,7 @@ module ChartMogul
|
|
12
12
|
readonly_attr :activity_mrr_movement
|
13
13
|
readonly_attr :currency
|
14
14
|
readonly_attr :currency_sign
|
15
|
+
readonly_attr :subscription_external_id
|
15
16
|
|
16
17
|
def self.all(customer_uuid, options = {})
|
17
18
|
ChartMogul::Metrics::Activities.all(customer_uuid, options)
|
@@ -4,8 +4,10 @@ module ChartMogul
|
|
4
4
|
module Utils
|
5
5
|
class JSONParser
|
6
6
|
class << self
|
7
|
-
def parse(json_string)
|
7
|
+
def parse(json_string, skip_case_conversion: false)
|
8
8
|
hash = JSON.parse(json_string, symbolize_names: true)
|
9
|
+
return hash if skip_case_conversion
|
10
|
+
|
9
11
|
HashSnakeCaser.new(hash).to_snake_keys
|
10
12
|
end
|
11
13
|
|
@@ -20,7 +22,15 @@ module ChartMogul
|
|
20
22
|
def opt_string_to_time(value)
|
21
23
|
return value unless value.instance_of?(String)
|
22
24
|
|
23
|
-
|
25
|
+
parse_timestamp(value)
|
26
|
+
rescue ArgumentError
|
27
|
+
value
|
28
|
+
end
|
29
|
+
|
30
|
+
def parse_timestamp(value)
|
31
|
+
Time.iso8601(value)
|
32
|
+
rescue ArgumentError
|
33
|
+
Time.rfc2822(value)
|
24
34
|
end
|
25
35
|
end
|
26
36
|
end
|
data/lib/chartmogul/version.rb
CHANGED
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.6.
|
4
|
+
version: 1.6.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petr Kopac
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-12 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.
|
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.
|
26
|
+
version: 1.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,6 +171,7 @@ executables: []
|
|
171
171
|
extensions: []
|
172
172
|
extra_rdoc_files: []
|
173
173
|
files:
|
174
|
+
- ".DS_Store"
|
174
175
|
- ".gitignore"
|
175
176
|
- ".rspec"
|
176
177
|
- ".travis.yml"
|
@@ -327,14 +328,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
327
328
|
requirements:
|
328
329
|
- - ">="
|
329
330
|
- !ruby/object:Gem::Version
|
330
|
-
version: '
|
331
|
+
version: '2.3'
|
331
332
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
332
333
|
requirements:
|
333
334
|
- - ">="
|
334
335
|
- !ruby/object:Gem::Version
|
335
336
|
version: '0'
|
336
337
|
requirements: []
|
337
|
-
rubygems_version: 3.
|
338
|
+
rubygems_version: 3.1.4
|
338
339
|
signing_key:
|
339
340
|
specification_version: 4
|
340
341
|
summary: Chartmogul API Ruby Client
|