intercom 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/changes.txt CHANGED
@@ -1,3 +1,6 @@
1
+ 0.1.10
2
+ - fix broken tag updating :(
3
+
1
4
  0.1.9
2
5
  - better response object for tags
3
6
 
@@ -1,9 +1,7 @@
1
1
  module Intercom
2
2
  module HashableObject
3
3
  def from_hash(hash)
4
- hash.each do |key,value|
5
- instance_variable_set("@#{key}".to_sym, value)
6
- end
4
+ hash.each {|attribute, value| instance_variable_set("@#{attribute}".to_sym, value) }
7
5
  end
8
6
 
9
7
  def to_hash
@@ -14,7 +12,11 @@ module Intercom
14
12
  end
15
13
 
16
14
  def displayable_attributes
17
- to_hash.delete_if {|k, v| !self.respond_to?(k) }
15
+ to_hash.select {|attribute, value| self.respond_to?(attribute) }
16
+ end
17
+
18
+ def to_wire
19
+ to_hash.select {|attribute, value| self.respond_to?("#{attribute.to_s}=") }
18
20
  end
19
21
  end
20
22
  end
data/lib/intercom/tag.rb CHANGED
@@ -32,7 +32,9 @@ module Intercom
32
32
  extend RequiresParameters
33
33
  include HashableObject
34
34
 
35
- attr_reader :name, :color, :segment, :tagged_user_count, :id
35
+ attr_accessor :name, :color
36
+ attr_reader :segment, :tagged_user_count, :id
37
+ attr_writer :user_ids, :emails, :tag_or_untag
36
38
 
37
39
  def initialize(attributes={})
38
40
  from_hash(attributes)
@@ -68,7 +70,7 @@ module Intercom
68
70
  ##
69
71
  # Saves a Tag on your application
70
72
  def save
71
- response = Intercom.post("/v1/tags", to_hash)
73
+ response = Intercom.post("/v1/tags", to_wire)
72
74
  self.from_hash(response)
73
75
  displayable_self
74
76
  end
@@ -1,3 +1,3 @@
1
1
  module Intercom #:nodoc:
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -98,6 +98,16 @@ def test_tag
98
98
  }
99
99
  end
100
100
 
101
+ def updated_test_tag
102
+ {
103
+ "id" => "4f73428b5e4dfc000b000112",
104
+ "name" => "Test Tag",
105
+ "color" => "green",
106
+ "segment" => false,
107
+ "tagged_user_count" => 2
108
+ }
109
+ end
110
+
101
111
  def error_on_modify_frozen
102
112
  RUBY_VERSION =~ /1.8/ ? TypeError : RuntimeError
103
113
  end
@@ -30,4 +30,13 @@ describe "Intercom::Tag" do
30
30
  tag.tagged_user_count.must_equal 2
31
31
  end
32
32
 
33
+ it "updates tags" do
34
+ Intercom.expects(:get).with("/v1/tags", {:name => "Test Tag"}).returns(test_tag)
35
+ tag = Intercom::Tag.find_by_name "Test Tag"
36
+ tag.color.must_equal "red"
37
+ tag.color = "green"
38
+ Intercom.expects(:post).with("/v1/tags", {:name => "Test Tag", :color => "green"}).returns(updated_test_tag)
39
+ tag.save
40
+ end
41
+
33
42
  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: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: