chartmogul-ruby 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/chartmogul-ruby.gemspec +1 -1
- data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_custom_attributes.yml +1 -2
- data/lib/chartmogul/customer.rb +2 -13
- data/lib/chartmogul/enrichment/customer.rb +3 -13
- data/lib/chartmogul/utils/json_parser.rb +19 -3
- data/lib/chartmogul/version.rb +1 -1
- metadata +18 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 31731f1df4e34d838b148dc025e7cf1ac680ff05
|
4
|
+
data.tar.gz: 4bc5b8118c09794398ae8b6c0ac0a856c3a6ba72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d59360584c726bc60c2073cddd222ef73963084998f289c51fc4f26fe27e42b20ffa515be5d3ce2b48d3ff3b273c286625ee2bd7558bb58b2c66339a9c32566
|
7
|
+
data.tar.gz: 439d8190fd2c792f13b47d036e30aa58650fcffaba927f8fff8306974d6d9f2786b9c57f8db230387bdf1cb77667b9f1ec9ff271021150c8fa673c563921319a
|
data/chartmogul-ruby.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'rake', '~> 10.0'
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
28
28
|
spec.add_development_dependency 'vcr', '~> 3.0'
|
29
|
-
spec.add_development_dependency 'pry', '~> 0.10.3'
|
30
29
|
spec.add_development_dependency 'webmock', '~> 3.4', '>= 3.4.2'
|
31
30
|
spec.add_development_dependency 'simplecov', '~> 0.16.0'
|
31
|
+
spec.add_development_dependency 'pry', '~> 0.12.2'
|
32
32
|
end
|
data/fixtures/vcr_cassettes/ChartMogul_Customer/API_Interactions/updates_custom_attributes.yml
CHANGED
@@ -75,8 +75,7 @@ http_interactions:
|
|
75
75
|
- 'true'
|
76
76
|
body:
|
77
77
|
encoding: UTF-8
|
78
|
-
string: '{"custom":{"string_key":"Another String Value","integer_key":5678,"timestamp_key":"2016-02-
|
79
|
-
00:00:00 UTC","boolean_key":false}}'
|
78
|
+
string: '{"custom":{"string_key":"Another String Value","integer_key":5678,"timestamp_key":"2016-02-01T00:00:00.000Z","boolean_key":false}}'
|
80
79
|
http_version:
|
81
80
|
recorded_at: Wed, 29 Jun 2016 12:47:09 GMT
|
82
81
|
recorded_with: VCR 3.0.3
|
data/lib/chartmogul/customer.rb
CHANGED
@@ -117,23 +117,12 @@ module ChartMogul
|
|
117
117
|
end
|
118
118
|
|
119
119
|
def custom_attributes=(custom_attributes = {})
|
120
|
-
@attributes[:custom] = typecast_custom_attributes(custom_attributes)
|
120
|
+
@attributes[:custom] = ChartMogul::Utils::JSONParser.typecast_custom_attributes(custom_attributes)
|
121
121
|
end
|
122
122
|
|
123
123
|
def set_attributes(attributes_attributes)
|
124
124
|
@attributes = attributes_attributes
|
125
|
-
@attributes[:custom] = typecast_custom_attributes(attributes_attributes[:custom])
|
126
|
-
end
|
127
|
-
|
128
|
-
def typecast_custom_attributes(custom_attributes)
|
129
|
-
return {} unless custom_attributes
|
130
|
-
custom_attributes.each_with_object({}) do |(key, value), hash|
|
131
|
-
hash[key] = value.instance_of?(String) ? (begin
|
132
|
-
Time.parse(value)
|
133
|
-
rescue
|
134
|
-
value
|
135
|
-
end) : value
|
136
|
-
end
|
125
|
+
@attributes[:custom] = ChartMogul::Utils::JSONParser.typecast_custom_attributes(attributes_attributes[:custom])
|
137
126
|
end
|
138
127
|
end
|
139
128
|
|
@@ -94,24 +94,14 @@ module ChartMogul
|
|
94
94
|
@attributes[:tags] = tags
|
95
95
|
end
|
96
96
|
|
97
|
+
# When passing timestamps, either use Time instance, or iso8601-parseable string.
|
97
98
|
def custom_attributes=(custom_attributes = {})
|
98
|
-
@attributes[:custom] = typecast_custom_attributes(custom_attributes)
|
99
|
+
@attributes[:custom] = ChartMogul::Utils::JSONParser.typecast_custom_attributes(custom_attributes)
|
99
100
|
end
|
100
101
|
|
101
102
|
def set_attributes(attributes_attributes)
|
102
103
|
@attributes = attributes_attributes
|
103
|
-
@attributes[:custom] = typecast_custom_attributes(attributes_attributes[:custom])
|
104
|
-
end
|
105
|
-
|
106
|
-
def typecast_custom_attributes(custom_attributes)
|
107
|
-
return {} unless custom_attributes
|
108
|
-
custom_attributes.each_with_object({}) do |(key, value), hash|
|
109
|
-
hash[key] = value.instance_of?(String) ? (begin
|
110
|
-
Time.parse(value)
|
111
|
-
rescue
|
112
|
-
value
|
113
|
-
end) : value
|
114
|
-
end
|
104
|
+
@attributes[:custom] = ChartMogul::Utils::JSONParser.typecast_custom_attributes(attributes_attributes[:custom])
|
115
105
|
end
|
116
106
|
end
|
117
107
|
|
@@ -1,9 +1,25 @@
|
|
1
1
|
module ChartMogul
|
2
2
|
module Utils
|
3
3
|
class JSONParser
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
class << self
|
5
|
+
def parse(json_string)
|
6
|
+
hash = JSON.parse(json_string, symbolize_names: true)
|
7
|
+
HashSnakeCaser.new(hash).to_snake_keys
|
8
|
+
end
|
9
|
+
|
10
|
+
def typecast_custom_attributes(custom_attributes)
|
11
|
+
return {} unless custom_attributes
|
12
|
+
|
13
|
+
custom_attributes.each_with_object({}) do |(key, value), hash|
|
14
|
+
hash[key] = opt_string_to_time(value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def opt_string_to_time(value)
|
19
|
+
return value unless value.instance_of?(String)
|
20
|
+
|
21
|
+
Time.iso8601(value) rescue Time.rfc2822(value) rescue value
|
22
|
+
end
|
7
23
|
end
|
8
24
|
end
|
9
25
|
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.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Langenauer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: pry
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.10.3
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.10.3
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: webmock
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,6 +114,20 @@ dependencies:
|
|
128
114
|
- - "~>"
|
129
115
|
- !ruby/object:Gem::Version
|
130
116
|
version: 0.16.0
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: pry
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 0.12.2
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 0.12.2
|
131
131
|
description: Official Ruby client for ChartMogul's API
|
132
132
|
email:
|
133
133
|
- jason@chartmogul.com
|
@@ -281,7 +281,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
281
281
|
- !ruby/object:Gem::Version
|
282
282
|
version: '0'
|
283
283
|
requirements: []
|
284
|
-
|
284
|
+
rubyforge_project:
|
285
|
+
rubygems_version: 2.6.14.4
|
285
286
|
signing_key:
|
286
287
|
specification_version: 4
|
287
288
|
summary: Chartmogul API Ruby Client
|