intercom 0.1.17 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +44 -31
- data/changes.txt +6 -0
- data/intercom.gemspec +2 -0
- data/lib/intercom/request.rb +4 -4
- data/lib/intercom/version.rb +1 -1
- data/spec/integration/fixtures/v1-user.json +45 -0
- data/spec/integration/fixtures/v1-users-impression.json +3 -0
- data/spec/integration/fixtures/v1-users-message_thread.json +44 -0
- data/spec/integration/fixtures/v1-users-message_threads.json +46 -0
- data/spec/integration/fixtures/v1-users-note.json +49 -0
- data/spec/integration/fixtures/v1-users.json +144 -0
- data/spec/integration/intercom_api_integration_spec.rb +22 -4
- metadata +28 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0f05d2c37716b065556503a2b8f4db41bb80431
|
4
|
+
data.tar.gz: f0ab697881c32c597a7ab7a176936f3f9b0e327d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe1d59e7f7aa6b898803b3a49649524d8de5fdb718996d9b86af0b70d98f29de67ecc988e47ae501ae1aeb95024892669757e6c06685a9f8150b3496b9a9379e
|
7
|
+
data.tar.gz: e0490f3a22078191de4d259c558181cc12871e183665b481aabc90600ceb5b5747e706bc0399ee62a23152bdde804d4aec98710583402645a5c0f2ef02df3024
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Ruby bindings for the Intercom API (https://api.intercom.io).
|
4
4
|
|
5
|
-
[API Documentation](https://api.intercom.io)
|
5
|
+
[API Documentation](https://api.intercom.io/docs)
|
6
6
|
|
7
7
|
[Gem Documentation](http://rubydoc.info/github/intercom/intercom-ruby/master/frames)
|
8
8
|
|
@@ -20,8 +20,10 @@ Using bundler:
|
|
20
20
|
|
21
21
|
### Configure your access credentials
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
```ruby
|
24
|
+
Intercom.app_id = "my_app_id"
|
25
|
+
Intercom.api_key = "my-super-crazy-api-key"
|
26
|
+
```
|
25
27
|
|
26
28
|
### Resources
|
27
29
|
|
@@ -35,44 +37,55 @@ The API supports:
|
|
35
37
|
### Examples
|
36
38
|
|
37
39
|
#### Users
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
user = Intercom::User.find_by_email("bob@example.com")
|
43
|
+
user.custom_data["average_monthly_spend"] = 1234.56
|
44
|
+
user.save
|
45
|
+
user = Intercom::User.find_by_user_id("bob@example.com")
|
46
|
+
user = Intercom::User.create(:email => "bob@example.com", :name => "Bob Smith")
|
47
|
+
user = Intercom::User.new(params)
|
48
|
+
user.save
|
49
|
+
Intercom::User.all.count
|
50
|
+
Intercom::User.all.each {|user| puts %Q(#{user.email} - #{user.custom_data["average_monthly_spend"]}) }
|
51
|
+
Intercom::User.all.map {|user| user.email }
|
52
|
+
```
|
48
53
|
|
49
54
|
#### Companies
|
50
|
-
|
51
|
-
|
52
|
-
|
55
|
+
```ruby
|
56
|
+
user = Intercom::User.find_by_email("bob@example.com")
|
57
|
+
user.company = {:id => 6, :name => "Intercom"}
|
58
|
+
user.companies = [{:id => 6, :name => "Intercom"}, {:id => 9, :name => "Test Company"}]
|
59
|
+
```
|
53
60
|
|
54
61
|
You can also pass custom data within a company:
|
55
62
|
|
56
|
-
|
63
|
+
```ruby
|
64
|
+
user.company = {:id => 6, :name => "Intercom", :referral_source => "Google"}
|
65
|
+
```
|
57
66
|
|
58
67
|
#### Message Threads
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
68
|
+
```ruby
|
69
|
+
Intercom::MessageThread.create(:email => "bob@example.com", :body => "Example message from bob@example.com to your application on Intercom.")
|
70
|
+
Intercom::MessageThread.find(:email => "bob@example.com", :thread_id => 123)
|
71
|
+
Intercom::MessageThread.find_all(:email => "bob@example.com")
|
72
|
+
Intercom::MessageThread.mark_as_read(:email => "bob@example.com", :thread_id => 123)
|
73
|
+
```
|
64
74
|
|
65
75
|
#### Impressions
|
66
|
-
|
67
|
-
|
76
|
+
```ruby
|
77
|
+
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"
|
78
|
+
```
|
68
79
|
|
69
80
|
#### Notes
|
70
|
-
|
71
|
-
|
81
|
+
```ruby
|
82
|
+
Intercom::Note.create(:email => "bob@example.com", :body => "This is the text of the note")
|
83
|
+
```
|
72
84
|
|
73
85
|
### Errors
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
86
|
+
```ruby
|
87
|
+
Intercom::AuthenticationError
|
88
|
+
Intercom::ServerError
|
89
|
+
Intercom::ServiceUnavailableError
|
90
|
+
Intercom::ResourceNotFound
|
91
|
+
```
|
data/changes.txt
CHANGED
data/intercom.gemspec
CHANGED
data/lib/intercom/request.rb
CHANGED
@@ -25,7 +25,7 @@ module Intercom
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.delete(path, params)
|
28
|
-
new(path, Net::HTTP::Delete
|
28
|
+
new(path, method_with_body(Net::HTTP::Delete, path, params))
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.put(path, form_data)
|
@@ -50,8 +50,8 @@ module Intercom
|
|
50
50
|
net.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
51
51
|
net.ca_file = File.join(File.dirname(__FILE__), '../data/cacert.pem')
|
52
52
|
end
|
53
|
-
net.read_timeout =
|
54
|
-
net.open_timeout =
|
53
|
+
net.read_timeout = 90
|
54
|
+
net.open_timeout = 30
|
55
55
|
net
|
56
56
|
end
|
57
57
|
|
@@ -93,4 +93,4 @@ module Intercom
|
|
93
93
|
url + "?#{query_string}"
|
94
94
|
end
|
95
95
|
end
|
96
|
-
end
|
96
|
+
end
|
data/lib/intercom/version.rb
CHANGED
@@ -0,0 +1,45 @@
|
|
1
|
+
{
|
2
|
+
"intercom_id": "528f291df8d4a41d8c000088",
|
3
|
+
"email": "somebody@example.com",
|
4
|
+
"user_id": "123",
|
5
|
+
"name": "Somebody",
|
6
|
+
"created_at": 1270000000,
|
7
|
+
"last_impression_at": 1300000000,
|
8
|
+
"custom_data": {
|
9
|
+
"app_name": "Genesis",
|
10
|
+
"monthly_spend": 155.5,
|
11
|
+
"team_mates": 7
|
12
|
+
},
|
13
|
+
"social_profiles": [
|
14
|
+
{
|
15
|
+
"type": "twitter",
|
16
|
+
"url": "http://twitter.com/abc",
|
17
|
+
"username": "abc"
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"type": "facebook",
|
21
|
+
"url": "http://facebook.com/vanity",
|
22
|
+
"username": "vanity",
|
23
|
+
"id": "13241141441141413"
|
24
|
+
}
|
25
|
+
],
|
26
|
+
"location_data": {
|
27
|
+
"city_name": "Santiago",
|
28
|
+
"continent_code": "SA",
|
29
|
+
"country_name": "Chile",
|
30
|
+
"latitude": -33.44999999999999,
|
31
|
+
"longitude": -70.6667,
|
32
|
+
"postal_code": "",
|
33
|
+
"region_name": "12",
|
34
|
+
"timezone": "Chile/Continental",
|
35
|
+
"country_code": "CHL"
|
36
|
+
},
|
37
|
+
"session_count": 0,
|
38
|
+
"last_seen_ip": "127.0.0.1",
|
39
|
+
"last_seen_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
|
40
|
+
"unsubscribed_from_emails": false,
|
41
|
+
"avatar_url": "https://graph.facebook.com/13241141441141413/picture?width=24&height=24",
|
42
|
+
"company_ids": [
|
43
|
+
|
44
|
+
]
|
45
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
{
|
2
|
+
"created_at": 1385114541,
|
3
|
+
"updated_at": 1385028141,
|
4
|
+
"read": true,
|
5
|
+
"created_by_user": true,
|
6
|
+
"thread_id": 5591,
|
7
|
+
"message_id": 5591,
|
8
|
+
"message_type": "conversation",
|
9
|
+
"interrupt": true,
|
10
|
+
"messages": [
|
11
|
+
{
|
12
|
+
"created_at": 1385114541,
|
13
|
+
"url": null,
|
14
|
+
"html": "<p>Hey Intercom, What is up?</p>\n\n<p></p>",
|
15
|
+
"subject": "",
|
16
|
+
"from": {
|
17
|
+
"email": "bob@example.com",
|
18
|
+
"user_id": "456",
|
19
|
+
"name": "Bob",
|
20
|
+
"is_admin": false,
|
21
|
+
"avatar": {
|
22
|
+
}
|
23
|
+
}
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"created_at": 1384941741,
|
27
|
+
"url": null,
|
28
|
+
"html": "<p>Not much, you?\n</p>"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"created_at": 1385028141,
|
32
|
+
"url": null,
|
33
|
+
"html": "<p>Not much either :(</p>\n\n<p></p>",
|
34
|
+
"from": {
|
35
|
+
"email": "bob@example.com",
|
36
|
+
"user_id": "123",
|
37
|
+
"name": "Bob",
|
38
|
+
"is_admin": false,
|
39
|
+
"avatar": {
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
]
|
44
|
+
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"created_at": 1385114400,
|
4
|
+
"updated_at": 1385028000,
|
5
|
+
"read": true,
|
6
|
+
"created_by_user": true,
|
7
|
+
"thread_id": 5591,
|
8
|
+
"message_id": 5591,
|
9
|
+
"message_type": "conversation",
|
10
|
+
"interrupt": true,
|
11
|
+
"messages": [
|
12
|
+
{
|
13
|
+
"created_at": 1385114400,
|
14
|
+
"url": null,
|
15
|
+
"html": "<p>Hey Intercom, What is up?</p>\n\n<p></p>",
|
16
|
+
"subject": "",
|
17
|
+
"from": {
|
18
|
+
"email": "somebody@example.com",
|
19
|
+
"user_id": "123",
|
20
|
+
"name": "Somebody",
|
21
|
+
"is_admin": false,
|
22
|
+
"avatar": {
|
23
|
+
}
|
24
|
+
}
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"created_at": 1384941600,
|
28
|
+
"url": null,
|
29
|
+
"html": "<p>Not much, you?\n</p>"
|
30
|
+
},
|
31
|
+
{
|
32
|
+
"created_at": 1385028000,
|
33
|
+
"url": null,
|
34
|
+
"html": "<p>Not much either :(</p>\n\n<p></p>",
|
35
|
+
"from": {
|
36
|
+
"email": "somebody@example.com",
|
37
|
+
"user_id": "123",
|
38
|
+
"name": "Somebody",
|
39
|
+
"is_admin": false,
|
40
|
+
"avatar": {
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
]
|
45
|
+
}
|
46
|
+
]
|
@@ -0,0 +1,49 @@
|
|
1
|
+
{
|
2
|
+
"html": "<p>This is a note</p>",
|
3
|
+
"created_at": null,
|
4
|
+
"user": {
|
5
|
+
"intercom_id": "528f2cbb1b393a6e470000e6",
|
6
|
+
"email": "somebody@example.com",
|
7
|
+
"user_id": "123",
|
8
|
+
"name": "Somebody",
|
9
|
+
"created_at": 1270000000,
|
10
|
+
"last_impression_at": 1300000000,
|
11
|
+
"custom_data": {
|
12
|
+
"app_name": "Genesis",
|
13
|
+
"monthly_spend": 155.5,
|
14
|
+
"team_mates": 7
|
15
|
+
},
|
16
|
+
"social_profiles": [
|
17
|
+
{
|
18
|
+
"type": "twitter",
|
19
|
+
"url": "http://twitter.com/abc",
|
20
|
+
"username": "abc"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"type": "facebook",
|
24
|
+
"url": "http://facebook.com/vanity",
|
25
|
+
"username": "vanity",
|
26
|
+
"id": "13241141441141413"
|
27
|
+
}
|
28
|
+
],
|
29
|
+
"location_data": {
|
30
|
+
"city_name": "Santiago",
|
31
|
+
"continent_code": "SA",
|
32
|
+
"country_name": "Chile",
|
33
|
+
"latitude": -33.44999999999999,
|
34
|
+
"longitude": -70.6667,
|
35
|
+
"postal_code": "",
|
36
|
+
"region_name": "12",
|
37
|
+
"timezone": "Chile/Continental",
|
38
|
+
"country_code": "CHL"
|
39
|
+
},
|
40
|
+
"session_count": 0,
|
41
|
+
"last_seen_ip": "127.0.0.1",
|
42
|
+
"last_seen_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
|
43
|
+
"unsubscribed_from_emails": false,
|
44
|
+
"avatar_url": "https://graph.facebook.com/13241141441141413/picture?width=24&height=24",
|
45
|
+
"company_ids": [
|
46
|
+
|
47
|
+
]
|
48
|
+
}
|
49
|
+
}
|
@@ -0,0 +1,144 @@
|
|
1
|
+
{
|
2
|
+
"users": [
|
3
|
+
{
|
4
|
+
"intercom_id": "528f27c330972d783600006d",
|
5
|
+
"email": "first.user@example.com",
|
6
|
+
"user_id": "123",
|
7
|
+
"name": "First User",
|
8
|
+
"created_at": 1270000000,
|
9
|
+
"last_impression_at": 1300000000,
|
10
|
+
"custom_data": {
|
11
|
+
"app_name": "Genesis",
|
12
|
+
"monthly_spend": 155.5,
|
13
|
+
"team_mates": 7
|
14
|
+
},
|
15
|
+
"social_profiles": [
|
16
|
+
{
|
17
|
+
"type": "twitter",
|
18
|
+
"url": "http://twitter.com/abc",
|
19
|
+
"username": "abc"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"type": "facebook",
|
23
|
+
"url": "http://facebook.com/vanity",
|
24
|
+
"username": "vanity",
|
25
|
+
"id": "13241141441141413"
|
26
|
+
}
|
27
|
+
],
|
28
|
+
"location_data": {
|
29
|
+
"city_name": "Santiago",
|
30
|
+
"continent_code": "SA",
|
31
|
+
"country_name": "Chile",
|
32
|
+
"latitude": -33.44999999999999,
|
33
|
+
"longitude": -70.6667,
|
34
|
+
"postal_code": "",
|
35
|
+
"region_name": "12",
|
36
|
+
"timezone": "Chile/Continental",
|
37
|
+
"country_code": "CHL"
|
38
|
+
},
|
39
|
+
"session_count": 0,
|
40
|
+
"last_seen_ip": "127.0.0.1",
|
41
|
+
"last_seen_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
|
42
|
+
"unsubscribed_from_emails": false,
|
43
|
+
"avatar_url": "https://graph.facebook.com/13241141441141413/picture?width=24&height=24",
|
44
|
+
"company_ids": [
|
45
|
+
|
46
|
+
]
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"intercom_id": "528f27c330972d7836000070",
|
50
|
+
"email": "second.user@example.com",
|
51
|
+
"user_id": "123",
|
52
|
+
"name": "Second User",
|
53
|
+
"created_at": 1270000000,
|
54
|
+
"last_impression_at": 1300000000,
|
55
|
+
"custom_data": {
|
56
|
+
"app_name": "Genesis",
|
57
|
+
"monthly_spend": 155.5,
|
58
|
+
"team_mates": 7
|
59
|
+
},
|
60
|
+
"social_profiles": [
|
61
|
+
{
|
62
|
+
"type": "twitter",
|
63
|
+
"url": "http://twitter.com/abc",
|
64
|
+
"username": "abc"
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"type": "facebook",
|
68
|
+
"url": "http://facebook.com/vanity",
|
69
|
+
"username": "vanity",
|
70
|
+
"id": "13241141441141413"
|
71
|
+
}
|
72
|
+
],
|
73
|
+
"location_data": {
|
74
|
+
"city_name": "Santiago",
|
75
|
+
"continent_code": "SA",
|
76
|
+
"country_name": "Chile",
|
77
|
+
"latitude": -33.44999999999999,
|
78
|
+
"longitude": -70.6667,
|
79
|
+
"postal_code": "",
|
80
|
+
"region_name": "12",
|
81
|
+
"timezone": "Chile/Continental",
|
82
|
+
"country_code": "CHL"
|
83
|
+
},
|
84
|
+
"session_count": 0,
|
85
|
+
"last_seen_ip": "127.0.0.1",
|
86
|
+
"last_seen_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
|
87
|
+
"unsubscribed_from_emails": false,
|
88
|
+
"avatar_url": "https://graph.facebook.com/13241141441141413/picture?width=24&height=24",
|
89
|
+
"company_ids": [
|
90
|
+
|
91
|
+
]
|
92
|
+
},
|
93
|
+
{
|
94
|
+
"intercom_id": "528f27c330972d7836000073",
|
95
|
+
"email": "third.user@example.com",
|
96
|
+
"user_id": "123",
|
97
|
+
"name": "Third User",
|
98
|
+
"created_at": 1270000000,
|
99
|
+
"last_impression_at": 1300000000,
|
100
|
+
"custom_data": {
|
101
|
+
"app_name": "Genesis",
|
102
|
+
"monthly_spend": 155.5,
|
103
|
+
"team_mates": 7
|
104
|
+
},
|
105
|
+
"social_profiles": [
|
106
|
+
{
|
107
|
+
"type": "twitter",
|
108
|
+
"url": "http://twitter.com/abc",
|
109
|
+
"username": "abc"
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"type": "facebook",
|
113
|
+
"url": "http://facebook.com/vanity",
|
114
|
+
"username": "vanity",
|
115
|
+
"id": "13241141441141413"
|
116
|
+
}
|
117
|
+
],
|
118
|
+
"location_data": {
|
119
|
+
"city_name": "Santiago",
|
120
|
+
"continent_code": "SA",
|
121
|
+
"country_name": "Chile",
|
122
|
+
"latitude": -33.44999999999999,
|
123
|
+
"longitude": -70.6667,
|
124
|
+
"postal_code": "",
|
125
|
+
"region_name": "12",
|
126
|
+
"timezone": "Chile/Continental",
|
127
|
+
"country_code": "CHL"
|
128
|
+
},
|
129
|
+
"session_count": 0,
|
130
|
+
"last_seen_ip": "127.0.0.1",
|
131
|
+
"last_seen_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
|
132
|
+
"unsubscribed_from_emails": false,
|
133
|
+
"avatar_url": "https://graph.facebook.com/13241141441141413/picture?width=24&height=24",
|
134
|
+
"company_ids": [
|
135
|
+
|
136
|
+
]
|
137
|
+
}
|
138
|
+
],
|
139
|
+
"total_count": 3,
|
140
|
+
"page": 1,
|
141
|
+
"next_page": null,
|
142
|
+
"previous_page": null,
|
143
|
+
"total_pages": 1
|
144
|
+
}
|
@@ -3,35 +3,46 @@ require 'fakeweb'
|
|
3
3
|
|
4
4
|
describe "api.intercom.io dummy data requests" do
|
5
5
|
before :each do
|
6
|
-
Intercom.app_id = "
|
7
|
-
Intercom.api_key = "
|
8
|
-
Intercom.endpoint = "https://
|
6
|
+
Intercom.app_id = "some-app-id"
|
7
|
+
Intercom.api_key = "some-secret-key"
|
8
|
+
Intercom.endpoint = "https://intercom.example.com"
|
9
|
+
FakeWeb.clean_registry
|
10
|
+
end
|
11
|
+
|
12
|
+
def fixture(name)
|
13
|
+
File.read(File.expand_path("../fixtures/#{name}.json", __FILE__))
|
9
14
|
end
|
10
15
|
|
11
16
|
it "should get all user" do
|
17
|
+
FakeWeb.register_uri(:get, %r|v1/users|, :body => fixture('v1-users'))
|
12
18
|
Intercom::User.all.count.must_be :>, 0
|
13
19
|
end
|
14
20
|
|
15
21
|
it "should get a user" do
|
22
|
+
FakeWeb.register_uri(:get, %r(v1/users\?email=), :body => fixture('v1-user'))
|
16
23
|
user = Intercom::User.find(:email => "somebody@example.com")
|
17
24
|
user.name.must_equal "Somebody"
|
18
25
|
end
|
19
26
|
|
20
27
|
it "not found... " do
|
28
|
+
FakeWeb.register_uri(:get, %r(v1/users\?email=not-found), :status => [404, "Not Found"])
|
21
29
|
proc { Intercom::User.find(:email => "not-found@example.com") }.must_raise Intercom::ResourceNotFound
|
22
30
|
end
|
23
31
|
|
24
32
|
it "server error" do
|
33
|
+
FakeWeb.register_uri(:get, %r(v1/users\?email=server-error), :status => [500, "Oh Noes"])
|
25
34
|
proc { Intercom::User.find(:email => "server-error@example.com") }.must_raise Intercom::ServerError
|
26
35
|
end
|
27
36
|
|
28
37
|
it "authentication failure with bad api key" do
|
38
|
+
FakeWeb.register_uri(:get, %r(v1/users\?email=authentication-error), :status => [401, "Authentication Error"])
|
29
39
|
Intercom.app_id = "bad-app-id"
|
30
40
|
Intercom.api_key = "bad-secret-key"
|
31
|
-
proc { Intercom::User.find(:email => "
|
41
|
+
proc { Intercom::User.find(:email => "authentication-error@example.com") }.must_raise Intercom::AuthenticationError
|
32
42
|
end
|
33
43
|
|
34
44
|
it "should find_all messages for a user" do
|
45
|
+
FakeWeb.register_uri(:get, %r(v1/users/message_threads\?email=somebody), :body => fixture('v1-users-message_threads'))
|
35
46
|
message_thread = Intercom::MessageThread.find_all(:email => "somebody@example.com").first
|
36
47
|
%w(thread_id read messages created_at updated_at created_by_user).each do |expected|
|
37
48
|
message_thread.send(expected).wont_be_nil
|
@@ -39,23 +50,30 @@ describe "api.intercom.io dummy data requests" do
|
|
39
50
|
end
|
40
51
|
|
41
52
|
it "should mark message_thread as read" do
|
53
|
+
FakeWeb.register_uri(:get, %r(v1/users/message_threads\?email=somebody), :body => fixture('v1-users-message_threads'))
|
54
|
+
FakeWeb.register_uri(:put, %r(v1/users/message_threads), :body => fixture('v1-users-message_thread'))
|
42
55
|
message_thread = Intercom::MessageThread.find_all(:email => "somebody@example.com").first
|
43
56
|
message_thread.mark_as_read!
|
44
57
|
end
|
45
58
|
|
46
59
|
it "should create some impression" do
|
60
|
+
FakeWeb.register_uri(:post, %r(v1/users/impressions), :body => fixture('v1-users-impression'))
|
47
61
|
impression = Intercom::Impression.create(:email => 'somebody@example.com')
|
48
62
|
impression.unread_messages.must_be :>, 0
|
49
63
|
impression.email.must_equal 'somebody@example.com'
|
50
64
|
end
|
51
65
|
|
52
66
|
it "should create some notes" do
|
67
|
+
FakeWeb.register_uri(:post, %r(v1/users/notes), :body => fixture('v1-users-note'))
|
53
68
|
note = Intercom::Note.create(:body => "This is a note", :email => "somebody@example.com")
|
54
69
|
note.html.must_equal "<p>This is a note</p>"
|
55
70
|
note.user.email.must_equal "somebody@example.com"
|
56
71
|
end
|
57
72
|
|
73
|
+
|
58
74
|
it "should failover to good endpoint when first one is un-reachable" do
|
75
|
+
FakeWeb.allow_net_connect = %r(127.0.0.7)
|
76
|
+
FakeWeb.register_uri(:get, %r(api.intercom.io/v1/users), :body => fixture('v1-user'))
|
59
77
|
Intercom.endpoints = unshuffleable_array(["http://127.0.0.7", "https://api.intercom.io"])
|
60
78
|
user = Intercom::User.find(:email => "somebody@example.com")
|
61
79
|
user.name.must_equal "Somebody"
|
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.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben McRedmond
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: minitest
|
@@ -70,6 +70,20 @@ dependencies:
|
|
70
70
|
- - ~>
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '1.3'
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: json
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
type: :runtime
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
73
87
|
description: 'Intercom (https://www.intercom.io) is a customer relationship management
|
74
88
|
and messaging tool for web app owners. This library wraps the api provided by Intercom.
|
75
89
|
See http://docs.intercom.io/api for more details. '
|
@@ -107,6 +121,12 @@ files:
|
|
107
121
|
- lib/intercom/user_collection_proxy.rb
|
108
122
|
- lib/intercom/user_resource.rb
|
109
123
|
- lib/intercom/version.rb
|
124
|
+
- spec/integration/fixtures/v1-user.json
|
125
|
+
- spec/integration/fixtures/v1-users-impression.json
|
126
|
+
- spec/integration/fixtures/v1-users-message_thread.json
|
127
|
+
- spec/integration/fixtures/v1-users-message_threads.json
|
128
|
+
- spec/integration/fixtures/v1-users-note.json
|
129
|
+
- spec/integration/fixtures/v1-users.json
|
110
130
|
- spec/integration/intercom_api_integration_spec.rb
|
111
131
|
- spec/spec_helper.rb
|
112
132
|
- spec/unit/intercom/flat_store_spec.rb
|
@@ -143,6 +163,12 @@ signing_key:
|
|
143
163
|
specification_version: 4
|
144
164
|
summary: Ruby bindings for the Intercom API
|
145
165
|
test_files:
|
166
|
+
- spec/integration/fixtures/v1-user.json
|
167
|
+
- spec/integration/fixtures/v1-users-impression.json
|
168
|
+
- spec/integration/fixtures/v1-users-message_thread.json
|
169
|
+
- spec/integration/fixtures/v1-users-message_threads.json
|
170
|
+
- spec/integration/fixtures/v1-users-note.json
|
171
|
+
- spec/integration/fixtures/v1-users.json
|
146
172
|
- spec/integration/intercom_api_integration_spec.rb
|
147
173
|
- spec/spec_helper.rb
|
148
174
|
- spec/unit/intercom/flat_store_spec.rb
|