chartmogul-ruby 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/changelog.md +7 -0
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/correctly_interracts_with_the_API.yml +67 -119
- data/lib/chartmogul/api/actions/all.rb +1 -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 +2 -1
- data/lib/chartmogul/api/actions/update.rb +2 -2
- data/lib/chartmogul/api_resource.rb +8 -4
- data/lib/chartmogul/customer.rb +2 -2
- data/lib/chartmogul/utils/hash_snake_caser.rb +9 -2
- data/lib/chartmogul/utils/json_parser.rb +2 -4
- data/lib/chartmogul/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5381b67c739d176db4a06bb7bda534885bd370253fcbae18c090196183cd37c4
|
|
4
|
+
data.tar.gz: 3b64a66d45d6a890b826d8eb7fd7baa8d9bb9fa942c42eda07dab1496a8e3f49
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f97167bbf6aaa21ae83003c073ed3a5fc69fcb8a81eebc105f7b16c6cf85dd2e775a97842a6fa050ca4311c316617c8a74af3b06feb67f60b043e2fb5a6f0eb
|
|
7
|
+
data.tar.gz: 7d82814b322e62b04baa2b4b4b44b7b516cebbca04e3540c7eb6b68d05c2267db0fdf8f483238efe10230de6790397d7af1a3a0fa22fe1e87f01aa57a23f0c4d
|
data/changelog.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# chartmogul-ruby Change Log
|
|
2
2
|
|
|
3
|
+
## Version 1.7.2 - 16 March 2021
|
|
4
|
+
- Fix bug preventing instantiating attributes on ChartMogul::Customers objects
|
|
5
|
+
|
|
6
|
+
## Version 1.7.1 - 8 March 2021
|
|
7
|
+
- Adds amount_in_cents to payment for partial payments
|
|
8
|
+
- Adds account API endpoint
|
|
9
|
+
|
|
3
10
|
## Version 1.6.9 - 10 December 2020
|
|
4
11
|
- Fix ChartMogul::Customers class
|
|
5
12
|
|
|
@@ -8,7 +8,7 @@ http_interactions:
|
|
|
8
8
|
string: '{"name":"Customer 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:
|
|
@@ -16,50 +16,38 @@ http_interactions:
|
|
|
16
16
|
response:
|
|
17
17
|
status:
|
|
18
18
|
code: 201
|
|
19
|
-
message:
|
|
19
|
+
message: Created
|
|
20
20
|
headers:
|
|
21
21
|
server:
|
|
22
22
|
- nginx/1.10.1
|
|
23
23
|
date:
|
|
24
|
-
- Tue,
|
|
24
|
+
- Tue, 16 Mar 2021 12:27:18 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/"bcfee5f9180970835929930b05411ff4"
|
|
39
|
-
cache-control:
|
|
40
|
-
- max-age=0, private, must-revalidate
|
|
41
|
-
x-request-id:
|
|
42
|
-
- 9505cefe-9a7a-46af-a173-7a686cf46800
|
|
43
|
-
x-runtime:
|
|
44
|
-
- '0.461858'
|
|
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
|
-
Test Data Source","created_at":"
|
|
37
|
+
string: '{"uuid":"ds_f2f67ad0-8652-11eb-a9f8-37471a677085","name":"Customer
|
|
38
|
+
Test Data Source","system":"Import API","created_at":"2021-03-16T12:27:18.630Z","status":"idle"}'
|
|
51
39
|
http_version:
|
|
52
|
-
recorded_at: Tue,
|
|
40
|
+
recorded_at: Tue, 16 Mar 2021 12:27:18 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: '{"external_id":"X1234","name":"Test Customer","email":"test@example.com","country":"DE","city":"Berlin","data_source_uuid":"
|
|
46
|
+
string: '{"external_id":"X1234","name":"Test Customer","email":"test@example.com","country":"DE","city":"Berlin","data_source_uuid":"ds_f2f67ad0-8652-11eb-a9f8-37471a677085","lead_created_at":"2016-10-01
|
|
59
47
|
23:55:00 UTC","free_trial_started_at":"2016-10-12 11:12:00 UTC"}'
|
|
60
48
|
headers:
|
|
61
49
|
User-Agent:
|
|
62
|
-
- Faraday
|
|
50
|
+
- Faraday v1.0.1
|
|
63
51
|
Content-Type:
|
|
64
52
|
- application/json
|
|
65
53
|
Authorization:
|
|
@@ -67,40 +55,29 @@ http_interactions:
|
|
|
67
55
|
response:
|
|
68
56
|
status:
|
|
69
57
|
code: 201
|
|
70
|
-
message:
|
|
58
|
+
message: Created
|
|
71
59
|
headers:
|
|
72
60
|
server:
|
|
73
61
|
- nginx/1.10.1
|
|
74
62
|
date:
|
|
75
|
-
- Tue,
|
|
63
|
+
- Tue, 16 Mar 2021 12:27:19 GMT
|
|
76
64
|
content-type:
|
|
77
|
-
- application/json
|
|
65
|
+
- application/json
|
|
78
66
|
transfer-encoding:
|
|
79
67
|
- chunked
|
|
80
68
|
connection:
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
-
|
|
84
|
-
|
|
85
|
-
-
|
|
86
|
-
x-content-type-options:
|
|
87
|
-
- nosniff
|
|
88
|
-
etag:
|
|
89
|
-
- W/"edb1e5e3324d47803eccb229a21363df"
|
|
90
|
-
cache-control:
|
|
91
|
-
- max-age=0, private, must-revalidate
|
|
92
|
-
x-request-id:
|
|
93
|
-
- bf049e2c-b057-4d90-85bf-f90c9ca98b31
|
|
94
|
-
x-runtime:
|
|
95
|
-
- '0.158973'
|
|
96
|
-
strict-transport-security:
|
|
97
|
-
- max-age=15768000
|
|
69
|
+
- keep-alive
|
|
70
|
+
status:
|
|
71
|
+
- 201 Created
|
|
72
|
+
access-control-allow-credentials:
|
|
73
|
+
- 'true'
|
|
98
74
|
body:
|
|
99
75
|
encoding: UTF-8
|
|
100
|
-
string: '{"uuid":"
|
|
101
|
-
Customer","
|
|
76
|
+
string: '{"id":93760512,"uuid":"cus_f340970a-8652-11eb-a9f8-cfc7971a103f","external_id":"X1234","name":"Test
|
|
77
|
+
Customer","email":"test@example.com","status":"Lead","customer-since":null,"attributes":{"custom":{},"clearbit":{},"stripe":{},"tags":[]},"data_source_uuid":"ds_f2f67ad0-8652-11eb-a9f8-37471a677085","data_source_uuids":["ds_f2f67ad0-8652-11eb-a9f8-37471a677085"],"external_ids":["X1234"],"company":"","country":"DE","state":null,"city":"Berlin","zip":null,"lead_created_at":"2016-10-01T23:55:00.000Z","free_trial_started_at":"2016-10-12T11:12:00.000Z","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/93760512-Test_Customer","billing-system-type":"Import
|
|
78
|
+
API","currency":"USD","currency-sign":"$"}'
|
|
102
79
|
http_version:
|
|
103
|
-
recorded_at: Tue,
|
|
80
|
+
recorded_at: Tue, 16 Mar 2021 12:27:19 GMT
|
|
104
81
|
- request:
|
|
105
82
|
method: get
|
|
106
83
|
uri: https://api.chartmogul.com/v1/customers
|
|
@@ -109,7 +86,7 @@ http_interactions:
|
|
|
109
86
|
string: ''
|
|
110
87
|
headers:
|
|
111
88
|
User-Agent:
|
|
112
|
-
- Faraday
|
|
89
|
+
- Faraday v1.0.1
|
|
113
90
|
Content-Type:
|
|
114
91
|
- application/json
|
|
115
92
|
Authorization:
|
|
@@ -117,81 +94,62 @@ http_interactions:
|
|
|
117
94
|
response:
|
|
118
95
|
status:
|
|
119
96
|
code: 200
|
|
120
|
-
message:
|
|
97
|
+
message: OK
|
|
121
98
|
headers:
|
|
122
99
|
server:
|
|
123
100
|
- nginx/1.10.1
|
|
124
101
|
date:
|
|
125
|
-
- Tue,
|
|
102
|
+
- Tue, 16 Mar 2021 12:27:19 GMT
|
|
126
103
|
content-type:
|
|
127
|
-
- application/json
|
|
104
|
+
- application/json
|
|
128
105
|
transfer-encoding:
|
|
129
106
|
- chunked
|
|
130
107
|
connection:
|
|
131
|
-
-
|
|
132
|
-
|
|
133
|
-
-
|
|
134
|
-
|
|
135
|
-
-
|
|
136
|
-
|
|
137
|
-
-
|
|
138
|
-
etag:
|
|
139
|
-
- W/"eb861872d3bd01a055485e96ccf38898"
|
|
140
|
-
cache-control:
|
|
141
|
-
- max-age=0, private, must-revalidate
|
|
142
|
-
x-request-id:
|
|
143
|
-
- 32f87d7c-f944-405d-a87c-2195f175940a
|
|
144
|
-
x-runtime:
|
|
145
|
-
- '0.022802'
|
|
146
|
-
strict-transport-security:
|
|
147
|
-
- max-age=15768000
|
|
108
|
+
- keep-alive
|
|
109
|
+
vary:
|
|
110
|
+
- Accept-Encoding, Accept-Encoding
|
|
111
|
+
status:
|
|
112
|
+
- 200 OK
|
|
113
|
+
access-control-allow-credentials:
|
|
114
|
+
- 'true'
|
|
148
115
|
body:
|
|
149
|
-
encoding:
|
|
150
|
-
string: '{"entries":[{"uuid":"
|
|
151
|
-
Customer","
|
|
116
|
+
encoding: ASCII-8BIT
|
|
117
|
+
string: '{"entries":[{"id":93760512,"uuid":"cus_f340970a-8652-11eb-a9f8-cfc7971a103f","external_id":"X1234","name":"Test
|
|
118
|
+
Customer","email":"test@example.com","status":"Lead","customer-since":null,"attributes":{"custom":{},"clearbit":{},"stripe":{},"tags":[]},"data_source_uuid":"ds_f2f67ad0-8652-11eb-a9f8-37471a677085","data_source_uuids":["ds_f2f67ad0-8652-11eb-a9f8-37471a677085"],"external_ids":["X1234"],"company":"","country":"DE","state":null,"city":"Berlin","zip":null,"lead_created_at":"2016-10-01T23:55:00.000Z","free_trial_started_at":"2016-10-12T11:12:00.000Z","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/93760512-Test_Customer","billing-system-type":"Import
|
|
119
|
+
API","currency":"USD","currency-sign":"$"}],"current_page":1,"total_pages":1,"has_more":false,"per_page":200,"page":1}'
|
|
152
120
|
http_version:
|
|
153
|
-
recorded_at: Tue,
|
|
121
|
+
recorded_at: Tue, 16 Mar 2021 12:27:19 GMT
|
|
154
122
|
- request:
|
|
155
123
|
method: delete
|
|
156
|
-
uri: https://api.chartmogul.com/v1/customers/
|
|
124
|
+
uri: https://api.chartmogul.com/v1/customers/cus_f340970a-8652-11eb-a9f8-cfc7971a103f
|
|
157
125
|
body:
|
|
158
126
|
encoding: US-ASCII
|
|
159
127
|
string: ''
|
|
160
128
|
headers:
|
|
161
129
|
User-Agent:
|
|
162
|
-
- Faraday
|
|
130
|
+
- Faraday v1.0.1
|
|
163
131
|
Authorization:
|
|
164
132
|
- Basic hidden
|
|
165
133
|
response:
|
|
166
134
|
status:
|
|
167
135
|
code: 204
|
|
168
|
-
message:
|
|
136
|
+
message: No Content
|
|
169
137
|
headers:
|
|
170
138
|
server:
|
|
171
139
|
- nginx/1.10.1
|
|
172
140
|
date:
|
|
173
|
-
- Tue,
|
|
141
|
+
- Tue, 16 Mar 2021 12:28:19 GMT
|
|
174
142
|
connection:
|
|
175
|
-
-
|
|
176
|
-
|
|
177
|
-
-
|
|
178
|
-
|
|
179
|
-
-
|
|
180
|
-
x-content-type-options:
|
|
181
|
-
- nosniff
|
|
182
|
-
cache-control:
|
|
183
|
-
- no-cache
|
|
184
|
-
x-request-id:
|
|
185
|
-
- f163488f-bbea-4937-897b-ee08b69a4560
|
|
186
|
-
x-runtime:
|
|
187
|
-
- '0.015696'
|
|
188
|
-
strict-transport-security:
|
|
189
|
-
- max-age=15768000
|
|
143
|
+
- keep-alive
|
|
144
|
+
status:
|
|
145
|
+
- 204 No Content
|
|
146
|
+
access-control-allow-credentials:
|
|
147
|
+
- 'true'
|
|
190
148
|
body:
|
|
191
149
|
encoding: UTF-8
|
|
192
150
|
string: ''
|
|
193
151
|
http_version:
|
|
194
|
-
recorded_at: Tue,
|
|
152
|
+
recorded_at: Tue, 16 Mar 2021 12:28:19 GMT
|
|
195
153
|
- request:
|
|
196
154
|
method: get
|
|
197
155
|
uri: https://api.chartmogul.com/v1/customers
|
|
@@ -200,7 +158,7 @@ http_interactions:
|
|
|
200
158
|
string: ''
|
|
201
159
|
headers:
|
|
202
160
|
User-Agent:
|
|
203
|
-
- Faraday
|
|
161
|
+
- Faraday v1.0.1
|
|
204
162
|
Content-Type:
|
|
205
163
|
- application/json
|
|
206
164
|
Authorization:
|
|
@@ -208,37 +166,27 @@ http_interactions:
|
|
|
208
166
|
response:
|
|
209
167
|
status:
|
|
210
168
|
code: 200
|
|
211
|
-
message:
|
|
169
|
+
message: OK
|
|
212
170
|
headers:
|
|
213
171
|
server:
|
|
214
172
|
- nginx/1.10.1
|
|
215
173
|
date:
|
|
216
|
-
- Tue,
|
|
174
|
+
- Tue, 16 Mar 2021 12:28:20 GMT
|
|
217
175
|
content-type:
|
|
218
|
-
- application/json
|
|
176
|
+
- application/json
|
|
219
177
|
transfer-encoding:
|
|
220
178
|
- chunked
|
|
221
179
|
connection:
|
|
222
|
-
-
|
|
223
|
-
|
|
224
|
-
-
|
|
225
|
-
|
|
226
|
-
-
|
|
227
|
-
|
|
228
|
-
-
|
|
229
|
-
etag:
|
|
230
|
-
- W/"82f80d77a5a88d6de206bb1feeb897cc"
|
|
231
|
-
cache-control:
|
|
232
|
-
- max-age=0, private, must-revalidate
|
|
233
|
-
x-request-id:
|
|
234
|
-
- 770d6629-03d8-4f55-8bec-dde047828e7e
|
|
235
|
-
x-runtime:
|
|
236
|
-
- '0.019712'
|
|
237
|
-
strict-transport-security:
|
|
238
|
-
- max-age=15768000
|
|
180
|
+
- keep-alive
|
|
181
|
+
vary:
|
|
182
|
+
- Accept-Encoding, Accept-Encoding
|
|
183
|
+
status:
|
|
184
|
+
- 200 OK
|
|
185
|
+
access-control-allow-credentials:
|
|
186
|
+
- 'true'
|
|
239
187
|
body:
|
|
240
|
-
encoding:
|
|
241
|
-
string: '{"
|
|
188
|
+
encoding: ASCII-8BIT
|
|
189
|
+
string: '{"entries":[],"current_page":1,"total_pages":1,"has_more":false,"per_page":200,"page":1}'
|
|
242
190
|
http_version:
|
|
243
|
-
recorded_at: Tue,
|
|
244
|
-
recorded_with: VCR
|
|
191
|
+
recorded_at: Tue, 16 Mar 2021 12:28:20 GMT
|
|
192
|
+
recorded_with: VCR 5.1.0
|
|
@@ -16,7 +16,7 @@ module ChartMogul
|
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
json = ChartMogul::Utils::JSONParser.parse(resp.body,
|
|
19
|
+
json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: immutable_keys)
|
|
20
20
|
new_from_json(json)
|
|
21
21
|
end
|
|
22
22
|
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, immutable_keys: self.class.immutable_keys)
|
|
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, immutable_keys: immutable_keys)
|
|
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, immutable_keys: immutable_keys)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def custom!(http_method, http_path, body_data = {})
|
|
@@ -15,7 +15,8 @@ module ChartMogul
|
|
|
15
15
|
req.headers['Content-Type'] = 'application/json'
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: immutable_keys)
|
|
19
20
|
new_from_json(json)
|
|
20
21
|
end
|
|
21
22
|
end
|
|
@@ -16,7 +16,7 @@ module ChartMogul
|
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
json = ChartMogul::Utils::JSONParser.parse(resp.body,
|
|
19
|
+
json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: self.class.immutable_keys)
|
|
20
20
|
|
|
21
21
|
assign_all_attributes(json)
|
|
22
22
|
end
|
|
@@ -31,7 +31,7 @@ module ChartMogul
|
|
|
31
31
|
req.body = JSON.dump(resource.serialize_for_write)
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
|
-
json = ChartMogul::Utils::JSONParser.parse(resp.body,
|
|
34
|
+
json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: immutable_keys)
|
|
35
35
|
|
|
36
36
|
new_from_json(json)
|
|
37
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
|
|
20
|
+
class << self; attr_reader :resource_path, :resource_name, :resource_root_key end
|
|
21
21
|
|
|
22
22
|
def self.set_resource_path(path)
|
|
23
23
|
@resource_path = ChartMogul::ResourcePath.new(path)
|
|
@@ -31,9 +31,13 @@ module ChartMogul
|
|
|
31
31
|
@resource_root_key = root_key
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
def self.immutable_keys
|
|
35
|
+
@immutable_keys ||= []
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# When set with keys, nested hash keys of these immutable keys won't be converted to snake case
|
|
39
|
+
def self.set_immutable_keys(array)
|
|
40
|
+
@immutable_keys = array
|
|
37
41
|
end
|
|
38
42
|
|
|
39
43
|
def self.connection
|
data/lib/chartmogul/customer.rb
CHANGED
|
@@ -4,7 +4,7 @@ module ChartMogul
|
|
|
4
4
|
class Customer < APIResource
|
|
5
5
|
set_resource_name 'Customer'
|
|
6
6
|
set_resource_path '/v1/customers'
|
|
7
|
-
|
|
7
|
+
set_immutable_keys([:attributes, :custom])
|
|
8
8
|
|
|
9
9
|
readonly_attr :uuid
|
|
10
10
|
readonly_attr :id
|
|
@@ -132,7 +132,7 @@ module ChartMogul
|
|
|
132
132
|
class Customers < APIResource
|
|
133
133
|
set_resource_name 'Customers'
|
|
134
134
|
set_resource_path '/v1/customers'
|
|
135
|
-
|
|
135
|
+
set_immutable_keys([:attributes, :custom])
|
|
136
136
|
|
|
137
137
|
include Concerns::Entries
|
|
138
138
|
include API::Actions::Custom
|
|
@@ -8,8 +8,9 @@ module ChartMogul
|
|
|
8
8
|
# Rubyish snake_case, suitable for use during instantiation of Ruby
|
|
9
9
|
# model attributes.
|
|
10
10
|
#
|
|
11
|
-
def initialize(hash)
|
|
11
|
+
def initialize(hash, immutable_keys: [])
|
|
12
12
|
@hash = hash
|
|
13
|
+
@immutable_keys = immutable_keys
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
def to_snake_keys(value = @hash)
|
|
@@ -26,7 +27,13 @@ module ChartMogul
|
|
|
26
27
|
private
|
|
27
28
|
|
|
28
29
|
def snake_hash(value)
|
|
29
|
-
Hash[value.map { |k, v| [underscore_key(k),
|
|
30
|
+
Hash[value.map { |k, v| [underscore_key(k), immutable_check(k, v)] }]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def immutable_check(k,v)
|
|
34
|
+
return v if @immutable_keys.include?(k)
|
|
35
|
+
|
|
36
|
+
to_snake_keys(v)
|
|
30
37
|
end
|
|
31
38
|
|
|
32
39
|
def underscore_key(k)
|
|
@@ -4,11 +4,9 @@ module ChartMogul
|
|
|
4
4
|
module Utils
|
|
5
5
|
class JSONParser
|
|
6
6
|
class << self
|
|
7
|
-
def parse(json_string,
|
|
7
|
+
def parse(json_string, immutable_keys: [])
|
|
8
8
|
hash = JSON.parse(json_string, symbolize_names: true)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
HashSnakeCaser.new(hash).to_snake_keys
|
|
9
|
+
HashSnakeCaser.new(hash, immutable_keys: immutable_keys).to_snake_keys
|
|
12
10
|
end
|
|
13
11
|
|
|
14
12
|
def typecast_custom_attributes(custom_attributes)
|
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.7.
|
|
4
|
+
version: 1.7.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Petr Kopac
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-03-
|
|
11
|
+
date: 2021-03-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|