intercom 4.2.2 → 4.2.3
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/.circleci/config.yml +65 -9
- data/Gemfile +1 -1
- data/changes.txt +3 -0
- data/lib/intercom/lib/dynamic_accessors.rb +31 -24
- data/lib/intercom/traits/api_resource.rb +10 -2
- data/lib/intercom/traits/dirty_tracking.rb +2 -2
- data/lib/intercom/version.rb +1 -1
- data/spec/unit/intercom/article_spec.rb +19 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 97caaa1c044ea1370944d335cfc0d6e004966d8f84ba547a83ca78daa2be3d11
|
|
4
|
+
data.tar.gz: dfd96074bef226daa006f2b4c18aa2b6b6ee5a582301ea18e783962a5a4bcab9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dfec5a80b9442a047087608f564db3d9380ae106e4cffae99f11d9e1c33915e5a984957712ea7f09d213abd4cd968cee6d642d241d2a9ef7020a30a1ce953497
|
|
7
|
+
data.tar.gz: a7370a062eff270da20077fba81930af2cdfa92f9845583bdf498ee95bc18867672577d916bf57843bbf07ed16da5524e971e85e97827ee578efa53a753303a5
|
data/.circleci/config.yml
CHANGED
|
@@ -1,35 +1,91 @@
|
|
|
1
|
-
version: 2
|
|
1
|
+
version: 2.1
|
|
2
2
|
jobs:
|
|
3
|
-
|
|
3
|
+
test-ruby-2-4:
|
|
4
4
|
docker:
|
|
5
5
|
- image: circleci/ruby:2.4.9
|
|
6
6
|
working_directory: ~/intercom-ruby
|
|
7
7
|
steps:
|
|
8
8
|
- checkout
|
|
9
|
+
- run:
|
|
10
|
+
name: Route Bundler through the Socket Firewall registry
|
|
11
|
+
command: |
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
if [ -z "${SOCKET_GEM_URL:-}" ]; then
|
|
14
|
+
# CircleCI does not share context credentials with forked PRs, so a
|
|
15
|
+
# fork cannot be routed. Say so rather than failing the contributor.
|
|
16
|
+
if [ -n "${CIRCLE_PR_REPONAME:-}" ]; then
|
|
17
|
+
echo "Forked PR: no Socket Firewall credentials available, gems will come from rubygems.org."
|
|
18
|
+
exit 0
|
|
19
|
+
fi
|
|
20
|
+
echo "FATAL: SOCKET_GEM_URL is required (provided by the socket-firewall context)"
|
|
21
|
+
exit 1
|
|
22
|
+
fi
|
|
23
|
+
# Legacy two-argument form: these images ship Bundler 1.x, where
|
|
24
|
+
# `bundle config set --global` does not exist and silently no-ops.
|
|
25
|
+
bundle config mirror.https://rubygems.org "$SOCKET_GEM_URL"
|
|
26
|
+
bundle config mirror.https://rubygems.org | grep -q socket-firewall-registry \
|
|
27
|
+
|| { echo "FAIL: bundler mirror not pointing at Socket Firewall"; exit 1; }
|
|
9
28
|
- run: bundle install
|
|
10
29
|
- run: bundle exec rake
|
|
11
|
-
|
|
30
|
+
test-ruby-2-5:
|
|
12
31
|
docker:
|
|
13
32
|
- image: circleci/ruby:2.5.7
|
|
14
33
|
working_directory: ~/intercom-ruby
|
|
15
34
|
steps:
|
|
16
35
|
- checkout
|
|
36
|
+
- run:
|
|
37
|
+
name: Route Bundler through the Socket Firewall registry
|
|
38
|
+
command: |
|
|
39
|
+
set -euo pipefail
|
|
40
|
+
if [ -z "${SOCKET_GEM_URL:-}" ]; then
|
|
41
|
+
if [ -n "${CIRCLE_PR_REPONAME:-}" ]; then
|
|
42
|
+
echo "Forked PR: no Socket Firewall credentials available, gems will come from rubygems.org."
|
|
43
|
+
exit 0
|
|
44
|
+
fi
|
|
45
|
+
echo "FATAL: SOCKET_GEM_URL is required (provided by the socket-firewall context)"
|
|
46
|
+
exit 1
|
|
47
|
+
fi
|
|
48
|
+
bundle config mirror.https://rubygems.org "$SOCKET_GEM_URL"
|
|
49
|
+
bundle config mirror.https://rubygems.org | grep -q socket-firewall-registry \
|
|
50
|
+
|| { echo "FAIL: bundler mirror not pointing at Socket Firewall"; exit 1; }
|
|
17
51
|
- run: bundle install
|
|
18
52
|
- run: bundle exec rake
|
|
19
|
-
|
|
53
|
+
test-ruby-2-6:
|
|
20
54
|
docker:
|
|
21
55
|
- image: circleci/ruby:2.6.5
|
|
22
56
|
working_directory: ~/intercom-ruby
|
|
23
57
|
steps:
|
|
24
58
|
- checkout
|
|
59
|
+
- run:
|
|
60
|
+
name: Route Bundler through the Socket Firewall registry
|
|
61
|
+
command: |
|
|
62
|
+
set -euo pipefail
|
|
63
|
+
if [ -z "${SOCKET_GEM_URL:-}" ]; then
|
|
64
|
+
if [ -n "${CIRCLE_PR_REPONAME:-}" ]; then
|
|
65
|
+
echo "Forked PR: no Socket Firewall credentials available, gems will come from rubygems.org."
|
|
66
|
+
exit 0
|
|
67
|
+
fi
|
|
68
|
+
echo "FATAL: SOCKET_GEM_URL is required (provided by the socket-firewall context)"
|
|
69
|
+
exit 1
|
|
70
|
+
fi
|
|
71
|
+
bundle config mirror.https://rubygems.org "$SOCKET_GEM_URL"
|
|
72
|
+
bundle config mirror.https://rubygems.org | grep -q socket-firewall-registry \
|
|
73
|
+
|| { echo "FAIL: bundler mirror not pointing at Socket Firewall"; exit 1; }
|
|
25
74
|
- run: bundle install
|
|
26
75
|
- run: bundle exec rake
|
|
27
76
|
|
|
28
77
|
workflows:
|
|
29
|
-
version: 2
|
|
30
78
|
build_and_test:
|
|
31
79
|
jobs:
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
80
|
+
- test-ruby-2-4:
|
|
81
|
+
name: "Test against Ruby 2.4"
|
|
82
|
+
context:
|
|
83
|
+
- socket-firewall
|
|
84
|
+
- test-ruby-2-5:
|
|
85
|
+
name: "Test against Ruby 2.5"
|
|
86
|
+
context:
|
|
87
|
+
- socket-firewall
|
|
88
|
+
- test-ruby-2-6:
|
|
89
|
+
name: "Test against Ruby 2.6"
|
|
90
|
+
context:
|
|
91
|
+
- socket-firewall
|
data/Gemfile
CHANGED
data/changes.txt
CHANGED
|
@@ -17,39 +17,46 @@ module Intercom
|
|
|
17
17
|
private
|
|
18
18
|
|
|
19
19
|
def define_flat_store_based_accessors(attribute, value, object)
|
|
20
|
-
object
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
ivar = ivar_name(attribute, object)
|
|
21
|
+
object.singleton_class.class_eval do
|
|
22
|
+
define_method("#{attribute}=") do |val|
|
|
23
|
+
mark_field_as_changed!(attribute.to_sym)
|
|
24
|
+
instance_variable_set(ivar, Intercom::Lib::FlatStore.new(val))
|
|
24
25
|
end
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
end
|
|
28
|
-
"
|
|
26
|
+
define_method(attribute) { instance_variable_get(ivar) }
|
|
27
|
+
end
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
def define_date_based_accessors(attribute, value, object)
|
|
32
|
-
object
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
ivar = ivar_name(attribute, object)
|
|
32
|
+
object.singleton_class.class_eval do
|
|
33
|
+
define_method("#{attribute}=") do |val|
|
|
34
|
+
mark_field_as_changed!(attribute.to_sym)
|
|
35
|
+
instance_variable_set(ivar, val.nil? ? nil : val.to_i)
|
|
36
36
|
end
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
define_method(attribute) do
|
|
38
|
+
time = instance_variable_get(ivar)
|
|
39
|
+
time.nil? ? nil : Time.at(time)
|
|
39
40
|
end
|
|
40
|
-
|
|
41
|
+
end
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
def define_standard_accessors(attribute, value, object)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
ivar = ivar_name(attribute, object)
|
|
46
|
+
object.singleton_class.class_eval do
|
|
47
|
+
define_method("#{attribute}=") do |val|
|
|
48
|
+
mark_field_as_changed!(attribute.to_sym)
|
|
49
|
+
instance_variable_set(ivar, val)
|
|
50
|
+
end
|
|
51
|
+
define_method(attribute) { instance_variable_get(ivar) }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Keys such as "pt-BR" are not valid identifiers, so normalise them for the ivar name.
|
|
56
|
+
def ivar_name(attribute, object)
|
|
57
|
+
ivar = "@#{attribute.to_s.gsub(/\W/, '_')}"
|
|
58
|
+
object.register_attribute_key(ivar, attribute) if ivar != "@#{attribute}"
|
|
59
|
+
ivar
|
|
53
60
|
end
|
|
54
61
|
|
|
55
62
|
end
|
|
@@ -37,7 +37,7 @@ module Intercom
|
|
|
37
37
|
|
|
38
38
|
def to_hash
|
|
39
39
|
instance_variables_excluding_dirty_tracking_field.each_with_object({}) do |variable, hash|
|
|
40
|
-
hash[variable
|
|
40
|
+
hash[attribute_key(variable)] = instance_variable_get(variable)
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -46,10 +46,18 @@ module Intercom
|
|
|
46
46
|
next if variable == :@client
|
|
47
47
|
|
|
48
48
|
value = instance_variable_get(variable)
|
|
49
|
-
hash[variable
|
|
49
|
+
hash[attribute_key(variable)] = value.respond_to?(:to_json) ? value.to_json(*args) : value
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
def register_attribute_key(ivar, attribute)
|
|
54
|
+
(@attribute_keys ||= {})[ivar.to_sym] = attribute.to_s
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def attribute_key(variable)
|
|
58
|
+
(@attribute_keys || {}).fetch(variable, variable.to_s.delete('@'))
|
|
59
|
+
end
|
|
60
|
+
|
|
53
61
|
def to_submittable_hash
|
|
54
62
|
submittable_hash = {}
|
|
55
63
|
to_hash.each do |attribute, value|
|
|
@@ -22,7 +22,7 @@ module Intercom
|
|
|
22
22
|
|
|
23
23
|
def field_changed?(field_name)
|
|
24
24
|
@changed_fields ||= Set.new
|
|
25
|
-
field = instance_variable_get("@#{field_name}")
|
|
25
|
+
field = instance_variable_get("@#{field_name.to_s.gsub(/\W/, '_')}")
|
|
26
26
|
if field.respond_to?(:field_changed?)
|
|
27
27
|
field.to_hash.any? do |attribute, _|
|
|
28
28
|
field.field_changed?(attribute)
|
|
@@ -33,7 +33,7 @@ module Intercom
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def instance_variables_excluding_dirty_tracking_field
|
|
36
|
-
instance_variables.reject{|var| var == :@changed_fields}
|
|
36
|
+
instance_variables.reject{|var| var == :@changed_fields || var == :@attribute_keys}
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
end
|
data/lib/intercom/version.rb
CHANGED
|
@@ -37,4 +37,22 @@ describe "Intercom::Article" do
|
|
|
37
37
|
client.articles.delete(article)
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
|
-
|
|
40
|
+
|
|
41
|
+
describe "Parsing an Article" do
|
|
42
|
+
it "handles hyphenated locale keys in translated content" do
|
|
43
|
+
article = Intercom::Article.from_api(
|
|
44
|
+
"id" => "1",
|
|
45
|
+
"type" => "article",
|
|
46
|
+
"translated_content" => {
|
|
47
|
+
"type" => "article_translated_content",
|
|
48
|
+
"fr" => { "type" => "article_content", "title" => "Bonjour" },
|
|
49
|
+
"pt-BR" => { "type" => "article_content", "title" => "Ola" }
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
_(article.translated_content.fr.title).must_equal "Bonjour"
|
|
53
|
+
_(article.translated_content.public_send("pt-BR").title).must_equal "Ola"
|
|
54
|
+
article.translated_content.public_send("pt-BR").title = "Oi"
|
|
55
|
+
_(article.to_submittable_hash).must_equal("translated_content" => { "pt-BR" => { "title" => "Oi" } })
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: intercom
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.2.
|
|
4
|
+
version: 4.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ben McRedmond
|
|
@@ -12,10 +12,10 @@ authors:
|
|
|
12
12
|
- Declan McGrath
|
|
13
13
|
- Jamie Osler
|
|
14
14
|
- Bob Long
|
|
15
|
-
autorequire:
|
|
15
|
+
autorequire:
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
|
-
date:
|
|
18
|
+
date: 2026-10-08 00:00:00.000000000 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: minitest
|
|
@@ -264,7 +264,7 @@ homepage: https://www.intercom.io
|
|
|
264
264
|
licenses:
|
|
265
265
|
- MIT
|
|
266
266
|
metadata: {}
|
|
267
|
-
post_install_message:
|
|
267
|
+
post_install_message:
|
|
268
268
|
rdoc_options: []
|
|
269
269
|
require_paths:
|
|
270
270
|
- lib
|
|
@@ -280,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
280
280
|
version: '0'
|
|
281
281
|
requirements: []
|
|
282
282
|
rubygems_version: 3.0.3.1
|
|
283
|
-
signing_key:
|
|
283
|
+
signing_key:
|
|
284
284
|
specification_version: 4
|
|
285
285
|
summary: Ruby bindings for the Intercom API
|
|
286
286
|
test_files:
|