intercom 0.1.8 → 0.1.9
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.
- data/changes.txt +3 -0
- data/lib/intercom/hashable_object.rb +5 -2
- data/lib/intercom/tag.rb +10 -4
- data/lib/intercom/version.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +2 -2
data/changes.txt
CHANGED
@@ -2,8 +2,7 @@ module Intercom
|
|
2
2
|
module HashableObject
|
3
3
|
def from_hash(hash)
|
4
4
|
hash.each do |key,value|
|
5
|
-
|
6
|
-
self.send(setter_method, value) if self.respond_to?(setter_method)
|
5
|
+
instance_variable_set("@#{key}".to_sym, value)
|
7
6
|
end
|
8
7
|
end
|
9
8
|
|
@@ -13,5 +12,9 @@ module Intercom
|
|
13
12
|
hash
|
14
13
|
end
|
15
14
|
end
|
15
|
+
|
16
|
+
def displayable_attributes
|
17
|
+
to_hash.delete_if {|k, v| !self.respond_to?(k) }
|
18
|
+
end
|
16
19
|
end
|
17
20
|
end
|
data/lib/intercom/tag.rb
CHANGED
@@ -24,7 +24,7 @@ module Intercom
|
|
24
24
|
# Or update a tag and save it like this:
|
25
25
|
# tag = Intercom::Tag.find_by_name "Super Tag"
|
26
26
|
# tag.color = "green"
|
27
|
-
# tag.user_ids
|
27
|
+
# tag.user_ids = ['abc123']
|
28
28
|
# tag.tag_or_untag = "untag"
|
29
29
|
# tag.save
|
30
30
|
|
@@ -32,7 +32,7 @@ module Intercom
|
|
32
32
|
extend RequiresParameters
|
33
33
|
include HashableObject
|
34
34
|
|
35
|
-
|
35
|
+
attr_reader :name, :color, :segment, :tagged_user_count, :id
|
36
36
|
|
37
37
|
def initialize(attributes={})
|
38
38
|
from_hash(attributes)
|
@@ -48,7 +48,7 @@ module Intercom
|
|
48
48
|
def self.from_api(api_response)
|
49
49
|
tag = Tag.new
|
50
50
|
tag.from_hash(api_response)
|
51
|
-
tag
|
51
|
+
tag.displayable_self
|
52
52
|
end
|
53
53
|
|
54
54
|
##
|
@@ -70,7 +70,13 @@ module Intercom
|
|
70
70
|
def save
|
71
71
|
response = Intercom.post("/v1/tags", to_hash)
|
72
72
|
self.from_hash(response)
|
73
|
-
|
73
|
+
displayable_self
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# Create a new clean instance to return (only showing the readable attributes)
|
78
|
+
def displayable_self
|
79
|
+
Tag.new(self.displayable_attributes)
|
74
80
|
end
|
75
81
|
end
|
76
82
|
end
|
data/lib/intercom/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
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: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2013-04-
|
16
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: minitest
|