intercom 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -0
- data/changes.txt +6 -0
- data/lib/intercom.rb +1 -0
- data/lib/intercom/note.rb +45 -0
- data/lib/intercom/unix_timestamp_unwrapper.rb +2 -2
- data/lib/intercom/version.rb +1 -1
- data/spec/integration/intercom_api_integration_spec.rb +6 -0
- data/spec/unit/intercom/note_spec.rb +18 -0
- data/spec/unit/intercom/user_spec.rb +1 -7
- metadata +5 -3
data/README.rdoc
CHANGED
@@ -25,6 +25,7 @@ The API supports:
|
|
25
25
|
POST,PUT,GET https://api.intercom.io/v1/users
|
26
26
|
POST,PUT,GET https://api.intercom.io/v1/users/messages
|
27
27
|
POST https://api.intercom.io/v1/users/impressions
|
28
|
+
POST https://api.intercom.io/v1/users/notes
|
28
29
|
|
29
30
|
=== Examples:
|
30
31
|
|
@@ -52,6 +53,10 @@ The API supports:
|
|
52
53
|
|
53
54
|
Intercom::Impression.create(:email => "bob@example.com", :location => "/path/in/my/app", :user_ip => "1.2.3.4", :user_agent => "my-savage-iphone-app-0.1"
|
54
55
|
|
56
|
+
==== Notes
|
57
|
+
|
58
|
+
Intercom::Note.create(:email => "bob@example.com", :body => "This is the text of the note"
|
59
|
+
|
55
60
|
=== Errors
|
56
61
|
|
57
62
|
Intercom::AuthenticationError
|
data/changes.txt
CHANGED
data/lib/intercom.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'intercom/user_resource'
|
2
|
+
|
3
|
+
module Intercom
|
4
|
+
|
5
|
+
##
|
6
|
+
# Represents a note on a user
|
7
|
+
#
|
8
|
+
# A note contains a note (the text of the note you want to leave)
|
9
|
+
#
|
10
|
+
# == Examples
|
11
|
+
#
|
12
|
+
# note = Intercom::Note.create(:email => "person@example.com", :body => "This is the note you want to make on the user account")
|
13
|
+
|
14
|
+
# You can also create a note and save it like this:
|
15
|
+
# note = Intercom::Note.new
|
16
|
+
# note.body = "This is the note you want to make on the user account"
|
17
|
+
# note.save
|
18
|
+
|
19
|
+
class Note < UserResource
|
20
|
+
##
|
21
|
+
# Creates a new Note using params and saves it
|
22
|
+
# @see #save
|
23
|
+
def self.create(params)
|
24
|
+
requires_parameters(params, %W(body))
|
25
|
+
Note.new(params).save
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Records a note on a user of your application
|
30
|
+
def save
|
31
|
+
response = Intercom.post("users/notes", to_hash)
|
32
|
+
self.update_from_api_response(response)
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Set the text of the note for the user
|
37
|
+
def body=(body)
|
38
|
+
@attributes["body"] = body
|
39
|
+
end
|
40
|
+
|
41
|
+
def user
|
42
|
+
User.from_api(@attributes['user'])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/intercom/version.rb
CHANGED
@@ -47,4 +47,10 @@ describe "api.intercom.io dummy data requests" do
|
|
47
47
|
impression.unread_messages.must_be :>, 0
|
48
48
|
impression.email.must_equal 'somebody@example.com'
|
49
49
|
end
|
50
|
+
|
51
|
+
it "should create some notes" do
|
52
|
+
note = Intercom::Note.create(:body => "This is a note", :email => "somebody@example.com")
|
53
|
+
note.html.must_equal "<p>This is a note</p>"
|
54
|
+
note.user.email.must_equal "somebody@example.com"
|
55
|
+
end
|
50
56
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "/v1/notes" do
|
4
|
+
it "creates a note" do
|
5
|
+
Intercom.expects(:post).with("users/notes", {"body" => "Note to leave on user"}).returns({"html" => "<p>Note to leave on user</p>", "created_at" => 1234567890})
|
6
|
+
note = Intercom::Note.create("body" => "Note to leave on user")
|
7
|
+
note.html.must_equal "<p>Note to leave on user</p>"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "sets/gets allowed keys" do
|
11
|
+
params = {"body" => "Note body", "email" => "me@example.com", :user_id => "abc123"}
|
12
|
+
note = Intercom::Note.new(params)
|
13
|
+
note.to_hash.keys.sort.must_equal params.keys.map(&:to_s).sort
|
14
|
+
params.keys.each do | key|
|
15
|
+
note.send(key).must_equal params[key]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -123,12 +123,6 @@ describe "Intercom::User" do
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
|
126
|
-
it "allows setting dates to nil without converting them to 0" do
|
127
|
-
Intercom.expects(:post).with("users", {"email" => "jo@example.com", "created_at" => nil}).returns({"email" => "jo@example.com"})
|
128
|
-
user = Intercom::User.create("email" => "jo@example.com", "created_at" => nil)
|
129
|
-
user.created_at.must_equal nil
|
130
|
-
end
|
131
|
-
|
132
126
|
it "sets/gets rw keys" do
|
133
127
|
params = {"email" => "me@example.com", :user_id => "abc123", "name" => "Bob Smith", "last_seen_ip" => "1.2.3.4", "last_seen_user_agent" => "ie6", "created_at" => Time.now}
|
134
128
|
user = Intercom::User.new(params)
|
@@ -158,4 +152,4 @@ describe "Intercom::User" do
|
|
158
152
|
Intercom::User.expects(:find).with(:user_id => "abc123")
|
159
153
|
Intercom::User.find_by_user_id("abc123")
|
160
154
|
end
|
161
|
-
end
|
155
|
+
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.0.
|
4
|
+
version: 0.0.11
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-01-
|
14
|
+
date: 2013-01-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: minitest
|
@@ -84,6 +84,7 @@ files:
|
|
84
84
|
- lib/intercom.rb
|
85
85
|
- lib/intercom/impression.rb
|
86
86
|
- lib/intercom/message_thread.rb
|
87
|
+
- lib/intercom/note.rb
|
87
88
|
- lib/intercom/request.rb
|
88
89
|
- lib/intercom/social_profile.rb
|
89
90
|
- lib/intercom/unix_timestamp_unwrapper.rb
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- spec/integration/intercom_api_integration_spec.rb
|
96
97
|
- spec/unit/intercom/impression_spec.rb
|
97
98
|
- spec/unit/intercom/message_thread_spec.rb
|
99
|
+
- spec/unit/intercom/note_spec.rb
|
98
100
|
- spec/unit/intercom/user_collection_proxy_spec.rb
|
99
101
|
- spec/unit/intercom/user_custom_data_spec.rb
|
100
102
|
- spec/unit/intercom/user_resource_spec.rb
|
@@ -129,10 +131,10 @@ test_files:
|
|
129
131
|
- spec/integration/intercom_api_integration_spec.rb
|
130
132
|
- spec/unit/intercom/impression_spec.rb
|
131
133
|
- spec/unit/intercom/message_thread_spec.rb
|
134
|
+
- spec/unit/intercom/note_spec.rb
|
132
135
|
- spec/unit/intercom/user_collection_proxy_spec.rb
|
133
136
|
- spec/unit/intercom/user_custom_data_spec.rb
|
134
137
|
- spec/unit/intercom/user_resource_spec.rb
|
135
138
|
- spec/unit/intercom/user_spec.rb
|
136
139
|
- spec/unit/intercom_spec.rb
|
137
140
|
- spec/unit/spec_helper.rb
|
138
|
-
has_rdoc:
|