intercom 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ 0.1.9
2
+ - better response object for tags
3
+
1
4
  0.1.8
2
5
  - change tag response to match the new api response. add support to query users that are tagged with a specific tag
3
6
 
@@ -2,8 +2,7 @@ module Intercom
2
2
  module HashableObject
3
3
  def from_hash(hash)
4
4
  hash.each do |key,value|
5
- setter_method = "#{key.to_s}="
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
@@ -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 << 'abc123'
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
- attr_accessor :name, :color, :user_ids, :emails, :tag_or_untag, :segment, :tagged_user_count, :id
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
- self
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
@@ -1,3 +1,3 @@
1
1
  module Intercom #:nodoc:
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'intercom'
2
2
  require 'minitest/autorun'
3
- require 'mocha'
3
+ require 'mocha/setup'
4
4
 
5
5
  def test_user(email="bob@example.com")
6
6
  {
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.8
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-09 00:00:00.000000000 Z
16
+ date: 2013-04-11 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: minitest